16 val put_lseq_result : |
16 val put_lseq_result : |
17 (unit -> int -> int -> int * int -> int -> term list Lazy_Sequence.lazy_sequence) -> |
17 (unit -> int -> int -> int * int -> int -> term list Lazy_Sequence.lazy_sequence) -> |
18 Proof.context -> Proof.context; |
18 Proof.context -> Proof.context; |
19 val put_new_dseq_result : (unit -> int -> term list Lazy_Sequence.lazy_sequence) -> |
19 val put_new_dseq_result : (unit -> int -> term list Lazy_Sequence.lazy_sequence) -> |
20 Proof.context -> Proof.context |
20 Proof.context -> Proof.context |
21 val put_cps_result : (unit -> int -> term list option) -> |
21 val put_cps_result : (unit -> int -> (bool * term list) option) -> |
22 Proof.context -> Proof.context |
22 Proof.context -> Proof.context |
23 val test_goals : (Predicate_Compile_Aux.compilation * bool) -> |
23 val test_goals : (Predicate_Compile_Aux.compilation * bool) -> |
24 Proof.context -> bool * bool -> (string * typ) list -> (term * term list) list |
24 Proof.context -> bool * bool -> (string * typ) list -> (term * term list) list |
25 -> Quickcheck.result list |
25 -> Quickcheck.result list |
26 val nrandom : int Unsynchronized.ref; |
26 val nrandom : int Unsynchronized.ref; |
68 ); |
68 ); |
69 val put_new_dseq_result = New_Dseq_Result.put; |
69 val put_new_dseq_result = New_Dseq_Result.put; |
70 |
70 |
71 structure CPS_Result = Proof_Data |
71 structure CPS_Result = Proof_Data |
72 ( |
72 ( |
73 type T = unit -> int -> term list option |
73 type T = unit -> int -> (bool * term list) option |
74 (* FIXME avoid user error with non-user text *) |
74 (* FIXME avoid user error with non-user text *) |
75 fun init _ () = error "CPS_Result" |
75 fun init _ () = error "CPS_Result" |
76 ); |
76 ); |
77 val put_cps_result = CPS_Result.put; |
77 val put_cps_result = CPS_Result.put; |
78 |
78 |
276 (map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
276 (map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
277 | Pos_Generator_DSeq => mk_gen_bind (prog, |
277 | Pos_Generator_DSeq => mk_gen_bind (prog, |
278 mk_split_lambda (map Free vs') (mk_gen_return (HOLogic.mk_list @{typ term} |
278 mk_split_lambda (map Free vs') (mk_gen_return (HOLogic.mk_list @{typ term} |
279 (map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
279 (map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
280 | Pos_Generator_CPS => prog $ |
280 | Pos_Generator_CPS => prog $ |
281 mk_split_lambda (map Free vs') (mk_Some @{typ "term list"} $ (HOLogic.mk_list @{typ term} |
281 mk_split_lambda (map Free vs') (mk_Some @{typ "bool * term list"} $ |
282 (map2 HOLogic.mk_term_of (map snd vs') (map Free vs')))) |
282 HOLogic.mk_prod (@{term "True"}, HOLogic.mk_list @{typ term} |
|
283 (map2 HOLogic.mk_term_of (map snd vs') (map Free vs')))) |
283 | Depth_Limited_Random => fold_rev absdummy |
284 | Depth_Limited_Random => fold_rev absdummy |
284 [@{typ code_numeral}, @{typ code_numeral}, @{typ code_numeral}, |
285 [@{typ code_numeral}, @{typ code_numeral}, @{typ code_numeral}, |
285 @{typ "code_numeral * code_numeral"}] |
286 @{typ "code_numeral * code_numeral"}] |
286 (mk_bind' (list_comb (prog, map Bound (3 downto 0)), |
287 (mk_bind' (list_comb (prog, map Bound (3 downto 0)), |
287 mk_split_lambda (map Free vs') (mk_return' (HOLogic.mk_list @{typ term} |
288 mk_split_lambda (map Free vs') (mk_return' (HOLogic.mk_list @{typ term} |
331 let |
332 let |
332 val compiled_term = |
333 val compiled_term = |
333 Code_Runtime.dynamic_value_strict |
334 Code_Runtime.dynamic_value_strict |
334 (CPS_Result.get, put_cps_result, "Predicate_Compile_Quickcheck.put_cps_result") |
335 (CPS_Result.get, put_cps_result, "Predicate_Compile_Quickcheck.put_cps_result") |
335 thy4 (SOME target) |
336 thy4 (SOME target) |
336 (fn proc => fn g => fn depth => g depth |> Option.map (map proc)) |
337 (fn proc => fn g => fn depth => g depth |> Option.map (apsnd (map proc))) |
337 qc_term [] |
338 qc_term [] |
338 in |
339 in |
339 fn size => fn nrandom => compiled_term |
340 fn size => fn nrandom => Option.map snd o compiled_term |
340 end |
341 end |
341 | Depth_Limited_Random => |
342 | Depth_Limited_Random => |
342 let |
343 let |
343 val compiled_term = Code_Runtime.dynamic_value_strict |
344 val compiled_term = Code_Runtime.dynamic_value_strict |
344 (Pred_Result.get, put_pred_result, "Predicate_Compile_Quickcheck.put_pred_result") |
345 (Pred_Result.get, put_pred_result, "Predicate_Compile_Quickcheck.put_pred_result") |
383 val size = Config.get ctxt Quickcheck.size |
384 val size = Config.get ctxt Quickcheck.size |
384 val c = compile_term compilation options ctxt t |
385 val c = compile_term compilation options ctxt t |
385 val counterexample = try_upto_depth ctxt (c size (!nrandom)) |
386 val counterexample = try_upto_depth ctxt (c size (!nrandom)) |
386 in |
387 in |
387 Quickcheck.Result |
388 Quickcheck.Result |
388 {counterexample = Option.map ((curry (op ~~)) (Term.add_free_names t [])) counterexample, |
389 {counterexample = Option.map (pair true o (curry (op ~~)) (Term.add_free_names t [])) counterexample, |
389 evaluation_terms = Option.map (K []) counterexample, timings = [], reports = []} |
390 evaluation_terms = Option.map (K []) counterexample, timings = [], reports = []} |
390 end |
391 end |
391 |
392 |
392 fun quickcheck_compile_term compilation function_flattening fail_safe_function_flattening = |
393 fun quickcheck_compile_term compilation function_flattening fail_safe_function_flattening = |
393 let |
394 let |