I am trying to prove the following simple theorem over natural numbers:
((i + j) = (i + k)) -> (j = k)
Here is what I have in Coq
:
Theorem cancel : forall (i j k : nat),
((add i j) = (add i k)) -> (j = k).
Proof.
intros i j k.
induction i.
simpl.
apply A_IMPLIES_A.
simpl.
And after that I have the sub-goal:
S (add i j) = S (add i k) -> j = k
So I thought I'd apply eq_add_S
which states that S m = S n -> m = n
.
However, when I try to do so with apply eq_add_S
I get the following error:
Error:
In environment
i, j, k : nat
IHi : add i j = add i k -> j = k
Unable to unify "k" with "add i k".
So I guess it can't understand that I want is m = (add i j)
and n = (add i k)
. How come Coq
can't read my mind? or more seriously, how can I help him do so? thanks!