Skip to content

Instantly share code, notes, and snippets.

@tautologico
Created October 30, 2015 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tautologico/59fe0d68c4616e9ecb55 to your computer and use it in GitHub Desktop.
Save tautologico/59fe0d68c4616e9ecb55 to your computer and use it in GitHub Desktop.
datatype nat = Z | S nat
fun plus :: "nat ⇒ nat ⇒ nat" where
"plus Z m = m" |
"plus (S n) m = S (plus n m)"
fun mult :: "nat ⇒ nat ⇒ nat" where
"mult Z m = Z" |
"mult (S n) m = plus (mult n m) m"
fun factorial :: "nat ⇒ nat" where
"factorial Z = (S Z)" |
"factorial (S n) = mult (S n) (factorial n)"
definition ten :: nat where "ten = (S (S (S (S (S (S (S (S (S Z)))))))))"
definition twelve :: nat where "twelve = (S (S (S (S (S (S (S (S (S Z)))))))))"
theorem test_factorial1 : "factorial (S (S (S Z))) = S (S (S (S (S (S Z)))))" by simp
(* simplification only simplifies the left side, not the right side
theorem test_factorial2 : "factorial (S (S (S (S (S Z))))) = mult ten twelve" by simp
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment