lean4-htt/tests/lean/omega-failure.lean
Joachim Breitner 784972462a
feat: omega: more helpful error messages (#3847)
while trying to help a user who was facing an unhelpful
```
omega did not find a contradiction:
[0, 0, 0, 0, 1, -1] ∈ [1, ∞)
[0, 0, 0, 0, 0, 1] ∈ [0, ∞)
[0, 0, 0, 0, 1] ∈ [0, ∞)
[1, -1] ∈ [1, ∞)
[0, 0, 0, 1] ∈ [0, ∞)
[0, 1] ∈ [0, ∞)
[1] ∈ [0, ∞)
[0, 0, 0, 1, 1] ∈ [-1, ∞)
```
I couldn’t resist and wrote a pretty-printer for these problem that
shows the linear combination as such, and includes the recognized atoms.
This is especially useful since oftem `omega` failures stem from failure
to recognize atoms as equal. In this case, we now get:

```
omega-failure.lean:19:2-19:7: error: omega could not prove the goal:
a possible counterexample may satisfy the constraints
  d - e ≥ 1
  e ≥ 0
  d ≥ 0
  a - b ≥ 1
  c ≥ 0
  b ≥ 0
  a ≥ 0
  c + d ≥ -1
where
 a := ↑(sizeOf xs)
 b := ↑(sizeOf x)
 c := ↑(sizeOf x.fst)
 d := ↑(sizeOf x.snd)
 e := ↑(sizeOf xs)
```
and this might help the user make progress (e.g. by using `case x`
first, and investingating why `sizeOf xs` shows up twice)
2024-04-16 15:11:51 +00:00

32 lines
911 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
Testing omega's failure message
-/
example : 0 < 0 := by omega
example (x : Nat) : x < 0 := by omega
example (x : Nat) (y : Int) : x < y := by omega
example (x y : Int) : 5 < x ∧ x < 10 → y > 0 := by omega
-- this used to fail with y = x, but then omega got better, so now there are unrelated x and y
-- to make omega fail
theorem sizeOf_snd_lt_sizeOf_list {α : Type u} {β : Type v} [SizeOf α] [SizeOf β]
{x y : α × β} {xs : List (α × β)} :
y ∈ xs → sizeOf x.snd < 1 + sizeOf xs
:= by
intro h
have := List.sizeOf_lt_of_mem h
have : sizeOf x = 1 + sizeOf x.1 + sizeOf x.2 := rfl
omega
example (reallyreallyreallyreally longlonglonglong namenamename : Nat) :
reallyreallyreallyreally < longlonglonglong + namenamename := by omega
def a := 1
example (b c d e f g h i j k l m n o p : Nat) :
b + c + d + e + f + g + h + i + j + k + l + m + n + o + p < 100 := by omega