Repository navigation
Conversation
StrataBoole/Shallow/Layer.lean: a nondeterministic monad on Lean's Std.Do with havoc, assume, assert and a while loop carrying its invariant, each with a proved rule, so mvcgen generates the verification conditions. StrataBooleTest/shallow_find_max.lean: three hand-written programs verified with it, find max among them, in the form a translation from Core should produce. The proofs use only Lean's standard axioms. docs/ShallowEmbedding.md: the design, the mapping from Core to Lean, the status, and the research and open questions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve StrataBooleTest.lean by keeping both sides' test imports. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Picks up the Strata bump to 8ec62c9 (strata-org#24). Resolve StrataBooleTest.lean by keeping both sides' test imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One inductive of constructor applications for all datatypes, with disjointness, injectivity and inversion proved once and pos.toInt by structural recursion. Not covered yet: Map fields keyed by a datatype and parametric datatypes.
…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.
Interpreter on Core, adequacy against Core's semantics, proof rules and mvcgen on top with find_max as the milestone, the model, then a Boole interpreter. Close the translator-or-interpreter question. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
interpProc takes a model; adequacy relates to Core's small-step semantics and its failure flag, with eval_denote_sound bridging eval and denote; the mapping table reflects what the interpreter does today; strata-org#25 and strata-org#26 are open PRs.
`assert` is a reserved `do` element since 4.33, so the layer's is written `ND.assert`. Note in the doc that `vcgen` and Velvet are now available. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Strata main has a Hoare logic for Core over its operational semantics, with proved rules, a contract reading and model genericity. The plan becomes a VC tactic over that triple plus lifting of goals to Lean values; the interpreter into ND and a separate semantics are superseded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… where Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…reuse of the concrete model Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ation Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eat/shallow-translator
The route this branch now takes keeps the program as data and proves contracts against Core's Hoare logic, so it is a deep embedding; only the Std.Do prototype in StrataBoole/Shallow/ and its test are shallow. Rename docs/ShallowEmbedding.md to docs/HoareLogic.md, and shallow_generic_datatypes.lean, the generic datatype carrier for the model, to generic_datatypes.lean. Mark the Std.Do layer as a prototype the route does not build on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pin moves to the integration branch at 07dfdf5c8: Strata main with strata-org/Strata#1499 merged, plus the open #1493 and #1483. hoare_max2 names the fields of InitEnvWFParams, the out-of-bounds obligation of seq_slicing now fails as it should, and the Hoare document records the merged change.
Scalar_add had the body assume false, after which no run continues: on the Hoare route every obligation of the caller after the first call would hold vacuously. The translator now emits a body that havocs the result and assumes each ensures. The program is regenerated; five obligation labels shift and cvc5 still passes all 36 obligations. The Hoare document describes the body. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The pin moves to integration/lean-route 869920098: Strata main (ce946780c) with strata-org/Strata#1483, #1493 and #1501. lean-smt moves to cbec5bd22, its last commit on Lean 4.35. - Procedure bodies carry Core's opaque flag; a Core procedure's opaque mark is kept. - Calls pass no explicit type arguments, which the type checker infers. - The nat model check accepts a model when the obligation has the value its query asks for, which Core's model validation now names. - hoare_max2 follows the new contract precondition (typed outputs) and passes hmono. - Pinned outputs follow Core's new label numbering and Lean's report of native_decide. - docs/HoareLogic.md describes the new pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings the real-number lowering (strata-org#32). Its expressions take the location booleLoc, as the rest of the lowering on this branch does. docs/HoareLogic.md: datatype inversion and induction are upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l copies The pin moves to integration/lean-route 53a3ff3c4: Strata main (6e123aba4) with strata-org/Strata#1483, #1493, #1501, #1506 and #1507. - HoareLift keeps only what Strata lacks: the Boolean connectives now come from Strata's BoolEvalProps. - docs/HoareLogic.md: step 2 lists what is done, in review and left; the target section says which operators the proof of sum_of_slice needs. Co-Authored-By: Claude Fable 5.2 <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.
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.