feat: port the mvcgen' tactic to the new Std.Internal.Do meta theory#14015
Open
sgraf812 wants to merge 5 commits into
Open
feat: port the mvcgen' tactic to the new Std.Internal.Do meta theory#14015sgraf812 wants to merge 5 commits into
sgraf812 wants to merge 5 commits into
Conversation
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
a63dc24 to
850515c
Compare
Contributor
Author
|
!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🟥)
|
Contributor
Author
|
!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>
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.
This PR ports the experimental
mvcgen'tactic to the newStd.Internal.Dometa theory. VC generation now works on lattice entailmentspre ⊑ wp x post epostinstead of the legacyStd.DoSPred triples. The spec lemmas inStd.Internal.Do.Triple.SpecLemmasare registered with@[spec]and populate the new spec database. The spec library 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 main pieces:
SpecTheorems that@[spec]stores at annotation time, plus the equational lemmas frommvcgen_simp. Instantiation normalisesTripleand⊑ wpconclusions withtripleToWpProof?.wp_consequence_le,wp_econs_leand the componentwiseEPost.Consdecomposition.⊓,⇨,⌜·⌝and⊤on the RHS decompose through cached logic rules built from their_applylemmas.The solver diverges from the legacy algorithm in three points:
Q x ⊑ wp (pure x) Q Eends inQ x ⊑ Q x. Closing these by rfl removes the need for an assumption search. The rfl step also instantiates spec parameters that occur only in rule premises.⊤ ⊑ ?inv argsby assigning?inv, silently dropping the invariant goal.Scope.lastLiftedPre?, and a targeted assumption step closes the handoff VCs of subsequent spec applications against it: one defeq check against one hypothesis, not an assumption search. Loop invariants need not restate pure facts, and spec chains close under plainmvcgen'at their previous cost.Invariant suggestion (
invariants?) yields no suggestions on the new surface; porting the suggestion analysis is deferred untilmvcgen'replaces the legacymvcgen.