feat: port the mvcgen' tactic to the new Std.Internal.Do meta theory#14015
Conversation
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
a63dc24 to
850515c
Compare
|
!bench |
|
Benchmark results for 79370a9 against 6271d8f are in. There are significant results. @sgraf812
Large changes (35✅, 3🟥) Too many entries to display here. View the full report on radar instead. Medium changes (8✅)
Small changes (4✅, 14🟥)
|
|
!bench |
|
Benchmark results for e3eb965 against 6271d8f are in. There are significant results. @sgraf812
Large changes (35✅, 3🟥) Too many entries to display here. View the full report on radar instead. Medium changes (7✅)
Small changes (5✅, 16🟥) Too many entries to display here. View the full report on radar instead. |
Accumulates the mvcgen' tactic port and its test suite. The Std.Internal.Do specification cleanup it builds on has landed upstream (#14051), so after rebasing this carries only the tactic and test changes. Co-authored-by: volodeyka <vovaglad00@gmail.com>
e3eb965 to
a0ed08f
Compare
…dling Replace the `LogicOp` classify-then-dispatch enum with a `LatticeSplit` record bundling each connective's rebuild function, distribution lemma, and split lemma, so the `match_expr` arm produces the rule data directly instead of re-dispatching across four tables. Drop the `preIsTop` rule specialization. Rather than baking `⊤` into a connective rule and selecting a `⊤`-specialized split lemma, `himp` always splits via `himp_complete`, and the residual `P ⊓ ⊤` precondition is cancelled by a new `meet_top_le_of_le` normalization step in `normalizePre?`. This removes `himp_complete_top` and shrinks the lattice-rule cache key. Also remove the dead `topStateArgIntro` rule and apply a `?`-suffix naming sweep to the `solve` strategies. Add a `⇨` regression test exercising the split and the `⊓ ⊤` cancellation. Co-authored-by: volodeyka <vovaglad00@gmail.com>
…Top` flag Replace the `match_expr` head dispatch in `splitLatticeOp?` (formerly `solveLatticeConnective?`) with a `latticeSplits : HashMap Name LatticeSplit` lookup keyed on the RHS head constant, so adding a connective is one map entry plus a `LatticeSplit` value. The per-connective argument slicing folds into a `numOperands` field, and the carrier-type argument is chosen from the existing `needApplyArgs` flag. Drop the `preIsTop` soundness check on `⌜p⌝`. The `ofProp` split now uses `top_le_ofProp` (LHS fixed to `⊤`), so its rule only unifies against a `⊤` precondition and falls through otherwise, making the gate a property of the lemma rather than an external probe. Credit Vladimir Gladshtein on the remaining ported tactic files (`Context`, `Frontend`, `RuleCache`). Co-authored-by: volodeyka <vovaglad00@gmail.com>
mvcgen' looped on programs containing a raw `monadLift`/`liftM`: `liftM.eq_1 : @liftM = @monadLift` registered as a productive simp spec and rewrote `monadLift …` to itself forever, since `liftM` is a reducible `abbrev` for `monadLift`. The no-op guard in `mkSpecTheoremFromSimpDecl?` only fired for value-level equations (`etaArgs == 0`) and compared the eta-expanded key against the un-expanded RHS, missing this function-level case. Compare the pre-eta key (`pattern.pattern`, already reducibly preprocessed) structurally against the RHS, dropping the `etaArgs` gate. A structural `==` skips only syntactic no-ops, so productive unfolds whose RHS is merely definitionally equal (`monadLift_trans`, ordinary `foo.eq_1`) stay registered. Add a `RawMonadLiftRegression` test pinning that a raw lift now terminates. Co-authored-by: volodeyka <vovaglad00@gmail.com>
The rule-construction functions in `RuleConstruction.lean` carried no `VCGenM` state and only needed plain metaprogramming, so move them from `SymM` to `MetaM`. The matcher re-shares subgoal types, so the `Sym.inferType` hash-consing was redundant; replace it with `Meta.inferType` and drop the `shareCommon` calls and the `Sym` infrastructure imports. Co-authored-by: volodeyka <vovaglad00@gmail.com>
Replace the local `predLevel` helper with `decLevel` when building the `bot_apply` rewrite in exception-postcondition reduction, and clarify the lifted-hypothesis discharge docstring. Co-authored-by: volodeyka <vovaglad00@gmail.com>
The function does one job: it adds the simp-side `@[spec]` equational lemmas to the triple spec database. The old name was a fossil from when the database was live-converted from a legacy representation. Co-authored-by: volodeyka <vovaglad00@gmail.com>
Collapse the separate `noEntailment`, `noProgramOrLatticeFoundInTarget`, and `noStrategyForProgram` constructors into a single `stop` carrying a `StopReason`, since every one of them is handled identically by emitting the current goal as a VC. The genuinely unreachable program case now throws. Co-authored-by: volodeyka <vovaglad00@gmail.com>
|
!bench |
|
Benchmark results for af52cf1 against ab122a1 are in. There are significant results. @sgraf812
Large changes (36✅, 3🟥) Too many entries to display here. View the full report on radar instead. Medium changes (5✅)
Small changes (7✅, 13🟥)
|
This PR ports the experimental
mvcgen'tactic to the newStd.Internal.Dometa theory, where verification-condition generation works on lattice entailmentspre ⊑ wp x post epost. Two changes are visible at the proof surface:mvcgen'now eagerly introduces all state components as local hypotheses, so more facts reachgrind; and loop invariants no longer have to restate the exceptional postcondition.Previously the invariant for a loop that can throw had to repeat the exception condition alongside the actual invariant:
Now the exceptional postcondition is taken from the surrounding
Triple, so the invariant case carries only the invariant:The spec lemmas in
Std.Internal.Do.Triple.SpecLemmasare registered with@[spec]and populate the new spec database, which also gains thewhileM/Lean.Loopspecifications,Invariant.withEarlyReturnNewDo, and pointwise entailment lemmas for state introduction.The port replays Vladimir Gladshtein's #13978 onto master's file structure.
The solver diverges from the legacy algorithm in three points. Reflexivity runs on every entailment before the pure-precondition lifts, closing the leaf VCs where a spec precondition meets an identical goal precondition (
Q x ⊑ wp (pure x) Q Eends inQ x ⊑ Q x) and instantiating spec parameters that occur only in rule premises. Reflexivity no longer assigns synthetic opaque metavariables, so function-typed invariant holes are not silently solved away. Pure preconditions are lifted into the local context as soon as they arise; the lifted hypothesis is cached inScope.lastLiftedPre?, and a targeted assumption step closes the handoff VCs of subsequent spec applications against it.This is the second of two steps that land
vova/new-mvcgenonto master. The first step (#13954) updated the@[spec]builtin attribute and regeneratedstage0, so this PR reuses master'sstage0and contains no generated C changes. Invariant suggestion (invariants?) yields no suggestions on the new surface; porting the suggestion analysis is deferred untilmvcgen'replaces the legacymvcgen.