author | bulwahn |
Fri, 10 Dec 2010 14:10:35 +0100 | |
changeset 41106 | 09037a02f5ec |
parent 40974 | 29e5cae93584 |
child 41190 | 0bdc6fac5f48 |
permissions | -rw-r--r-- |
37744 | 1 |
(* Title: HOL/Mutabelle/mutabelle_extra.ML |
34965 | 2 |
Author: Stefan Berghofer, Jasmin Blanchette, Lukas Bulwahn, TU Muenchen |
3 |
||
4 |
Invokation of Counterexample generators |
|
5 |
*) |
|
6 |
signature MUTABELLE_EXTRA = |
|
7 |
sig |
|
8 |
||
9 |
val take_random : int -> 'a list -> 'a list |
|
10 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
11 |
datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error | Solved | Unsolved |
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:
35092
diff
changeset
|
12 |
type timing = (string * int) list |
34965 | 13 |
|
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
14 |
type mtd = string * (theory -> term -> outcome * (timing * (int * Quickcheck.report list) list option)) |
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:
35092
diff
changeset
|
15 |
|
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
16 |
type mutant_subentry = term * (string * (outcome * (timing * Quickcheck.report option))) list |
34965 | 17 |
type detailed_entry = string * bool * term * mutant_subentry list |
18 |
||
19 |
type subentry = string * int * int * int * int * int * int |
|
20 |
type entry = string * bool * subentry list |
|
21 |
type report = entry list |
|
22 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
23 |
val quickcheck_mtd : (Proof.context -> Proof.context) -> string -> mtd |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
24 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
25 |
val solve_direct_mtd : mtd |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
26 |
val try_mtd : mtd |
40974 | 27 |
(* |
40971
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
28 |
val sledgehammer_mtd : mtd |
40974 | 29 |
*) |
34965 | 30 |
(* |
31 |
val refute_mtd : mtd |
|
32 |
val nitpick_mtd : mtd |
|
33 |
*) |
|
34 |
||
35 |
val freezeT : term -> term |
|
36 |
val thms_of : bool -> theory -> thm list |
|
37 |
||
38 |
val string_for_report : report -> string |
|
39 |
val write_report : string -> report -> unit |
|
40 |
val mutate_theorems_and_write_report : |
|
41 |
theory -> mtd list -> thm list -> string -> unit |
|
42 |
||
43 |
val random_seed : real Unsynchronized.ref |
|
44 |
end; |
|
45 |
||
46 |
structure MutabelleExtra : MUTABELLE_EXTRA = |
|
47 |
struct |
|
48 |
||
49 |
(* Own seed; can't rely on the Isabelle one to stay the same *) |
|
50 |
val random_seed = Unsynchronized.ref 1.0; |
|
51 |
||
52 |
||
53 |
(* mutation options *) |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
54 |
(*val max_mutants = 4 |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
55 |
val num_mutations = 1*) |
34965 | 56 |
(* soundness check: *) |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
57 |
val max_mutants = 10 |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
58 |
val num_mutations = 1 |
34965 | 59 |
|
60 |
(* quickcheck options *) |
|
61 |
(*val quickcheck_generator = "SML"*) |
|
62 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
63 |
(* Another Random engine *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
64 |
|
34965 | 65 |
exception RANDOM; |
66 |
||
67 |
fun rmod x y = x - y * Real.realFloor (x / y); |
|
68 |
||
69 |
local |
|
70 |
val a = 16807.0; |
|
71 |
val m = 2147483647.0; |
|
72 |
in |
|
73 |
||
74 |
fun random () = CRITICAL (fn () => |
|
75 |
let val r = rmod (a * ! random_seed) m |
|
76 |
in (random_seed := r; r) end); |
|
77 |
||
78 |
end; |
|
79 |
||
80 |
fun random_range l h = |
|
81 |
if h < l orelse l < 0 then raise RANDOM |
|
82 |
else l + Real.floor (rmod (random ()) (real (h - l + 1))); |
|
83 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
84 |
fun take_random 0 _ = [] |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
85 |
| take_random _ [] = [] |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
86 |
| take_random n xs = |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
87 |
let val j = random_range 0 (length xs - 1) in |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
88 |
Library.nth xs j :: take_random (n - 1) (nth_drop j xs) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
89 |
end |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
90 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
91 |
(* possible outcomes *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
92 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
93 |
datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error | Solved | Unsolved |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
94 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
95 |
fun string_of_outcome GenuineCex = "GenuineCex" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
96 |
| string_of_outcome PotentialCex = "PotentialCex" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
97 |
| string_of_outcome NoCex = "NoCex" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
98 |
| string_of_outcome Donno = "Donno" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
99 |
| string_of_outcome Timeout = "Timeout" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
100 |
| string_of_outcome Error = "Error" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
101 |
| string_of_outcome Solved = "Solved" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
102 |
| string_of_outcome Unsolved = "Unsolved" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
103 |
|
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:
35092
diff
changeset
|
104 |
type timing = (string * int) list |
34965 | 105 |
|
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
106 |
type mtd = string * (theory -> term -> outcome * (timing * (int * Quickcheck.report list) list option)) |
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:
35092
diff
changeset
|
107 |
|
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
108 |
type mutant_subentry = term * (string * (outcome * (timing * Quickcheck.report option))) list |
34965 | 109 |
type detailed_entry = string * bool * term * mutant_subentry list |
110 |
||
111 |
type subentry = string * int * int * int * int * int * int |
|
112 |
type entry = string * bool * subentry list |
|
113 |
type report = entry list |
|
114 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
115 |
(* possible invocations *) |
34965 | 116 |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
117 |
(** quickcheck **) |
34965 | 118 |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
119 |
fun invoke_quickcheck change_options quickcheck_generator thy t = |
40931 | 120 |
TimeLimit.timeLimit (seconds (!Auto_Tools.time_limit)) |
34965 | 121 |
(fn _ => |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
122 |
case Quickcheck.test_goal_terms (change_options (ProofContext.init_global thy)) |
40920 | 123 |
false [] [t] of |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
124 |
(NONE, _) => (NoCex, ([], NONE)) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
125 |
| (SOME _, _) => (GenuineCex, ([], NONE))) () |
40931 | 126 |
handle TimeLimit.TimeOut => |
40932 | 127 |
(Timeout, ([("timelimit", Real.floor (!Auto_Tools.time_limit))], NONE)) |
34965 | 128 |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
129 |
fun quickcheck_mtd change_options quickcheck_generator = |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
130 |
("quickcheck_" ^ quickcheck_generator, invoke_quickcheck change_options quickcheck_generator) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
131 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
132 |
(** solve direct **) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
133 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
134 |
fun invoke_solve_direct thy t = |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
135 |
let |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
136 |
val state = Proof.theorem NONE (K I) (map (single o rpair []) [t]) (ProofContext.init_global thy) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
137 |
in |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
138 |
case Solve_Direct.solve_direct false state of |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
139 |
(true, _) => (Solved, ([], NONE)) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
140 |
| (false, _) => (Unsolved, ([], NONE)) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
141 |
end |
34965 | 142 |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
143 |
val solve_direct_mtd = ("solve_direct", invoke_solve_direct) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
144 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
145 |
(** try **) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
146 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
147 |
fun invoke_try thy t = |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
148 |
let |
40971
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
149 |
val state = Proof.theorem NONE (K I) (map (single o rpair []) [t]) (ProofContext.init_global thy) |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
150 |
in |
40972 | 151 |
case Try.invoke_try (SOME (seconds 5.0)) state of |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
152 |
true => (Solved, ([], NONE)) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
153 |
| false => (Unsolved, ([], NONE)) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
154 |
end |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
155 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
156 |
val try_mtd = ("try", invoke_try) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
157 |
|
40971
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
158 |
(** sledgehammer **) |
40974 | 159 |
(* |
40971
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
160 |
fun invoke_sledgehammer thy t = |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
161 |
if can (Goal.prove_global thy (Term.add_free_names t []) [] t) |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
162 |
(fn {context, ...} => Sledgehammer_Tactics.sledgehammer_with_metis_tac context 1) then |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
163 |
(Solved, ([], NONE)) |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
164 |
else |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
165 |
(Unsolved, ([], NONE)) |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
166 |
|
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
167 |
val sledgehammer_mtd = ("sledgehammer", invoke_sledgehammer) |
40974 | 168 |
*) |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
169 |
(* |
34965 | 170 |
fun invoke_refute thy t = |
171 |
let |
|
172 |
val res = MyRefute.refute_term thy [] t |
|
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
173 |
val _ = Output.urgent_message ("Refute: " ^ res) |
34965 | 174 |
in |
175 |
case res of |
|
176 |
"genuine" => GenuineCex |
|
177 |
| "likely_genuine" => GenuineCex |
|
178 |
| "potential" => PotentialCex |
|
179 |
| "none" => NoCex |
|
180 |
| "unknown" => Donno |
|
181 |
| _ => Error |
|
182 |
end |
|
183 |
handle MyRefute.REFUTE (loc, details) => |
|
184 |
(error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^ |
|
185 |
".")) |
|
186 |
val refute_mtd = ("refute", invoke_refute) |
|
187 |
*) |
|
188 |
||
189 |
(* |
|
190 |
open Nitpick_Util |
|
191 |
open Nitpick_Rep |
|
192 |
open Nitpick_Nut |
|
193 |
||
194 |
fun invoke_nitpick thy t = |
|
195 |
let |
|
36610
bafd82950e24
renamed ProofContext.init to ProofContext.init_global to emphasize that this is not the real thing;
wenzelm
parents:
36255
diff
changeset
|
196 |
val ctxt = ProofContext.init_global thy |
34965 | 197 |
val state = Proof.init ctxt |
198 |
in |
|
199 |
let |
|
200 |
val (res, _) = Nitpick.pick_nits_in_term state (Nitpick_Isar.default_params thy []) false [] t |
|
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
201 |
val _ = Output.urgent_message ("Nitpick: " ^ res) |
34965 | 202 |
in |
203 |
case res of |
|
204 |
"genuine" => GenuineCex |
|
205 |
| "likely_genuine" => GenuineCex |
|
206 |
| "potential" => PotentialCex |
|
207 |
| "none" => NoCex |
|
208 |
| "unknown" => Donno |
|
209 |
| _ => Error |
|
210 |
end |
|
211 |
handle ARG (loc, details) => |
|
212 |
(error ("Bad argument(s) to " ^ quote loc ^ ": " ^ details ^ ".")) |
|
213 |
| BAD (loc, details) => |
|
214 |
(error ("Internal error (" ^ quote loc ^ "): " ^ details ^ ".")) |
|
215 |
| LIMIT (_, details) => |
|
216 |
(warning ("Limit reached: " ^ details ^ "."); Donno) |
|
217 |
| NOT_SUPPORTED details => |
|
218 |
(warning ("Unsupported case: " ^ details ^ "."); Donno) |
|
219 |
| NUT (loc, us) => |
|
220 |
(error ("Invalid nut" ^ plural_s_for_list us ^ |
|
221 |
" (" ^ quote loc ^ "): " ^ |
|
222 |
commas (map (string_for_nut ctxt) us) ^ ".")) |
|
223 |
| REP (loc, Rs) => |
|
224 |
(error ("Invalid representation" ^ plural_s_for_list Rs ^ |
|
225 |
" (" ^ quote loc ^ "): " ^ |
|
226 |
commas (map string_for_rep Rs) ^ ".")) |
|
227 |
| TERM (loc, ts) => |
|
228 |
(error ("Invalid term" ^ plural_s_for_list ts ^ |
|
229 |
" (" ^ quote loc ^ "): " ^ |
|
230 |
commas (map (Syntax.string_of_term ctxt) ts) ^ ".")) |
|
231 |
| TYPE (loc, Ts, ts) => |
|
232 |
(error ("Invalid type" ^ plural_s_for_list Ts ^ |
|
233 |
(if null ts then |
|
234 |
"" |
|
235 |
else |
|
236 |
" for term" ^ plural_s_for_list ts ^ " " ^ |
|
237 |
commas (map (quote o Syntax.string_of_term ctxt) ts)) ^ |
|
238 |
" (" ^ quote loc ^ "): " ^ |
|
239 |
commas (map (Syntax.string_of_typ ctxt) Ts) ^ ".")) |
|
240 |
| Kodkod.SYNTAX (_, details) => |
|
241 |
(warning ("Ill-formed Kodkodi output: " ^ details ^ "."); Error) |
|
242 |
| Refute.REFUTE (loc, details) => |
|
243 |
(error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^ |
|
244 |
".")) |
|
40381
96c37a685a13
explicit indication of some remaining violations of the Isabelle/ML interrupt model;
wenzelm
parents:
40301
diff
changeset
|
245 |
| Exn.Interrupt => raise Exn.Interrupt (* FIXME violates Isabelle/ML exception model *) |
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
246 |
| _ => (Output.urgent_message ("Unknown error in Nitpick"); Error) |
34965 | 247 |
end |
248 |
val nitpick_mtd = ("nitpick", invoke_nitpick) |
|
249 |
*) |
|
250 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
251 |
(* filtering forbidden theorems and mutants *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
252 |
|
38864
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
haftmann
parents:
38857
diff
changeset
|
253 |
val comms = [@{const_name HOL.eq}, @{const_name HOL.disj}, @{const_name HOL.conj}] |
34965 | 254 |
|
255 |
val forbidden = |
|
256 |
[(* (@{const_name "power"}, "'a"), *) |
|
35325
4123977b469d
adding ROOT.ML to HOL-Mutabelle session; uncommenting HOL.induct constants in Mutabelle session
bulwahn
parents:
35324
diff
changeset
|
257 |
(*(@{const_name induct_equal}, "'a"), |
4123977b469d
adding ROOT.ML to HOL-Mutabelle session; uncommenting HOL.induct constants in Mutabelle session
bulwahn
parents:
35324
diff
changeset
|
258 |
(@{const_name induct_implies}, "'a"), |
4123977b469d
adding ROOT.ML to HOL-Mutabelle session; uncommenting HOL.induct constants in Mutabelle session
bulwahn
parents:
35324
diff
changeset
|
259 |
(@{const_name induct_conj}, "'a"),*) |
34965 | 260 |
(@{const_name "undefined"}, "'a"), |
261 |
(@{const_name "default"}, "'a"), |
|
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
262 |
(@{const_name "dummy_pattern"}, "'a::{}"), |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
263 |
(@{const_name "HOL.simp_implies"}, "prop => prop => prop"), |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
264 |
(@{const_name "bot_fun_inst.bot_fun"}, "'a"), |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
265 |
(@{const_name "top_fun_inst.top_fun"}, "'a"), |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
266 |
(@{const_name "Pure.term"}, "'a"), |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
267 |
(@{const_name "top_class.top"}, "'a"), |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
268 |
(@{const_name "Quotient.Quot_True"}, "'a")(*, |
34965 | 269 |
(@{const_name "uminus"}, "'a"), |
270 |
(@{const_name "Nat.size"}, "'a"), |
|
35092
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
haftmann
parents:
34974
diff
changeset
|
271 |
(@{const_name "Groups.abs"}, "'a") *)] |
34965 | 272 |
|
273 |
val forbidden_thms = |
|
274 |
["finite_intvl_succ_class", |
|
275 |
"nibble"] |
|
276 |
||
277 |
val forbidden_consts = |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
278 |
[@{const_name nibble_pair_of_char}, @{const_name "TYPE"}] |
34965 | 279 |
|
280 |
fun is_forbidden_theorem (s, th) = |
|
281 |
let val consts = Term.add_const_names (prop_of th) [] in |
|
36692
54b64d4ad524
farewell to old-style mem infixes -- type inference in situations with mem_int and mem_string should provide enough information to resolve the type of (op =)
haftmann
parents:
36610
diff
changeset
|
282 |
exists (member (op =) (space_explode "." s)) forbidden_thms orelse |
54b64d4ad524
farewell to old-style mem infixes -- type inference in situations with mem_int and mem_string should provide enough information to resolve the type of (op =)
haftmann
parents:
36610
diff
changeset
|
283 |
exists (member (op =) forbidden_consts) consts orelse |
34965 | 284 |
length (space_explode "." s) <> 2 orelse |
285 |
String.isPrefix "type_definition" (List.last (space_explode "." s)) orelse |
|
286 |
String.isSuffix "_def" s orelse |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
287 |
String.isSuffix "_raw" s orelse |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
288 |
String.isPrefix "term_of" (List.last (space_explode "." s)) |
34965 | 289 |
end |
290 |
||
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
291 |
val forbidden_mutant_constnames = |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
292 |
["HOL.induct_equal", |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
293 |
"HOL.induct_implies", |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
294 |
"HOL.induct_conj", |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
295 |
@{const_name undefined}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
296 |
@{const_name default}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
297 |
@{const_name dummy_pattern}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
298 |
@{const_name "HOL.simp_implies"}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
299 |
@{const_name "bot_fun_inst.bot_fun"}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
300 |
@{const_name "top_fun_inst.top_fun"}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
301 |
@{const_name "Pure.term"}, |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
302 |
@{const_name "top_class.top"}, |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
303 |
(*@{const_name "HOL.equal"},*) |
40971
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
304 |
@{const_name "Quotient.Quot_True"}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
305 |
@{const_name "equal_fun_inst.equal_fun"}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
306 |
@{const_name "equal_bool_inst.equal_bool"}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
307 |
@{const_name "ord_fun_inst.less_eq_fun"}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
308 |
@{const_name "ord_fun_inst.less_fun"}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
309 |
@{const_name Metis.fequal}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
310 |
@{const_name Meson.skolem}, |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
311 |
@{const_name transfer_morphism} |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
312 |
(*@{const_name "==>"}, @{const_name "=="}*)] |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
313 |
|
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
314 |
val forbidden_mutant_consts = |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
315 |
[ |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
316 |
(@{const_name "Groups.zero_class.zero"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
317 |
(@{const_name "Groups.one_class.one"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
318 |
(@{const_name "Groups.plus_class.plus"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
319 |
(@{const_name "Groups.minus_class.minus"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
320 |
(@{const_name "Groups.times_class.times"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
321 |
(@{const_name "Rings.inverse_class.divide"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
322 |
(@{const_name "Lattices.semilattice_inf_class.inf"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
323 |
(@{const_name "Lattices.semilattice_sup_class.sup"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
324 |
(@{const_name "Orderings.bot_class.bot"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
325 |
(@{const_name "Orderings.ord_class.min"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
326 |
(@{const_name "Orderings.ord_class.max"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
327 |
(@{const_name "Divides.div_class.mod"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
328 |
(@{const_name "Divides.div_class.div"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
329 |
(@{const_name "GCD.gcd_class.gcd"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
330 |
(@{const_name "GCD.gcd_class.lcm"}, @{typ "prop => prop => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
331 |
(@{const_name "Orderings.bot_class.bot"}, @{typ "bool => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
332 |
(@{const_name "Groups.one_class.one"}, @{typ "bool => prop"}), |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
333 |
(@{const_name "Groups.zero_class.zero"},@{typ "bool => prop"})] |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
334 |
|
34965 | 335 |
fun is_forbidden_mutant t = |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
336 |
let |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
337 |
val const_names = Term.add_const_names t [] |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
338 |
val consts = Term.add_consts t [] |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
339 |
in |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
340 |
exists (String.isPrefix "Nitpick") const_names orelse |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
341 |
exists (String.isSubstring "_sumC") const_names orelse |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
342 |
exists (member (op =) forbidden_mutant_constnames) const_names orelse |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
343 |
exists (member (op =) forbidden_mutant_consts) consts |
34965 | 344 |
end |
345 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
346 |
(* executable via quickcheck *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
347 |
|
40248 | 348 |
fun is_executable_term thy t = |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
349 |
let |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
350 |
val ctxt = ProofContext.init_global thy |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
351 |
in |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
352 |
can (TimeLimit.timeLimit (seconds 2.0) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
353 |
(Quickcheck.test_goal_terms |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
354 |
((Config.put Quickcheck.finite_types true #> |
41106 | 355 |
Config.put Quickcheck.finite_type_size 1 #> |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
356 |
Config.put Quickcheck.size 1 #> Config.put Quickcheck.iterations 1) ctxt) |
40920 | 357 |
false [])) (map (Object_Logic.atomize_term thy) (fst (Variable.import_terms true [t] ctxt))) |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
358 |
end |
40248 | 359 |
|
34965 | 360 |
fun is_executable_thm thy th = is_executable_term thy (prop_of th) |
361 |
||
362 |
val freezeT = |
|
363 |
map_types (map_type_tvar (fn ((a, i), S) => |
|
364 |
TFree (if i = 0 then a else a ^ "_" ^ string_of_int i, S))) |
|
365 |
||
366 |
fun thms_of all thy = |
|
367 |
filter |
|
368 |
(fn th => (all orelse Context.theory_name (theory_of_thm th) = Context.theory_name thy) |
|
369 |
(* andalso is_executable_thm thy th *)) |
|
370 |
(map snd (filter_out is_forbidden_theorem (Mutabelle.all_unconcealed_thms_of thy))) |
|
371 |
||
372 |
val count = length oo filter o equal |
|
373 |
||
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:
35092
diff
changeset
|
374 |
fun cpu_time description f = |
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:
35092
diff
changeset
|
375 |
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:
35092
diff
changeset
|
376 |
val start = start_timing () |
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:
35092
diff
changeset
|
377 |
val result = Exn.capture f () |
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:
35092
diff
changeset
|
378 |
val time = Time.toMilliseconds (#cpu (end_timing start)) |
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:
35092
diff
changeset
|
379 |
in (Exn.release result, (description, time)) end |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
380 |
(* |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
381 |
fun unsafe_invoke_mtd thy (mtd_name, invoke_mtd) t = |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
382 |
let |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
383 |
val _ = Output.urgent_message ("Invoking " ^ mtd_name) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
384 |
val ((res, (timing, reports)), time) = cpu_time "total time" (fn () => invoke_mtd thy t |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
385 |
handle ERROR s => (tracing s; (Error, ([], NONE)))) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
386 |
val _ = Output.urgent_message (" Done") |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
387 |
in (res, (time :: timing, reports)) end |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
388 |
*) |
34965 | 389 |
fun safe_invoke_mtd thy (mtd_name, invoke_mtd) t = |
390 |
let |
|
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
391 |
val _ = Output.urgent_message ("Invoking " ^ mtd_name) |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
392 |
val (res, (timing, reports)) = (*cpu_time "total time" |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
393 |
(fn () => *)case try (invoke_mtd thy) t of |
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
394 |
SOME (res, (timing, reports)) => (res, (timing, reports)) |
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
395 |
| NONE => (Output.urgent_message ("**** PROBLEMS WITH " ^ Syntax.string_of_term_global thy t); |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
396 |
(Error, ([], NONE))) |
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
397 |
val _ = Output.urgent_message (" Done") |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
398 |
in (res, (timing, reports)) end |
34965 | 399 |
|
400 |
(* theory -> term list -> mtd -> subentry *) |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
401 |
|
34965 | 402 |
fun test_mutants_using_one_method thy mutants (mtd_name, invoke_mtd) = |
403 |
let |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
404 |
val res = map (fst o safe_invoke_mtd thy (mtd_name, invoke_mtd)) mutants |
34965 | 405 |
in |
406 |
(mtd_name, count GenuineCex res, count PotentialCex res, count NoCex res, |
|
407 |
count Donno res, count Timeout res, count Error res) |
|
408 |
end |
|
409 |
||
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
410 |
(* creating entries *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
411 |
|
34965 | 412 |
fun create_entry thy thm exec mutants mtds = |
36743
ce2297415b54
prefer Thm.get_name_hint, which is closer to a user-space idea of "theorem name";
wenzelm
parents:
36692
diff
changeset
|
413 |
(Thm.get_name_hint thm, exec, map (test_mutants_using_one_method thy mutants) mtds) |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
414 |
|
34965 | 415 |
fun create_detailed_entry thy thm exec mutants mtds = |
416 |
let |
|
417 |
fun create_mutant_subentry mutant = (mutant, |
|
418 |
map (fn (mtd_name, invoke_mtd) => |
|
419 |
(mtd_name, safe_invoke_mtd thy (mtd_name, invoke_mtd) mutant)) mtds) |
|
420 |
in |
|
36743
ce2297415b54
prefer Thm.get_name_hint, which is closer to a user-space idea of "theorem name";
wenzelm
parents:
36692
diff
changeset
|
421 |
(Thm.get_name_hint thm, exec, prop_of thm, map create_mutant_subentry mutants) |
34965 | 422 |
end |
423 |
||
424 |
(* (theory -> thm -> bool -> term list -> mtd list -> 'a) -> theory -> mtd list -> thm -> 'a *) |
|
425 |
fun mutate_theorem create_entry thy mtds thm = |
|
426 |
let |
|
427 |
val exec = is_executable_thm thy thm |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
428 |
val _ = Output.tracing (if exec then "EXEC" else "NOEXEC") |
34965 | 429 |
val mutants = |
430 |
(if num_mutations = 0 then |
|
431 |
[Thm.prop_of thm] |
|
432 |
else |
|
433 |
Mutabelle.mutate_mix (Thm.prop_of thm) thy comms forbidden |
|
434 |
num_mutations) |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
435 |
|> tap (fn muts => tracing ("mutants: " ^ string_of_int (length muts))) |
34965 | 436 |
|> filter_out is_forbidden_mutant |
437 |
val mutants = |
|
438 |
if exec then |
|
439 |
let |
|
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
440 |
val _ = Output.urgent_message ("BEFORE PARTITION OF " ^ |
34965 | 441 |
Int.toString (length mutants) ^ " MUTANTS") |
442 |
val (execs, noexecs) = List.partition (is_executable_term thy) (take_random (20 * max_mutants) mutants) |
|
443 |
val _ = tracing ("AFTER PARTITION (" ^ Int.toString (length execs) ^ |
|
444 |
" vs " ^ Int.toString (length noexecs) ^ ")") |
|
445 |
in |
|
446 |
execs @ take_random (Int.max (0, max_mutants - length execs)) noexecs |
|
447 |
end |
|
448 |
else |
|
449 |
mutants |
|
450 |
val mutants = mutants |
|
451 |
|> map Mutabelle.freeze |> map freezeT |
|
452 |
(* |> filter (not o is_forbidden_mutant) *) |
|
453 |
|> List.mapPartial (try (Sign.cert_term thy)) |
|
40971
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
454 |
|> List.filter (is_some o try (Thm.cterm_of thy)) |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
455 |
|> List.filter (is_some o try (Syntax.check_term (ProofContext.init_global thy))) |
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents:
40932
diff
changeset
|
456 |
|> take_random max_mutants |
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
457 |
val _ = map (fn t => Output.urgent_message ("MUTANT: " ^ Syntax.string_of_term_global thy t)) mutants |
34965 | 458 |
in |
459 |
create_entry thy thm exec mutants mtds |
|
460 |
end |
|
461 |
||
462 |
(* theory -> mtd list -> thm list -> report *) |
|
463 |
val mutate_theorems = map ooo mutate_theorem |
|
464 |
||
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:
35092
diff
changeset
|
465 |
fun string_of_mutant_subentry thy thm_name (t, results) = |
34965 | 466 |
"mutant: " ^ Syntax.string_of_term_global thy t ^ "\n" ^ |
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:
35092
diff
changeset
|
467 |
space_implode "; " |
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:
35092
diff
changeset
|
468 |
(map (fn (mtd_name, (outcome, timing)) => mtd_name ^ ": " ^ string_of_outcome outcome) results) ^ |
34965 | 469 |
"\n" |
470 |
||
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
471 |
(* string -> string *) |
39555
ccb223a4d49c
added XML.content_of convenience -- cover XML.body, which is the general situation;
wenzelm
parents:
39324
diff
changeset
|
472 |
val unyxml = XML.content_of o YXML.parse_body |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
473 |
|
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:
35092
diff
changeset
|
474 |
fun string_of_mutant_subentry' thy thm_name (t, results) = |
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
475 |
let |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
476 |
fun string_of_report (Quickcheck.Report {iterations = i, raised_match_errors = e, |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
477 |
satisfied_assms = s, positive_concl_tests = p}) = |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
478 |
"errors: " ^ string_of_int e ^ "; conclusion tests: " ^ string_of_int p |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
479 |
fun string_of_reports NONE = "" |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
480 |
| string_of_reports (SOME reports) = |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
481 |
cat_lines (map (fn (size, [report]) => |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
482 |
"size " ^ string_of_int size ^ ": " ^ string_of_report report) (rev reports)) |
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
483 |
fun string_of_mtd_result (mtd_name, (outcome, (timing, reports))) = |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
484 |
mtd_name ^ ": " ^ string_of_outcome outcome |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
485 |
(*" with time " ^ " (" ^ space_implode "; " (map (fn (s, t) => (s ^ ": " ^ string_of_int t)) timing) ^ ")"*) |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
486 |
(*^ "\n" ^ string_of_reports reports*) |
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
487 |
in |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
488 |
"mutant of " ^ thm_name ^ ":\n" |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
489 |
^ unyxml (Syntax.string_of_term_global thy t) ^ "\n" ^ space_implode "; " (map string_of_mtd_result results) |
35380
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents:
35325
diff
changeset
|
490 |
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:
35092
diff
changeset
|
491 |
|
34965 | 492 |
fun string_of_detailed_entry thy (thm_name, exec, t, mutant_subentries) = |
493 |
thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ": " ^ |
|
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
494 |
Syntax.string_of_term_global thy t ^ "\n" ^ |
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:
35092
diff
changeset
|
495 |
cat_lines (map (string_of_mutant_subentry' thy thm_name) mutant_subentries) ^ "\n" |
34965 | 496 |
|
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
497 |
fun theoryfile_string_of_mutant_subentry thy thm_name (i, (t, results)) = |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
498 |
"lemma " ^ thm_name ^ "_" ^ string_of_int (i + 1) ^ ":\n" ^ |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
499 |
"\"" ^ unyxml (Syntax.string_of_term_global thy t) ^ |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
500 |
"\" \nquickcheck\noops\n" |
36255
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
501 |
|
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
502 |
fun theoryfile_string_of_detailed_entry thy (thm_name, exec, t, mutant_subentries) = |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
503 |
"subsubsection {* mutants of " ^ thm_name ^ " *}\n\n" ^ |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
504 |
cat_lines (map_index |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
505 |
(theoryfile_string_of_mutant_subentry thy thm_name) mutant_subentries) ^ "\n" |
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents:
35625
diff
changeset
|
506 |
|
34965 | 507 |
(* subentry -> string *) |
508 |
fun string_for_subentry (mtd_name, genuine_cex, potential_cex, no_cex, donno, |
|
509 |
timeout, error) = |
|
510 |
" " ^ mtd_name ^ ": " ^ Int.toString genuine_cex ^ "+ " ^ |
|
511 |
Int.toString potential_cex ^ "= " ^ Int.toString no_cex ^ "- " ^ |
|
512 |
Int.toString donno ^ "? " ^ Int.toString timeout ^ "T " ^ |
|
513 |
Int.toString error ^ "!" |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
514 |
|
34965 | 515 |
(* entry -> string *) |
516 |
fun string_for_entry (thm_name, exec, subentries) = |
|
517 |
thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ":\n" ^ |
|
518 |
cat_lines (map string_for_subentry subentries) ^ "\n" |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
519 |
|
34965 | 520 |
(* report -> string *) |
521 |
fun string_for_report report = cat_lines (map string_for_entry report) |
|
522 |
||
523 |
(* string -> report -> unit *) |
|
524 |
fun write_report file_name = |
|
525 |
File.write (Path.explode file_name) o string_for_report |
|
526 |
||
527 |
(* theory -> mtd list -> thm list -> string -> unit *) |
|
528 |
fun mutate_theorems_and_write_report thy mtds thms file_name = |
|
529 |
let |
|
40132
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents:
39555
diff
changeset
|
530 |
val _ = Output.urgent_message "Starting Mutabelle..." |
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
531 |
val ctxt = ProofContext.init_global thy |
34965 | 532 |
val path = Path.explode file_name |
533 |
(* for normal report: *) |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
534 |
(* |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
535 |
val (gen_create_entry, gen_string_for_entry) = (create_entry, string_for_entry) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
536 |
*) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
537 |
(* for detailled report: *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
538 |
val (gen_create_entry, gen_string_for_entry) = (create_detailed_entry, string_of_detailed_entry thy) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
539 |
(* for theory creation: *) |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
540 |
(*val (gen_create_entry, gen_string_for_entry) = (create_detailed_entry, theoryfile_string_of_detailed_entry thy)*) |
34965 | 541 |
in |
542 |
File.write path ( |
|
543 |
"Mutation options = " ^ |
|
544 |
"max_mutants: " ^ string_of_int max_mutants ^ |
|
545 |
"; num_mutations: " ^ string_of_int num_mutations ^ "\n" ^ |
|
546 |
"QC options = " ^ |
|
547 |
(*"quickcheck_generator: " ^ quickcheck_generator ^ ";*) |
|
40653
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
548 |
"size: " ^ string_of_int (Config.get ctxt Quickcheck.size) ^ |
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
bulwahn
parents:
40381
diff
changeset
|
549 |
"; iterations: " ^ string_of_int (Config.get ctxt Quickcheck.iterations) ^ "\n"); |
34965 | 550 |
map (File.append path o gen_string_for_entry o mutate_theorem gen_create_entry thy mtds) thms; |
551 |
() |
|
552 |
end |
|
553 |
||
554 |
end; |