src/HOL/Tools/Predicate_Compile/predicate_compile_compilations.ML
changeset 51126 df86080de4cb
parent 50056 72efd6b4038d
child 51143 0a2371e7ced3
equal deleted inserted replaced
51125:f90874d3a246 51126:df86080de4cb
   223 
   223 
   224 fun mk_randompredT T =
   224 fun mk_randompredT T =
   225   @{typ Random.seed} --> HOLogic.mk_prodT (Predicate_Comp_Funs.mk_monadT T, @{typ Random.seed})
   225   @{typ Random.seed} --> HOLogic.mk_prodT (Predicate_Comp_Funs.mk_monadT T, @{typ Random.seed})
   226 
   226 
   227 fun dest_randompredT (Type ("fun", [@{typ Random.seed}, Type (@{type_name Product_Type.prod},
   227 fun dest_randompredT (Type ("fun", [@{typ Random.seed}, Type (@{type_name Product_Type.prod},
   228   [Type (@{type_name "Predicate.pred"}, [T]), @{typ Random.seed}])])) = T
   228   [Type (@{type_name Predicate.pred}, [T]), @{typ Random.seed}])])) = T
   229   | dest_randompredT T = raise TYPE ("dest_randompredT", [T], []);
   229   | dest_randompredT T = raise TYPE ("dest_randompredT", [T], []);
   230 
   230 
   231 fun mk_empty T = Const(@{const_name Quickcheck.empty}, mk_randompredT T)
   231 fun mk_empty T = Const(@{const_name Random_Pred.empty}, mk_randompredT T)
   232 
   232 
   233 fun mk_single t =
   233 fun mk_single t =
   234   let               
   234   let               
   235     val T = fastype_of t
   235     val T = fastype_of t
   236   in
   236   in
   237     Const (@{const_name Quickcheck.single}, T --> mk_randompredT T) $ t
   237     Const (@{const_name Random_Pred.single}, T --> mk_randompredT T) $ t
   238   end;
   238   end;
   239 
   239 
   240 fun mk_bind (x, f) =
   240 fun mk_bind (x, f) =
   241   let
   241   let
   242     val T as (Type ("fun", [_, U])) = fastype_of f
   242     val T as (Type ("fun", [_, U])) = fastype_of f
   243   in
   243   in
   244     Const (@{const_name Quickcheck.bind}, fastype_of x --> T --> U) $ x $ f
   244     Const (@{const_name Random_Pred.bind}, fastype_of x --> T --> U) $ x $ f
   245   end
   245   end
   246 
   246 
   247 val mk_plus = HOLogic.mk_binop @{const_name Quickcheck.union}
   247 val mk_plus = HOLogic.mk_binop @{const_name Random_Pred.union}
   248 
   248 
   249 fun mk_if cond = Const (@{const_name Quickcheck.if_randompred},
   249 fun mk_if cond = Const (@{const_name Random_Pred.if_randompred},
   250   HOLogic.boolT --> mk_randompredT HOLogic.unitT) $ cond;
   250   HOLogic.boolT --> mk_randompredT HOLogic.unitT) $ cond;
   251 
   251 
   252 fun mk_iterate_upto T (f, from, to) =
   252 fun mk_iterate_upto T (f, from, to) =
   253   list_comb (Const (@{const_name Quickcheck.iterate_upto},
   253   list_comb (Const (@{const_name Random_Pred.iterate_upto},
   254       [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}] ---> mk_randompredT T),
   254       [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}] ---> mk_randompredT T),
   255     [f, from, to])
   255     [f, from, to])
   256 
   256 
   257 fun mk_not t =
   257 fun mk_not t =
   258   let
   258   let
   259     val T = mk_randompredT HOLogic.unitT
   259     val T = mk_randompredT HOLogic.unitT
   260   in Const (@{const_name Quickcheck.not_randompred}, T --> T) $ t end
   260   in Const (@{const_name Random_Pred.not_randompred}, T --> T) $ t end
   261 
   261 
   262 fun mk_map T1 T2 tf tp = Const (@{const_name Quickcheck.map},
   262 fun mk_map T1 T2 tf tp = Const (@{const_name Random_Pred.map},
   263   (T1 --> T2) --> mk_randompredT T1 --> mk_randompredT T2) $ tf $ tp
   263   (T1 --> T2) --> mk_randompredT T1 --> mk_randompredT T2) $ tf $ tp
   264 
   264 
   265 val compfuns = Predicate_Compile_Aux.CompilationFuns
   265 val compfuns = Predicate_Compile_Aux.CompilationFuns
   266     {mk_monadT = mk_randompredT, dest_monadT = dest_randompredT,
   266     {mk_monadT = mk_randompredT, dest_monadT = dest_randompredT,
   267     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
   267     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
   277 
   277 
   278 fun dest_dseqT (Type ("fun", [@{typ code_numeral}, Type ("fun", [@{typ bool},
   278 fun dest_dseqT (Type ("fun", [@{typ code_numeral}, Type ("fun", [@{typ bool},
   279   Type (@{type_name Option.option}, [Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])) = T
   279   Type (@{type_name Option.option}, [Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])) = T
   280   | dest_dseqT T = raise TYPE ("dest_dseqT", [T], []);
   280   | dest_dseqT T = raise TYPE ("dest_dseqT", [T], []);
   281 
   281 
   282 fun mk_empty T = Const (@{const_name DSequence.empty}, mk_dseqT T);
   282 fun mk_empty T = Const (@{const_name Limited_Sequence.empty}, mk_dseqT T);
   283 
   283 
   284 fun mk_single t =
   284 fun mk_single t =
   285   let val T = fastype_of t
   285   let val T = fastype_of t
   286   in Const(@{const_name DSequence.single}, T --> mk_dseqT T) $ t end;
   286   in Const(@{const_name Limited_Sequence.single}, T --> mk_dseqT T) $ t end;
   287 
   287 
   288 fun mk_bind (x, f) =
   288 fun mk_bind (x, f) =
   289   let val T as Type ("fun", [_, U]) = fastype_of f
   289   let val T as Type ("fun", [_, U]) = fastype_of f
   290   in
   290   in
   291     Const (@{const_name DSequence.bind}, fastype_of x --> T --> U) $ x $ f
   291     Const (@{const_name Limited_Sequence.bind}, fastype_of x --> T --> U) $ x $ f
   292   end;
   292   end;
   293 
   293 
   294 val mk_plus = HOLogic.mk_binop @{const_name DSequence.union};
   294 val mk_plus = HOLogic.mk_binop @{const_name Limited_Sequence.union};
   295 
   295 
   296 fun mk_if cond = Const (@{const_name DSequence.if_seq},
   296 fun mk_if cond = Const (@{const_name Limited_Sequence.if_seq},
   297   HOLogic.boolT --> mk_dseqT HOLogic.unitT) $ cond;
   297   HOLogic.boolT --> mk_dseqT HOLogic.unitT) $ cond;
   298 
   298 
   299 fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
   299 fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
   300 
   300 
   301 fun mk_not t = let val T = mk_dseqT HOLogic.unitT
   301 fun mk_not t = let val T = mk_dseqT HOLogic.unitT
   302   in Const (@{const_name DSequence.not_seq}, T --> T) $ t end
   302   in Const (@{const_name Limited_Sequence.not_seq}, T --> T) $ t end
   303 
   303 
   304 fun mk_map T1 T2 tf tp = Const (@{const_name DSequence.map},
   304 fun mk_map T1 T2 tf tp = Const (@{const_name Limited_Sequence.map},
   305   (T1 --> T2) --> mk_dseqT T1 --> mk_dseqT T2) $ tf $ tp
   305   (T1 --> T2) --> mk_dseqT T1 --> mk_dseqT T2) $ tf $ tp
   306 
   306 
   307 val compfuns = Predicate_Compile_Aux.CompilationFuns
   307 val compfuns = Predicate_Compile_Aux.CompilationFuns
   308     {mk_monadT = mk_dseqT, dest_monadT = dest_dseqT,
   308     {mk_monadT = mk_dseqT, dest_monadT = dest_dseqT,
   309     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
   309     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_bind, mk_plus = mk_plus, mk_if = mk_if,
   319 
   319 
   320 fun dest_pos_dseqT (Type ("fun", [@{typ code_numeral},
   320 fun dest_pos_dseqT (Type ("fun", [@{typ code_numeral},
   321     Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])) = T
   321     Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])) = T
   322   | dest_pos_dseqT T = raise TYPE ("dest_pos_dseqT", [T], []);
   322   | dest_pos_dseqT T = raise TYPE ("dest_pos_dseqT", [T], []);
   323 
   323 
   324 fun mk_empty T = Const (@{const_name New_DSequence.pos_empty}, mk_pos_dseqT T);
   324 fun mk_empty T = Const (@{const_name Limited_Sequence.pos_empty}, mk_pos_dseqT T);
   325 
   325 
   326 fun mk_single t =
   326 fun mk_single t =
   327   let
   327   let
   328     val T = fastype_of t
   328     val T = fastype_of t
   329   in Const(@{const_name New_DSequence.pos_single}, T --> mk_pos_dseqT T) $ t end;
   329   in Const(@{const_name Limited_Sequence.pos_single}, T --> mk_pos_dseqT T) $ t end;
   330 
   330 
   331 fun mk_bind (x, f) =
   331 fun mk_bind (x, f) =
   332   let
   332   let
   333     val T as Type ("fun", [_, U]) = fastype_of f
   333     val T as Type ("fun", [_, U]) = fastype_of f
   334   in
   334   in
   335     Const (@{const_name New_DSequence.pos_bind}, fastype_of x --> T --> U) $ x $ f
   335     Const (@{const_name Limited_Sequence.pos_bind}, fastype_of x --> T --> U) $ x $ f
   336   end;
   336   end;
   337   
   337   
   338 fun mk_decr_bind (x, f) =
   338 fun mk_decr_bind (x, f) =
   339   let
   339   let
   340     val T as Type ("fun", [_, U]) = fastype_of f
   340     val T as Type ("fun", [_, U]) = fastype_of f
   341   in
   341   in
   342     Const (@{const_name New_DSequence.pos_decr_bind}, fastype_of x --> T --> U) $ x $ f
   342     Const (@{const_name Limited_Sequence.pos_decr_bind}, fastype_of x --> T --> U) $ x $ f
   343   end;
   343   end;
   344 
   344 
   345 val mk_plus = HOLogic.mk_binop @{const_name New_DSequence.pos_union};
   345 val mk_plus = HOLogic.mk_binop @{const_name Limited_Sequence.pos_union};
   346 
   346 
   347 fun mk_if cond = Const (@{const_name New_DSequence.pos_if_seq},
   347 fun mk_if cond = Const (@{const_name Limited_Sequence.pos_if_seq},
   348   HOLogic.boolT --> mk_pos_dseqT HOLogic.unitT) $ cond;
   348   HOLogic.boolT --> mk_pos_dseqT HOLogic.unitT) $ cond;
   349 
   349 
   350 fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
   350 fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
   351 
   351 
   352 fun mk_not t =
   352 fun mk_not t =
   353   let
   353   let
   354     val pT = mk_pos_dseqT HOLogic.unitT
   354     val pT = mk_pos_dseqT HOLogic.unitT
   355     val nT =
   355     val nT =
   356       @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
   356       @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
   357         [Type (@{type_name Option.option}, [@{typ unit}])])
   357         [Type (@{type_name Option.option}, [@{typ unit}])])
   358   in Const (@{const_name New_DSequence.pos_not_seq}, nT --> pT) $ t end
   358   in Const (@{const_name Limited_Sequence.pos_not_seq}, nT --> pT) $ t end
   359 
   359 
   360 fun mk_map T1 T2 tf tp = Const (@{const_name New_DSequence.pos_map},
   360 fun mk_map T1 T2 tf tp = Const (@{const_name Limited_Sequence.pos_map},
   361   (T1 --> T2) --> mk_pos_dseqT T1 --> mk_pos_dseqT T2) $ tf $ tp
   361   (T1 --> T2) --> mk_pos_dseqT T1 --> mk_pos_dseqT T2) $ tf $ tp
   362 
   362 
   363 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   363 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   364     {mk_monadT = mk_pos_dseqT, dest_monadT = dest_pos_dseqT,
   364     {mk_monadT = mk_pos_dseqT, dest_monadT = dest_pos_dseqT,
   365     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   365     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   380 
   380 
   381 fun dest_neg_dseqT (Type ("fun", [@{typ code_numeral},
   381 fun dest_neg_dseqT (Type ("fun", [@{typ code_numeral},
   382     Type (@{type_name Lazy_Sequence.lazy_sequence}, [Type (@{type_name Option.option}, [T])])])) = T
   382     Type (@{type_name Lazy_Sequence.lazy_sequence}, [Type (@{type_name Option.option}, [T])])])) = T
   383   | dest_neg_dseqT T = raise TYPE ("dest_neg_dseqT", [T], []);
   383   | dest_neg_dseqT T = raise TYPE ("dest_neg_dseqT", [T], []);
   384 
   384 
   385 fun mk_empty T = Const (@{const_name New_DSequence.neg_empty}, mk_neg_dseqT T);
   385 fun mk_empty T = Const (@{const_name Limited_Sequence.neg_empty}, mk_neg_dseqT T);
   386 
   386 
   387 fun mk_single t =
   387 fun mk_single t =
   388   let
   388   let
   389     val T = fastype_of t
   389     val T = fastype_of t
   390   in Const(@{const_name New_DSequence.neg_single}, T --> mk_neg_dseqT T) $ t end;
   390   in Const(@{const_name Limited_Sequence.neg_single}, T --> mk_neg_dseqT T) $ t end;
   391 
   391 
   392 fun mk_bind (x, f) =
   392 fun mk_bind (x, f) =
   393   let
   393   let
   394     val T as Type ("fun", [_, U]) = fastype_of f
   394     val T as Type ("fun", [_, U]) = fastype_of f
   395   in
   395   in
   396     Const (@{const_name New_DSequence.neg_bind}, fastype_of x --> T --> U) $ x $ f
   396     Const (@{const_name Limited_Sequence.neg_bind}, fastype_of x --> T --> U) $ x $ f
   397   end;
   397   end;
   398   
   398   
   399 fun mk_decr_bind (x, f) =
   399 fun mk_decr_bind (x, f) =
   400   let
   400   let
   401     val T as Type ("fun", [_, U]) = fastype_of f
   401     val T as Type ("fun", [_, U]) = fastype_of f
   402   in
   402   in
   403     Const (@{const_name New_DSequence.neg_decr_bind}, fastype_of x --> T --> U) $ x $ f
   403     Const (@{const_name Limited_Sequence.neg_decr_bind}, fastype_of x --> T --> U) $ x $ f
   404   end;
   404   end;
   405 
   405 
   406 val mk_plus = HOLogic.mk_binop @{const_name New_DSequence.neg_union};
   406 val mk_plus = HOLogic.mk_binop @{const_name Limited_Sequence.neg_union};
   407 
   407 
   408 fun mk_if cond = Const (@{const_name New_DSequence.neg_if_seq},
   408 fun mk_if cond = Const (@{const_name Limited_Sequence.neg_if_seq},
   409   HOLogic.boolT --> mk_neg_dseqT HOLogic.unitT) $ cond;
   409   HOLogic.boolT --> mk_neg_dseqT HOLogic.unitT) $ cond;
   410 
   410 
   411 fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
   411 fun mk_iterate_upto _ _ = raise Fail "No iterate_upto compilation"
   412 
   412 
   413 fun mk_not t =
   413 fun mk_not t =
   414   let
   414   let
   415     val nT = mk_neg_dseqT HOLogic.unitT
   415     val nT = mk_neg_dseqT HOLogic.unitT
   416     val pT =
   416     val pT =
   417       @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
   417       @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
   418         [@{typ unit}])
   418         [@{typ unit}])
   419   in Const (@{const_name New_DSequence.neg_not_seq}, pT --> nT) $ t end
   419   in Const (@{const_name Limited_Sequence.neg_not_seq}, pT --> nT) $ t end
   420 
   420 
   421 fun mk_map T1 T2 tf tp = Const (@{const_name New_DSequence.neg_map},
   421 fun mk_map T1 T2 tf tp = Const (@{const_name Limited_Sequence.neg_map},
   422   (T1 --> T2) --> mk_neg_dseqT T1 --> mk_neg_dseqT T2) $ tf $ tp
   422   (T1 --> T2) --> mk_neg_dseqT T1 --> mk_neg_dseqT T2) $ tf $ tp
   423 
   423 
   424 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   424 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   425     {mk_monadT = mk_neg_dseqT, dest_monadT = dest_neg_dseqT,
   425     {mk_monadT = mk_neg_dseqT, dest_monadT = dest_neg_dseqT,
   426     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   426     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   443 fun dest_pos_random_dseqT (Type ("fun", [@{typ code_numeral}, Type ("fun", [@{typ code_numeral},
   443 fun dest_pos_random_dseqT (Type ("fun", [@{typ code_numeral}, Type ("fun", [@{typ code_numeral},
   444     Type ("fun", [@{typ Random.seed}, Type ("fun", [@{typ code_numeral},
   444     Type ("fun", [@{typ Random.seed}, Type ("fun", [@{typ code_numeral},
   445     Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])])) = T
   445     Type (@{type_name Lazy_Sequence.lazy_sequence}, [T])])])])])) = T
   446   | dest_pos_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], []);
   446   | dest_pos_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], []);
   447 
   447 
   448 fun mk_empty T = Const (@{const_name New_Random_Sequence.pos_empty}, mk_pos_random_dseqT T);
   448 fun mk_empty T = Const (@{const_name Random_Sequence.pos_empty}, mk_pos_random_dseqT T);
   449 
   449 
   450 fun mk_single t =
   450 fun mk_single t =
   451   let
   451   let
   452     val T = fastype_of t
   452     val T = fastype_of t
   453   in Const(@{const_name New_Random_Sequence.pos_single}, T --> mk_pos_random_dseqT T) $ t end;
   453   in Const(@{const_name Random_Sequence.pos_single}, T --> mk_pos_random_dseqT T) $ t end;
   454 
   454 
   455 fun mk_bind (x, f) =
   455 fun mk_bind (x, f) =
   456   let
   456   let
   457     val T as Type ("fun", [_, U]) = fastype_of f
   457     val T as Type ("fun", [_, U]) = fastype_of f
   458   in
   458   in
   459     Const (@{const_name New_Random_Sequence.pos_bind}, fastype_of x --> T --> U) $ x $ f
   459     Const (@{const_name Random_Sequence.pos_bind}, fastype_of x --> T --> U) $ x $ f
   460   end;
   460   end;
   461 
   461 
   462 fun mk_decr_bind (x, f) =
   462 fun mk_decr_bind (x, f) =
   463   let
   463   let
   464     val T as Type ("fun", [_, U]) = fastype_of f
   464     val T as Type ("fun", [_, U]) = fastype_of f
   465   in
   465   in
   466     Const (@{const_name New_Random_Sequence.pos_decr_bind}, fastype_of x --> T --> U) $ x $ f
   466     Const (@{const_name Random_Sequence.pos_decr_bind}, fastype_of x --> T --> U) $ x $ f
   467   end;
   467   end;
   468 
   468 
   469 val mk_plus = HOLogic.mk_binop @{const_name New_Random_Sequence.pos_union};
   469 val mk_plus = HOLogic.mk_binop @{const_name Random_Sequence.pos_union};
   470 
   470 
   471 fun mk_if cond = Const (@{const_name New_Random_Sequence.pos_if_random_dseq},
   471 fun mk_if cond = Const (@{const_name Random_Sequence.pos_if_random_dseq},
   472   HOLogic.boolT --> mk_pos_random_dseqT HOLogic.unitT) $ cond;
   472   HOLogic.boolT --> mk_pos_random_dseqT HOLogic.unitT) $ cond;
   473 
   473 
   474 fun mk_iterate_upto T (f, from, to) =
   474 fun mk_iterate_upto T (f, from, to) =
   475   list_comb (Const (@{const_name New_Random_Sequence.pos_iterate_upto},
   475   list_comb (Const (@{const_name Random_Sequence.pos_iterate_upto},
   476       [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}]
   476       [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}]
   477         ---> mk_pos_random_dseqT T),
   477         ---> mk_pos_random_dseqT T),
   478     [f, from, to])
   478     [f, from, to])
   479 
   479 
   480 fun mk_not t =
   480 fun mk_not t =
   482     val pT = mk_pos_random_dseqT HOLogic.unitT
   482     val pT = mk_pos_random_dseqT HOLogic.unitT
   483     val nT = @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
   483     val nT = @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
   484       @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
   484       @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence},
   485         [Type (@{type_name Option.option}, [@{typ unit}])])
   485         [Type (@{type_name Option.option}, [@{typ unit}])])
   486 
   486 
   487   in Const (@{const_name New_Random_Sequence.pos_not_random_dseq}, nT --> pT) $ t end
   487   in Const (@{const_name Random_Sequence.pos_not_random_dseq}, nT --> pT) $ t end
   488 
   488 
   489 fun mk_map T1 T2 tf tp = Const (@{const_name New_Random_Sequence.pos_map},
   489 fun mk_map T1 T2 tf tp = Const (@{const_name Random_Sequence.pos_map},
   490   (T1 --> T2) --> mk_pos_random_dseqT T1 --> mk_pos_random_dseqT T2) $ tf $ tp
   490   (T1 --> T2) --> mk_pos_random_dseqT T1 --> mk_pos_random_dseqT T2) $ tf $ tp
   491 
   491 
   492 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   492 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   493     {mk_monadT = mk_pos_random_dseqT, dest_monadT = dest_pos_random_dseqT,
   493     {mk_monadT = mk_pos_random_dseqT, dest_monadT = dest_pos_random_dseqT,
   494     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   494     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   512     Type ("fun", [@{typ Random.seed}, Type ("fun", [@{typ code_numeral},
   512     Type ("fun", [@{typ Random.seed}, Type ("fun", [@{typ code_numeral},
   513       Type (@{type_name Lazy_Sequence.lazy_sequence},
   513       Type (@{type_name Lazy_Sequence.lazy_sequence},
   514         [Type (@{type_name Option.option}, [T])])])])])])) = T
   514         [Type (@{type_name Option.option}, [T])])])])])])) = T
   515   | dest_neg_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], []);
   515   | dest_neg_random_dseqT T = raise TYPE ("dest_random_dseqT", [T], []);
   516 
   516 
   517 fun mk_empty T = Const (@{const_name New_Random_Sequence.neg_empty}, mk_neg_random_dseqT T);
   517 fun mk_empty T = Const (@{const_name Random_Sequence.neg_empty}, mk_neg_random_dseqT T);
   518 
   518 
   519 fun mk_single t =
   519 fun mk_single t =
   520   let
   520   let
   521     val T = fastype_of t
   521     val T = fastype_of t
   522   in Const(@{const_name New_Random_Sequence.neg_single}, T --> mk_neg_random_dseqT T) $ t end;
   522   in Const(@{const_name Random_Sequence.neg_single}, T --> mk_neg_random_dseqT T) $ t end;
   523 
   523 
   524 fun mk_bind (x, f) =
   524 fun mk_bind (x, f) =
   525   let
   525   let
   526     val T as Type ("fun", [_, U]) = fastype_of f
   526     val T as Type ("fun", [_, U]) = fastype_of f
   527   in
   527   in
   528     Const (@{const_name New_Random_Sequence.neg_bind}, fastype_of x --> T --> U) $ x $ f
   528     Const (@{const_name Random_Sequence.neg_bind}, fastype_of x --> T --> U) $ x $ f
   529   end;
   529   end;
   530 
   530 
   531 fun mk_decr_bind (x, f) =
   531 fun mk_decr_bind (x, f) =
   532   let
   532   let
   533     val T as Type ("fun", [_, U]) = fastype_of f
   533     val T as Type ("fun", [_, U]) = fastype_of f
   534   in
   534   in
   535     Const (@{const_name New_Random_Sequence.neg_decr_bind}, fastype_of x --> T --> U) $ x $ f
   535     Const (@{const_name Random_Sequence.neg_decr_bind}, fastype_of x --> T --> U) $ x $ f
   536   end;
   536   end;
   537 
   537 
   538 val mk_plus = HOLogic.mk_binop @{const_name New_Random_Sequence.neg_union};
   538 val mk_plus = HOLogic.mk_binop @{const_name Random_Sequence.neg_union};
   539 
   539 
   540 fun mk_if cond = Const (@{const_name New_Random_Sequence.neg_if_random_dseq},
   540 fun mk_if cond = Const (@{const_name Random_Sequence.neg_if_random_dseq},
   541   HOLogic.boolT --> mk_neg_random_dseqT HOLogic.unitT) $ cond;
   541   HOLogic.boolT --> mk_neg_random_dseqT HOLogic.unitT) $ cond;
   542 
   542 
   543 fun mk_iterate_upto T (f, from, to) =
   543 fun mk_iterate_upto T (f, from, to) =
   544   list_comb (Const (@{const_name New_Random_Sequence.neg_iterate_upto},
   544   list_comb (Const (@{const_name Random_Sequence.neg_iterate_upto},
   545       [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}]
   545       [@{typ code_numeral} --> T, @{typ code_numeral}, @{typ code_numeral}]
   546         ---> mk_neg_random_dseqT T),
   546         ---> mk_neg_random_dseqT T),
   547     [f, from, to])
   547     [f, from, to])
   548 
   548 
   549 fun mk_not t =
   549 fun mk_not t =
   550   let
   550   let
   551     val nT = mk_neg_random_dseqT HOLogic.unitT
   551     val nT = mk_neg_random_dseqT HOLogic.unitT
   552     val pT = @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
   552     val pT = @{typ code_numeral} --> @{typ code_numeral} --> @{typ Random.seed} -->
   553     @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence}, [@{typ unit}])
   553     @{typ code_numeral} --> Type (@{type_name Lazy_Sequence.lazy_sequence}, [@{typ unit}])
   554   in Const (@{const_name New_Random_Sequence.neg_not_random_dseq}, pT --> nT) $ t end
   554   in Const (@{const_name Random_Sequence.neg_not_random_dseq}, pT --> nT) $ t end
   555 
   555 
   556 fun mk_map T1 T2 tf tp = Const (@{const_name New_Random_Sequence.neg_map},
   556 fun mk_map T1 T2 tf tp = Const (@{const_name Random_Sequence.neg_map},
   557   (T1 --> T2) --> mk_neg_random_dseqT T1 --> mk_neg_random_dseqT T2) $ tf $ tp
   557   (T1 --> T2) --> mk_neg_random_dseqT T1 --> mk_neg_random_dseqT T2) $ tf $ tp
   558 
   558 
   559 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   559 val depth_limited_compfuns = Predicate_Compile_Aux.CompilationFuns
   560     {mk_monadT = mk_neg_random_dseqT, dest_monadT = dest_neg_random_dseqT,
   560     {mk_monadT = mk_neg_random_dseqT, dest_monadT = dest_neg_random_dseqT,
   561     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,
   561     mk_empty = mk_empty, mk_single = mk_single, mk_bind = mk_decr_bind, mk_plus = mk_plus, mk_if = mk_if,