doc-src/Codegen/Thy/examples/bool_literal.ML
author haftmann
Tue, 03 Mar 2009 11:00:51 +0100
changeset 30209 2f4684e2ea95
parent 26318 doc-src/IsarAdvanced/Codegen/Thy/examples/bool_literal.ML@967323f93c67
permissions -rw-r--r--
more canonical directory structure of manuals
haftmann@21341
     1
structure HOL = 
haftmann@21341
     2
struct
haftmann@21341
     3
haftmann@24421
     4
datatype boola = False | True;
haftmann@21341
     5
haftmann@23107
     6
fun anda x True = x
haftmann@23107
     7
  | anda x False = False
haftmann@23107
     8
  | anda True x = x
haftmann@23107
     9
  | anda False x = False;
haftmann@21341
    10
haftmann@21341
    11
end; (*struct HOL*)
haftmann@21341
    12
haftmann@21341
    13
structure Nat = 
haftmann@21341
    14
struct
haftmann@21341
    15
haftmann@24421
    16
datatype nat = Suc of nat | Zero_nat;
haftmann@21341
    17
wenzelm@26318
    18
fun less_nat m (Suc n) = less_eq_nat m n
haftmann@21994
    19
  | less_nat n Zero_nat = HOL.False
wenzelm@26318
    20
and less_eq_nat (Suc m) n = less_nat m n
wenzelm@26318
    21
  | less_eq_nat Zero_nat n = HOL.True;
haftmann@21341
    22
haftmann@21341
    23
end; (*struct Nat*)
haftmann@21341
    24
haftmann@21341
    25
structure Codegen = 
haftmann@21341
    26
struct
haftmann@21341
    27
haftmann@21341
    28
fun in_interval (k, l) n =
haftmann@23107
    29
  HOL.anda (Nat.less_eq_nat k n) (Nat.less_eq_nat n l);
haftmann@21341
    30
haftmann@21341
    31
end; (*struct Codegen*)