Skip to content

Instantly share code, notes, and snippets.

@minamiyama1994
Last active October 3, 2017 06:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minamiyama1994/db5cc050799b36a2e13e to your computer and use it in GitHub Desktop.
Save minamiyama1994/db5cc050799b36a2e13e to your computer and use it in GitHub Desktop.
Coq demo.
Goal forall A B : Prop , A -> ( A -> B ) -> B.
Proof.
intros.
apply H0.
apply H.
Qed.
Lemma plus_0_r_ : forall n : nat , n + 0 = n.
Proof.
intros.
induction n.
simpl.
reflexivity.
simpl.
f_equal.
apply IHn.
Qed.
Lemma plus_succ_comm_ : forall n m : nat , n + S m = S ( n + m ).
Proof.
intros.
induction n.
simpl.
reflexivity.
simpl.
f_equal.
apply IHn.
Qed.
Goal forall n m : nat , n + m = m + n.
Proof.
intros.
induction n.
rewrite plus_0_r_.
simpl.
reflexivity.
simpl.
rewrite plus_succ_comm_.
f_equal.
apply IHn.
Qed.
Require Import List.
Goal forall A : Prop , forall l1 l2 l3 : list A , ( l1 ++ l2 ) ++ l3 = l1 ++ ( l2 ++ l3 ).
Proof.
intros.
induction l1.
simpl.
reflexivity.
simpl.
f_equal.
apply IHl1.
Qed.
Require Import Arith.
Fixpoint sum_odd ( n : nat ) : nat :=
match n with
| 0 => 0
| S m => n * 2 - 1 + sum_odd m
end.
Goal forall n : nat , n * n = sum_odd n.
Proof.
intros.
induction n.
simpl.
reflexivity.
simpl.
f_equal.
rewrite mult_comm.
simpl.
rewrite mult_succ_r.
rewrite mult_1_r.
rewrite plus_assoc_reverse.
f_equal.
f_equal.
apply IHn.
Qed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment