author | wenzelm |
Wed, 12 Feb 2014 13:33:05 +0100 | |
changeset 55437 | 3fd63b92ea3b |
parent 52788 | da1fdbfebd39 |
child 55757 | 9fc71814b8c1 |
permissions | -rw-r--r-- |
33265 | 1 |
(* Title: HOL/Tools/Predicate_Compile/predicate_compile_quickcheck.ML |
2 |
Author: Lukas Bulwahn, TU Muenchen |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
3 |
|
33265 | 4 |
A quickcheck generator based on the predicate compiler. |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
5 |
*) |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
6 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
7 |
signature PREDICATE_COMPILE_QUICKCHECK = |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
8 |
sig |
50057 | 9 |
type seed = Random_Engine.seed |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
10 |
(*val quickcheck : Proof.context -> term -> int -> term list option*) |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
11 |
val put_pred_result : |
55437 | 12 |
(unit -> Code_Numeral.natural -> Code_Numeral.natural -> Code_Numeral.natural -> seed -> |
13 |
term list Predicate.pred) -> |
|
14 |
Proof.context -> Proof.context |
|
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
15 |
val put_dseq_result : |
55437 | 16 |
(unit -> Code_Numeral.natural -> Code_Numeral.natural -> seed -> |
17 |
term list Limited_Sequence.dseq * seed) -> |
|
18 |
Proof.context -> Proof.context |
|
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
19 |
val put_lseq_result : |
55437 | 20 |
(unit -> Code_Numeral.natural -> Code_Numeral.natural -> seed -> Code_Numeral.natural -> |
21 |
term list Lazy_Sequence.lazy_sequence) -> |
|
22 |
Proof.context -> Proof.context |
|
23 |
val put_new_dseq_result : |
|
24 |
(unit -> Code_Numeral.natural -> term list Lazy_Sequence.lazy_sequence) -> |
|
40103 | 25 |
Proof.context -> Proof.context |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
26 |
val put_cps_result : (unit -> Code_Numeral.natural -> (bool * term list) option) -> |
45450 | 27 |
Proof.context -> Proof.context |
28 |
val test_goals : (Predicate_Compile_Aux.compilation * bool) -> |
|
55437 | 29 |
Proof.context -> bool * bool -> (string * typ) list -> (term * term list) list -> |
30 |
Quickcheck.result list |
|
31 |
val nrandom : int Unsynchronized.ref |
|
32 |
val debug : bool Unsynchronized.ref |
|
33 |
val no_higher_order_predicate : string list Unsynchronized.ref |
|
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
34 |
val setup : theory -> theory |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
35 |
end; |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
36 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
37 |
structure Predicate_Compile_Quickcheck : PREDICATE_COMPILE_QUICKCHECK = |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
38 |
struct |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
39 |
|
33257 | 40 |
open Predicate_Compile_Aux; |
41 |
||
50093
a2886be4d615
repaired slip accidentally introduced in 57209cfbf16b
haftmann
parents:
50057
diff
changeset
|
42 |
type seed = Random_Engine.seed; |
50057 | 43 |
|
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
44 |
(* FIXME just one data slot (record) per program unit *) |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
45 |
|
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
46 |
structure Pred_Result = Proof_Data |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
47 |
( |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
48 |
type T = unit -> Code_Numeral.natural -> Code_Numeral.natural -> Code_Numeral.natural -> seed -> term list Predicate.pred |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
49 |
(* FIXME avoid user error with non-user text *) |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
50 |
fun init _ () = error "Pred_Result" |
55437 | 51 |
) |
52 |
val put_pred_result = Pred_Result.put |
|
34948
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
53 |
|
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
54 |
structure Dseq_Result = Proof_Data |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
55 |
( |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
56 |
type T = unit -> Code_Numeral.natural -> Code_Numeral.natural -> seed -> term list Limited_Sequence.dseq * seed |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
57 |
(* FIXME avoid user error with non-user text *) |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
58 |
fun init _ () = error "Dseq_Result" |
55437 | 59 |
) |
60 |
val put_dseq_result = Dseq_Result.put |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
61 |
|
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
62 |
structure Lseq_Result = Proof_Data |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
63 |
( |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
64 |
type T = unit -> Code_Numeral.natural -> Code_Numeral.natural -> seed -> Code_Numeral.natural -> term list Lazy_Sequence.lazy_sequence |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
65 |
(* FIXME avoid user error with non-user text *) |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
66 |
fun init _ () = error "Lseq_Result" |
55437 | 67 |
) |
68 |
val put_lseq_result = Lseq_Result.put |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
69 |
|
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
70 |
structure New_Dseq_Result = Proof_Data |
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
71 |
( |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
72 |
type T = unit -> Code_Numeral.natural -> term list Lazy_Sequence.lazy_sequence |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40924
diff
changeset
|
73 |
(* FIXME avoid user error with non-user text *) |
40103 | 74 |
fun init _ () = error "New_Dseq_Random_Result" |
55437 | 75 |
) |
76 |
val put_new_dseq_result = New_Dseq_Result.put |
|
40103 | 77 |
|
45450 | 78 |
structure CPS_Result = Proof_Data |
79 |
( |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
80 |
type T = unit -> Code_Numeral.natural -> (bool * term list) option |
45450 | 81 |
(* FIXME avoid user error with non-user text *) |
82 |
fun init _ () = error "CPS_Result" |
|
55437 | 83 |
) |
84 |
val put_cps_result = CPS_Result.put |
|
45450 | 85 |
|
35537
59dd6be5834c
adding depth to predicate compile quickcheck for mutabelle tests; removing obsolete references in predicate compile quickcheck
bulwahn
parents:
35380
diff
changeset
|
86 |
val target = "Quickcheck" |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
87 |
|
55437 | 88 |
val nrandom = Unsynchronized.ref 3 |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
89 |
|
55437 | 90 |
val debug = Unsynchronized.ref false |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
91 |
|
55437 | 92 |
val no_higher_order_predicate = Unsynchronized.ref ([] : string list) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
93 |
|
33257 | 94 |
val options = Options { |
95 |
expected_modes = NONE, |
|
39382
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
bulwahn
parents:
39253
diff
changeset
|
96 |
proposed_modes = [], |
33651
e4aad90618ad
adding the predicate compiler quickcheck to the ex/ROOT.ML; adopting this quickcheck to the latest changes
bulwahn
parents:
33486
diff
changeset
|
97 |
proposed_names = [], |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
98 |
show_steps = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
99 |
show_intermediate_results = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
100 |
show_proof_trace = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
101 |
show_modes = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
102 |
show_mode_inference = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
103 |
show_compilation = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
104 |
show_caught_failures = false, |
55437 | 105 |
show_invalid_clauses = false, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
106 |
skip_proof = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
107 |
compilation = Random, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
108 |
inductify = true, |
36256 | 109 |
specialise = true, |
110 |
detect_switches = false, |
|
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
111 |
function_flattening = true, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
112 |
fail_safe_function_flattening = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
113 |
no_higher_order_predicate = [], |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
114 |
smart_depth_limiting = true, |
36250 | 115 |
no_topmost_reordering = false |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
116 |
} |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
117 |
|
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
118 |
val debug_options = Options { |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
119 |
expected_modes = NONE, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
120 |
proposed_modes = [], |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
121 |
proposed_names = [], |
33257 | 122 |
show_steps = true, |
123 |
show_intermediate_results = true, |
|
124 |
show_proof_trace = false, |
|
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
125 |
show_modes = true, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
126 |
show_mode_inference = true, |
34948
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
127 |
show_compilation = false, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
128 |
show_caught_failures = true, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
129 |
show_invalid_clauses = false, |
33257 | 130 |
skip_proof = false, |
34948
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
131 |
compilation = Random, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
132 |
inductify = true, |
36256 | 133 |
specialise = true, |
134 |
detect_switches = false, |
|
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
135 |
function_flattening = true, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
136 |
fail_safe_function_flattening = false, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
137 |
no_higher_order_predicate = [], |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
138 |
smart_depth_limiting = true, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
139 |
no_topmost_reordering = true |
33257 | 140 |
} |
141 |
||
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
142 |
|
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
143 |
fun set_function_flattening b |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
144 |
(Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
145 |
show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
146 |
show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, |
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
147 |
show_invalid_clauses = s_ic, skip_proof = s_p, |
55437 | 148 |
compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = _, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
149 |
fail_safe_function_flattening = fs_ff, no_higher_order_predicate = no_ho, |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
150 |
smart_depth_limiting = sm_dl, no_topmost_reordering = re}) = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
151 |
(Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
152 |
show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
153 |
show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, |
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
154 |
show_invalid_clauses = s_ic, skip_proof = s_p, |
36256 | 155 |
compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = b, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
156 |
fail_safe_function_flattening = fs_ff, no_higher_order_predicate = no_ho, |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
157 |
smart_depth_limiting = sm_dl, no_topmost_reordering = re}) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
158 |
|
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
159 |
fun set_fail_safe_function_flattening b |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
160 |
(Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
161 |
show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
162 |
show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, |
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
163 |
show_invalid_clauses = s_ic, skip_proof = s_p, |
55437 | 164 |
compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
165 |
fail_safe_function_flattening = _, no_higher_order_predicate = no_ho, |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
166 |
smart_depth_limiting = sm_dl, no_topmost_reordering = re}) = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
167 |
(Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
168 |
show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
169 |
show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, |
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
170 |
show_invalid_clauses = s_ic, skip_proof = s_p, |
36256 | 171 |
compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
172 |
fail_safe_function_flattening = b, no_higher_order_predicate = no_ho, |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
173 |
smart_depth_limiting = sm_dl, no_topmost_reordering = re}) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
174 |
|
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
175 |
fun set_no_higher_order_predicate ss |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
176 |
(Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
177 |
show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
178 |
show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, |
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
179 |
show_invalid_clauses = s_ic, skip_proof = s_p, |
55437 | 180 |
compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
181 |
fail_safe_function_flattening = fs_ff, no_higher_order_predicate = _, |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
182 |
smart_depth_limiting = sm_dl, no_topmost_reordering = re}) = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
183 |
(Options { expected_modes = e_m, proposed_modes = p_m, proposed_names = p_n, show_steps = s_s, |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
184 |
show_intermediate_results = s_ir, show_proof_trace = s_pt, show_modes = s_m, |
39383
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
185 |
show_mode_inference = s_mi, show_compilation = s_c, show_caught_failures = s_cf, |
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
bulwahn
parents:
39382
diff
changeset
|
186 |
show_invalid_clauses = s_ic, skip_proof = s_p, |
36256 | 187 |
compilation = c, inductify = i, specialise = sp, detect_switches = ds, function_flattening = f_f, |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
188 |
fail_safe_function_flattening = fs_ff, no_higher_order_predicate = ss, |
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
189 |
smart_depth_limiting = sm_dl, no_topmost_reordering = re}) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
190 |
|
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
191 |
|
55437 | 192 |
fun get_options () = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
193 |
set_no_higher_order_predicate (!no_higher_order_predicate) |
45450 | 194 |
(if !debug then debug_options else options) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
195 |
|
45461
130c90bb80b4
using more conventional names for monad plus operations
bulwahn
parents:
45450
diff
changeset
|
196 |
val mk_predT = Predicate_Compile_Aux.mk_monadT Predicate_Comp_Funs.compfuns |
45450 | 197 |
val mk_return' = Predicate_Compile_Aux.mk_single Predicate_Comp_Funs.compfuns |
198 |
val mk_bind' = Predicate_Compile_Aux.mk_bind Predicate_Comp_Funs.compfuns |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
199 |
|
45461
130c90bb80b4
using more conventional names for monad plus operations
bulwahn
parents:
45450
diff
changeset
|
200 |
val mk_randompredT = Predicate_Compile_Aux.mk_monadT RandomPredCompFuns.compfuns |
36046
c3946372f556
putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
36025
diff
changeset
|
201 |
val mk_return = Predicate_Compile_Aux.mk_single RandomPredCompFuns.compfuns |
c3946372f556
putting compilation setup of predicate compiler in a separate file
bulwahn
parents:
36025
diff
changeset
|
202 |
val mk_bind = Predicate_Compile_Aux.mk_bind RandomPredCompFuns.compfuns |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
203 |
|
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
204 |
val mk_new_randompredT = |
45461
130c90bb80b4
using more conventional names for monad plus operations
bulwahn
parents:
45450
diff
changeset
|
205 |
Predicate_Compile_Aux.mk_monadT New_Pos_Random_Sequence_CompFuns.depth_unlimited_compfuns |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
206 |
val mk_new_return = |
40103 | 207 |
Predicate_Compile_Aux.mk_single New_Pos_Random_Sequence_CompFuns.depth_unlimited_compfuns |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
208 |
val mk_new_bind = |
40103 | 209 |
Predicate_Compile_Aux.mk_bind New_Pos_Random_Sequence_CompFuns.depth_unlimited_compfuns |
210 |
||
211 |
val mk_new_dseqT = |
|
45461
130c90bb80b4
using more conventional names for monad plus operations
bulwahn
parents:
45450
diff
changeset
|
212 |
Predicate_Compile_Aux.mk_monadT New_Pos_DSequence_CompFuns.depth_unlimited_compfuns |
40103 | 213 |
val mk_gen_return = |
214 |
Predicate_Compile_Aux.mk_single New_Pos_DSequence_CompFuns.depth_unlimited_compfuns |
|
215 |
val mk_gen_bind = |
|
216 |
Predicate_Compile_Aux.mk_bind New_Pos_DSequence_CompFuns.depth_unlimited_compfuns |
|
55437 | 217 |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
218 |
|
45450 | 219 |
val mk_cpsT = |
45461
130c90bb80b4
using more conventional names for monad plus operations
bulwahn
parents:
45450
diff
changeset
|
220 |
Predicate_Compile_Aux.mk_monadT Pos_Bounded_CPS_Comp_Funs.compfuns |
45450 | 221 |
|
39756
6c8e83d94536
consolidated tupled_lambda; moved to structure HOLogic
krauss
parents:
39541
diff
changeset
|
222 |
val mk_split_lambda = HOLogic.tupled_lambda o HOLogic.mk_tuple |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
223 |
|
42014
75417ef605ba
simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
wenzelm
parents:
42012
diff
changeset
|
224 |
fun cpu_time description e = |
75417ef605ba
simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
wenzelm
parents:
42012
diff
changeset
|
225 |
let val ({cpu, ...}, result) = Timing.timing e () |
75417ef605ba
simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
wenzelm
parents:
42012
diff
changeset
|
226 |
in (result, (description, Time.toMilliseconds cpu)) end |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
227 |
|
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
228 |
fun compile_term compilation options ctxt t = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
229 |
let |
44241 | 230 |
val t' = fold_rev absfree (Term.add_frees t []) t |
52788 | 231 |
val thy = Proof_Context.theory_of ctxt |
39541
6605c1e87c7f
removing clone in code_prolog and predicate_compile_quickcheck
bulwahn
parents:
39471
diff
changeset
|
232 |
val ((((full_constname, constT), vs'), intro), thy1) = |
42031 | 233 |
Predicate_Compile_Aux.define_quickcheck_predicate t' thy |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
234 |
val thy2 = Context.theory_map (Predicate_Compile_Alternative_Defs.add_thm intro) thy1 |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
235 |
val (thy3, _) = cpu_time "predicate preprocessing" |
39541
6605c1e87c7f
removing clone in code_prolog and predicate_compile_quickcheck
bulwahn
parents:
39471
diff
changeset
|
236 |
(fn () => Predicate_Compile.preprocess options (Const (full_constname, constT)) thy2) |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
237 |
val (thy4, _) = cpu_time "random_dseq core compilation" |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
238 |
(fn () => |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
239 |
case compilation of |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
240 |
Pos_Random_DSeq => |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
241 |
Predicate_Compile_Core.add_random_dseq_equations options [full_constname] thy3 |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
242 |
| New_Pos_Random_DSeq => |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
243 |
Predicate_Compile_Core.add_new_random_dseq_equations options [full_constname] thy3 |
40103 | 244 |
| Pos_Generator_DSeq => |
245 |
Predicate_Compile_Core.add_generator_dseq_equations options [full_constname] thy3 |
|
45450 | 246 |
| Pos_Generator_CPS => |
247 |
Predicate_Compile_Core.add_generator_cps_equations options [full_constname] thy3 |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
248 |
(*| Depth_Limited_Random => |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
249 |
Predicate_Compile_Core.add_depth_limited_random_equations options [full_constname] thy3*)) |
36256 | 250 |
(*val _ = Predicate_Compile_Core.print_all_modes compilation thy4*) |
42361 | 251 |
val ctxt4 = Proof_Context.init_global thy4 |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
252 |
val modes = Core_Data.modes_of compilation ctxt4 full_constname |
34948
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
253 |
val output_mode = fold_rev (curry Fun) (map (K Output) (binder_types constT)) Bool |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
254 |
val prog = |
34948
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
255 |
if member eq_mode modes output_mode then |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
256 |
let |
40054
cd7b1fa20bce
adapting alternative_defs, predicate_compile_quickcheck, examples and code_prolog
bulwahn
parents:
39756
diff
changeset
|
257 |
val name = Core_Data.function_name_of compilation ctxt4 full_constname output_mode |
55437 | 258 |
val T = |
259 |
(case compilation of |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
260 |
Pos_Random_DSeq => mk_randompredT (HOLogic.mk_tupleT (map snd vs')) |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
261 |
| New_Pos_Random_DSeq => mk_new_randompredT (HOLogic.mk_tupleT (map snd vs')) |
40103 | 262 |
| Pos_Generator_DSeq => mk_new_dseqT (HOLogic.mk_tupleT (map snd vs')) |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
263 |
| Depth_Limited_Random => |
55437 | 264 |
[@{typ natural}, @{typ natural}, @{typ natural}, |
265 |
@{typ Random.seed}] ---> mk_predT (HOLogic.mk_tupleT (map snd vs')) |
|
266 |
| Pos_Generator_CPS => mk_cpsT (HOLogic.mk_tupleT (map snd vs'))) |
|
34948
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
267 |
in |
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
268 |
Const (name, T) |
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
bulwahn
parents:
34028
diff
changeset
|
269 |
end |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
270 |
else error ("Predicate Compile Quickcheck failed: " ^ commas (map string_of_mode modes)) |
45450 | 271 |
fun mk_Some T = Const (@{const_name "Option.Some"}, T --> Type (@{type_name "Option.option"}, [T])) |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
272 |
val qc_term = |
55437 | 273 |
(case compilation of |
274 |
Pos_Random_DSeq => mk_bind (prog, |
|
275 |
mk_split_lambda (map Free vs') (mk_return (HOLogic.mk_list @{typ term} |
|
276 |
(map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
|
277 |
| New_Pos_Random_DSeq => mk_new_bind (prog, |
|
278 |
mk_split_lambda (map Free vs') (mk_new_return (HOLogic.mk_list @{typ term} |
|
279 |
(map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
|
280 |
| Pos_Generator_DSeq => mk_gen_bind (prog, |
|
281 |
mk_split_lambda (map Free vs') (mk_gen_return (HOLogic.mk_list @{typ term} |
|
282 |
(map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))) |
|
283 |
| Pos_Generator_CPS => prog $ |
|
284 |
mk_split_lambda (map Free vs') (mk_Some @{typ "bool * term list"} $ |
|
285 |
HOLogic.mk_prod (@{term "True"}, HOLogic.mk_list @{typ term} |
|
286 |
(map2 HOLogic.mk_term_of (map snd vs') (map Free vs')))) |
|
287 |
| Depth_Limited_Random => fold_rev absdummy |
|
288 |
[@{typ natural}, @{typ natural}, @{typ natural}, |
|
289 |
@{typ Random.seed}] |
|
290 |
(mk_bind' (list_comb (prog, map Bound (3 downto 0)), |
|
291 |
mk_split_lambda (map Free vs') (mk_return' (HOLogic.mk_list @{typ term} |
|
292 |
(map2 HOLogic.mk_term_of (map snd vs') (map Free vs'))))))) |
|
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
293 |
val prog = |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
294 |
case compilation of |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
295 |
Pos_Random_DSeq => |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
296 |
let |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
297 |
val compiled_term = |
39471 | 298 |
Code_Runtime.dynamic_value_strict (Dseq_Result.get, put_dseq_result, "Predicate_Compile_Quickcheck.put_dseq_result") |
299 |
thy4 (SOME target) |
|
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50093
diff
changeset
|
300 |
(fn proc => fn g => fn n => fn size => fn s => g n size s |>> (Limited_Sequence.map o map) proc) |
39471 | 301 |
qc_term [] |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
302 |
in |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
303 |
(fn size => fn nrandom => fn depth => |
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50093
diff
changeset
|
304 |
Option.map fst (Limited_Sequence.yield |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
305 |
(compiled_term nrandom size |> Random_Engine.run) depth true)) |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
306 |
end |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
307 |
| New_Pos_Random_DSeq => |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
308 |
let |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
309 |
val compiled_term = |
39471 | 310 |
Code_Runtime.dynamic_value_strict |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
311 |
(Lseq_Result.get, put_lseq_result, "Predicate_Compile_Quickcheck.put_lseq_result") |
39471 | 312 |
thy4 (SOME target) |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
313 |
(fn proc => fn g => fn nrandom => fn size => fn s => fn depth => |
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50093
diff
changeset
|
314 |
g nrandom size s depth |> (Lazy_Sequence.map o map) proc) |
39471 | 315 |
qc_term [] |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
316 |
in |
55437 | 317 |
fn size => fn nrandom => fn depth => Option.map fst (Lazy_Sequence.yield |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
318 |
( |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
319 |
let |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
320 |
val seed = Random_Engine.next_seed () |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
321 |
in compiled_term nrandom size seed depth end)) |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
322 |
end |
40103 | 323 |
| Pos_Generator_DSeq => |
324 |
let |
|
325 |
val compiled_term = |
|
326 |
Code_Runtime.dynamic_value_strict |
|
327 |
(New_Dseq_Result.get, put_new_dseq_result, "Predicate_Compile_Quickcheck.put_new_dseq_result") |
|
328 |
thy4 (SOME target) |
|
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50093
diff
changeset
|
329 |
(fn proc => fn g => fn depth => g depth |> (Lazy_Sequence.map o map) proc) |
40103 | 330 |
qc_term [] |
331 |
in |
|
332 |
fn size => fn nrandom => fn depth => Option.map fst (Lazy_Sequence.yield (compiled_term depth)) |
|
333 |
end |
|
45450 | 334 |
| Pos_Generator_CPS => |
335 |
let |
|
336 |
val compiled_term = |
|
337 |
Code_Runtime.dynamic_value_strict |
|
338 |
(CPS_Result.get, put_cps_result, "Predicate_Compile_Quickcheck.put_cps_result") |
|
339 |
thy4 (SOME target) |
|
45750
17100f4ce0b5
adding genuine flag to predicate_compile_quickcheck and prolog_quickcheck (cf. 5e46c225370e);
bulwahn
parents:
45484
diff
changeset
|
340 |
(fn proc => fn g => fn depth => g depth |> Option.map (apsnd (map proc))) |
45450 | 341 |
qc_term [] |
342 |
in |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
343 |
fn _ => fn _ => Option.map snd o compiled_term |
45450 | 344 |
end |
40103 | 345 |
| Depth_Limited_Random => |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
346 |
let |
39471 | 347 |
val compiled_term = Code_Runtime.dynamic_value_strict |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
348 |
(Pred_Result.get, put_pred_result, "Predicate_Compile_Quickcheck.put_pred_result") |
39471 | 349 |
thy4 (SOME target) (fn proc => fn g => fn depth => fn nrandom => fn size => fn seed => |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
350 |
g depth nrandom size seed |> (Predicate.map o map) proc) |
39471 | 351 |
qc_term [] |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
352 |
in |
55437 | 353 |
fn size => fn nrandom => fn depth => Option.map fst (Predicate.yield |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
354 |
(compiled_term depth nrandom size (Random_Engine.run (fn s => (s, s))))) |
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
355 |
end |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
356 |
in |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
357 |
prog |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
358 |
end |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
359 |
|
45214 | 360 |
fun try_upto_depth ctxt f = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
361 |
let |
45214 | 362 |
val max_depth = Config.get ctxt Quickcheck.depth |
363 |
fun message s = if Config.get ctxt Quickcheck.quiet then () else Output.urgent_message s |
|
364 |
fun try' i = |
|
365 |
if i <= max_depth then |
|
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
366 |
let |
45214 | 367 |
val _ = message ("Depth: " ^ string_of_int i) |
368 |
val (result, time) = |
|
369 |
cpu_time ("Depth " ^ string_of_int i) (fn () => |
|
370 |
f i handle Match => (if Config.get ctxt Quickcheck.quiet then () |
|
371 |
else warning "Exception Match raised during quickcheck"; NONE)) |
|
372 |
val _ = if Config.get ctxt Quickcheck.timing then |
|
373 |
message (fst time ^ ": " ^ string_of_int (snd time) ^ " ms") else () |
|
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
374 |
in |
55437 | 375 |
(case result of NONE => try' (i + 1) | SOME q => SOME q) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
376 |
end |
55437 | 377 |
else NONE |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
378 |
in |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
379 |
try' 0 |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
380 |
end |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
381 |
|
55437 | 382 |
|
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
383 |
(* quickcheck interface functions *) |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
384 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
385 |
fun compile_term' compilation options ctxt (t, _) = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
386 |
let |
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
387 |
val size = Config.get ctxt Quickcheck.size |
36025
d25043e7843f
made quickcheck generic with respect to which compilation; added random compilation to quickcheck
bulwahn
parents:
35886
diff
changeset
|
388 |
val c = compile_term compilation options ctxt t |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
389 |
val counterexample = try_upto_depth ctxt (c (Code_Numeral.natural_of_integer size) |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
390 |
(Code_Numeral.natural_of_integer (!nrandom)) o Code_Numeral.natural_of_integer) |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
391 |
in |
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
392 |
Quickcheck.Result |
55437 | 393 |
{counterexample = |
394 |
Option.map (pair true o (curry (op ~~)) (Term.add_free_names t [])) counterexample, |
|
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
395 |
evaluation_terms = Option.map (K []) counterexample, timings = [], reports = []} |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
396 |
end |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
397 |
|
45214 | 398 |
fun quickcheck_compile_term compilation function_flattening fail_safe_function_flattening = |
35324
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
399 |
let |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
400 |
val options = |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
401 |
set_fail_safe_function_flattening fail_safe_function_flattening |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
402 |
(set_function_flattening function_flattening (get_options ())) |
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
bulwahn
parents:
34948
diff
changeset
|
403 |
in |
45214 | 404 |
compile_term' compilation options |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
405 |
end |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
diff
changeset
|
406 |
|
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
407 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
408 |
fun test_goals options ctxt _ insts goals = |
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
409 |
let |
45450 | 410 |
val (compilation, fail_safe_function_flattening) = options |
411 |
val function_flattening = Config.get ctxt (Quickcheck.allow_function_inversion) |
|
45214 | 412 |
val correct_inst_goals = Quickcheck_Common.instantiate_goals ctxt insts goals |
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
413 |
val test_term = |
45214 | 414 |
quickcheck_compile_term compilation function_flattening fail_safe_function_flattening |
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
415 |
in |
45214 | 416 |
Quickcheck_Common.collect_results (test_term ctxt) |
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
417 |
(maps (map snd) correct_inst_goals) [] |
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
418 |
end |
45450 | 419 |
|
55437 | 420 |
val smart_exhaustive_active = |
421 |
Attrib.setup_config_bool @{binding quickcheck_smart_exhaustive_active} (K true) |
|
422 |
val smart_slow_exhaustive_active = |
|
423 |
Attrib.setup_config_bool @{binding quickcheck_slow_smart_exhaustive_active} (K false) |
|
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
424 |
|
45484
23871e17dddb
setting up exhaustive generators which are used for the smart generators
bulwahn
parents:
45461
diff
changeset
|
425 |
val setup = |
55437 | 426 |
Exhaustive_Generators.setup_exhaustive_datatype_interpretation |
45484
23871e17dddb
setting up exhaustive generators which are used for the smart generators
bulwahn
parents:
45461
diff
changeset
|
427 |
#> Context.theory_map (Quickcheck.add_tester ("smart_exhaustive", |
45450 | 428 |
(smart_exhaustive_active, test_goals (Predicate_Compile_Aux.Pos_Generator_CPS, false)))) |
429 |
#> Context.theory_map (Quickcheck.add_tester ("smart_slow_exhaustive", |
|
430 |
(smart_slow_exhaustive_active, test_goals (Predicate_Compile_Aux.Pos_Generator_DSeq, false)))) |
|
43886
bf068e758783
adapting quickcheck based on the analysis of the predicate compiler
bulwahn
parents:
42361
diff
changeset
|
431 |
|
55437 | 432 |
end |