doc-src/Codegen/Thy/examples/fac.ML
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Wed, 13 Jul 2011 00:23:24 +0900
changeset 43785 2bd54d4b5f3d
parent 30226 2f4684e2ea95
permissions -rw-r--r--
HOL/Import for HOLLight revival: Proper theory headers, update generation scripts to SVN version of HOL Light, add some constant maps and compatibility theorems

structure Nat = 
struct

datatype nat = Suc of nat | Zero_nat;

val one_nat : nat = Suc Zero_nat;

fun plus_nat (Suc m) n = plus_nat m (Suc n)
  | plus_nat Zero_nat n = n;

fun times_nat (Suc m) n = plus_nat n (times_nat m n)
  | times_nat Zero_nat n = Zero_nat;

end; (*struct Nat*)

structure Codegen = 
struct

fun fac (Nat.Suc n) = Nat.times_nat (Nat.Suc n) (fac n)
  | fac Nat.Zero_nat = Nat.one_nat;

end; (*struct Codegen*)