Require Import Arith. Compute 1+1. Compute 1+2*3. Definition add x y := x+y. Compute add 3 4. Check add. Definition hypotenuse x y := let xsquared := x*x in let ysquared := y*y in xsquared + ysquared. Print "+". Check Nat.add. Compute Nat.add 1 1. Compute 3 <=? 4. Compute 3 =? 4. Compute if 3 <=? 4 then 1 else 0. Compute andb true false. Compute orb false false. Open Scope bool_scope. Compute true && false. Compute true || false. Require Import String. Open Scope string_scope. Compute "foo". Compute "foo" ++ "bar". Compute (true,3). Compute ((true,3),"hello"). Compute fst (true,3). Compute snd (true,3). Inductive color := | Red | Blue | Dark (c:color) | Light (c:color) (* | Mix (c1:color) (c2:color) *). Fixpoint isred c := match c with | Red => true | Blue => false | Dark x | Light x => isred x end. Check nat. Print isred. Print nat. Definition iszero n := match n with | O => true | S _ => false end. Fixpoint factorial n := match n with | O => 1 | S m => n * factorial m end. Compute factorial 4. Close Scope string. (* Fixpoint factorial' n := if n <=? 1 then 1 else n * (factorial' (n-1)). *) Require Import List. Open Scope list_scope. Compute cons 1 (cons 2 (cons 3 (cons 4 nil))). Compute 1 :: 2 :: 3 :: 4 :: nil. Fixpoint length {A:Type} (s:list A) : nat := match s with | nil => 0 | _ :: t => S (length t) end. Compute length (1::2::3::nil). Compute @length nat (1::2::3::nil). Fixpoint map {A:Type} {B:Type} (f: A -> B) (s:list A) : list B := match s with | nil => nil | h::t => (f h)::(map f t) end. Theorem map_length: forall A B (f: A -> B) (s:list A), length (map f s) = length s. Proof. intros. induction s. simpl. reflexivity. simpl. rewrite IHs. reflexivity. Qed.