Naturals


Inductive nat := O | S : nat->nat.

Fixpoint plus x y := match x with
  O => y
| S x' => plus x' (S y)
end.

Notation "x + y" := (plus x y) (at level 50, left associativity).

Proposition P1: forall x y, S x+y = S(x+y).

Proof. induction x.
intros y. trivial.
intros y. simpl. rewrite <- IHx. trivial.
Qed.

Proposition P2: forall x, x+O = x.

Proof. induction x.
trivial.
rewrite P1. rewrite IHx. trivial.
Qed.

Proposition P3: forall x y, x+y=y+x.

Proof. induction x.
intros y. rewrite P2. trivial.
intros y. simpl. rewrite IHx. trivial.
Qed.

Proposition InjectivityS: forall x y, S x=S y -> x=y.

Proof. intros. inversion H. trivial. Qed.

Proposition InjectivityP: forall x y z, x+y=x+z -> y=z.

Proof. induction x.
intros. trivial.
intros. simpl in H. apply IHx in H. inversion H. trivial.
Qed.

Proposition P: forall x, x=S x -> False.

Proof. induction x.
intros H. inversion H.
intros H. inversion H. apply IHx in H1. trivial.
Qed.


This page has been generated by coqdoc