pub struct ProofState { /* private fields */ }Expand description
The interactive proof state: the partial derivation plus the queue of open
goals (front = focused). Tactics consume the focused goal and push any subgoals
they create back to the front, so the proof is built depth-first, first-subgoal
first — the order a reader expects. Clone is cheap relative to a proof and is
what lets the backtracking combinators (first/try/repeat) speculate.
Implementations§
Source§impl ProofState
impl ProofState
Sourcepub fn start(premises: Vec<ProofExpr>, goal: ProofExpr) -> Self
pub fn start(premises: Vec<ProofExpr>, goal: ProofExpr) -> Self
Begin proving goal from premises, naming the hypotheses hp0, hp1, ….
Sourcepub fn start_with_names(
premises: Vec<ProofExpr>,
names: &[Option<String>],
goal: ProofExpr,
) -> Self
pub fn start_with_names( premises: Vec<ProofExpr>, names: &[Option<String>], goal: ProofExpr, ) -> Self
Begin proving goal from premises, using the given names for the
hypotheses where present (parallel to premises), falling back to the
positional hp{i} otherwise. Lets a surface Given (h): … name a premise so a
Proof: script can say cases h instead of cases hp0.
Sourcepub fn open_goals(&self) -> usize
pub fn open_goals(&self) -> usize
Number of still-open goals.
Sourcepub fn focused_target(&self) -> Option<&ProofExpr>
pub fn focused_target(&self) -> Option<&ProofExpr>
The focused goal’s target, if any goal is open — the tactic-script and IDE surface for inspecting where a proof stands.
Sourcepub fn scope_simp_set(&self) -> SimpSet
pub fn scope_simp_set(&self) -> SimpSet
A crate::simp::SimpSet compiled from every in-scope hypothesis that
orients as a rewrite rule — the default rule set for the script-level
simp (a premise or cited lemma of rule shape is automatically a rule).
Sourcepub fn context_simp_set(&self, ctx: &Context) -> SimpSet
pub fn context_simp_set(&self, ctx: &Context) -> SimpSet
A crate::simp::SimpSet combining the in-scope hypotheses with every @[simp]
lemma REGISTERED in a kernel context — the script-level simp of a development whose
attribute set is available.
The scope set alone is a per-goal accident: a lemma is a rule because it happens to be
a hypothesis here. @[simp] is the opposite — a declaration, made once, that says this
equation is how the simplifier should normalise from now on. Both feed the same
rewriter, which is the point: one notion of a rule, two ways to reach it.
Sourcepub fn named_simp_set(&self, names: &[String]) -> Result<SimpSet, TacticError>
pub fn named_simp_set(&self, names: &[String]) -> Result<SimpSet, TacticError>
A crate::simp::SimpSet built from EXACTLY the named hypotheses — the rule set of
Lean’s simp only [h₁, h₂].
Selection is the whole point of only: the default set is every in-scope hypothesis
that orients, so two simp only calls meant to stop at different normal forms
collapse into one, and the collapse runs in the dangerous direction (MORE rules than
the source asked for). An unknown name, or one that does not orient as a rewrite
rule, is an error rather than a silently empty set.
Sourcepub fn intro(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn intro(&mut self, name: &str) -> Result<&mut Self, TacticError>
intro name: for a goal P → Q, assume P as hypothesis name and reduce
to Q; for ∀x. φ(x), introduce the bound variable under name and reduce
to φ(name). Mirrors Lean’s intro.
Sourcepub fn assumption(&mut self) -> Result<&mut Self, TacticError>
pub fn assumption(&mut self) -> Result<&mut Self, TacticError>
assumption: close the goal with any hypothesis whose proposition is exactly
the target, emitting THAT hypothesis’s proof (a direct reference, or a
ConjunctionElim projection for a conjunct extracted by cases).
Sourcepub fn exact(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn exact(&mut self, name: &str) -> Result<&mut Self, TacticError>
exact name: close the goal with the specifically-named hypothesis, which
must prove the target.
Sourcepub fn split(&mut self) -> Result<&mut Self, TacticError>
pub fn split(&mut self) -> Result<&mut Self, TacticError>
constructor / split: for a goal A ∧ B, reduce to the two subgoals A
and B.
Sourcepub fn left(&mut self) -> Result<&mut Self, TacticError>
pub fn left(&mut self) -> Result<&mut Self, TacticError>
left: prove A ∨ B by proving A.
Sourcepub fn right(&mut self) -> Result<&mut Self, TacticError>
pub fn right(&mut self) -> Result<&mut Self, TacticError>
right: prove A ∨ B by proving B.
Sourcepub fn exists(&mut self, witness: ProofTerm) -> Result<&mut Self, TacticError>
pub fn exists(&mut self, witness: ProofTerm) -> Result<&mut Self, TacticError>
exists w: prove ∃x. φ(x) by exhibiting the witness w and reducing to
φ(w).
The witness is an arbitrary TERM — use (n + 1), use (f x) — which is what Lean’s
exists/use takes. A compound witness used to be REFUSED here, because
InferenceRule::ExistentialIntro carries its witness as a String that the certifier
resolves as one name: add(n, 1) certified to a global literally called
"add(n, 1)", which no context declares, so the kernel rejected the artefact at
qed — a failure arriving so far from the mistake that it read as “the theorem is
false”. The rule now carries the term (InferenceRule::ExistentialIntroTerm,
exactly as UniversalInstTerm sits beside UniversalInst for the dual quantifier),
so the honest answer is to take the step.
A bare NAME still emits ExistentialIntro, which is not a fast path but a
COMPATIBILITY one: producers and consumers of that rule (including the eigenconstant
renaming in engine::rewrite_tree_const_to_var) match on its String witness.
The ∃-binder’s DOMAIN is computed, not assumed: certifier::existential_domain reads
it off the body, and proof_expr_to_type builds the goal type with the same function,
so an arithmetic existential is Ex Int (λm:Int. …) on both sides of the trust door.
Stamping the FOL default Entity on ∃m. m = n + 1 produced Eq Int m with
m : Entity, which is not well-typed at all.
Sourcepub fn rfl(&mut self) -> Result<&mut Self, TacticError>
pub fn rfl(&mut self) -> Result<&mut Self, TacticError>
rfl: close a goal t = t by reflexivity.
The closer itself is not new — simp has always ended with it — but it had no name of its
own, so a script could only reach reflexivity by asking for simplification and hoping. One
closer, two names: simp now delegates here rather than carrying a second copy.
Sourcepub fn exact_term(&mut self, term: &PTerm) -> Result<&mut Self, TacticError>
pub fn exact_term(&mut self, term: &PTerm) -> Result<&mut Self, TacticError>
exact e: close the goal with a proof TERM, not merely a hypothesis name.
exact (hpq hp), exact (hp, hq), exact h where h : ∀m. P m against P n — all
ordinary Lean, and all of them elaborate here against the goal. A term carrying a
hole is refused: leaving goals open is refine’s job, and an
exact that quietly did that would report a proof it had not finished.
Sourcepub fn refine_term(&mut self, term: &PTerm) -> Result<&mut Self, TacticError>
pub fn refine_term(&mut self, term: &PTerm) -> Result<&mut Self, TacticError>
refine e: elaborate a proof term against the goal, and leave one SUBGOAL per hole,
in the order the holes appear.
The holes are proof-state goals (Node::Hole), never kernel term holes: the kernel’s
types_equal matches Term::Hole against ANYTHING, so a term with a hole in it
typechecks and the resulting certificate is indistinguishable from a real one. A hole
that is the WHOLE term is refused — it leaves the goal exactly as it was, so it is a
step that claims to have done something and has not.
Sourcepub fn have_term(
&mut self,
name: &str,
term: &PTerm,
) -> Result<&mut Self, TacticError>
pub fn have_term( &mut self, name: &str, term: &PTerm, ) -> Result<&mut Self, TacticError>
have h from e: add h, proved by the term e, to the local scope.
Nothing among the primitives introduced a hypothesis with an accompanying proof:
intro takes one from the goal’s antecedent, cases from an existing hypothesis’s
shape, and that was the complete set of ways a name entered a goal’s scope. The
hypothesis carries the elaborated derivation itself, so each USE emits that proof —
no new rule, no lifted theorem, and a have whose statement mentions an
intro-bound variable works like any other.
Sourcepub fn value_term(&self, term: &PTerm) -> Result<ProofTerm, TacticError>
pub fn value_term(&self, term: &PTerm) -> Result<ProofTerm, TacticError>
Elaborate a script term as a VALUE — an ∃ witness, or the argument of a universal.
A bare name is the Variable the surrounding proof bound if the goal’s scope has one
of that name, and a Constant otherwise. That distinction is invisible in every
diagnostic a user sees (both Display as the bare name) and decides whether the
instantiated goal matches its context at all, so it is READ OFF the scope rather than
guessed: intro n . exists n must produce the n that intro bound.
Sourcepub fn by_contra(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn by_contra(&mut self, name: &str) -> Result<&mut Self, TacticError>
by_contra h: assume the goal is FALSE under the name h and leave ⊥ to derive.
Lean’s by_contra is a STEP, and that is the whole point: a proof shaped
intro x; by_contra h; <twenty steps> needs the twenty steps to be writable. The
classical reductio itself is not new — auto’s search reaches it — but only as one
opaque call with no way to help it along. Certified as ClassicalReductio, which
discharges through the single classical axiom dne, so the axiom footprint of the
theorem still records that it went classical.
Sourcepub fn ring(&mut self) -> Result<&mut Self, TacticError>
pub fn ring(&mut self) -> Result<&mut Self, TacticError>
ring: close a polynomial identity over the commutative-ring vocabulary
(add/sub/mul over literals and opaque atoms).
The normaliser is not new — it is crate::arith::prove_int_eq, the same
proof-PRODUCING oracle InferenceRule::ArithDecision certifies through, whose
trusted base is the seven registered ring axioms. What was missing was a name on the
tactic-script surface: ring was reachable only from the literate kernel surface,
and the three vernacular surfaces did not interoperate.
The oracle is consulted HERE, not only at qed: its polynomial layer is a COMPLETE
negative decision, so a goal that is not a formal ring identity is declined by the
tactic rather than accepted and blown up at the trust door.
Sourcepub fn apply_named(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn apply_named(&mut self, name: &str) -> Result<&mut Self, TacticError>
apply h: look the rule up by hypothesis NAME, then reduce the goal by modus ponens.
ProofState::apply takes the rule as a ProofExpr, which a proof script has no way to
write — that is the whole reason apply was unreachable from script text despite working.
This is the name-taking door, mirroring ProofState::exact.
Sourcepub fn apply(&mut self, rule: &ProofExpr) -> Result<&mut Self, TacticError>
pub fn apply(&mut self, rule: &ProofExpr) -> Result<&mut Self, TacticError>
apply rule: rule is P → Goal (a hypothesis or premise). Reduce the goal
to its antecedent P by modus ponens.
Sourcepub fn cases(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn cases(&mut self, name: &str) -> Result<&mut Self, TacticError>
cases h / destruct h: eliminate a hypothesis by its shape.
A ∧ B: addh_1 : Aandh_2 : Bto the goal, each backed by theConjunctionElimprojection ofh— so using a conjunct emits the projection, never a dangling reference.A ∨ B: split into two goals, one assumingA, one assumingB(DisjunctionCases).∃x. φ: introduce a fresh witnesscand the hypothesisφ(c)(ExistentialElim); the goal must not mentionc, which holds since it is fresh.
Sourcepub fn cases_with(
&mut self,
name: &str,
names: &[String],
) -> Result<&mut Self, TacticError>
pub fn cases_with( &mut self, name: &str, names: &[String], ) -> Result<&mut Self, TacticError>
cases h with a b / obtain ⟨a, b⟩ := h: cases, with the components
bound under the names the PROOF chose instead of the generated
h_1/h_2/h_l/h_r/h_w.
A Lean proof names what it destructures and every later step cites those names; a
translator forced to renumber them is rewriting the proof. The arity is checked
against the shape, because cases h with hp on a conjunction is a mistake about what
h IS, not a shorthand.
The ∃ branch takes with w hw: w names the fresh eigen-constant and hw the
instantiated body. A chosen witness name is REFUSED when it is already in play in the
goal or its scope — the eigenvariable condition is what makes ∃-elimination sound,
and a name the surrounding proof already uses is not fresh.
Sourcepub fn induction(&mut self) -> Result<&mut Self, TacticError>
pub fn induction(&mut self) -> Result<&mut Self, TacticError>
induction: structural induction on the goal’s OUTERMOST ∀ binder.
The scheme is READ OFF the scope rather than hard-wired: a hypothesis P(C) names a
nullary constructor and a hypothesis ∀ā. (P(aᵢ) → …) → P(C ā) names a constructor
with induction hypotheses at the aᵢ, so a goal over a list whose ENil/ECons
premises are in scope splits on ENil and ECons — where the hard-wired Peano scheme
substituted Zero/Succ k into a list-valued position and produced syntactically
well-formed nonsense that the automation would then happily “prove”. Nat keeps the
specialised path, whose Fix/Match certifies over the kernel’s own Nat recursor;
everything else routes to the dependent induction_over.
Sourcepub fn induction_on(&mut self, variable: &str) -> Result<&mut Self, TacticError>
pub fn induction_on(&mut self, variable: &str) -> Result<&mut Self, TacticError>
induction n: structural induction on the NAMED variable, wherever it sits in the
goal’s ∀ prefix.
The argumentless induction takes whatever binder happens to be
outermost, so against ∀m n. Q m n it and Lean’s induction n prove DIFFERENT
theorems — both certified, and nothing downstream can tell. Naming the variable is
how a translator says which one it meant.
For an inner variable the goal is first GENERALIZED: ∀ō. ∀v. body is proved from
∀v. ∀ō. body — the motive λv. ∀ō. body, which is the strengthened induction
hypothesis a proof by induction on an inner variable needs. The bridge between the
two orders is built from UniversalIntro and UniversalInst alone (introduce the
prefix, then instantiate the reordered theorem at the introduced variables), so it
certifies through rules that already existed — no new axiom, no new rule.
When the prefix does not bind v at all the tactic does NOT refuse: it takes Lean’s
reading and generalizes — see induction_generalizing.
Sourcepub fn induction_over(
&mut self,
ind_type: &str,
ctors: Vec<CtorSpec>,
) -> Result<&mut Self, TacticError>
pub fn induction_over( &mut self, ind_type: &str, ctors: Vec<CtorSpec>, ) -> Result<&mut Self, TacticError>
induction_over: generic structural induction over ANY inductive ind_type,
one subgoal per constructor. On a goal ∀x. P(x), each constructor C a₀…aₙ
yields the subgoal P(C a₀ … aₙ); every recursive argument aᵢ (one of the
inductive type) contributes an induction hypothesis P(aᵢ), placed FIRST so
auto/assumption discharge the recursive obligation against the IH rather
than a base fact. Generalizes induction (fixed to the
nullary-base + unary-step Nat shape) to constructors with several — or zero —
recursive positions (Nil/Cons, Leaf/Node, an N-way enum). Assembled as
the dependent InductionScheme eliminator (fix rec. λx. match x { … }), which
the kernel re-checks for coverage, case types, and termination.
The constructor arguments run the search as rigid eigen-CONSTANTS (so the
backward chainer neither grounds nor unrolls them); assemble
remaps each back to the bound Variable the certifier’s match arm binds.
Sourcepub fn rewrite(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn rewrite(&mut self, name: &str) -> Result<&mut Self, TacticError>
rewrite h: rewrite the goal left-to-right by the equation h.
h may be GROUND (lhs = rhs) or ∀-QUANTIFIED (∀x̄. lhs = rhs), which is the
commonest kind in real mathematics and had no image at all before. A quantified
equation is instantiated the way Lean’s rw instantiates it: the first (outermost,
leftmost) subterm of the goal that matches lhs fixes the pattern variables, and the
rewrite then replaces that INSTANTIATED left-hand side — so ∀x. f x = g x against
f 1 = g 1 ∧ f 2 = g 2 touches the f 1 and leaves the f 2 alone.
Substitution is capture-avoiding (substitute_in_expr), so an occurrence the goal
BINDS is not an occurrence of the pattern and a replacement mentioning a free
variable is not captured by a binder that happens to share its spelling.
Certified by Eq_rec (Leibniz): the node concludes the original goal, its equality
premise proves rhs = lhs (the ∀-instantiation chain over h, then symmetry), and
its source premise is the rewritten subgoal. Fails if the pattern does not occur.
ONE occurrence — the first. rw used to rewrite every structural match, so a goal
P(a, a) with h : a = b could only become P(b, b), and the frequently-provable
P(b, a) was unreachable from any surface: InferenceRule::Rewrite carried no
position either, so even a Rust caller had nowhere to say which one it meant. Use
ProofState::rewrite_at to name another occurrence; repeat (rewrite h) recovers
the all-occurrences sweep, one certified step per occurrence.
Sourcepub fn rewrite_at(
&mut self,
name: &str,
occurrence: usize,
) -> Result<&mut Self, TacticError>
pub fn rewrite_at( &mut self, name: &str, occurrence: usize, ) -> Result<&mut Self, TacticError>
rewrite h at k: ProofState::rewrite aimed at the k-th (0-based) FREE
occurrence of the equation’s left-hand side, counted left to right. Lean’s conv
and its occurrence arguments exist for exactly this, and the occurrence travels all
the way to the trust door as InferenceRule::RewriteAt — the Eq_rec motive
abstracts that one position, so the kernel re-checks the choice rather than taking
the tactic’s word for it.
Sourcepub fn rewrite_hyp_at(
&mut self,
eq_name: &str,
hyp_name: &str,
occurrence: usize,
) -> Result<&mut Self, TacticError>
pub fn rewrite_hyp_at( &mut self, eq_name: &str, hyp_name: &str, occurrence: usize, ) -> Result<&mut Self, TacticError>
rewrite h at hp: rewrite the HYPOTHESIS hp with the equation h — Lean’s
rw [h] at hp, and the LOCATION half of positional rewriting.
ProofState::rewrite_at reads and writes the GOAL only, so a Lean proof that
normalises a hypothesis before using it had no image at all. The corpus case for conv
makes the point sharply: positional rewriting has two aspects, the POSITION and the
LOCATION, and “a translator that fixes only one of them has fixed nothing”.
The step runs FORWARD, where the goal rewrite runs backward: the hypothesis’s own
derivation is the SOURCE premise and the rewritten proposition is the conclusion, so the
goal is untouched and only the context moves. Nothing is ASSUMED — the new hypothesis
carries a complete Eq_rec derivation built from the old one, which assumption and
exact splice in and which qed re-checks like any other step. That is why no
refinement node is needed: a hypothesis in this proof state is a proposition WITH its
proof, and this replaces both at once.
The motive’s position is CHOSEN by crate::engine::leibniz_step rather than taken
from the caller’s index: the tactic layer counts occurrences in a ProofExpr and the
kernel counts them in a Term, the two agree on the leftmost and can differ deeper, and
the kernel is the one that decides.
Sourcepub fn rewrite_hyp(
&mut self,
eq_name: &str,
hyp_name: &str,
) -> Result<&mut Self, TacticError>
pub fn rewrite_hyp( &mut self, eq_name: &str, hyp_name: &str, ) -> Result<&mut Self, TacticError>
rewrite h at hp at the FIRST occurrence — the spelling a script writes.
Sourcepub fn simp(&mut self, set: &SimpSet) -> Result<&mut Self, TacticError>
pub fn simp(&mut self, set: &SimpSet) -> Result<&mut Self, TacticError>
simp: normalize the focused goal by the rule set, left-to-right to a
fixpoint, then close it if it became trivial (reflexivity or an exact
hypothesis). Mirrors Lean’s simp.
Each rewrite is one certified Rewrite refinement — the instantiated
rule equality (a UniversalInstTerm chain over the lemma, conditions
discharged by ModusPonens) is the closed premise, the rewritten goal
the open one — so qed re-checks every step in the kernel. Loop
protection is a step budget plus a seen-goal set (commuting rules like
a = b, b = a terminate instead of ping-ponging). Fails only if it
neither rewrote nor closed anything.
Sourcepub fn decide(&mut self) -> Result<&mut Self, TacticError>
pub fn decide(&mut self) -> Result<&mut Self, TacticError>
decide: close the focused goal by evaluation, if it is a closed decidable
proposition that evaluates TRUE — ground arithmetic (at ARBITRARY precision, the
kernel’s own), comparisons, Bool equalities, a ground DISEQUALITY, and ∧/∨/→/¬ over
them. Mirrors Lean’s decide. A false or open goal is declined.
The two ways this declines are now two different messages. They used to be one — “not
a closed decidable goal (or it is false)” — and that conflation is dangerous in one
direction: a caller that reads DoesNotApply as “try another tactic” keeps searching
past a goal that is actually FALSE, and may eventually close it from an unrelated
contradiction by ex falso, producing a certified proof of a statement nobody asserted.
decide knows the difference; now it says it.
Sourcepub fn linarith(&mut self) -> Result<&mut Self, TacticError>
pub fn linarith(&mut self) -> Result<&mut Self, TacticError>
omega: linear INTEGER arithmetic. When the in-scope ≤/< hypotheses
are jointly unsatisfiable over ℤ — using discreteness (a < b ⟹ a+1 ≤ b),
the fact rational solvers lack — refute them and discharge ANY goal by
ex-falso. Proves x < y ∧ y < x+1 ⊢ Q, which linarith cannot (that
system is rationally satisfiable). Mirrors the refutation half of Lean’s
omega. Declines when the hypotheses have an integer model.
linarith: refute the arithmetic hypotheses over the RATIONALS, by Fourier-Motzkin with
a Farkas certificate — and decline anything that needs integrality.
linarith was an ALIAS for omega, which tightens a < b to a + 1 ≤ b. That is sound
over ℤ and unsound over an ordered field: ProofExpr is untyped, so nothing records the
carrier, and a goal false over ℚ could be certified because the integer step found a
refutation the rationals do not have. Routing here — engine::cert_farkas, the same
rational core the backward chainer already uses, without the discreteness step — makes
linarith mean what its name means. omega keeps the integer reasoning under its own name.
Sourcepub fn omega(&mut self) -> Result<&mut Self, TacticError>
pub fn omega(&mut self) -> Result<&mut Self, TacticError>
A DECISION PROCEDURE for the goal, not only a refutation of the hypotheses.
Lean’s omega negates the goal, adds it to the hypothesis set, and refutes; ours
only ever refuted g.hyps, so x ≤ 3 ⊢ x ≤ 4 — the shape most real uses have —
was DECLINED with a message (“the integer hypotheses are satisfiable”) that described
the hypotheses when the problem was that there was no way to attack the goal at all.
Three halves now, in order:
- Refute the hypotheses. Unchanged, and still first: contradictory bounds discharge ANY goal by ex falso.
- Prove the goal directly. A ground comparison by computation; a
≤goal by chaining the in-scope≤facts (le_trans/le_refl); anIntEQUALITY goal through the ring oracle, which is hown + 0 = n— anomegagoal in Lean with no hypotheses whatever — gets proved. - Split on totality and refute the other side.
le_total a bis already in the trusted base, and its own comment names this use. For a≤goal, take the goal itself in the left branch and refutehyps ∪ {b ≤ a}in the right.
Half 3 is deliberately the SOUND, axiom-free approximation of “negate the goal”:
¬(a ≤ b) is b + 1 ≤ a over ℤ, one unit stronger than the b ≤ a totality gives,
and the extra unit needs an axiom (¬(a ≤ b) → b + 1 ≤ a, or antisymmetry) that the
trusted base does not have. Adding one to widen a tactic would trade a visible
capability gap for an invisible trust cost, so it is NOT done here; the fragment this
reaches is “every goal whose negation-by-totality is refutable”, which covers every
goal with slack. The gate is likewise relaxed: an arithmetic GOAL admits the tactic
even with no arithmetic hypothesis in scope, which is the no-hypothesis Lean case.
Sourcepub fn calc(&mut self, names: &[String]) -> Result<&mut Self, TacticError>
pub fn calc(&mut self, names: &[String]) -> Result<&mut Self, TacticError>
calc h₁ h₂ …: compose the NAMED order/equality facts into the goal — Lean’s calc,
whose job is a chain whose RELATION CHANGES along it.
calc existed on no LOGOS surface. The pure-= chain had an expansion (three
rewrites), but a MIXED chain did not: the order graph walked ≤ edges alone, with no
arm that could consume an equality, so a single = step anywhere made the chain
unreachable. The composition now lives in engine::cert_le_chain — ≤ edges,
discreteness-tightened < edges, and equality edges including their CONGRUENT images
(a = b bridging a + 1 to b + 1) — and this is its name on the surface.
Naming the facts is the point, exactly as simp only [h] names its rule set: auto
searches everything in scope, while a calc block says which steps, in which order,
and fails if they do not compose. A goal a ≤ d composes through the chain; an
equality goal composes through congruence closure over the named equations.
The relation the chain CONCLUDES is = or ≤. A strict < conclusion is not
certifiable at all: of the eight Int order axioms none concludes a lt (lt_succ_le
and lt_add1_le both take one as a premise), so the composition can state its result
only in the tightened form a + 1 ≤ d. The missing primitive is the converse
le_succ_lt : Π a b. (a + 1) ≤ b → a < b, one new Int axiom — named here rather than
assumed, because widening a tactic by growing the trusted base is the one trade this
campaign forbids.
Sourcepub fn by_rule(&mut self, name: &str) -> Result<&mut Self, TacticError>
pub fn by_rule(&mut self, name: &str) -> Result<&mut Self, TacticError>
by_rule R: discharge the focused goal in ONE step with the NAMED inference rule,
from the facts already in scope.
The language AST has carried a public ProofStrategy::ByRule(name) variant — with
Proof: ModusPonens. as its own documented example — that nothing in the workspace
constructs and no driver has an arm for, because the proof layer offered no way to
apply a rule by its name. This is that door.
It is a real tactic and not a label, and three things make it one:
- A name that is not a rule is a NAME error, listing the rules that are — a translator handing us a Lean rule name needs to know which of the two kinds of failure it hit.
- A rule that is declared but has no certifier arm reports
InferenceRule::uncertifiable_reason— the list exists precisely so a PRODUCER can consult it before emitting a tree, and this is the one place in the crate that does. - The node is certified BEFORE success is reported.
by_rule Rsucceeds only when the kernel agrees that R, applied to facts in scope, proves this goal — so it can never handqeda derivation the trust door must refuse.
The premises are drawn from the hypotheses in scope and nowhere else: by_rule is one
step, not a search. A goal needing a subproof is auto’s, or is written out.
Sourcepub fn crush(&mut self) -> Result<&mut Self, TacticError>
pub fn crush(&mut self) -> Result<&mut Self, TacticError>
crush: the grind-style closer. E-matches the in-scope ∀-equality
lemmas at the goal’s ground terms, then discharges the goal by certified
congruence closure. Proves goals plain auto cannot — e.g.
∀x. f(x)=g(x), a=b, P(g(b)) ⊢ P(f(a)) — and every step is kernel-checked.
Sourcepub fn auto(&mut self) -> Result<&mut Self, TacticError>
pub fn auto(&mut self) -> Result<&mut Self, TacticError>
auto: discharge the focused goal with the backward chainer (the existing
automation, hosted as one tactic). Its hypotheses and the premises are the
available knowledge base.
With the verification feature the chainer’s last resort is the Z3 oracle, whose
OracleVerification leaf attests a goal without a proof term. The chainer reaches
it only after every certifiable strategy failed, so such a tree means auto found
no proof: close refuses it and auto declines.
Sourcepub fn assembled(&self) -> Option<DerivationTree>
pub fn assembled(&self) -> Option<DerivationTree>
Assemble the current proof tree, if every goal is closed (for inspection/debug).
Sourcepub fn run(&mut self, t: &Tactic) -> Result<&mut Self, TacticError>
pub fn run(&mut self, t: &Tactic) -> Result<&mut Self, TacticError>
Run a composed Tactic against this state, for fluent chaining with the
primitive methods.
Sourcepub fn qed(&self) -> Result<VerifiedProof, TacticError>
pub fn qed(&self) -> Result<VerifiedProof, TacticError>
Finish the proof: every goal must be closed. Assembles the recorded tactic
steps into one derivation and runs it through the kernel trust door — the
returned VerifiedProof is verified only if the kernel accepts the term.
Source§impl ProofState
impl ProofState
Sourcepub fn run_script(&mut self, src: &str) -> Result<&mut Self, ScriptError>
pub fn run_script(&mut self, src: &str) -> Result<&mut Self, ScriptError>
Parse and run a proof script against this state. The state is unchanged on a parse error; a tactic that fails mid-run leaves whatever it had committed.
Sourcepub fn run_script_with_env(
&mut self,
src: &str,
env: &TacticEnv,
) -> Result<&mut Self, ScriptError>
pub fn run_script_with_env( &mut self, src: &str, env: &TacticEnv, ) -> Result<&mut Self, ScriptError>
Parse and run a proof script that may reference USER-DEFINED tactics from env (M).
Trait Implementations§
Source§impl Clone for ProofState
impl Clone for ProofState
Source§fn clone(&self) -> ProofState
fn clone(&self) -> ProofState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more