doc-src/IsarAdvanced/Codegen/Thy/examples/fac.ML
author krauss
Fri, 22 Jun 2007 10:23:37 +0200
changeset 23473 997bca36d4fe
parent 22751 1bfd75c1f232
child 23850 f1434532a562
permissions -rw-r--r--
new method "elim_to_cases" provides ad-hoc conversion of obtain-style elimination goals to a disjunction of existentials.

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

end; (*struct Codegen*)

end; (*struct ROOT*)