equal
deleted
inserted
replaced
34 val zero: term |
34 val zero: term |
35 val is_zero: term -> bool |
35 val is_zero: term -> bool |
36 val mk_Suc: term -> term |
36 val mk_Suc: term -> term |
37 val dest_Suc: term -> term |
37 val dest_Suc: term -> term |
38 val mk_nat: int -> term |
38 val mk_nat: int -> term |
|
39 val dest_nat: term -> int |
39 end; |
40 end; |
40 |
41 |
41 |
42 |
42 structure HOLogic: HOLOGIC = |
43 structure HOLogic: HOLOGIC = |
43 struct |
44 struct |
110 |
111 |
111 (* nat *) |
112 (* nat *) |
112 |
113 |
113 val natT = Type ("nat", []); |
114 val natT = Type ("nat", []); |
114 |
115 |
|
116 |
115 val zero = Const ("0", natT); |
117 val zero = Const ("0", natT); |
116 fun is_zero t = t = zero; |
118 |
|
119 fun is_zero (Const ("0", _)) = true |
|
120 | is_zero _ = false; |
|
121 |
117 |
122 |
118 fun mk_Suc t = Const ("Suc", natT --> natT) $ t; |
123 fun mk_Suc t = Const ("Suc", natT --> natT) $ t; |
119 |
124 |
120 fun dest_Suc (Const ("Suc", _) $ t) = t |
125 fun dest_Suc (Const ("Suc", _) $ t) = t |
121 | dest_Suc t = raise TERM ("dest_Suc", [t]); |
126 | dest_Suc t = raise TERM ("dest_Suc", [t]); |
122 |
127 |
|
128 |
123 fun mk_nat 0 = zero |
129 fun mk_nat 0 = zero |
124 | mk_nat n = mk_Suc (mk_nat (n - 1)); |
130 | mk_nat n = mk_Suc (mk_nat (n - 1)); |
125 |
131 |
|
132 fun dest_nat (Const ("0", _)) = 0 |
|
133 | dest_nat (Const ("Suc", _) $ t) = dest_nat t + 1 |
|
134 | dest_nat t = raise TERM ("dest_nat", [t]); |
|
135 |
126 |
136 |
127 end; |
137 end; |