1

I'm reading the book Software Foundation. On the chapter "More on Induction", the authors talk about the induction principle generated by coq when a inductive type is define.

An exercice is the following. Encapsulate the notion of association for "+" in a definition and then apply the nat_ind on it.

My first guess for the definition was the following :

Definition P_plusassoc (n m o:nat) : Prop :=
  n + (m+ o) = (n+m) +o.

But then, I have the problem when I want to proof this :

Theorem plus_assoct : forall o m n, P_plusassoc n m o.
Proof.
  apply nat_ind.

nat_ind doesn't work. So I thought it was because P_plusassoc does not depend of just one integer but three.

So I rewrite P_plusassoc this way :

Definition P_plusassoc (n:nat) : nat->nat->Prop :=
      fun (m o:nat) => n + (m+ o) = (n+m) +o.

But it still doesn't work. Where is the problem ? How can I define P_plusassoc to use nat_ind ?

Saroupille
  • 609
  • 8
  • 14

2 Answers2

1

The book gives an answer after. The definition could be :

Definition P_plusassoc (n:nat) : Prop :=
      forall m o, n + (m+ o) = (n+m) +o.
Saroupille
  • 609
  • 8
  • 14
0

The question wants you to prove a lemma. However, you are defining a function. What you should do, is define something of type Prop (like Definition P_plusassoc (n:nat) : Prop := forall m o, n + (m+ o) = (n+m) +o.).

Personally, I would define a Lemma : forall m n o :nat, n+(m+o)=(n+m)+o. Coq will then allow you to prove this lemma, which you could do via intros. apply (nat_ind n).