% Definition of plus val plus : nat -> nat -> nat = fn x => rec x of p 0 => fn y => y | p (s n) => fn y => s (p n y) end; % -------------------------------------------------------------------- % Tutch proofs % Here's an example of a proof that uses induction over natural numbers. proof plus0R : (!m:nat. m = plus m 0) = begin [m : nat; % the 0 case 0 = plus 0 0; % the s case; note that it binds two assumptions [x : nat , x = plus x 0; s x = plus (s x) 0]; m = plus m 0]; (!m:nat. m = plus m 0); end; % Your task is to prove transitivity % Hint: this will be longer than any tutch proof you have done so far proof eqtrans : !x:nat. !y:nat. !z:nat. (x = y) => (y = z) => (x = z) = begin !x:nat. !y:nat. !z:nat. (x = y) => (y = z) => (x = z); end; % ---------------------------------------------------------------------- % Proof terms % Here's an example proof term using recursion. The recursor % R(t,M0,x.u.M1(x,u)) % is written as a primitive recursion schema: % rec t of f 0 => M0 % | f (s x) => M1(x,f(x)) end; term plus0R : (!m:nat. m = plus m 0) = fn m => rec m of p 0 => eq0 | p (s x) => eqS (p x) end; % Prove the following: term eqrefl : (!m:nat. m = m) = fn m => m; % Hint: you will need to call the function eqrefl in this proof term plusSR : (!m:nat. !n:nat. s (plus m n) = plus m (s n)) = fn m => m;