In-place simplification for Coq
Question
I want this goal:
forall (A : Type) (j' : nat) (f : nat -> A),
f (S j') = f (j' + 1)
to be proven automatically by Coq. Currently I have to write:
A: Type
j': nat
f: nat -> Af (S j') = f (j' + 1)lia.A: Type
j': nat
f: nat -> AS j' = j' + 1
But in general it can be more difficult and I might need to assert for instance that m - 0 = m and then rewrite. Is there a way to rewrite a term in-place, as Isabelle has?
Answer
I'm not sure exactly what you want. Perhaps the replace tactic can be of help to you.
Basically you would write
A: Type
j': nat
f: nat -> Af (S j') = f (j' + 1)A: Type
j': nat
f: nat -> Af (j' + 1) = f (j' + 1)A: Type
j': nat
f: nat -> Aj' + 1 = S j'reflexivity.A: Type
j': nat
f: nat -> Af (j' + 1) = f (j' + 1)lia.A: Type
j': nat
f: nat -> Aj' + 1 = S j'
(Note that I'm using lia and not omega as omega is deprecated in favour of lia.)
You can even discharge the replacement directly by lia:
A: Type
j': nat
f: nat -> Af (S j') = f (j' + 1)reflexivity.A: Type
j': nat
f: nat -> Af (j' + 1) = f (j' + 1)
This way the replacement only succeeds if lia is able to solve the needed equality.