10 val take_random : int -> 'a list -> 'a list |
10 val take_random : int -> 'a list -> 'a list |
11 |
11 |
12 datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error |
12 datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error |
13 type timing = (string * int) list |
13 type timing = (string * int) list |
14 |
14 |
15 type mtd = string * (theory -> term -> outcome * timing) |
15 type mtd = string * (theory -> term -> outcome * (timing * (int * Quickcheck.report list) list option)) |
16 |
16 |
17 type mutant_subentry = term * (string * (outcome * timing)) list |
17 type mutant_subentry = term * (string * (outcome * (timing * Quickcheck.report option))) list |
18 type detailed_entry = string * bool * term * mutant_subentry list |
18 type detailed_entry = string * bool * term * mutant_subentry list |
19 |
19 |
20 type subentry = string * int * int * int * int * int * int |
20 type subentry = string * int * int * int * int * int * int |
21 type entry = string * bool * subentry list |
21 type entry = string * bool * subentry list |
22 type report = entry list |
22 type report = entry list |
77 else l + Real.floor (rmod (random ()) (real (h - l + 1))); |
77 else l + Real.floor (rmod (random ()) (real (h - l + 1))); |
78 |
78 |
79 datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error |
79 datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error |
80 type timing = (string * int) list |
80 type timing = (string * int) list |
81 |
81 |
82 type mtd = string * (theory -> term -> outcome * timing) |
82 type mtd = string * (theory -> term -> outcome * (timing * (int * Quickcheck.report list) list option)) |
83 |
83 |
84 type mutant_subentry = term * (string * (outcome * timing)) list |
84 type mutant_subentry = term * (string * (outcome * (timing * Quickcheck.report option))) list |
85 type detailed_entry = string * bool * term * mutant_subentry list |
85 type detailed_entry = string * bool * term * mutant_subentry list |
86 |
86 |
87 type subentry = string * int * int * int * int * int * int |
87 type subentry = string * int * int * int * int * int * int |
88 type entry = string * bool * subentry list |
88 type entry = string * bool * subentry list |
89 type report = entry list |
89 type report = entry list |
95 (map_types (inst_type insts) (Mutabelle.freeze t)); |
95 (map_types (inst_type insts) (Mutabelle.freeze t)); |
96 |
96 |
97 fun invoke_quickcheck quickcheck_generator thy t = |
97 fun invoke_quickcheck quickcheck_generator thy t = |
98 TimeLimit.timeLimit (Time.fromSeconds (! Auto_Counterexample.time_limit)) |
98 TimeLimit.timeLimit (Time.fromSeconds (! Auto_Counterexample.time_limit)) |
99 (fn _ => |
99 (fn _ => |
100 case Quickcheck.timed_test_term (ProofContext.init thy) false (SOME quickcheck_generator) |
100 case Quickcheck.gen_test_term (ProofContext.init thy) true true (SOME quickcheck_generator) |
101 size iterations (preprocess thy [] t) of |
101 size iterations (preprocess thy [] t) of |
102 (NONE, time_report) => (NoCex, time_report) |
102 (NONE, (time_report, report)) => (NoCex, (time_report, report)) |
103 | (SOME _, time_report) => (GenuineCex, time_report)) () |
103 | (SOME _, (time_report, report)) => (GenuineCex, (time_report, report))) () |
104 handle TimeLimit.TimeOut => (Timeout, [("timelimit", !Auto_Counterexample.time_limit)]) |
104 handle TimeLimit.TimeOut => (Timeout, ([("timelimit", !Auto_Counterexample.time_limit)], NONE)) |
105 |
105 |
106 fun quickcheck_mtd quickcheck_generator = |
106 fun quickcheck_mtd quickcheck_generator = |
107 ("quickcheck_" ^ quickcheck_generator, invoke_quickcheck quickcheck_generator) |
107 ("quickcheck_" ^ quickcheck_generator, invoke_quickcheck quickcheck_generator) |
108 |
108 |
109 (* |
109 (* |
256 in (Exn.release result, (description, time)) end |
256 in (Exn.release result, (description, time)) end |
257 |
257 |
258 fun safe_invoke_mtd thy (mtd_name, invoke_mtd) t = |
258 fun safe_invoke_mtd thy (mtd_name, invoke_mtd) t = |
259 let |
259 let |
260 val _ = priority ("Invoking " ^ mtd_name) |
260 val _ = priority ("Invoking " ^ mtd_name) |
261 val ((res, timing), time) = cpu_time "total time" |
261 val ((res, (timing, reports)), time) = cpu_time "total time" |
262 (fn () => case try (invoke_mtd thy) t of |
262 (fn () => case try (invoke_mtd thy) t of |
263 SOME (res, timing) => (res, timing) |
263 SOME (res, (timing, reports)) => (res, (timing, reports)) |
264 | NONE => (priority ("**** PROBLEMS WITH " ^ Syntax.string_of_term_global thy t); |
264 | NONE => (priority ("**** PROBLEMS WITH " ^ Syntax.string_of_term_global thy t); |
265 (Error , []))) |
265 (Error , ([], NONE)))) |
266 val _ = priority (" Done") |
266 val _ = priority (" Done") |
267 in (res, time :: timing) end |
267 in (res, (time :: timing, reports)) end |
268 |
268 |
269 (* theory -> term list -> mtd -> subentry *) |
269 (* theory -> term list -> mtd -> subentry *) |
270 (* |
270 (* |
271 fun test_mutants_using_one_method thy mutants (mtd_name, invoke_mtd) = |
271 fun test_mutants_using_one_method thy mutants (mtd_name, invoke_mtd) = |
272 let |
272 let |
339 space_implode "; " |
339 space_implode "; " |
340 (map (fn (mtd_name, (outcome, timing)) => mtd_name ^ ": " ^ string_of_outcome outcome) results) ^ |
340 (map (fn (mtd_name, (outcome, timing)) => mtd_name ^ ": " ^ string_of_outcome outcome) results) ^ |
341 "\n" |
341 "\n" |
342 |
342 |
343 fun string_of_mutant_subentry' thy thm_name (t, results) = |
343 fun string_of_mutant_subentry' thy thm_name (t, results) = |
344 "mutant of " ^ thm_name ^ ":" ^ |
344 let |
345 cat_lines (map (fn (mtd_name, (outcome, timing)) => |
345 fun string_of_report (Quickcheck.Report {iterations = i, raised_match_errors = e, |
|
346 satisfied_assms = s, positive_concl_tests = p}) = |
|
347 "errors: " ^ string_of_int e ^ "; conclusion tests: " ^ string_of_int p |
|
348 fun string_of_reports NONE = "" |
|
349 | string_of_reports (SOME reports) = |
|
350 cat_lines (map (fn (size, [report]) => |
|
351 "size " ^ string_of_int size ^ ": " ^ string_of_report report) (rev reports)) |
|
352 fun string_of_mtd_result (mtd_name, (outcome, (timing, reports))) = |
346 mtd_name ^ ": " ^ string_of_outcome outcome ^ "; " ^ |
353 mtd_name ^ ": " ^ string_of_outcome outcome ^ "; " ^ |
347 space_implode "; " (map (fn (s, t) => (s ^ ": " ^ string_of_int t)) timing)) results) |
354 space_implode "; " (map (fn (s, t) => (s ^ ": " ^ string_of_int t)) timing) |
|
355 ^ "\n" ^ string_of_reports reports |
|
356 in |
|
357 "mutant of " ^ thm_name ^ ":\n" ^ cat_lines (map string_of_mtd_result results) |
|
358 end |
348 |
359 |
349 fun string_of_detailed_entry thy (thm_name, exec, t, mutant_subentries) = |
360 fun string_of_detailed_entry thy (thm_name, exec, t, mutant_subentries) = |
350 thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ": " ^ |
361 thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ": " ^ |
351 Syntax.string_of_term_global thy t ^ "\n" ^ |
362 Syntax.string_of_term_global thy t ^ "\n" ^ |
352 cat_lines (map (string_of_mutant_subentry' thy thm_name) mutant_subentries) ^ "\n" |
363 cat_lines (map (string_of_mutant_subentry' thy thm_name) mutant_subentries) ^ "\n" |