Require Import Arith. Open Scope bool_scope. Require Import List. Open Scope list_scope. Compute (fun (n:nat) => n+10) 3. Theorem map_length: forall (A:Type) (B:Type) (f: A -> B) (l: list A), length (map f l) = length l. Proof. intros. induction l. reflexivity. simpl. rewrite IHl. reflexivity. Qed. Check map_length. Check (map_length nat). Check (map_length nat bool (fun n => n <=? 3)). Check (map_length nat bool (fun n => n <=? 3) (1::2::3::nil)). Lemma map_length_nat: forall B (f: nat -> B) (l: list nat), length (map f l) = length l. Proof. apply (map_length nat). Qed. Definition map_length_nat2 := map_length nat. Check map_length_nat2. Definition apply (A B:Type) (f: A -> B) (x:A) : B := f x. Check apply. Theorem apply_theorem: forall A B, (A -> B) -> A -> B. Proof. intros. apply X. assumption. Qed. Check apply. Check apply_theorem. Print apply. Print apply_theorem. Definition hasfixedpoint (A:Type) (f: A -> A) : Prop := exists (x:A), f x = x. Check hasfixedpoint. Check hasfixedpoint nat (fun (n:nat) => n). Check hasfixedpoint nat (fun (n:nat) => n+1). Theorem hfp_add0: hasfixedpoint nat (fun (n:nat) => n+0). Proof. exists 0. reflexivity. Qed. Inductive color : Type := | Red: color | Blue: color | Dark (c:color): color | Light (c:color): color. Inductive vacuous : Type := | Vac (v:vacuous): vacuous. Theorem nat_exists: nat. Proof. exact 3. Qed. Theorem vac_exists: vacuous. Proof. apply Vac. apply Vac. Abort. Print nat_exists. (* Definition is_sorted (l:list nat) : Prop := length l <= 1 \/ ... *) Inductive sorted : list nat -> Prop := | SortNil: sorted nil | SortUnit (x:nat): sorted (x::nil) | SortCons (x:nat) (y:nat) (t:list nat) (LE: x <=? y = true) (S: sorted (y::t)): sorted (x::y::t). Theorem sorted123: sorted (1::2::3::nil). Proof. apply SortCons. reflexivity. apply SortCons. reflexivity. apply SortUnit. Qed. Inductive sorted2 : list nat -> Prop := | SortNil2: sorted2 nil | SortUnit2 (x:nat): sorted2 (x::nil) | SortCons2 (x:nat) (y:nat) (t:list nat) (LE: x <=? y = true) : sorted2 (x::y::t). Theorem sorted231: sorted2 (2::3::1::nil). Proof. apply SortCons2. reflexivity. Qed. Axiom myaxiom: forall (P:Prop), P. Theorem disaster: False. Proof. apply myaxiom. Qed.