author | wenzelm |
Fri, 06 Mar 2015 23:53:52 +0100 | |
changeset 59637 | f643308472ce |
parent 59621 | 291934bac95e |
child 59859 | f9d1442c70f3 |
permissions | -rw-r--r-- |
41923
f05fc0711bc7
renaming signatures and structures; correcting header
bulwahn
parents:
41921
diff
changeset
|
1 |
(* Title: HOL/Tools/Quickcheck/random_generators.ML |
37744 | 2 |
Author: Florian Haftmann, TU Muenchen |
31260 | 3 |
|
41923
f05fc0711bc7
renaming signatures and structures; correcting header
bulwahn
parents:
41921
diff
changeset
|
4 |
Random generators for various types. |
31260 | 5 |
*) |
6 |
||
41923
f05fc0711bc7
renaming signatures and structures; correcting header
bulwahn
parents:
41921
diff
changeset
|
7 |
signature RANDOM_GENERATORS = |
31260 | 8 |
sig |
9 |
type seed = Random_Engine.seed |
|
10 |
val random_fun: typ -> typ -> ('a -> 'a -> bool) -> ('a -> term) |
|
11 |
-> (seed -> ('b * (unit -> term)) * seed) -> (seed -> seed * seed) |
|
33243 | 12 |
-> seed -> (('a -> 'b) * (unit -> term)) * seed |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
13 |
val compile_generator_expr: |
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
14 |
Proof.context -> (term * term list) list -> bool -> int list -> (bool * term list) option * Quickcheck.report option |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
15 |
val put_counterexample: (unit -> Code_Numeral.natural -> bool -> Code_Numeral.natural -> seed -> (bool * term list) option * seed) |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
16 |
-> Proof.context -> Proof.context |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
17 |
val put_counterexample_report: (unit -> Code_Numeral.natural -> bool -> Code_Numeral.natural -> seed -> ((bool * term list) option * (bool list * bool)) * seed) |
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
18 |
-> Proof.context -> Proof.context |
58112
8081087096ad
renamed modules defining old datatypes, as a step towards having 'datatype_new' take 'datatype's place
blanchet
parents:
55757
diff
changeset
|
19 |
val instantiate_random_datatype : Old_Datatype_Aux.config -> Old_Datatype_Aux.descr -> |
45940
71970a26a269
quickcheck_generator command also creates random generators
bulwahn
parents:
45923
diff
changeset
|
20 |
(string * sort) list -> string list -> string -> string list * string list -> typ list * typ list -> theory -> theory |
31260 | 21 |
end; |
22 |
||
41923
f05fc0711bc7
renaming signatures and structures; correcting header
bulwahn
parents:
41921
diff
changeset
|
23 |
structure Random_Generators : RANDOM_GENERATORS = |
31260 | 24 |
struct |
25 |
||
31950 | 26 |
(** abstract syntax **) |
31260 | 27 |
|
31950 | 28 |
fun termifyT T = HOLogic.mk_prodT (T, @{typ "unit => term"}) |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
29 |
val size = @{term "i::natural"}; |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
30 |
val size_pred = @{term "(i::natural) - 1"}; |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
31 |
val size' = @{term "j::natural"}; |
31950 | 32 |
val seed = @{term "s::Random.seed"}; |
31260 | 33 |
|
45723
75691bcc2c0f
quickcheck-random compilation also indicates if the counterexample is potentially spurious or not
bulwahn
parents:
45721
diff
changeset
|
34 |
val resultT = @{typ "(bool * term list) option"}; |
45721
d1fb55c2ed65
quickcheck's compilation returns if it is genuine counterexample or a counterexample due to a match exception
bulwahn
parents:
45719
diff
changeset
|
35 |
|
31260 | 36 |
(** typ "'a => 'b" **) |
37 |
||
38 |
type seed = Random_Engine.seed; |
|
39 |
||
31603
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
40 |
fun random_fun T1 T2 eq term_of random random_split seed = |
31260 | 41 |
let |
42 |
val fun_upd = Const (@{const_name fun_upd}, |
|
43 |
(T1 --> T2) --> T1 --> T2 --> T1 --> T2); |
|
50046 | 44 |
val ((_, t2), seed') = random seed; |
32344 | 45 |
val (seed'', seed''') = random_split seed'; |
31933
cd6511035315
proper closures -- imperative programming considered harmful...
haftmann
parents:
31902
diff
changeset
|
46 |
|
32740 | 47 |
val state = Unsynchronized.ref (seed'', [], fn () => Abs ("x", T1, t2 ())); |
31260 | 48 |
fun random_fun' x = |
49 |
let |
|
50 |
val (seed, fun_map, f_t) = ! state; |
|
51 |
in case AList.lookup (uncurry eq) fun_map x |
|
52 |
of SOME y => y |
|
53 |
| NONE => let |
|
54 |
val t1 = term_of x; |
|
55 |
val ((y, t2), seed') = random seed; |
|
56 |
val fun_map' = (x, y) :: fun_map; |
|
31933
cd6511035315
proper closures -- imperative programming considered harmful...
haftmann
parents:
31902
diff
changeset
|
57 |
val f_t' = fn () => fun_upd $ f_t () $ t1 $ t2 (); |
31260 | 58 |
val _ = state := (seed', fun_map', f_t'); |
59 |
in y end |
|
60 |
end; |
|
31933
cd6511035315
proper closures -- imperative programming considered harmful...
haftmann
parents:
31902
diff
changeset
|
61 |
fun term_fun' () = #3 (! state) (); |
32344 | 62 |
in ((random_fun', term_fun'), seed''') end; |
31260 | 63 |
|
45762
daf57640d4df
the reporting random testing also returns if the counterexample is genuine or potentially spurious
bulwahn
parents:
45761
diff
changeset
|
64 |
|
31260 | 65 |
(** datatypes **) |
66 |
||
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
67 |
(* definitional scheme for random instances on datatypes *) |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
68 |
|
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
69 |
local |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
70 |
|
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
71 |
fun dest_ctyp_nth k cT = nth (Thm.dest_ctyp cT) k; |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
72 |
val eq = Thm.cprop_of @{thm random_aux_rec} |> Thm.dest_arg |> Thm.dest_arg |> Thm.dest_arg; |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
73 |
val lhs = eq |> Thm.dest_arg1; |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
74 |
val pt_random_aux = lhs |> Thm.dest_fun; |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
75 |
val pt_rhs = eq |> Thm.dest_arg |> Thm.dest_fun; |
59586 | 76 |
val aT = pt_random_aux |> Thm.ctyp_of_cterm |> dest_ctyp_nth 1; |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
77 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
78 |
val rew_thms = map mk_meta_eq [@{thm natural_zero_minus_one}, |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
79 |
@{thm Suc_natural_minus_one}, @{thm select_weight_cons_zero}, @{thm beyond_zero}]; |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
80 |
val rew_ts = map (Logic.dest_equals o Thm.prop_of) rew_thms; |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51551
diff
changeset
|
81 |
val rew_ss = simpset_of (put_simpset HOL_ss @{context} addsimps rew_thms); |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
82 |
|
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
83 |
in |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
84 |
|
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
85 |
fun random_aux_primrec eq lthy = |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
86 |
let |
42361 | 87 |
val thy = Proof_Context.theory_of lthy; |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
88 |
val ((t_random_aux as Free (random_aux, T)) $ (t_k as Free (v, _)), proto_t_rhs) = |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
89 |
(HOLogic.dest_eq o HOLogic.dest_Trueprop) eq; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
90 |
val Type (_, [_, iT]) = T; |
59637 | 91 |
val icT = Thm.ctyp_of lthy iT; |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
92 |
val inst = Thm.instantiate_cterm ([(aT, icT)], []); |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
93 |
fun subst_v t' = map_aterms (fn t as Free (w, _) => if v = w then t' else t | t => t); |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
94 |
val t_rhs = lambda t_k proto_t_rhs; |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
95 |
val eqs0 = [subst_v @{term "0::natural"} eq, |
46547
d1dcb91a512e
use qualified constant names instead of suffixes (from Florian Haftmann)
huffman
parents:
46331
diff
changeset
|
96 |
subst_v (@{const Code_Numeral.Suc} $ t_k) eq]; |
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
97 |
val eqs1 = map (Pattern.rewrite_term thy rew_ts []) eqs0; |
59617 | 98 |
val ((_, (_, eqs2)), lthy') = lthy |
99 |
|> BNF_LFP_Compat.add_primrec_simple |
|
100 |
[((Binding.conceal (Binding.name random_aux), T), NoSyn)] eqs1; |
|
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
101 |
val cT_random_aux = inst pt_random_aux; |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
102 |
val cT_rhs = inst pt_rhs; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
103 |
val rule = @{thm random_aux_rec} |
59617 | 104 |
|> Drule.instantiate_normalize |
105 |
([(aT, icT)], |
|
59637 | 106 |
[(cT_random_aux, Thm.cterm_of lthy' t_random_aux), |
107 |
(cT_rhs, Thm.cterm_of lthy' t_rhs)]); |
|
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51551
diff
changeset
|
108 |
fun tac ctxt = |
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51551
diff
changeset
|
109 |
ALLGOALS (rtac rule) |
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51551
diff
changeset
|
110 |
THEN ALLGOALS (simp_tac (put_simpset rew_ss ctxt)) |
59617 | 111 |
THEN (ALLGOALS (Proof_Context.fact_tac ctxt eqs2)); |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51551
diff
changeset
|
112 |
val simp = Goal.prove_sorry lthy' [v] [] eq (tac o #context); |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
113 |
in (simp, lthy') end; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
114 |
|
31611
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
115 |
end; |
a577f77af93f
explicit instantiation yields considerable speedup
haftmann
parents:
31609
diff
changeset
|
116 |
|
31868 | 117 |
fun random_aux_primrec_multi auxname [eq] lthy = |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
118 |
lthy |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
119 |
|> random_aux_primrec eq |
58229 | 120 |
|>> single |
31868 | 121 |
| random_aux_primrec_multi auxname (eqs as _ :: _ :: _) lthy = |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
122 |
let |
42361 | 123 |
val thy = Proof_Context.theory_of lthy; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
124 |
val (lhss, rhss) = map_split (HOLogic.dest_eq o HOLogic.dest_Trueprop) eqs; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
125 |
val (vs, (arg as Free (v, _)) :: _) = map_split (fn (t1 $ t2) => (t1, t2)) lhss; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
126 |
val Ts = map fastype_of lhss; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
127 |
val tupleT = foldr1 HOLogic.mk_prodT Ts; |
31868 | 128 |
val aux_lhs = Free ("mutual_" ^ auxname, fastype_of arg --> tupleT) $ arg; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
129 |
val aux_eq = (HOLogic.mk_Trueprop o HOLogic.mk_eq) |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
130 |
(aux_lhs, foldr1 HOLogic.mk_prod rhss); |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
131 |
fun mk_proj t [T] = [t] |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
132 |
| mk_proj t (Ts as T :: (Ts' as _ :: _)) = |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
133 |
Const (@{const_name fst}, foldr1 HOLogic.mk_prodT Ts --> T) $ t |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
134 |
:: mk_proj (Const (@{const_name snd}, |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
135 |
foldr1 HOLogic.mk_prodT Ts --> foldr1 HOLogic.mk_prodT Ts') $ t) Ts'; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
136 |
val projs = mk_proj (aux_lhs) Ts; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
137 |
val proj_eqs = map2 (fn v => fn proj => (v, lambda arg proj)) vs projs; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
138 |
val proj_defs = map2 (fn Free (name, _) => fn (_, rhs) => |
33205 | 139 |
((Binding.conceal (Binding.name name), NoSyn), |
33280 | 140 |
(apfst Binding.conceal Attrib.empty_binding, rhs))) vs proj_eqs; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
141 |
val aux_eq' = Pattern.rewrite_term thy proj_eqs [] aux_eq; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
142 |
fun prove_eqs aux_simp proj_defs lthy = |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
143 |
let |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
144 |
val proj_simps = map (snd o snd) proj_defs; |
31645 | 145 |
fun tac { context = ctxt, prems = _ } = |
51717
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
wenzelm
parents:
51551
diff
changeset
|
146 |
ALLGOALS (simp_tac (put_simpset HOL_ss ctxt addsimps proj_simps)) |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
147 |
THEN ALLGOALS (EqSubst.eqsubst_tac ctxt [0] [aux_simp]) |
58229 | 148 |
THEN ALLGOALS (simp_tac (put_simpset HOL_ss ctxt addsimps @{thms fst_conv snd_conv})); |
51551 | 149 |
in (map (fn prop => Goal.prove_sorry lthy [v] [] prop tac) eqs, lthy) end; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
150 |
in |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
151 |
lthy |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
152 |
|> random_aux_primrec aux_eq' |
33766
c679f05600cd
adapted Local_Theory.define -- eliminated odd thm kind;
wenzelm
parents:
33671
diff
changeset
|
153 |
||>> fold_map Local_Theory.define proj_defs |
58229 | 154 |
|-> uncurry prove_eqs |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
155 |
end; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
156 |
|
31868 | 157 |
fun random_aux_specification prfx name eqs lthy = |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
158 |
let |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
159 |
val vs = fold Term.add_free_names ((snd o strip_comb o fst o HOLogic.dest_eq |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
160 |
o HOLogic.dest_Trueprop o hd) eqs) []; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
161 |
fun mk_proto_eq eq = |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
162 |
let |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
163 |
val (head $ t $ u, rhs) = (HOLogic.dest_eq o HOLogic.dest_Trueprop) eq; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
164 |
in ((HOLogic.mk_Trueprop o HOLogic.mk_eq) (head, lambda t (lambda u rhs))) end; |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
165 |
val proto_eqs = map mk_proto_eq eqs; |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
166 |
fun prove_simps proto_simps lthy = |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
167 |
let |
31625 | 168 |
val ext_simps = map (fn thm => fun_cong OF [fun_cong OF [thm]]) proto_simps; |
54742
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents:
51717
diff
changeset
|
169 |
val tac = ALLGOALS (Proof_Context.fact_tac lthy ext_simps); |
51551 | 170 |
in (map (fn prop => Goal.prove_sorry lthy vs [] prop (K tac)) eqs, lthy) end; |
33205 | 171 |
val b = Binding.conceal (Binding.qualify true prfx |
172 |
(Binding.qualify true name (Binding.name "simps"))); |
|
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
173 |
in |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
174 |
lthy |
31868 | 175 |
|> random_aux_primrec_multi (name ^ prfx) proto_eqs |
58229 | 176 |
|-> prove_simps |
33671 | 177 |
|-> (fn simps => Local_Theory.note |
45592 | 178 |
((b, Code.add_default_eqn_attrib :: @{attributes [simp, nitpick_simp]}), simps)) |
31485
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
179 |
|> snd |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
180 |
end |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
181 |
|
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
182 |
|
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
183 |
(* constructing random instances on datatypes *) |
259a3c90016e
added infrastructure for definitorial construction of generators for datatypes
haftmann
parents:
31260
diff
changeset
|
184 |
|
31868 | 185 |
val random_auxN = "random_aux"; |
186 |
||
50046 | 187 |
fun mk_random_aux_eqs thy descr vs (names, auxnames) (Ts, Us) = |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
188 |
let |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
189 |
val mk_const = curry (Sign.mk_const thy); |
31603
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
190 |
val random_auxsN = map (prefix (random_auxN ^ "_")) (names @ auxnames); |
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
191 |
val rTs = Ts @ Us; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
192 |
fun random_resultT T = @{typ Random.seed} |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
193 |
--> HOLogic.mk_prodT (termifyT T,@{typ Random.seed}); |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
194 |
fun sizeT T = @{typ natural} --> @{typ natural} --> T; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
195 |
val random_auxT = sizeT o random_resultT; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
196 |
val random_auxs = map2 (fn s => fn rT => Free (s, random_auxT rT)) |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
197 |
random_auxsN rTs; |
31950 | 198 |
fun mk_random_call T = (NONE, (HOLogic.mk_random T size', T)); |
31603
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
199 |
fun mk_random_aux_call fTs (k, _) (tyco, Ts) = |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
200 |
let |
31623
b72c11302b39
quickcheck generators for datatypes with functions
haftmann
parents:
31611
diff
changeset
|
201 |
val T = Type (tyco, Ts); |
b72c11302b39
quickcheck generators for datatypes with functions
haftmann
parents:
31611
diff
changeset
|
202 |
fun mk_random_fun_lift [] t = t |
b72c11302b39
quickcheck generators for datatypes with functions
haftmann
parents:
31611
diff
changeset
|
203 |
| mk_random_fun_lift (fT :: fTs) t = |
b72c11302b39
quickcheck generators for datatypes with functions
haftmann
parents:
31611
diff
changeset
|
204 |
mk_const @{const_name random_fun_lift} [fTs ---> T, fT] $ |
b72c11302b39
quickcheck generators for datatypes with functions
haftmann
parents:
31611
diff
changeset
|
205 |
mk_random_fun_lift fTs t; |
31984 | 206 |
val t = mk_random_fun_lift fTs (nth random_auxs k $ size_pred $ size'); |
58112
8081087096ad
renamed modules defining old datatypes, as a step towards having 'datatype_new' take 'datatype's place
blanchet
parents:
55757
diff
changeset
|
207 |
val size = Option.map snd (Old_Datatype_Aux.find_shortest_path descr k) |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
208 |
|> the_default 0; |
31623
b72c11302b39
quickcheck generators for datatypes with functions
haftmann
parents:
31611
diff
changeset
|
209 |
in (SOME size, (t, fTs ---> T)) end; |
58112
8081087096ad
renamed modules defining old datatypes, as a step towards having 'datatype_new' take 'datatype's place
blanchet
parents:
55757
diff
changeset
|
210 |
val tss = Old_Datatype_Aux.interpret_construction descr vs |
31603
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
211 |
{ atyp = mk_random_call, dtyp = mk_random_aux_call }; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
212 |
fun mk_consexpr simpleT (c, xs) = |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
213 |
let |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
214 |
val (ks, simple_tTs) = split_list xs; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
215 |
val T = termifyT simpleT; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
216 |
val tTs = (map o apsnd) termifyT simple_tTs; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
217 |
val is_rec = exists is_some ks; |
33029 | 218 |
val k = fold (fn NONE => I | SOME k => Integer.max k) ks 0; |
43329
84472e198515
tuned signature: Name.invent and Name.invent_names;
wenzelm
parents:
42361
diff
changeset
|
219 |
val vs = Name.invent_names Name.context "x" (map snd simple_tTs); |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
220 |
val tc = HOLogic.mk_return T @{typ Random.seed} |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
221 |
(HOLogic.mk_valtermify_app c vs simpleT); |
38543 | 222 |
val t = HOLogic.mk_ST |
223 |
(map2 (fn (t, _) => fn (v, T') => ((t, @{typ Random.seed}), SOME ((v, termifyT T')))) tTs vs) |
|
224 |
tc @{typ Random.seed} (SOME T, @{typ Random.seed}); |
|
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
225 |
val tk = if is_rec |
31950 | 226 |
then if k = 0 then size |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
227 |
else @{term "Quickcheck_Random.beyond :: natural \<Rightarrow> natural \<Rightarrow> natural"} |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
228 |
$ HOLogic.mk_number @{typ natural} k $ size |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
229 |
else @{term "1::natural"} |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
230 |
in (is_rec, HOLogic.mk_prod (tk, t)) end; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
231 |
fun sort_rec xs = |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
232 |
map_filter (fn (true, t) => SOME t | _ => NONE) xs |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
233 |
@ map_filter (fn (false, t) => SOME t | _ => NONE) xs; |
31603
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
234 |
val gen_exprss = tss |
fa30cd74d7d6
revised interpretation combinator for datatype constructions
haftmann
parents:
31595
diff
changeset
|
235 |
|> (map o apfst) Type |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
236 |
|> map (fn (T, cs) => (T, (sort_rec o map (mk_consexpr T)) cs)); |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
237 |
fun mk_select (rT, xs) = |
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50818
diff
changeset
|
238 |
mk_const @{const_name Quickcheck_Random.collapse} [@{typ Random.seed}, termifyT rT] |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
239 |
$ (mk_const @{const_name Random.select_weight} [random_resultT rT] |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
240 |
$ HOLogic.mk_list (HOLogic.mk_prodT (@{typ natural}, random_resultT rT)) xs) |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
241 |
$ seed; |
31950 | 242 |
val auxs_lhss = map (fn t => t $ size $ size' $ seed) random_auxs; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
243 |
val auxs_rhss = map mk_select gen_exprss; |
31868 | 244 |
in (random_auxs, auxs_lhss ~~ auxs_rhss) end; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
245 |
|
38543 | 246 |
fun instantiate_random_datatype config descr vs tycos prfx (names, auxnames) (Ts, Us) thy = |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
247 |
let |
58112
8081087096ad
renamed modules defining old datatypes, as a step towards having 'datatype_new' take 'datatype's place
blanchet
parents:
55757
diff
changeset
|
248 |
val _ = Old_Datatype_Aux.message config "Creating quickcheck generators ..."; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
249 |
val mk_prop_eq = HOLogic.mk_Trueprop o HOLogic.mk_eq; |
58112
8081087096ad
renamed modules defining old datatypes, as a step towards having 'datatype_new' take 'datatype's place
blanchet
parents:
55757
diff
changeset
|
250 |
fun mk_size_arg k = case Old_Datatype_Aux.find_shortest_path descr k |
31950 | 251 |
of SOME (_, l) => if l = 0 then size |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
252 |
else @{term "max :: natural \<Rightarrow> natural \<Rightarrow> natural"} |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
253 |
$ HOLogic.mk_number @{typ natural} l $ size |
31950 | 254 |
| NONE => size; |
31868 | 255 |
val (random_auxs, auxs_eqs) = (apsnd o map) mk_prop_eq |
50046 | 256 |
(mk_random_aux_eqs thy descr vs (names, auxnames) (Ts, Us)); |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
257 |
val random_defs = map_index (fn (k, T) => mk_prop_eq |
31950 | 258 |
(HOLogic.mk_random T size, nth random_auxs k $ mk_size_arg k $ size)) Ts; |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
259 |
in |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
260 |
thy |
38348
cf7b2121ad9d
moved instantiation target formally to class_target.ML
haftmann
parents:
37744
diff
changeset
|
261 |
|> Class.instantiation (tycos, vs, @{sort random}) |
31868 | 262 |
|> random_aux_specification prfx random_auxN auxs_eqs |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
263 |
|> `(fn lthy => map (Syntax.check_term lthy) random_defs) |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
264 |
|-> (fn random_defs' => fold_map (fn random_def => |
33280 | 265 |
Specification.definition (NONE, (apfst Binding.conceal |
33205 | 266 |
Attrib.empty_binding, random_def))) random_defs') |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
267 |
|> snd |
59498
50b60f501b05
proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents:
59154
diff
changeset
|
268 |
|> Class.prove_instantiation_exit (fn ctxt => Class.intro_classes_tac ctxt []) |
31595
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
269 |
end; |
bd2f7211a420
first running version of qc generators for datatypes
haftmann
parents:
31485
diff
changeset
|
270 |
|
59154 | 271 |
|
31950 | 272 |
(** building and compiling generator expressions **) |
273 |
||
59154 | 274 |
structure Data = Proof_Data |
41472
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
wenzelm
parents:
40911
diff
changeset
|
275 |
( |
59154 | 276 |
type T = |
277 |
(unit -> Code_Numeral.natural -> bool -> Code_Numeral.natural -> seed -> |
|
278 |
(bool * term list) option * seed) * |
|
279 |
(unit -> Code_Numeral.natural -> bool -> Code_Numeral.natural -> seed -> |
|
280 |
((bool * term list) option * (bool list * bool)) * seed); |
|
281 |
val empty: T = |
|
282 |
(fn () => raise Fail "counterexample", |
|
283 |
fn () => raise Fail "counterexample_report"); |
|
284 |
fun init _ = empty; |
|
39388
fdbb2c55ffc2
replaced ML_Context.evaluate by ML_Context.value -- using context data instead of bare metal references
haftmann
parents:
39253
diff
changeset
|
285 |
); |
31950 | 286 |
|
59154 | 287 |
val get_counterexample = #1 o Data.get; |
288 |
val get_counterexample_report = #2 o Data.get; |
|
289 |
||
290 |
val put_counterexample = Data.map o @{apply 2(1)} o K; |
|
291 |
val put_counterexample_report = Data.map o @{apply 2(2)} o K; |
|
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
292 |
|
31950 | 293 |
val target = "Quickcheck"; |
294 |
||
50046 | 295 |
fun mk_generator_expr ctxt (t, _) = |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
296 |
let |
42361 | 297 |
val thy = Proof_Context.theory_of ctxt |
44241 | 298 |
val prop = fold_rev absfree (Term.add_frees t []) t |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
299 |
val Ts = (map snd o fst o strip_abs) prop |
31950 | 300 |
val bound_max = length Ts - 1; |
301 |
val bounds = map_index (fn (i, ty) => |
|
302 |
(2 * (bound_max - i) + 1, 2 * (bound_max - i), 2 * i, ty)) Ts; |
|
303 |
val result = list_comb (prop, map (fn (i, _, _, _) => Bound i) bounds); |
|
304 |
val terms = HOLogic.mk_list @{typ term} (map (fn (_, i, _, _) => Bound i $ @{term "()"}) bounds); |
|
50046 | 305 |
val ([genuine_only_name], _) = Variable.variant_fixes ["genuine_only"] ctxt |
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
306 |
val genuine_only = Free (genuine_only_name, @{typ bool}) |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
307 |
val none_t = Const (@{const_name "None"}, resultT) |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
308 |
val check = Quickcheck_Common.mk_safe_if genuine_only none_t (result, none_t, |
45721
d1fb55c2ed65
quickcheck's compilation returns if it is genuine counterexample or a counterexample due to a match exception
bulwahn
parents:
45719
diff
changeset
|
309 |
fn genuine => @{term "Some :: bool * term list => (bool * term list) option"} $ |
d1fb55c2ed65
quickcheck's compilation returns if it is genuine counterexample or a counterexample due to a match exception
bulwahn
parents:
45719
diff
changeset
|
310 |
HOLogic.mk_prod (Quickcheck_Common.reflect_bool genuine, terms)) |
45723
75691bcc2c0f
quickcheck-random compilation also indicates if the counterexample is potentially spurious or not
bulwahn
parents:
45721
diff
changeset
|
311 |
val return = HOLogic.pair_const resultT @{typ Random.seed}; |
31950 | 312 |
fun liftT T sT = sT --> HOLogic.mk_prodT (T, sT); |
313 |
fun mk_termtyp T = HOLogic.mk_prodT (T, @{typ "unit => term"}); |
|
314 |
fun mk_scomp T1 T2 sT f g = Const (@{const_name scomp}, |
|
315 |
liftT T1 sT --> (T1 --> liftT T2 sT) --> liftT T2 sT) $ f $ g; |
|
316 |
fun mk_split T = Sign.mk_const thy |
|
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
54742
diff
changeset
|
317 |
(@{const_name case_prod}, [T, @{typ "unit => term"}, liftT resultT @{typ Random.seed}]); |
31950 | 318 |
fun mk_scomp_split T t t' = |
45723
75691bcc2c0f
quickcheck-random compilation also indicates if the counterexample is potentially spurious or not
bulwahn
parents:
45721
diff
changeset
|
319 |
mk_scomp (mk_termtyp T) resultT @{typ Random.seed} t |
31950 | 320 |
(mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
321 |
fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
|
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50818
diff
changeset
|
322 |
(Sign.mk_const thy (@{const_name Quickcheck_Random.random}, [T]) $ Bound i); |
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
323 |
in |
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
324 |
lambda genuine_only |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
325 |
(Abs ("n", @{typ natural}, fold_rev mk_bindclause bounds (return $ check true))) |
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
326 |
end; |
31950 | 327 |
|
50046 | 328 |
fun mk_reporting_generator_expr ctxt (t, _) = |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
329 |
let |
42361 | 330 |
val thy = Proof_Context.theory_of ctxt |
45762
daf57640d4df
the reporting random testing also returns if the counterexample is genuine or potentially spurious
bulwahn
parents:
45761
diff
changeset
|
331 |
val resultT = @{typ "(bool * term list) option * (bool list * bool)"} |
44241 | 332 |
val prop = fold_rev absfree (Term.add_frees t []) t |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
333 |
val Ts = (map snd o fst o strip_abs) prop |
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
334 |
val bound_max = length Ts - 1 |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
335 |
val bounds = map_index (fn (i, ty) => |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
336 |
(2 * (bound_max - i) + 1, 2 * (bound_max - i), 2 * i, ty)) Ts; |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
337 |
val prop' = betapplys (prop, map (fn (i, _, _, _) => Bound i) bounds); |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
338 |
val terms = HOLogic.mk_list @{typ term} (map (fn (_, i, _, _) => Bound i $ @{term "()"}) bounds) |
42195
1e7b62c93f5d
adding an exhaustive validator for quickcheck's batch validating; moving strip_imp; minimal setup for bounded_forall
bulwahn
parents:
42159
diff
changeset
|
339 |
val (assms, concl) = Quickcheck_Common.strip_imp prop' |
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50818
diff
changeset
|
340 |
val return = HOLogic.pair_const resultT @{typ Random.seed}; |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
341 |
fun mk_assms_report i = |
45762
daf57640d4df
the reporting random testing also returns if the counterexample is genuine or potentially spurious
bulwahn
parents:
45761
diff
changeset
|
342 |
HOLogic.mk_prod (@{term "None :: (bool * term list) option"}, |
38553
56965d8e4e11
use HOLogic.boolT and @{typ bool} more pervasively
haftmann
parents:
38549
diff
changeset
|
343 |
HOLogic.mk_prod (HOLogic.mk_list HOLogic.boolT |
56965d8e4e11
use HOLogic.boolT and @{typ bool} more pervasively
haftmann
parents:
38549
diff
changeset
|
344 |
(replicate i @{term True} @ replicate (length assms - i) @{term False}), |
56965d8e4e11
use HOLogic.boolT and @{typ bool} more pervasively
haftmann
parents:
38549
diff
changeset
|
345 |
@{term False})) |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
346 |
fun mk_concl_report b = |
38553
56965d8e4e11
use HOLogic.boolT and @{typ bool} more pervasively
haftmann
parents:
38549
diff
changeset
|
347 |
HOLogic.mk_prod (HOLogic.mk_list HOLogic.boolT (replicate (length assms) @{term True}), |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
348 |
Quickcheck_Common.reflect_bool b) |
50046 | 349 |
val ([genuine_only_name], _) = Variable.variant_fixes ["genuine_only"] ctxt |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
350 |
val genuine_only = Free (genuine_only_name, @{typ bool}) |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
351 |
val none_t = HOLogic.mk_prod (@{term "None :: (bool * term list) option"}, mk_concl_report true) |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
352 |
val concl_check = Quickcheck_Common.mk_safe_if genuine_only none_t (concl, none_t, |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
353 |
fn genuine => HOLogic.mk_prod (@{term "Some :: bool * term list => (bool * term list) option"} $ |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
354 |
HOLogic.mk_prod (Quickcheck_Common.reflect_bool genuine, terms), mk_concl_report false)) |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
355 |
val check = fold_rev (fn (i, assm) => fn t => Quickcheck_Common.mk_safe_if genuine_only |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
356 |
(mk_assms_report i) (HOLogic.mk_not assm, mk_assms_report i, t)) |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
357 |
(map_index I assms) concl_check |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
358 |
fun liftT T sT = sT --> HOLogic.mk_prodT (T, sT); |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
359 |
fun mk_termtyp T = HOLogic.mk_prodT (T, @{typ "unit => term"}); |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
360 |
fun mk_scomp T1 T2 sT f g = Const (@{const_name scomp}, |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
361 |
liftT T1 sT --> (T1 --> liftT T2 sT) --> liftT T2 sT) $ f $ g; |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
362 |
fun mk_split T = Sign.mk_const thy |
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
54742
diff
changeset
|
363 |
(@{const_name case_prod}, [T, @{typ "unit => term"}, liftT resultT @{typ Random.seed}]); |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
364 |
fun mk_scomp_split T t t' = |
45762
daf57640d4df
the reporting random testing also returns if the counterexample is genuine or potentially spurious
bulwahn
parents:
45761
diff
changeset
|
365 |
mk_scomp (mk_termtyp T) resultT @{typ Random.seed} t |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
366 |
(mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
367 |
fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
51126
df86080de4cb
reform of predicate compiler / quickcheck theories:
haftmann
parents:
50818
diff
changeset
|
368 |
(Sign.mk_const thy (@{const_name Quickcheck_Random.random}, [T]) $ Bound i); |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
369 |
in |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
370 |
lambda genuine_only |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
371 |
(Abs ("n", @{typ natural}, fold_rev mk_bindclause bounds (return $ check true))) |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
372 |
end |
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
373 |
|
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
374 |
val mk_parametric_generator_expr = Quickcheck_Common.gen_mk_parametric_generator_expr |
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
375 |
((mk_generator_expr, |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
376 |
absdummy @{typ bool} (absdummy @{typ natural} |
45759 | 377 |
@{term "Pair None :: Random.seed => (bool * term list) option * Random.seed"})), |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
378 |
@{typ "bool => natural => Random.seed => (bool * term list) option * Random.seed"}) |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
379 |
|
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
380 |
val mk_parametric_reporting_generator_expr = Quickcheck_Common.gen_mk_parametric_generator_expr |
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
381 |
((mk_reporting_generator_expr, |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
382 |
absdummy @{typ bool} (absdummy @{typ natural} |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
383 |
@{term "Pair (None, ([], False)) :: Random.seed => |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
384 |
((bool * term list) option * (bool list * bool)) * Random.seed"})), |
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
385 |
@{typ "bool => natural => Random.seed => ((bool * term list) option * (bool list * bool)) * Random.seed"}) |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
386 |
|
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
387 |
|
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
388 |
(* single quickcheck report *) |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
389 |
|
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
390 |
datatype single_report = Run of bool list * bool | MatchExc |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
391 |
|
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
392 |
fun collect_single_report single_report |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
393 |
(Quickcheck.Report {iterations = iterations, raised_match_errors = raised_match_errors, |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
394 |
satisfied_assms = satisfied_assms, positive_concl_tests = positive_concl_tests}) = |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
395 |
case single_report |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
396 |
of MatchExc => |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
397 |
Quickcheck.Report {iterations = iterations + 1, raised_match_errors = raised_match_errors + 1, |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
398 |
satisfied_assms = satisfied_assms, positive_concl_tests = positive_concl_tests} |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
399 |
| Run (assms, concl) => |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
400 |
Quickcheck.Report {iterations = iterations + 1, raised_match_errors = raised_match_errors, |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
401 |
satisfied_assms = |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
402 |
map2 (fn b => fn s => if b then s + 1 else s) assms |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
403 |
(if null satisfied_assms then replicate (length assms) 0 else satisfied_assms), |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
404 |
positive_concl_tests = if concl then positive_concl_tests + 1 else positive_concl_tests} |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
405 |
|
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
406 |
val empty_report = Quickcheck.Report { iterations = 0, raised_match_errors = 0, |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
407 |
satisfied_assms = [], positive_concl_tests = 0 } |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
408 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
409 |
fun compile_generator_expr_raw ctxt ts = |
31950 | 410 |
let |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
411 |
val iterations = Config.get ctxt Quickcheck.iterations |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
412 |
in |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
413 |
if Config.get ctxt Quickcheck.report then |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
414 |
let |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
415 |
val t' = mk_parametric_reporting_generator_expr ctxt ts; |
59154 | 416 |
val compile = |
417 |
Code_Runtime.dynamic_value_strict |
|
418 |
(get_counterexample_report, put_counterexample_report, |
|
419 |
"Random_Generators.put_counterexample_report") |
|
420 |
ctxt (SOME target) |
|
421 |
(fn proc => fn g => fn c => fn b => fn s => |
|
422 |
g c b s #>> (apfst o Option.map o apsnd o map) proc) |
|
423 |
t' []; |
|
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
424 |
fun single_tester c b s = compile c b s |> Random_Engine.run |
50046 | 425 |
fun iterate_and_collect _ _ 0 report = (NONE, report) |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
426 |
| iterate_and_collect genuine_only (card, size) j report = |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
427 |
let |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
428 |
val (test_result, single_report) = apsnd Run (single_tester card genuine_only size) |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
429 |
val report = collect_single_report single_report report |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
430 |
in |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
431 |
case test_result of NONE => iterate_and_collect genuine_only (card, size) (j - 1) report |
45762
daf57640d4df
the reporting random testing also returns if the counterexample is genuine or potentially spurious
bulwahn
parents:
45761
diff
changeset
|
432 |
| SOME q => (SOME q, report) |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
433 |
end |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
434 |
in |
45763
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
435 |
fn genuine_only => fn [card, size] => |
3bb2bdf654f7
random reporting compilation returns if counterexample is genuine or potentially spurious, and takes genuine_only option as argument
bulwahn
parents:
45762
diff
changeset
|
436 |
apsnd SOME (iterate_and_collect genuine_only (card, size) iterations empty_report) |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
437 |
end |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
438 |
else |
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
439 |
let |
42159
234ec7011e5d
generalizing compilation scheme of quickcheck generators to multiple arguments; changing random and exhaustive tester to use one code invocation for polymorphic instances with multiple cardinalities
bulwahn
parents:
42028
diff
changeset
|
440 |
val t' = mk_parametric_generator_expr ctxt ts; |
59154 | 441 |
val compile = |
442 |
Code_Runtime.dynamic_value_strict |
|
443 |
(get_counterexample, put_counterexample, "Random_Generators.put_counterexample") |
|
444 |
ctxt (SOME target) |
|
445 |
(fn proc => fn g => fn c => fn b => fn s => |
|
446 |
g c b s #>> (Option.map o apsnd o map) proc) |
|
447 |
t' []; |
|
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
448 |
fun single_tester c b s = compile c b s |> Random_Engine.run |
50046 | 449 |
fun iterate _ _ 0 = NONE |
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
450 |
| iterate genuine_only (card, size) j = |
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
451 |
case single_tester card genuine_only size of |
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
452 |
NONE => iterate genuine_only (card, size) (j - 1) |
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
453 |
| SOME q => SOME q |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
454 |
in |
45754
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
455 |
fn genuine_only => fn [card, size] => |
394ecd91434a
dynamic genuine_flag in compilation of random and exhaustive
bulwahn
parents:
45728
diff
changeset
|
456 |
(rpair NONE (iterate genuine_only (card, size) iterations)) |
40911
7febf76e0a69
moving iteration of tests to the testers in quickcheck
bulwahn
parents:
40644
diff
changeset
|
457 |
end |
35378
95d0e3adf38e
added basic reporting of test cases to quickcheck
bulwahn
parents:
35166
diff
changeset
|
458 |
end; |
31950 | 459 |
|
51143
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
460 |
fun compile_generator_expr ctxt ts = |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
461 |
let |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
462 |
val compiled = compile_generator_expr_raw ctxt ts |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
463 |
in fn genuine_only => fn [card, size] => |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
464 |
compiled genuine_only [Code_Numeral.natural_of_integer card, 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
|
465 |
end; |
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
haftmann
parents:
51126
diff
changeset
|
466 |
|
50818 | 467 |
val size_types = [@{type_name Enum.finite_1}, @{type_name Enum.finite_2}, |
468 |
@{type_name Enum.finite_3}, @{type_name Enum.finite_4}, @{type_name Enum.finite_5}]; |
|
469 |
||
470 |
fun size_matters_for _ Ts = |
|
471 |
not (forall (fn Type (tyco, []) => member (op =) size_types tyco | _ => false) Ts); |
|
46331
f5598b604a54
generalizing check if size matters because it is different for random and exhaustive testing
bulwahn
parents:
45940
diff
changeset
|
472 |
|
f5598b604a54
generalizing check if size matters because it is different for random and exhaustive testing
bulwahn
parents:
45940
diff
changeset
|
473 |
val test_goals = |
f5598b604a54
generalizing check if size matters because it is different for random and exhaustive testing
bulwahn
parents:
45940
diff
changeset
|
474 |
Quickcheck_Common.generator_test_goal_terms ("random", (size_matters_for, compile_generator_expr)); |
43875
485d2ad43528
adding random, exhaustive and SML quickcheck as testers
bulwahn
parents:
43333
diff
changeset
|
475 |
|
31260 | 476 |
(** setup **) |
477 |
||
43878
eeb10fdd9535
changed every tester to have a configuration in quickcheck; enabling parallel testing of different testers in quickcheck
bulwahn
parents:
43877
diff
changeset
|
478 |
val active = Attrib.setup_config_bool @{binding quickcheck_random_active} (K false); |
eeb10fdd9535
changed every tester to have a configuration in quickcheck; enabling parallel testing of different testers in quickcheck
bulwahn
parents:
43877
diff
changeset
|
479 |
|
58826 | 480 |
val _ = |
481 |
Theory.setup |
|
482 |
(Quickcheck_Common.datatype_interpretation @{plugin quickcheck_random} |
|
483 |
(@{sort random}, instantiate_random_datatype) #> |
|
484 |
Context.theory_map (Quickcheck.add_tester ("random", (active, test_goals)))); |
|
31260 | 485 |
|
486 |
end; |