doc-src/IsarAdvanced/Codegen/Thy/examples/fac.ML
author wenzelm
Tue, 14 Oct 2008 15:16:11 +0200
changeset 28586 d238b83ba3fc
parent 25160 72fcf0832cfe
permissions -rw-r--r--
renamed kill_all to kill, in conformance with atp_kill command; simplified/unified treatment of preferences; check_thread_manager: CRITICAL due to global ref; goal addressing via Thm.cprem_of; reduced NJ basis library stuff to bare minimum;

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*)