Require Import Arith. Require Import List. Open Scope list_scope. Fixpoint count (x:nat) (l:list nat) : nat := match l with | nil => 0 | h::t => if h =? x then S (count x t) else count x t end. Theorem count_swap: forall (x y z:nat) (t:list nat), count x (y::z::t) = count x (z::y::t). Proof. intros. simpl. destruct (y =? x); destruct (z =? x); reflexivity. Qed. Theorem equality_examples: forall (m n:nat), m+1 = n+1 -> m = n. Proof. intros. symmetry. symmetry in H. transitivity (n+n-m). Check Nat.add_comm. rewrite Nat.add_comm in H. rewrite (Nat.add_comm m 1) in H. simpl in H. inversion H. Abort. Inductive sorted : list nat -> Prop := | SortNil: sorted nil | SortUnit (x:nat): sorted (x::nil) | SortCons (x y:nat) (t:list nat) (LE: x <=? y = true) (H: sorted (y::t)): sorted (x::y::t). Theorem inversion_example: forall t, sorted t -> sorted t. Proof. intros. inversion H. 3:{ Abort. Print and. Print or. Print True. Print False. Theorem false_example: False -> True. Proof. intro. inversion H. Qed. Print "<->". Print "~". Theorem contrapositive: forall (A B:Prop), (A -> B) -> (~B -> ~A). Proof. intros. unfold "~". intro. (* assert (H2 := H1). apply H in H1. *) apply H0. apply H. assumption. Qed. Theorem discriminate_example: forall (n:nat), 0 = n+1 -> False. Proof. intros. rewrite Nat.add_comm in H. simpl in H. discriminate. Qed. Theorem exfalso_example: forall (A:Prop), (True -> False) -> A. Proof. intros. exfalso. apply H. apply I. Qed. Theorem double_negation: forall (A:Prop), ~~A -> A. Proof. intros. unfold "~" in H. exfalso. apply H. intro. apply H. intro. Abort. Theorem nat_or_eq_ne: forall (m n:nat), (m=n) \/ ~(m=n). Proof. intro. induction m. intro. destruct n. left. reflexivity. right. intro. discriminate. intro. destruct n. right. intro. discriminate. specialize IHm with (n:=n). destruct IHm. left. rewrite H. reflexivity. right. intro. apply H. inversion H0. reflexivity. Qed. Print sumbool. Print or. Theorem sum_implies_or: forall (A B:Prop), {A}+{B} -> A \/ B. Proof. intros. destruct H. left. assumption. right. assumption. Qed. Theorem or_implies_sum: forall (A B:Prop), A \/ B -> {A}+{B}. Proof. intros. (* destruct H. *) Abort. Theorem foo: nat. Proof. exact 3. Defined. Print foo.