Skip to main content

Module combinators

Module combinators 

Source
Expand description

Tactic values and the combinators that compose them — the language layer over the primitive ProofState methods. The backtracking combinators (first, try_, repeat) speculate on a clone of the state and commit only on success, so a partial failure never corrupts the proof.

Functions§

all_goals
any_goals
t1 <;> t2-style: apply t to EVERY goal currently open (not just the focused one). Each goal is focused in turn; the subgoals t produces for it become the new open set, in original goal order. any_goals t: run t on every open goal, keeping the goals it left and the goals it declined alike, and succeed iff it succeeded on AT LEAST ONE.
apply
apply name (modus ponens against a named rule) as a tactic value.
assumption
assumption as a tactic value.
auto
auto (the backward chainer) as a tactic value.
by_contra
by_contra h as a tactic value.
by_rule
by_rule R as a tactic value — discharge the goal with the NAMED inference rule.
calc
calc h1 h2 … as a tactic value — compose the named chain.
cases
cases name (∧/∨/∃ elimination) as a tactic value.
cases_with
cases name with a b as a tactic value.
crush
crush as a tactic value.
decide
decide as a tactic value.
exact
exact name as a tactic value.
exact_term
exact <term> as a tactic value.
exists
exists witness (∃I) as a tactic value.
exists_term
exists <term> as a tactic value, with the witness resolved against the goal’s scope.
first
first [t1, t2, …]: try each tactic on a speculative copy and commit the first that succeeds; fail only if none apply.
focus
· t / focus t / next t: run t on the focused goal ALONE, and make it an error for the block to leave that goal open.
have
have name from <term> as a tactic value.
induction
induction (structural induction over Nat) as a tactic value.
induction_on
induction name as a tactic value.
induction_over
induction_over (generic structural induction over ind_type) as a tactic value.
intro
intro name as a tactic value.
left
left (∨I) as a tactic value.
linarith
omega as a tactic value. linarith (rational Fourier-Motzkin with a Farkas certificate) as a tactic value.
omega
refine
refine <term> as a tactic value.
repeat
repeat t: apply t as long as it keeps applying (committing each success), then stop. Always succeeds. Bounded to avoid a non-progressing tactic looping forever.
rewrite
rewrite_at
rewrite name (Leibniz substitution by an equality) as a tactic value. rewrite h at k as a tactic value — the k-th occurrence, 0-based.
rewrite_hyp_at
rewrite h at hp — the LOCATION form, rewriting a HYPOTHESIS rather than the goal.
rfl
rfl (close t = t by reflexivity) as a tactic value.
right
right (∨I) as a tactic value.
ring
ring (commutative-ring normalisation) as a tactic value.
seq
t1; t2; …: run each tactic in turn; fail (without committing the rest) at the first that does not apply.
simp
simp as a tactic value, its rule set drawn from everything in scope (premises, intro’d hypotheses, cited lemmas) — the script-level default.
simp_only
simp only [a, b] as a tactic value — the rule set is exactly the named hypotheses.
simp_with
simp [a, b] as a tactic value — Lean’s “these AS WELL”, which for a default set that is already the whole scope adds nothing. The names are still resolved, so a typo is an error rather than a silently ignored rule.
split
split (∧I) as a tactic value.
then_all
t1 <;> t2: run t1 on the focused goal, then t2 on exactly the goals t1 PRODUCED — not on every goal that happens to be open.
try_
try t: run t if it applies, otherwise leave the state unchanged. Always succeeds.