The Lean Language Reference

16.1. Error Messages🔗

When grind fails, its error message reports any search thresholds that were reached on the way. This is typically not enough information to diagnose why grind failed, however. Enabling the verbose flag causes the error message to show the subgoal that could not be solved, along with all the information returned by grind's subsystems—the contents of the “shared whiteboard.” In particular, it presents equivalence classes of terms that it has determined to be equal. The two largest classes are shown as True propositions and False propositions, listing every literal currently known to be provable or refutable. Inspect these lists to spot missing facts or contradictory assumptions.

Verbose Failure Messages

This example uses grind in a situation where there is not sufficient information for it to prove the theorem.

example (f : Nat → Nat) (h : f 0 = 1) : f 1 = 1 := f:Nat → Nath:f 0 = 1⊢ f 1 = 1 `grind` has failed, use `+verbose` to obtain diagnostic informationAll goals completed! 🐙

The resulting error message includes almost no information:

`grind` has failed, use `+verbose` to obtain diagnostic information

Enabling the verbose flag makes the error message much more informative:

example (f : Nat → Nat) (h : f 0 = 1) : f 1 = 1 := f:Nat → Nath:f 0 = 1⊢ f 1 = 1 `grind` failed f:Nat → Nath:f 0 = 1h_1:¬f 1 = 1⊢ False
[grind] Goal diagnostics
  • [facts] Asserted facts
    • [prop] f 0 = 1
    • [prop] ¬f 1 = 1
  • [eqc] False propositions
    • [prop] f 1 = 1
  • [eqc] Equivalence classes
    • [eqc] {f 0, 1}
  • [cutsat] Assignment satisfying linear constraints
    • [assign] f 0 := 1
    • [assign] f 1 := 2
All goals completed! 🐙
`grind` failed
f:Nat → Nath:f 0 = 1h_1:¬f 1 = 1⊢ False
[grind] Goal diagnostics
  • [facts] Asserted facts
    • [prop] f 0 = 1
    • [prop] ¬f 1 = 1
  • [eqc] False propositions
    • [prop] f 1 = 1
  • [eqc] Equivalence classes
    • [eqc] {f 0, 1}
  • [cutsat] Assignment satisfying linear constraints
    • [assign] f 0 := 1
    • [assign] f 1 := 2
Threshold Messages

This attempted proof leads to an infinite chain of instantiates of the hypothesis:

example (f : Nat → Nat) (h : ∀ n, f n = f (n + 1)) : f 0 = 1 := f:Nat → Nath:∀ (n : Nat), f n = f (n + 1)⊢ f 0 = 1 `grind` has failed after reaching the threshold `(ematch := 5)`, use `+verbose` to obtain diagnostic informationAll goals completed! 🐙

grind fails after too much E-matching:

`grind` has failed after reaching the threshold `(ematch := 5)`, use `+verbose` to obtain diagnostic information

To see which hypothesis reached the limit, add the verbose flag:

example (f : Nat → Nat) (h : ∀ n, f n = f (n + 1)) : f 0 = 1 := f:Nat → Nath:∀ (n : Nat), f n = f (n + 1)⊢ f 0 = 1 `grind` failed f:Nat → Nath:∀ (n : Nat), f n = f (n + 1)h_1:¬f 0 = 1⊢ False
[grind] Goal diagnostics
  • [facts] Asserted facts
    • [prop] ∀ (n : Nat), f n = f (n + 1)
    • [prop] ¬f 0 = 1
    • [prop] f 0 = f 1
    • [prop] f 1 = f 2
    • [prop] f 2 = f 3
    • [prop] f 3 = f 4
    • [prop] f 4 = f 5
  • [eqc] True propositions
    • [prop] ∀ (n : Nat), f n = f (n + 1)
  • [eqc] False propositions
    • [prop] f 0 = 1
  • [eqc] Equivalence classes
    • [eqc] {f 0, f 1, f 2, f 3, f 4, f 5}
  • [ematch] E-matching patterns
  • [cutsat] Assignment satisfying linear constraints
    • [assign] f 0 := 6
    • [assign] f 1 := 6
    • [assign] f 2 := 6
    • [assign] f 3 := 6
    • [assign] f 4 := 6
    • [assign] f 5 := 6
  • [limits] Thresholds reached
    • [limit] maximum number of E-matching rounds has been reached, threshold: `(ematch := 5)`
[grind] Diagnostics
  • [ematch] E-matching Diagnostics
    • [thm] Theorem Instance Count
      • [thm] h ↦ 5
All goals completed! 🐙

The resulting message demonstrates that h is instantiated five times:

`grind` failed
f:Nat → Nath:∀ (n : Nat), f n = f (n + 1)h_1:¬f 0 = 1⊢ False
[grind] Goal diagnostics
  • [facts] Asserted facts
    • [prop] ∀ (n : Nat), f n = f (n + 1)
    • [prop] ¬f 0 = 1
    • [prop] f 0 = f 1
    • [prop] f 1 = f 2
    • [prop] f 2 = f 3
    • [prop] f 3 = f 4
    • [prop] f 4 = f 5
  • [eqc] True propositions
    • [prop] ∀ (n : Nat), f n = f (n + 1)
  • [eqc] False propositions
    • [prop] f 0 = 1
  • [eqc] Equivalence classes
    • [eqc] {f 0, f 1, f 2, f 3, f 4, f 5}
  • [ematch] E-matching patterns
  • [cutsat] Assignment satisfying linear constraints
    • [assign] f 0 := 6
    • [assign] f 1 := 6
    • [assign] f 2 := 6
    • [assign] f 3 := 6
    • [assign] f 4 := 6
    • [assign] f 5 := 6
  • [limits] Thresholds reached
    • [limit] maximum number of E-matching rounds has been reached, threshold: `(ematch := 5)`
[grind] Diagnostics
  • [ematch] E-matching Diagnostics
    • [thm] Theorem Instance Count
      • [thm] h ↦ 5