Require Import Arith. Compute 1+1. Compute 1+2*3. Definition add (x:nat) (y:nat) : nat := x+y. Compute add 3 4. Check add. Definition hypotenuse (x:nat) (y:nat) : nat := let xsquared := x*x in let ysquared := y*y in xsquared + ysquared. Compute hypotenuse 3 4. Compute hypotenuse (2+1) ((2+2)*1). Definition hypotenuse2 (x:nat) (y:nat) : nat := let s := x*x in s + let s := y*y in s. Compute 2*4. Print "*". Compute Init.Nat.mul 2 4. Compute 3 <=? 4. Compute 3 <= 4. Print "<=?". Compute Nat.leb 3 4. Compute leb 3 4. Compute if 3 <=? 4 then (add 1 2) else (add 5 6). Compute true. Compute false. Compute 42. Compute andb true false. Open Scope bool_scope. Compute true && false. Compute true || false. Compute orb true false. Require Import String. Open Scope string_scope. Compute "foo". Compute "foo"++"bar". Compute (true,3). Compute fst (true,3). Compute snd (true,3). Compute (1,2,3). Compute fst (1,2,3). Compute fst (fst (1,2,3)). Print fst. Definition math (x:nat) (y:nat) := (x+y, x-y). Check math. Compute math 2 3. Print "-". Inductive color : Type := | Red: color | Blue: color | Dark: color -> color | Light (c:color): color. Compute Red. Compute Dark Red. Compute Dark (Dark Red). Compute Light (Dark Red). (* Compute Light Dark Red. *) Fixpoint isred (c:color) : bool := match c with | Red => true | Blue => false | Dark c2 => isred c2 | Light c2 => isred c2 end. Compute isred Blue. Compute isred (Dark Red). Compute isred (Dark (Light (Light (Dark Red)))). Compute 3. Print nat. Compute O. Compute S O. Compute S (S O). Definition iszero (n:nat) : bool := match n with | O => true | S _ => false end. Fixpoint factorial (n:nat) : nat := match n with | O => 1 | S m => n * factorial m end. Compute factorial 5. (* Fixpoint factorial (n:nat) : nat := if n <=? 1 then 1 else n*(factorial (n-1)). *) Theorem darkness: forall c1 c2, (c1 = Dark c2) -> (isred c1 = isred c2). Proof. intros. rewrite H. destruct c2. simpl. reflexivity. simpl. reflexivity. simpl. reflexivity. simpl. reflexivity. Qed. Compute 2 = 2. Compute 2 = 3. Compute 2 =? 2. Compute 2 =? 3. Print "=?". Print "=". Check darkness. Compute Nat.eqb 2 3.