doc-src/IsarAdvanced/Codegen/Thy/examples/fac_case.ML
author urbanc
Fri, 17 Nov 2006 17:32:30 +0100
changeset 21405 26b51f724fe6
parent 21190 08ec81dfc7fb
child 21993 4b802a9e0738
permissions -rw-r--r--
added an intro lemma for freshness of products; set up the simplifier so that it can deal with the compact and long notation for freshness constraints (FIXME: it should also be able to deal with the special case of freshness of atoms)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     1
structure ROOT = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     2
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     3
21190
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
     4
structure Nat = 
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     5
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     6
21190
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
     7
datatype nat = Zero_nat | Suc of nat;
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     8
21190
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
     9
fun plus_nat (Suc m) n = plus_nat m (Suc n)
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    10
  | plus_nat Zero_nat y = y;
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    11
21190
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
    12
fun times_nat (Suc m) n = plus_nat n (times_nat m n)
21172
eea3c9048c7a updated;
wenzelm
parents: 21147
diff changeset
    13
  | times_nat Zero_nat n = Zero_nat;
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    14
21190
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
    15
end; (*struct Nat*)
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    16
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    17
structure Codegen = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    18
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    19
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    20
fun fac n =
21190
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
    21
  (case n of Nat.Zero_nat => Nat.Suc Nat.Zero_nat
08ec81dfc7fb (continued)
haftmann
parents: 21172
diff changeset
    22
     | Nat.Suc ma => Nat.times_nat n (fac ma));
21147
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    23
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    24
end; (*struct Codegen*)
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    25
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    26
end; (*struct ROOT*)