3.2. Choosing Solver Facts
3.2.1. Hint Lists Add Facts
Hint lists follow grind: every form of the call includes every local
hypothesis whose type is a proposition, and a list only adds to them.
theorem orderedTrans (a b c : Int)
(hab : a ≤ b) (hbc : b ≤ c) : a ≤ c := a:Intb:Intc:Inthab:a ≤ bhbc:b ≤ c⊢ a ≤ c
All goals completed! 🐙
-
Bare
crushandcrush []use all local hypotheses. -
crush [h], for a localh, also givesheager ground instantiation. -
crush [foo], for a lemma, addsfoowith eager ground instantiation. -
crush [f], for a definition, adds the equations off, asu[f]does. -
crush [*]gives every local hypothesis eager ground instantiation. -
crush only [...]drops the automatically collected lemmas:@[crush_unfold]and@[crush_defeq]equations,@[reducible]rewrites, and premise selection. -
crush [-foo]removes the global lemmafoofrom the automatic lemmas; for a definition, it removes the definition's equations. -
crush [-h], for a localh, is an error that suggestsclear h.
A list therefore never shrinks the query.
To exclude a hypothesis, clear it before the call:
theorem orderedTransWithoutNoise (a b c : Int)
(hab : a ≤ b) (hbc : b ≤ c)
(noise : ∀ x : Int, x < x + 100) : a ≤ c := a:Intb:Intc:Inthab:a ≤ bhbc:b ≤ cnoise:∀ (x : Int), x < x + 100⊢ a ≤ c
a:Intb:Intc:Inthab:a ≤ bhbc:b ≤ c⊢ a ≤ c
All goals completed! 🐙
Use * to give every local proposition eager ground instantiation, together
with named lemmas that are not already in the context:
theorem orderedTransWithContext (a b c : Int)
(hab : a ≤ b) (hbc : b ≤ c) : a ≤ c := a:Intb:Intc:Inthab:a ≤ bhbc:b ≤ c⊢ a ≤ c
All goals completed! 🐙
Naming the same constant as -foo and as a hint, or in u[...] or d[...],
is an error.
crush removes -foo from everything it collects itself, but it cannot hide it
from Lean code it runs without assembling, such as instance synthesis, simprocs,
and the tactics used in checked reconstruction.
When the finished proof still uses foo (or, for a definition -f, one of its
equation lemmas), crush warns, says how the goal was closed, and lists the
axioms foo depends on.
The kernel unfolding a definition by definitional reduction leaves no constant,
so the warning cannot see that use.
3.2.2. Supplying Lemmas
Explicit lemmas need not already be hypotheses. lean-crush specializes polymorphic lemmas and generates bounded ground instances before translation. This often avoids unpredictable solver-side quantifier instantiation:
axiom successorPositive :
∀ x : Int, 0 ≤ x → 0 < x + 1
example (x : Int) (hx : 0 ≤ x) : 0 < x + 1 := x:Inthx:0 ≤ x⊢ 0 < x + 1
All goals completed! 🐙
Ground instantiation is bounded by crush.inst.fuel and
crush.inst.rounds.
Monomorphization has separate crush.mono.fuel and crush.mono.rounds
bounds.
3.2.3. Automatic Premise Selection
Bare crush can ask Lean's registered LibrarySuggestions engine for relevant
library theorems:
set_option crush.premises true set_option crush.premises.max 32
Premise selection is useful when the needed theorem is not obvious, but it can
make performance and dependencies less predictable.
A hint list keeps premise selection; crush only [...] disables it, and
-foo keeps one theorem out of it.
Once the relevant theorems are known, prefer naming them explicitly.