more appropriate printing of function terms
authorhaftmann
Thu, 30 Jul 2009 15:21:31 +0200
changeset 32344 55ca0df19af5
parent 32343 605877054de7
child 32345 4da4fa060bb6
more appropriate printing of function terms
src/HOL/Code_Eval.thy
src/HOL/Tools/quickcheck_generators.ML
--- a/src/HOL/Code_Eval.thy	Thu Jul 30 15:21:18 2009 +0200
+++ b/src/HOL/Code_Eval.thy	Thu Jul 30 15:21:31 2009 +0200
@@ -39,6 +39,17 @@
 
 subsubsection {* @{text term_of} instances *}
 
+instantiation "fun" :: (typerep, typerep) term_of
+begin
+
+definition
+  "term_of (f \<Colon> 'a \<Rightarrow> 'b) = Const (STR ''dummy_pattern'') (Typerep.Typerep (STR ''fun'')
+     [Typerep.typerep TYPE('a), Typerep.typerep TYPE('b)])"
+
+instance ..
+
+end
+
 setup {*
 let
   fun add_term_of tyco raw_vs thy =
--- a/src/HOL/Tools/quickcheck_generators.ML	Thu Jul 30 15:21:18 2009 +0200
+++ b/src/HOL/Tools/quickcheck_generators.ML	Thu Jul 30 15:21:31 2009 +0200
@@ -40,9 +40,10 @@
   let
     val fun_upd = Const (@{const_name fun_upd},
       (T1 --> T2) --> T1 --> T2 --> T1 --> T2);
-    val (seed', seed'') = random_split seed;
+    val ((y, t2), seed') = random seed;
+    val (seed'', seed''') = random_split seed';
 
-    val state = ref (seed', [], fn () => Const (@{const_name undefined}, T1 --> T2));
+    val state = ref (seed'', [], fn () => Abs ("x", T1, t2 ()));
     fun random_fun' x =
       let
         val (seed, fun_map, f_t) = ! state;
@@ -57,7 +58,7 @@
             in y end
       end;
     fun term_fun' () = #3 (! state) ();
-  in ((random_fun', term_fun'), seed'') end;
+  in ((random_fun', term_fun'), seed''') end;
 
 
 (** type copies **)