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 xsquared. <-- ERROR: out of scope *) Compute Nat.mul 3 4. Compute 3 <=? 4. Compute 4 <=? 3. Compute leb 3 4. Compute leb 4 3. Print "*". Print "<=?". Compute if (leb 3 4) then (add 1 2) else (add 5 6). (* Compute if (leb 3 4) then (add 1 2) else false. <-- Type mismatch *) Compute andb true false. Compute orb false false. Open Scope bool_scope. Compute true && false. Compute false || false. Require Import String. Open Scope string_scope. Compute "foo". Compute "foo"++"bar". Compute (true,3). Compute (("hello",3),false). Compute ("hello",(3,false)). Compute fst (true,3). Compute snd ("hello",3,false). Compute fst ("hello",3,false). Compute snd (fst ("hello",3,false)). Inductive color : Type := | Red: color | Blue: color | Dark (c:color) : color | Light (c:color) : color. Compute Red. Compute Dark Red. Compute Dark (Dark Red). Definition isdark (c:color) : bool := match c with | Dark _ => true | _ => false end. Compute isdark Red. Compute isdark (Dark Red). Compute isdark (Dark (Light Blue)). Fixpoint isred (c:color) : bool := match c with | Red => true | Blue => false | Dark x => isred x | Light x => isred x end. Compute isred Red. Compute isred (Light Blue). Compute isred (Light (Dark (Dark (Dark (Light Red))))). Compute 3. Print nat. Print "+". Fixpoint factorial (n:nat) : nat := match n with | O => 1 | S x => n * factorial x end. Compute factorial 5. Close Scope string_scope. Fixpoint myfactorial (n:nat) : nat := if n <=? 1 then 1 else n * (myfactorial (n-1)).