doc-src/IsarAdvanced/Codegen/Thy/examples/fac.ML
author berghofe
Wed, 07 Feb 2007 17:30:53 +0100
changeset 22264 6a65e9b2ae05
parent 21994 dfa5133dbe73
child 22751 1bfd75c1f232
permissions -rw-r--r--
Theorems for converting between wf and wfP are now declared as hints.

structure ROOT = 
struct

structure Nat = 
struct

datatype nat = Zero_nat | Suc of nat;

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

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.Suc Nat.Zero_nat;

end; (*struct Codegen*)

end; (*struct ROOT*)