lean4-htt/tests/lean/run/simpIfPre.lean
Leonardo de Moura 22c8154811 feat: add pre simp lemmas for if-then-else terms
See new test for example that takes exponential time without new simp
theorems.
TODO: replace auxiliary theorems with simprocs as soon as we implement them.
2024-01-09 12:57:15 +01:00

23 lines
661 B
Text

/-!
Test support for `if-then-else` terms in the simplifier.
The condition should be simplified before trying to apply congruence.
We are currently accomplished that using pre-simp theorems.
TODO: replace them with simprocs.
In the following example, the term `g (a + <num>)` takes an
exponential amount of time to be simplified without the pre-simp theorems.
-/
def myid (x : Nat) := 0 + x
@[simp] theorem myid_eq : myid x = x := by simp [myid]
def f (x : Nat) (y z : Nat) : Nat :=
if myid x = 0 then y else z
def g (x : Nat) : Nat :=
match x with
| 0 => 1
| a+1 => f x (g a + 1) (g a)
theorem ex (h : a = 1) : g (a+32) = a := by
simp [g, f, h]