Repository navigation
Conversation
…eat/shallow-translator
Add StrataBoole/Shallow/Interpreter/, which interprets Core statements as ND computations. The adequacy proof will be stated about this interpreter. - Interp.lean: the interpreter over a store of Lean values (FreeVarVal); expressions go through LExpr.denote after LExpr.typeCheck; a loop carries only the variables its body assigns. Calls, exit, nondeterministic loops and local type declarations are not interpreted yet. - Model.lean: partial concrete model of Core's built-ins for denote, no consistency proofs yet. - Sort.lean: recursion principle and decidable equality for LSort. - Reflect.lean, Command.lean: `shallow_reflect p` binds each procedure's type-checked Core AST to `<name>_ast : Core.Procedure`. - Pipeline.lean: the type-checked Core program at elaboration time, shared with shallow_embed.
…t whole programs - ND.fail is the failed-assert outcome, so unsupported statements and ill-typed expressions or loop guards make a specification unprovable. - shallow_reflect also binds the program as `<p>_ast : Core.Program`, with its functions, axioms, lemmas and type declarations.
…eat/shallow-translator
- hoare_contract, hoare_vcs, hoare_lift prove Procedure.contractTriple for integer programs from Boole source; max2 and demo.lean's loop pass - Deep embedding, shallow_reflect and #core_reflect in StrataBoole/HoareLogic - Route code and tests grouped under StrataBoole/HoareLogic and StrataBooleTest/HoareLogic; translator and interpreter prototypes removed - docs/HoareLogic.md: Status updated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d core_reflect; remove the Deep prototype The merge of feat/hoare-logic moved Strata to d68fdcb6e, where a statement evaluates its expressions denotationally, in the model of the runtime factory. - Hoare/Lift: the evaluation lemmas are restated over that factory (Eval.lean), with a bridge from an evaluation to `LExpr.denote` (Denote.lean). Contract, Rules, WP and Tactic follow. - Boolean parameters and the value of a `havoc` are read: hoare_havoc_core replaces hoare_havoc_gap. - `shallow_reflect` becomes `boole_reflect`; `core_reflect` does the same for a program in Core syntax. The delaborators move to HoareLogic/Delab.lean. - The Deep prototype (HoareLogic/Deep and its tests) is removed.
Brings Lean 4.35 and Strata 53a3ff3c. Conflicts: - StrataBoole.lean, StrataBooleTest.lean: both sides' entries are kept. The Std.Do prototype (Shallow/Layer.lean, shallow_find_max.lean), removed upstream, is removed here too. - docs/HoareLogic.md, hoare_max2.lean: upstream's text, with the paths of the files this branch keeps under HoareLogic/. The status bullets of this branch stay. - hoare_lift_forall.lean, new upstream, goes under StrataBooleTest/HoareLogic/ with the other tests of the route, and imports HoareLift from its place here. The files of the route are ported in the next commit.
- Proj.lean: the triple now also asks every assertion to hold on every finite execution, and the template rules no longer take the argument types. The four rules are proved again after Strata's `block`, `ite` and `while_rule`; the nondeterministic loop is split into `while_nondet_iterE`, `while_nondet_genE` and `while_nondet_prefixE`. - WP.lean, Rules.lean, Contract.lean, Tactic.lean: the new shapes of the triple, of `InitEnvWF` (`runtimeFactoryDeclared`), of a body (`opaque`, monotonicity at the entry) and of `contractPre` (five parts). - Reflect, Delab: `call` carries type arguments, a body is `structured` with an `opaque` flag or `abstract`, a program carries `usedIdentPrefixes`. - Lift: `Bool.And` and `Bool.Or` are read with Strata's lemmas, which HoareLift no longer has.
- `Eval.OverCore factory`: the factory resolves every name `Core.Factory` knows to the same function. It holds for the factory any procedure of any program sees (`OverCore.factoryBeforeProcedure`), so a contract no longer needs the program to declare nothing. The operator lemmas take `OverCore` in place of `factory = Core.Factory`. - `entryPre` states the precondition over `p.factoryBeforeProcedure procName`, with the axioms before the procedure. - An `out` parameter has a typed value at the entry, `x_entry` (`hoare_typed_outputs`): a `havoc` of an output never assigned is now proved (`unassigned_contract` in hoare_havoc_core). - A condition the lifting cannot read stays in the context as it is, and `hoare_lift` tries it by assumption.
- Call.lean: `call_wp_args`, from Strata's `Procedure.call_of_contract`. The condition `wpCallArgs` asks for the value of each argument, the callee's `requires` on its frame, and the continuation for every exit store that meets the `ensures`. - Tactic.lean: `hoare_call` applies the rule, `hoare_open_call` opens the condition: one goal per `requires` of the callee, one hypothesis per `ensures`, a new value for each variable the call writes. - Limits: the callee has no body and no `inout` parameter, and no function or datatype is declared between the callee and the caller.
A value whose type is not `int` or `bool` is read as an element of the model's carrier for that type, and an operator without a Lean counterpart as the model's interpretation of it (`denote_op1`, `denote_op2`, …). `findMax`, which reads a map with `select`, is proved: its conditions hold whatever `select` is.
- `hoare_axioms`: every axiom declared before the procedure becomes a hypothesis named after it, read like a clause. - A `bv` literal is read as a `BitVec`; `div` and `mod` are read at a divisor the context knows to be non-zero. - dalek_lift: the conditions of `sum_of_slice`, lifted and pinned.
…e` proved - `hoare_functions`: a function declared with a body before the procedure gives the hypothesis `<name>_def`, an equivalence for a Boolean result and an equation otherwise (at most two parameters, no type parameters, not recursive). The fact rests on HoareLift's `opInterp_of_body`. - The function the factory finds under a name is computed by the kernel, without `native_decide`: `lookupDecls` walks the declarations, and `coreBuiltinNames` lists the names of the built-ins, checked once when the library is built. - `hoare_seq_facts`: `0 ≤ Sequence.length s` for every sequence in the context. - dalek_lift: `sum_of_slice_contract`, over a callee without a body, from the three standard axioms.
A procedure declared without a body was lowered to a structured body with no statement, which says that the procedure does nothing. It is now `Body.abstract`: there is no body to run, and a call goes through the contract. The verifier labels the assumed `ensures` of an abstract callee `callElimPost` where it wrote `$__callElimAssume`, which moves two labels pinned in option_matches.
…k theorems on the Boole program - `hoare_contract` closes the contract of a procedure without a body with `contractTriple_abstract`: it holds by definition. - boole_call: a Boole procedure calls one declared without a body. - dalek_lift: `Scalar_add` is declared without a body, and `Scalar_add_contract` and `sum_of_slice_contract` are stated on the reflected Boole program.
- `hoare_abstract`, the last step of `hoare_lift`: the goal is generalized over the model. A type the model interprets becomes a type variable, an operator a function variable, and the runtime factory leaves the context. What is left mentions only Lean types and local variables, which lean-smt's `smt` accepts. - dalek_lift: `sum_of_slice_contract` by `all_goals smt [*]`; the proof with `rw` and `omega` stays as `sum_of_slice_contract_by_hand`. boole_smt: a small program closed the same way. - Lifting is about three times faster on `sum_of_slice`: a store slot is read by walking the updates directly (`hoare_slot`), and the read axioms and function definitions are set aside while a goal is lifted (`hoare_freeze`).
`hoare_open_call` split its goal with named holes, which replaced the goal's name: after a call in a branch or in a loop body the goals lost `then.`, `else.` or `step.`. The name is now read before the split and set on every goal the call leaves. boole_call pins the names for a call in a branch and in a loop.
- Eval.lean kept its own `coreFactory_intDiv`, `coreFactory_intMod` and `coreFactory_boolImplies`, their `*_opInterp_of_lookup` lemmas and `eval_app1_op`. Strata has all of them; the callers use Strata's. `Int.Neg` and `Bool.Equiv` stay, Strata has no lemma for them. - WP.lean: `exists_pre` and `frame_const` had no caller. - Tactic.lean: the loop section said a loop binds integer or Boolean variables; it binds every variable the body writes.
The lowering labels such a clause `<kind>_<counter>_<offset>`. Goals and hypotheses were named after the whole label, so a name changed whenever the text before the clause did. `clauseName` drops the offset; it is used for the `requires`, `ensures`, invariant, `assume` and axiom hypotheses and for the goals. boole_unlabeled pins the names.
The status said `call`, `exit` and `bool` parameters were not covered. They are, and `sum_of_slice` is proved; the list of what is not covered is brought up to date.
kondylidou
reviewed
Dec 1, 2026
kondylidou
left a comment
Collaborator
There was a problem hiding this comment.
Great work, this reaches the target: sum_of_slice against Procedure.contractTriple, kernel-checked.
What I checked:
- Built the branch with all tests on the current
feat/hoare-logic: green,dalek_lifttakes about 155 s. - The program in
dalek_lift.leanis the benchmark's, except forScalar_add's body. - No
sorry,axiomornative_decidein the new code; every#print axiomsguard lists onlypropext,Classical.choiceandQuot.sound, thesmtproof included.
Small things to add before it leaves draft:
- Trusted base in
docs/HoareLogic.md: add the contract of a procedure without a body, and that the reflected<p>_astis the lowering of the source (it is computed by compiled code). Thenative_deciderow can go. dalek_lift.lean: add theprogramFaithful dalekPgm dalekPgm_astcheck your other tests have.- Wording there:
Scalar_add's contract is trusted, not met "by definition". - A test that pins the new meaning of a bodyless procedure: the caller relies on its
ensures, and the call site still checks itsrequires. - A PR description: what is covered, what is not (calls to procedures with a body,
inoutarguments, loop measures,bvoperators).
Heads-up for the next pin move, not for this PR: Strata moved the lemma files to Core/FactoryOpsEvalProps/, and AxiomsBeforeProcedureDecl.callee now takes htyped : Analysis.Program.formulasTypedB p = true instead of hclosed (Tactic.lean, around line 1323).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.