(* Some useful tactics *) Tactic Notation "spec" hyp(H) := match type of H with ?a -> _ => let H1 := fresh in (assert (H1: a); [|generalize (H H1); clear H H1; intro H]) end. Tactic Notation "spec" hyp(H) constr(a) := (generalize (H a); clear H; intro H). Tactic Notation "spec" hyp(H) constr(a) constr(b) := (generalize (H a b); clear H; intro H). Tactic Notation "spec" hyp(H) constr(a) constr(b) constr(c) := (generalize (H a b c); clear H; intro H). Tactic Notation "spec" hyp(H) constr(a) constr(b) constr(c) constr(d) := (generalize (H a b c d); clear H; intro H). Tactic Notation "spec" hyp(H) constr(a) constr(b) constr(c) constr(d) constr(e) := (generalize (H a b c d e); clear H; intro H). Ltac remembertac2 x a := let x := fresh x in let H := fresh "Heq" x in (set (x:=a) in *; assert (H: a=x) by reflexivity; clearbody x). Tactic Notation "cases" constr(a) := let x := fresh in (remembertac2 x a; destruct x). Require ClassicalFacts. (* no axioms in this line *) Require Export Coq.Logic.ClassicalChoice. (* Axioms dependent_unique_choice, relational_choice *) Tactic Notation "LEM" constr(a) := destruct (classic a). Require Import Omega. Inductive Tree : Type := | Leaf : Tree | Node : Tree -> Tree -> Tree. Definition tree1 := Leaf. Definition tree2 := Node (Node Leaf Leaf) Leaf. Fixpoint leaves(t : Tree) : nat := match t with | Leaf => 1 | Node tl tr => leaves tl + leaves tr end. Fixpoint nodes(t : Tree) : nat := match t with | Leaf => 0 | Node tl tr => 1 + nodes tl + nodes tr end. Lemma leaves_gt_nodes: forall t, leaves t > nodes t. Proof. intro. induction t. simpl. omega. simpl. omega. Qed. (* Lemma leaves_ge_nodes: forall t, leaves t >= nodes t. Proof. induction t. simpl. omega. simpl. omega. Qed. *) Lemma leaves_ge_nodes: forall t, leaves t >= nodes t. Proof. intro. generalize (leaves_gt_nodes t); intro. omega. Qed. Fixpoint size(t : Tree) : nat := match t with | Leaf => 1 | Node tl tr => 1 + size tl + size tr end. Lemma size_eq_leavesnodes: forall t, size t = leaves t + nodes t. Proof. induction t. simpl. trivial. simpl. omega. Qed. Lemma leaves_ge_nodes': forall t, leaves t >= nodes t. Proof. assert (forall t, leaves t > nodes t). induction t; simpl; omega. intro. spec H t. omega. Qed. Inductive Nat : Type := | Z : Nat | S : Nat -> Nat. Fixpoint Add (n1 n2 : Nat) : Nat := match n1 with | Z => n2 | S n1' => S (Add n1' n2) end. Lemma Add_Comm : forall n1 n2, Add n1 n2 = Add n2 n1. Proof. intros. induction n2. induction n1. trivial. simpl. rewrite IHn1. simpl. trivial. simpl. rewrite <- IHn2. (* clear IHn2. *) induction n1. simpl. trivial. simpl. rewrite IHn1. trivial. (* uh oh... :-) *) Qed. Print Add_Comm. Print leaves_gt_nodes. (* revert, clear, etc. are very useful... as well as assert *)