doc-src/IsarAdvanced/Codegen/Thy/examples/bool2.ML
author haftmann
Fri, 03 Nov 2006 14:22:33 +0100
changeset 21147 737a94f047e3
child 21172 eea3c9048c7a
permissions -rw-r--r--
continued tutorial
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
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     4
structure HOL = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     5
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     6
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     7
fun nota false = true
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     8
  | nota true = false;
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
     9
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    10
end; (*struct HOL*)
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    11
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    12
structure IntDef = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    13
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    14
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    15
datatype nat = Zero_nat | Succ_nat of nat;
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    16
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    17
fun less_nat Zero_nat (Succ_nat n) = true
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    18
  | less_nat na Zero_nat = false
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    19
  | less_nat (Succ_nat m) (Succ_nat nb) = less_nat m nb;
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    20
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    21
fun less_eq_nat m n = HOL.nota (less_nat n m);
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    22
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    23
end; (*struct IntDef*)
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    24
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    25
structure Codegen = 
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    26
struct
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    27
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    28
fun in_interval (k, l) n =
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    29
  (IntDef.less_eq_nat k n) andalso (IntDef.less_eq_nat n l);
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    30
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    31
end; (*struct Codegen*)
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    32
737a94f047e3 continued tutorial
haftmann
parents:
diff changeset
    33
end; (*struct ROOT*)