Added mk_int and mk_list.
authorberghofe
Mon, 16 Dec 2002 13:43:11 +0100
changeset 13755 a9bb54a3cfb7
parent 13754 021cf00435a9
child 13756 41abb61ecce9
Added mk_int and mk_list.
src/HOL/Main.thy
src/HOL/hologic.ML
--- a/src/HOL/Main.thy	Mon Dec 16 11:18:35 2002 +0100
+++ b/src/HOL/Main.thy	Mon Dec 16 13:43:11 2002 +0100
@@ -39,7 +39,12 @@
 
   "wfrec"   ("wf'_rec?")
 
-ML {* fun wf_rec f x = f (wf_rec f) x; *}
+ML {*
+fun wf_rec f x = f (wf_rec f) x;
+
+val term_of_list = HOLogic.mk_list;
+val term_of_int = HOLogic.mk_int;
+*}
 
 lemma [code]: "((n::nat) < 0) = False" by simp
 declare less_Suc_eq [code]
--- a/src/HOL/hologic.ML	Mon Dec 16 11:18:35 2002 +0100
+++ b/src/HOL/hologic.ML	Mon Dec 16 13:43:11 2002 +0100
@@ -66,6 +66,7 @@
   val mk_nat: int -> term
   val dest_nat: term -> int
   val intT: typ
+  val mk_int: int -> term
   val realT: typ
   val binT: typ
   val pls_const: term
@@ -74,7 +75,8 @@
   val number_of_const: typ -> term
   val int_of: int list -> int
   val dest_binum: term -> int
-  val mk_bin   : int -> term
+  val mk_bin: int -> term
+  val mk_list: ('a -> term) -> typ -> 'a list -> term
 end;
 
 
@@ -271,11 +273,6 @@
   | dest_nat t = raise TERM ("dest_nat", [t]);
 
 
-val intT = Type ("IntDef.int", []);
-
-val realT = Type("RealDef.real",[]);
-
-
 (* binary numerals *)
 
 val binT = Type ("Numeral.bin", []);
@@ -316,4 +313,24 @@
       | term_of (b :: bs) = bit_const $ term_of bs $ mk_bit b;
     in term_of (bin_of n) end;
 
+
+(* int *)
+
+val intT = Type ("IntDef.int", []);
+
+fun mk_int i = number_of_const intT $ mk_bin i;
+
+
+(* real *)
+
+val realT = Type("RealDef.real", []);
+
+
+(* list *)
+
+fun mk_list f T [] = Const ("List.list.Nil", Type ("List.list", [T]))
+  | mk_list f T (x :: xs) = Const ("List.list.Cons",
+      T --> Type ("List.list", [T]) --> Type ("List.list", [T])) $ f x $
+        mk_list f T xs;
+
 end;