Documentation

Lean.Elab.Tactic.VCGen.Context

The VCGenM monad: its read-only Context (a fixed bundle of pre-built BackwardRules + user-customisable simp methods) and its mutable State (rule caches, accumulated invariants/VCs, simp cache).

A single elaborated frames alternative: its program pattern, the binder name of each pattern variable (none for _, index-aligned with pat.varTypes), the raw frame term (elaborated in the matched goal's context), the source position (a precedence tiebreak among matches, and its index into FrameDB.entries), and whether it has already been applied.

Instances For

    The frame database: program patterns keyed in a discrimination tree to the srcIdx of the matching alternative, alongside the alternatives themselves in source order. Held in State.frameDB; the discrimination tree is fixed, and only the retired flags of entries change.

    Instances For

      Pre-built backward rules used by solve.

      Instances For

        Build the backward rules used by solve from their underlying lemmas.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          • backwardRules : BackwardRules

            Pre-built backward rules used by solve.

          • frameProcs : FrameProcs

            The @[frameproc] registry snapshot taken at frontend init. solve selects a procedure per program node by the node's monad.

          • The @[vcgen_rintro] rules, keyed by their conclusion.

          • The Sym.simp methods that rewrite hypotheses, state arguments and verification conditions with the @[vcgen_simp] theorems and those of the simp [...] clause. none when the simp config option is false.

          • The configuration of every Sym.simp run with simpMethods.

          • useJP : Bool

            The jp config option: when true, tryLetIntro recognises __do_jp lets whose body is a splitter and sets up shared-continuation handling instead of zeta-unfolding. When false (default, matching original mvcgen), every call site of the JP zeta-unfolds, leading to exponential blow-up on nested splits.

          • errorOnMissingSpec : Bool

            The errorOnMissingSpec config option: when true (default), a program with no matching spec raises a hard error. When false, the goal is emitted as an unsolved VC for the user to discharge — useful with vcgen [-some_spec] patterns where the user knows the spec is intentionally removed and wants to handle the residual goal by hand.

          • debug : Bool

            The debug config option: when true, tryApplyRule retries failed BackwardRule.apply calls after unfoldReducible and reports an error when the retry succeeds, pinpointing missing normalization steps in vcgen.

          • internalize : Bool

            The internalize config option: when true (default), emitVC and the multi-subgoal fork in Driver.work call Grind.processHypotheses. The tactic-mode entry point disables this when there is no with clause.

          • invariantAlts : Std.HashMap Nat Syntax

            Pre-parsed invariants/invariants? alternatives, indexed by 1-based invariant number. Bullet form maps positions to entries (bullet n+1 → alt); labelled form maps the parsed inv<n> numbers (out-of-order labels are supported). Empty when no invariants clause is provided or in invariants? (suggest) mode (handled separately).

          • The until pattern: when some pat, VC generation stops and emits the current goal as a VC once the program in wp⟦e⟧ matches pat, before applying a spec.

          Instances For

            A join point __do_jp that vcgen +jp proves once. See Lean.Elab.Tactic.VCGen.JoinPoint.

            • spec : Expr

              The let-bound proof __do_jp_spec : ∀ xs ss, ?H xs ss → ⊤ ⊑ wp⟦__do_jp xs⟧ post eposts ss.

            • top : Expr

              The ⊤ of the goals of __do_jp, with their lattice instance.

            • hyp : MVarId

              The metavariable ?H, which finalizeJoinPoint assigns.

            • rhsGoal : MVarId

              The goal for the join RHS, the value of __do_jp.

            • numStates : Nat

              The number of states that ?H takes after the join parameters.

            Instances For

              A jump to a join point with the arguments args, which include the states, and the proof ?pf : ?H args that finalizeJoinPoint assigns in the local context of the jump.

              Instances For
                • Spec database in scope: globals plus locals from in-scope hypotheses.

                • lastLiftedPre? : Option FVarId

                  The most recently lifted pure precondition. tryLiftedHyp closes handoff VCs against it without walking the local context.

                • nextDeclIdx : Nat

                  Index of the next local declaration to consider for local specs.

                • joinPoints : FVarIdMap JoinPoint

                  The join points of vcgen +jp in scope, keyed by their let variable.

                Instances For
                  • A cache mapping registered SpecThms to their backward rule to apply. The particular rule depends on the theorem name, the WPMonad instance and the number of excess state arguments that the weakest precondition target is applied to.

                    The instance is keyed by ExprPtr, so lookups compare it by pointer rather than structurally. This is sound because the instance is a subterm of the hash-consed goal target.

                  • A cache mapping matchers to their splitting backward rule to apply. The particular rule depends on the matcher name, the monad and the number of excess state arguments that the weakest precondition target is applied to.

                    The instance is keyed by ExprPtr, so lookups compare it by pointer rather than structurally. This is sound because the instance is a subterm of the hash-consed goal target.

                  • A cache mapping lattice connectives to their backward rule to apply, keyed by the head … cₙ prefix of constant arguments the rule bakes in verbatim and the total argument count that fixes the schematic operand and state count.

                    The prefix is keyed by ExprPtr, so lookups compare it by pointer rather than structurally. This is sound because it is a subterm of the hash-consed goal target.

                  • Caches the frame rule (meet_op_wp_upperAdjoint_le_wp), keyed by the WPMonad instance and the number of excess state arguments.

                  • rintroBackwardRuleCache : Std.HashMap Name Meta.Sym.BackwardRule

                    Caches the backward rules of the @[vcgen_rintro] rules, keyed by declaration name.

                  • frameDB : FrameDB

                    The frame database from the frames clause.

                  • invariants : Array MVarId

                    Holes of type Invariant that have been generated so far.

                  • The verification conditions that have been generated so far. Each entry shares the parent Grind.Goal's state.

                  • Persistent cache of Context.simpMethods. Threading this cache across VCGen iterations avoids re-simplifying shared subexpressions (e.g., s + 1 + 1 + ... chains).

                  • fuel : Do.Fuel

                    Remaining VC-generation steps. Initialized from Context.config.stepLimit (or .unlimited when no limit is set). Decremented at each successful program-shape step (tryLetHoist, trySplit, tryFvarZeta, applySpec). When exhausted, solve short-circuits and emits the current goal as a VC.

                  • inlineHandledInvariants : Std.HashSet Nat

                    Set of invariant numbers that have been inline-elaborated by Driver.emitVC via tryInlineInvariant. The post-hoc invariant elaboration in Frontend consults this to know which user-provided alts have already been consumed (so it doesn't warn about them).

                  • pendingJoinPoints : Std.HashMap MVarId (JoinPoint × Array Jump)

                    The join points whose RHS goal vcgen has yet to process, keyed by that goal, with their jumps so far.

                  Instances For
                    Equations
                    Instances For

                      Walk goal's local context from scope.nextDeclIdx onward, registering any spec-shaped hypotheses as local specs. Advances nextDeclIdx to the current context size so siblings share work.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        True iff fuel has been exhausted (Fuel.limited 0).

                        Equations
                        Instances For

                          Decrement remaining fuel by one. No-op when fuel is .unlimited or already at zero.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Run k with methods and Context.simpConfig on the persistent simp state State.simpState. The state is taken out of VCGenM's state for the run, so k updates it in place.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For