Unary VCGen Internals #
Implementation details for the unary VCGen planner and close passes.
Cached raw-wp structural leaf for pure.
The equality theorem wp_pure remains the canonical rewrite rule.
This lower-bound form lets raw wp goals use the cached @[vcspec]
backward-rule path before falling back to @[wpStep].
Cached raw-wp structural leaf for functorial map.
Cached raw-wp structural leaf for conditionals.
Cached raw-wp structural leaf for dependent conditionals.
Cached raw-wp structural leaf for replicate (n + 1).
Cached raw-wp structural leaf for List.mapM on x :: xs.
Cached raw-wp structural leaf for List.foldlM on x :: xs.
Cached raw-wp structural leaf for oracle queries.
Cached raw-wp structural leaf for HasQuery.query.
Generic Loom triple bind step with the intermediate postcondition fixed to
the weakest precondition of the continuation. This is the Std.Do'.Triple
counterpart of OracleComp.ProgramLogic.triple_bind_wp, and lets unary
automation walk transformer-stack do blocks without guessing a user cut.
Close a Loom triple from the corresponding WP entailment.
This is just Std.Do'.Triple.iff.mpr packaged as a theorem so tactic code can expose
the weakest-precondition side condition and then run transformer-specific WP normalizers.
vcspec_simp normalization set #
Centralized registration of the transformer-wp peel lemmas, *.run
projections, monadic-algebra rewrites, and the Loom.wp_eq_mAlgOrdered_wp
bridges that the unary tactic uses to expose spec-applicable goal shapes.
The single simp set is consumed by runVCSpecSimp. New normalization rewrites
should be tagged here (or at definition) rather than inserted into a
tactic-local simp only [...] list.
Instances For
Try to close the current goal using only immediate local information.
This is intentionally cheap: it is used while speculating on triple_bind, so it must not
launch expensive proof search on goals with unresolved cut metavariables.
Instances For
Try bounded local proof search on a closed goal.
We only invoke solve_by_elim once the target has no unresolved expression metavariables; this
avoids pathological search on speculative intermediate cuts introduced by triple_bind.
Instances For
Apply an explicit unary theorem/assumption step and try to close any easy side goals.
When requireClosed is true, the step only succeeds if no goals remain afterwards.
Instances For
Try to close the current goal (typically a Triple subgoal) using direct hypotheses,
canonical leaf rules, or bounded local consequence search.
Instances For
Finish-only closure step: includes the support-sensitive leaf rules that are too expensive
for the default vcstep hot path.
Instances For
Run one bounded finish/closure pass across all current goals.
Instances For
Try to decompose a match expression in the computation by case-splitting
on its discriminant(s). Only fires when the computation is a compiled matcher
(detected via matchMatcherApp?). Delegates to split which handles the actual
case analysis.
Instances For
Check if an expression is a lambda whose body does not use the bound variable
(i.e. a constant function fun _ => c).
Instances For
Try the strongest automatic bind step: triple_bind plus immediate closure of the
spec side-goal.
Instances For
Try only the automatic loop-invariant rules, without the structural fallback rules.
Instances For
Try only the structural loop fallback rules (succ / cons) after invariant search.
Instances For
Apply a loop invariant rule with an explicitly provided invariant.
Instances For
Find the local hypotheses that work as explicit bind cuts.
Instances For
Find the unique local hypothesis that works as an explicit bind cut.
Returns none if there are 0 or ≥ 2 viable candidates.
Instances For
Find the local hypotheses that work as explicit loop invariants.
Instances For
Find the unique local hypothesis that works as an explicit loop invariant.
Returns none if there are 0 or ≥ 2 viable candidates.
Instances For
Find the registered unary @[vcspec] entries whose bounded application
makes progress on the current goal. Prefers direct discrimination-tree hits on
the goal's comp, falling back to kind-matched entries filtered by structural
compatibility.
Instances For
Find the first registered unary @[vcspec] entry whose bounded
application makes progress.
Instances For
Try to close or rewrite a Pr[ ...] = Pr[ ...] goal by swapping adjacent independent binds.
Handles 0–2 layers of tsum peeling.
- swap : ProbEqAction
- congr : ProbEqAction
- congrNoSupport : ProbEqAction
- rewrite : ProbEqAction
- rewriteUnder (depth : ℕ) : ProbEqAction
Instances For
Instances For
Try to decompose a Pr[ ... | mx >>= f₁] = Pr[ ... | mx >>= f₂] goal by congruence,
then auto-intro the bound variable and support hypothesis.
Instances For
Instances For
Build a theorem that swaps adjacent binds under depth shared prefixes.
Try to rewrite one top-level bind-swap without closing the goal.
Instances For
Try to rewrite one bind-swap under depth shared prefixes on either side.
Instances For
Try a small backtracking-free sequence of probability-equality steps.
Instances For
Instances For
Instances For
Explicit probability-equality normalization.
This runs the deeper planner-backed bind-rewrite/congruence search used by vcstep?, but only
when the user asks for it. Plain vcstep keeps the smaller default plan set.
Instances For
Try to handle a Pr[ ...] = Pr[ ...] equality goal by swap, congr, or swap+congr.
Also tries a fallback bridge from exact probOutput equalities into relational VCGen.
Instances For
Try to handle a Pr[ ...] = Pr[ ...] equality goal by swap, congr, or swap+congr.
Instances For
Instances For
Instances For
Try to lower a probability goal into a Triple, wp, or probability-equality goal.
Instances For
Continue structural stepping on a raw wp goal after probability lowering or explicit
wp-level work. This stays deliberately smaller than the Triple path.
Instances For
Try to synthesize a support-based intermediate postcondition for a bind step.
When the computation is oa >>= f and no explicit spec is available, tries applying
triple_bind with an inferred cut and closing the spec subgoal via triple_support,
which unifies the cut to fun x => 𝟙⟦x ∈ support oa⟧.
Instances For
Goal classification and per-kind dispatch #
Mirrors Loom.Tactic.VCGen.GoalKind and classifyGoalKind: the structural
core picks one strategy per goal kind instead of falling through a procedural
cascade. New monad transformers / combinators become a new
UnaryGoalKind constructor plus a registered @[vcspec] rule, not another
tryEvalTacticSyntax block.
Probability lowering is run opportunistically before classification, since
Pr[…] may appear inside wp … goals that should ultimately dispatch via
raw wp or Triple rules; only goals where lowering actually fires bypass
the rest of the pipeline.
High-level classification of a unary VCGen target.
Kept intentionally coarse: structural details (the bind continuation,
ite condition, matcher app, …) live in the comp payload, not in the
constructor, so per-kind handlers can share tryEvalTacticSyntax-style logic
with the existing helpers.
- relational : UnaryGoalKind
A relational
RelTriple/RelWPgoal; defer to the relational planner. - tripleBind
(comp : Lean.Expr)
: UnaryGoalKind
A unary
Triplewhose computation is a>>=application. - tripleIte : UnaryGoalKind
A unary
Triplewhose computation isite c a b(non-dependent). - tripleDite : UnaryGoalKind
A unary
Triplewhose computation isdite c a b(dependent). - tripleMatch
(comp : Lean.Expr)
: UnaryGoalKind
A unary
Triplewhose computation is a compiledmatchmatcher. - tripleLoop
(comp : Lean.Expr)
: UnaryGoalKind
A unary
Triplewhose computation is areplicate/List.mapM/List.foldlMhead. - tripleOther : UnaryGoalKind
A unary
Triplewhose computation does not match the cases above; the dispatcher unfolds to rawwpand lets@[wpStep]rewrite. - rawWp : UnaryGoalKind
A raw
wp/≤ wpgoal. - unknown : UnaryGoalKind
Unrecognized goal shape.
Instances For
Classify the current goal target as a UnaryGoalKind.
Probability lowering is intentionally not a kind here: it runs opportunistically
in runVCGenStructuralCore before classification, so a wp … = ∑' u, Pr[…] * …
goal still classifies as rawWp / tripleOther rather than getting stuck in a
non-lowerable prob branch.
Instances For
Structural/default unary VCGen step, excluding explicit cut/invariant/theorem-driven fallbacks and the final close/search phase.
Implemented as a single goal-kind dispatch (mirroring
Loom.Tactic.VCGen.solve): each kind picks one cluster of strategies, with
the triple* kinds optionally chaining into runTripleFallback so that
specialized dispatchers can defer cleanly. Probability lowering is run
opportunistically before classification so that goals where lowering does not
fire still flow through the structural dispatcher.
Instances For
Choose one unary VCGen step and remember how to replay it explicitly.
Instances For
Execute one planned unary VCGen step, returning the chosen step for replay/trace.
Instances For
One step of VCGen on a Triple goal. Returns true if any progress was made.
Instances For
Run one VCGen pass across all current goals and record the chosen steps.
Instances For
Run one VCGen pass across all current goals.