I'm in the first chapter of Software Foundation. In my attempt to write a simple theorem as follows (It is just an implementation of the built-in theorem mult_n_O):
Theorem mult_n_O' : forall n : nat, 0 = n * 0.
Proof. intros n. reflexivity. Qed.
I got the error: Unable to unify "n * 0" with "0" At the reflexivity step. Can someone please explain the error and why I get this error when it is the exact same theorem as mult_n_O?
For Coq,
n * 0and0are different terms, which cannot be made equal by (syntactic) unification, hence the error message.You can, however, prove this theorem by using induction on
n, which is going to create two new goals, one forn = 0, and the other for "n + 1", i.e.,S norn.+1, assuming that the theorem holds forn(the induction hypothesis).EDITED (answering comments)
A simple step-by-step solution can be as follows (I'm using ssreflect, where induction is performed via the
elimtactic, but you should get the idea).Note the use of IH to rewrite
n * 0as0.Since ssreflect offers quite a bit of automation, this can be simplified to