Zulip Chat Archive
Stream: lean4
Topic: Failed rewrite by equation lemmas
Heather Macbeth (Mar 06 2023 at 05:34):
The first of these works but the second fails. Is this expected behaviour?
def factorial : Nat → Nat
| 0 => 1
| n + 1 => (n + 1) * factorial n
example (a : Nat) : factorial (a + 1) = (a + 1) * factorial a := by
rw [factorial] -- works
example (a b : Nat) : factorial ((a + b) + 1) = ((a + b) + 1) * factorial (a + b) := by
rw [factorial] -- fails
Heather Macbeth (Mar 06 2023 at 05:34):
The error message is
failed to rewrite using equation theorems for 'factorial'
Mario Carneiro (Mar 06 2023 at 05:37):
sounds like a bug somewhere in core, probably rw latched on the wrong addition
Mario Carneiro (Mar 06 2023 at 05:41):
note that it works with factorial (Nat.succ (a + b))
on the left; the actual equation lemma uses Nat.succ
Heather Macbeth (Mar 06 2023 at 05:43):
I really appreciate having the version with a + 1
rather than Nat.succ a
, when it works -- I hope it's not too hard to fix.
Mario Carneiro (Mar 06 2023 at 05:46):
minimized:
opaque zero : Nat → Nat
theorem foo : zero (Nat.succ a) = 0 := sorry
example : zero (a + 1) = 0 := by with_reducible exact foo -- ok
example : zero (a + a + 1) = 0 := by with_reducible exact foo -- fail
Heather Macbeth (Mar 06 2023 at 21:15):
I opened lean4#2136 for this.
Last updated: Dec 20 2023 at 11:08 UTC