Skip to content

[anneal] Add 3-axiom Anneal.LoopInv loop invariant library - #3964

Open
joshlf wants to merge 1 commit into
joshlf-anneal-p2-theory-bitvec-arithfrom
joshlf-anneal-p2-theory-loopinv
Open

joshlf wants to merge 1 commit into
joshlf-anneal-p2-theory-bitvec-arithfrom
joshlf-anneal-p2-theory-loopinv

Conversation

@joshlf

@joshlf joshlf commented Nov 20, 2026

Copy link
Copy Markdown
Member

Human review surface

Add theory/Anneal/LoopInv.lean (1711 lines, zero noncomputable defs)
providing reusable, 3-axiom CFG loop-invariant, checkpoint
weakest-precondition, and simulation combinators over Anneal.MirWp and
Trusted.MirSemantics for Fuchsia Merkle, Starnix eBPF, and general Rust
loop verification without custom axioms or bv_decide:

  • Checkpoint WP and execution predicates (wpUntil, wpUntilOk,
    wpReach, execUntil, execUntilOk, execReach) with equivalence,
    monotonicity, sequential composition (wpUntil_bind), and handover
    theorems (wpUntil_to_wpOutcomeState, wellFormed_and_spec_of_wpUntil).
  • Structured loop-invariant combinators (wpLoop_nat, wpLoop_nat_le,
    wpLoop_countdown, wpLoop_list, wpLoop_list_measure,
    wpLoop_list_split, wpLoop_nat_or_done, wpLoop_state_exists).
  • Relational and deterministic simulation combinators (ReflTrans,
    wpSim_rel, wpSim_det_run, wpSim_det) plus symbolic MIR stepping
    helpers and a non-vacuity countDown self-test.
  • Wire Anneal.LoopInv into theory/Anneal.lean,
    trusted/cargo-anneal/src/bundle.rs, regenerated
    trusted/cargo-anneal/src/bundled_resources.rs, and
    trusted/audit/tests/boundary_audit.rs.
  • Add live_demand_driven_loopinv_three_axiom_proof in
    trusted/cargo-anneal/src/target.rs, verifying a real UnitTheorem
    (including BodyVerified and symbolic return spec across all u32
    inputs for a while n != 0 count_down loop) within the 3-axiom
    ceiling with demand-driven Anneal.Unused pruning.

Layer 13 of 19 in the migrated Anneal verification stack under anneal/.

Public Anneal source checkpoint.

Authored by an AI agent acting on joshlf's behalf.

Add theory/Anneal/LoopInv.lean (1711 lines, zero noncomputable defs)
providing reusable, 3-axiom CFG loop-invariant, checkpoint
weakest-precondition, and simulation combinators over Anneal.MirWp and
Trusted.MirSemantics for Fuchsia Merkle, Starnix eBPF, and general Rust
loop verification without custom axioms or bv_decide:

- Checkpoint WP and execution predicates (`wpUntil`, `wpUntilOk`,
  `wpReach`, `execUntil`, `execUntilOk`, `execReach`) with equivalence,
  monotonicity, sequential composition (`wpUntil_bind`), and handover
  theorems (`wpUntil_to_wpOutcomeState`, `wellFormed_and_spec_of_wpUntil`).
- Structured loop-invariant combinators (`wpLoop_nat`, `wpLoop_nat_le`,
  `wpLoop_countdown`, `wpLoop_list`, `wpLoop_list_measure`,
  `wpLoop_list_split`, `wpLoop_nat_or_done`, `wpLoop_state_exists`).
- Relational and deterministic simulation combinators (`ReflTrans`,
  `wpSim_rel`, `wpSim_det_run`, `wpSim_det`) plus symbolic MIR stepping
  helpers and a non-vacuity `countDown` self-test.
- Wire `Anneal.LoopInv` into `theory/Anneal.lean`,
  `trusted/cargo-anneal/src/bundle.rs`, regenerated
  `trusted/cargo-anneal/src/bundled_resources.rs`, and
  `trusted/audit/tests/boundary_audit.rs`.
- Add `live_demand_driven_loopinv_three_axiom_proof` in
  `trusted/cargo-anneal/src/target.rs`, verifying a real `UnitTheorem`
  (including `BodyVerified` and symbolic return spec across all `u32`
  inputs for a `while n != 0` `count_down` loop) within the 3-axiom
  ceiling with demand-driven `Anneal.Unused` pruning.

Source: https://github.com/joshlf/anneal/tree/0ac625345fa1a010e5d67d13bc15e1c55957662c
Agent-authored-by: AI agent acting on joshlf's behalf
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T15:39:58.825660Z 42862a8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.99%. Comparing base (afa4a9e) to head (42862a8).

Additional details and impacted files
@@                          Coverage Diff                          @@
##           joshlf-anneal-p2-theory-bitvec-arith    #3964   +/-   ##
=====================================================================
  Coverage                                 92.99%   92.99%           
=====================================================================
  Files                                        16       16           
  Lines                                      2469     2469           
=====================================================================
  Hits                                       2296     2296           
  Misses                                      173      173           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42862a8cc9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

subst hOut
exact ⟨hSat.1, hBeh⟩

end Anneal.LoopInv

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Correct the Human review surface line count

The commit's required Human review surface describes LoopInv.lean as 1,711 lines, but the added file ends at line 1,716. This makes the recorded review surface inaccurate; update the count or remove the brittle count before handoff.

AGENTS.md reference: anneal/AGENTS.md:L123-L129

Useful? React with 👍 / 👎.

@joshlf
joshlf added this pull request to stack #3976 November 20, 2026 17:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants