| author | berghofe | 
| Tue, 10 Jan 2012 18:12:03 +0100 | |
| changeset 46176 | 1898e61e89c4 | 
| parent 45428 | aa35c9454a95 | 
| child 46310 | 8af202923906 | 
| permissions | -rw-r--r-- | 
| 37744 | 1 | (* Title: HOL/Mutabelle/mutabelle_extra.ML | 
| 34965 | 2 | Author: Stefan Berghofer, Jasmin Blanchette, Lukas Bulwahn, TU Muenchen | 
| 3 | ||
| 41408 | 4 | Invokation of Counterexample generators. | 
| 34965 | 5 | *) | 
| 41408 | 6 | |
| 34965 | 7 | signature MUTABELLE_EXTRA = | 
| 8 | sig | |
| 9 | ||
| 10 | val take_random : int -> 'a list -> 'a list | |
| 11 | ||
| 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: 
40381diff
changeset | 12 | datatype outcome = GenuineCex | PotentialCex | NoCex | Donno | Timeout | Error | Solved | Unsolved | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 13 | type timings = (string * int) list | 
| 34965 | 14 | |
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 15 | type mtd = string * (theory -> term -> outcome * timings) | 
| 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: 
35092diff
changeset | 16 | |
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 17 | type mutant_subentry = term * (string * (outcome * timings)) list | 
| 34965 | 18 | type detailed_entry = string * bool * term * mutant_subentry list | 
| 19 | ||
| 20 | type subentry = string * int * int * int * int * int * int | |
| 21 | type entry = string * bool * subentry list | |
| 22 | type report = entry list | |
| 23 | ||
| 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: 
40381diff
changeset | 24 | 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: 
40381diff
changeset | 25 | |
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 26 | val solve_direct_mtd : mtd | 
| 43030 | 27 | val try_methods_mtd : mtd | 
| 40974 | 28 | (* | 
| 40971 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 29 | val sledgehammer_mtd : mtd | 
| 40974 | 30 | *) | 
| 41190 | 31 | val nitpick_mtd : mtd | 
| 32 | ||
| 34965 | 33 | val refute_mtd : mtd | 
| 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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
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: 
40381diff
changeset | 103 | |
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 104 | type timings = (string * int) list | 
| 34965 | 105 | |
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 106 | type mtd = string * (theory -> term -> outcome * timings) | 
| 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: 
35092diff
changeset | 107 | |
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 108 | type mutant_subentry = term * (string * (outcome * timings)) 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: 
40381diff
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: 
40381diff
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: 
40381diff
changeset | 119 | fun invoke_quickcheck change_options quickcheck_generator thy t = | 
| 43018 | 120 | TimeLimit.timeLimit (seconds (!Try.auto_time_limit)) | 
| 34965 | 121 | (fn _ => | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 122 | let | 
| 45159 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 123 | val ctxt' = change_options (Proof_Context.init_global thy) | 
| 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 124 | val [result] = case Quickcheck.active_testers ctxt' of | 
| 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 125 | [] => error "No active testers for quickcheck" | 
| 45428 
aa35c9454a95
quickcheck invocations in mutabelle must not catch codegenerator errors internally
 bulwahn parents: 
45397diff
changeset | 126 | | [tester] => tester ctxt' false [] [(t, [])] | 
| 45159 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 127 | | _ => error "Multiple active testers for quickcheck" | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 128 | in | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 129 | case Quickcheck.counterexample_of result of | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 130 | NONE => (NoCex, Quickcheck.timings_of result) | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 131 | | SOME _ => (GenuineCex, Quickcheck.timings_of result) | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 132 | end) () | 
| 40931 | 133 | handle TimeLimit.TimeOut => | 
| 43018 | 134 |          (Timeout, [("timelimit", Real.floor (!Try.auto_time_limit))])
 | 
| 34965 | 135 | |
| 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: 
40381diff
changeset | 136 | 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: 
40381diff
changeset | 137 |   ("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: 
40381diff
changeset | 138 | |
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 139 | (** 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: 
40381diff
changeset | 140 | |
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 141 | 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: 
40381diff
changeset | 142 | let | 
| 42361 | 143 | val state = Proof.theorem NONE (K I) (map (single o rpair []) [t]) (Proof_Context.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: 
40381diff
changeset | 144 | in | 
| 43030 | 145 | case Solve_Direct.solve_direct state of | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 146 | (true, _) => (Solved, []) | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 147 | | (false, _) => (Unsolved, []) | 
| 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: 
40381diff
changeset | 148 | end | 
| 34965 | 149 | |
| 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: 
40381diff
changeset | 150 | 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: 
40381diff
changeset | 151 | |
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 152 | (** 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: 
40381diff
changeset | 153 | |
| 43030 | 154 | fun invoke_try_methods 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: 
40381diff
changeset | 155 | let | 
| 42361 | 156 | val state = Proof.theorem NONE (K I) (map (single o rpair []) [t]) (Proof_Context.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: 
40381diff
changeset | 157 | in | 
| 43030 | 158 | case Try_Methods.try_methods (SOME (seconds 5.0)) ([], [], [], []) state of | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 159 | true => (Solved, []) | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 160 | | false => (Unsolved, []) | 
| 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: 
40381diff
changeset | 161 | 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: 
40381diff
changeset | 162 | |
| 43030 | 163 | val try_methods_mtd = ("try_methods", invoke_try_methods)
 | 
| 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: 
40381diff
changeset | 164 | |
| 40971 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 165 | (** sledgehammer **) | 
| 40974 | 166 | (* | 
| 40971 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 167 | fun invoke_sledgehammer thy t = | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 168 | if can (Goal.prove_global thy (Term.add_free_names t []) [] t) | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 169 |       (fn {context, ...} => Sledgehammer_Tactics.sledgehammer_with_metis_tac context 1) then
 | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 170 | (Solved, ([], NONE)) | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 171 | else | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 172 | (Unsolved, ([], NONE)) | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 173 | |
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 174 | val sledgehammer_mtd = ("sledgehammer", invoke_sledgehammer)
 | 
| 40974 | 175 | *) | 
| 45397 | 176 | |
| 34965 | 177 | fun invoke_refute thy t = | 
| 178 | let | |
| 45397 | 179 | val params = [] | 
| 180 | val res = Refute.refute_term (Proof_Context.init_global thy) params [] t | |
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 181 |     val _ = Output.urgent_message ("Refute: " ^ res)
 | 
| 34965 | 182 | in | 
| 45397 | 183 | (rpair []) (case res of | 
| 34965 | 184 | "genuine" => GenuineCex | 
| 185 | | "likely_genuine" => GenuineCex | |
| 186 | | "potential" => PotentialCex | |
| 187 | | "none" => NoCex | |
| 188 | | "unknown" => Donno | |
| 45397 | 189 | | _ => Error) | 
| 34965 | 190 | end | 
| 45397 | 191 | handle Refute.REFUTE (loc, details) => | 
| 34965 | 192 |          (error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^
 | 
| 193 | ".")) | |
| 194 | val refute_mtd = ("refute", invoke_refute)
 | |
| 195 | ||
| 41190 | 196 | (** nitpick **) | 
| 34965 | 197 | |
| 198 | fun invoke_nitpick thy t = | |
| 199 | let | |
| 42361 | 200 | val ctxt = Proof_Context.init_global thy | 
| 34965 | 201 | val state = Proof.init ctxt | 
| 41190 | 202 | val (res, _) = Nitpick.pick_nits_in_term state | 
| 43030 | 203 | (Nitpick_Isar.default_params thy []) Nitpick.Normal 1 1 1 [] [] t | 
| 41190 | 204 |     val _ = Output.urgent_message ("Nitpick: " ^ res)
 | 
| 34965 | 205 | in | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 206 | (rpair []) (case res of | 
| 41190 | 207 | "genuine" => GenuineCex | 
| 208 | | "likely_genuine" => GenuineCex | |
| 209 | | "potential" => PotentialCex | |
| 210 | | "none" => NoCex | |
| 211 | | "unknown" => Donno | |
| 212 | | _ => Error) | |
| 34965 | 213 | end | 
| 41190 | 214 | |
| 34965 | 215 | val nitpick_mtd = ("nitpick", invoke_nitpick)
 | 
| 216 | ||
| 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: 
40381diff
changeset | 217 | (* 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: 
40381diff
changeset | 218 | |
| 38864 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 haftmann parents: 
38857diff
changeset | 219 | val comms = [@{const_name HOL.eq}, @{const_name HOL.disj}, @{const_name HOL.conj}]
 | 
| 34965 | 220 | |
| 221 | val forbidden = | |
| 222 |  [(* (@{const_name "power"}, "'a"), *)
 | |
| 35325 
4123977b469d
adding ROOT.ML to HOL-Mutabelle session; uncommenting HOL.induct constants in Mutabelle session
 bulwahn parents: 
35324diff
changeset | 223 |   (*(@{const_name induct_equal}, "'a"),
 | 
| 
4123977b469d
adding ROOT.ML to HOL-Mutabelle session; uncommenting HOL.induct constants in Mutabelle session
 bulwahn parents: 
35324diff
changeset | 224 |   (@{const_name induct_implies}, "'a"),
 | 
| 
4123977b469d
adding ROOT.ML to HOL-Mutabelle session; uncommenting HOL.induct constants in Mutabelle session
 bulwahn parents: 
35324diff
changeset | 225 |   (@{const_name induct_conj}, "'a"),*)
 | 
| 34965 | 226 |   (@{const_name "undefined"}, "'a"),
 | 
| 227 |   (@{const_name "default"}, "'a"),
 | |
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 228 |   (@{const_name "dummy_pattern"}, "'a::{}"),
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 229 |   (@{const_name "HOL.simp_implies"}, "prop => prop => prop"),
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 230 |   (@{const_name "bot_fun_inst.bot_fun"}, "'a"),
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 231 |   (@{const_name "top_fun_inst.top_fun"}, "'a"),
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 232 |   (@{const_name "Pure.term"}, "'a"),
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 233 |   (@{const_name "top_class.top"}, "'a"),
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 234 |   (@{const_name "Quotient.Quot_True"}, "'a")(*,
 | 
| 34965 | 235 |   (@{const_name "uminus"}, "'a"),
 | 
| 236 |   (@{const_name "Nat.size"}, "'a"),
 | |
| 35092 
cfe605c54e50
moved less_eq, less to Orderings.thy; moved abs, sgn to Groups.thy
 haftmann parents: 
34974diff
changeset | 237 |   (@{const_name "Groups.abs"}, "'a") *)]
 | 
| 34965 | 238 | |
| 239 | val forbidden_thms = | |
| 240 | ["finite_intvl_succ_class", | |
| 241 | "nibble"] | |
| 242 | ||
| 243 | 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: 
40381diff
changeset | 244 |  [@{const_name nibble_pair_of_char}, @{const_name "TYPE"}]
 | 
| 34965 | 245 | |
| 246 | fun is_forbidden_theorem (s, th) = | |
| 247 | 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: 
36610diff
changeset | 248 | 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: 
36610diff
changeset | 249 | exists (member (op =) forbidden_consts) consts orelse | 
| 34965 | 250 | length (space_explode "." s) <> 2 orelse | 
| 251 | String.isPrefix "type_definition" (List.last (space_explode "." s)) orelse | |
| 252 | 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: 
40381diff
changeset | 253 | 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: 
40381diff
changeset | 254 | String.isPrefix "term_of" (List.last (space_explode "." s)) | 
| 34965 | 255 | end | 
| 256 | ||
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 257 | val forbidden_mutant_constnames = | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 258 | ["HOL.induct_equal", | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 259 | "HOL.induct_implies", | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 260 | "HOL.induct_conj", | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 261 |  @{const_name undefined},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 262 |  @{const_name default},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 263 |  @{const_name dummy_pattern},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 264 |  @{const_name "HOL.simp_implies"},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 265 |  @{const_name "bot_fun_inst.bot_fun"},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 266 |  @{const_name "top_fun_inst.top_fun"},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 267 |  @{const_name "Pure.term"},
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 268 |  @{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: 
40381diff
changeset | 269 |  (*@{const_name "HOL.equal"},*)
 | 
| 40971 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 270 |  @{const_name "Quotient.Quot_True"},
 | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 271 |  @{const_name "equal_fun_inst.equal_fun"},
 | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 272 |  @{const_name "equal_bool_inst.equal_bool"},
 | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 273 |  @{const_name "ord_fun_inst.less_eq_fun"},
 | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 274 |  @{const_name "ord_fun_inst.less_fun"},
 | 
| 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 275 |  @{const_name Meson.skolem},
 | 
| 43111 | 276 |  @{const_name ATP.fequal},
 | 
| 42435 
c3d880b13aa9
adding two further code-generator internal constants to the blacklist of Mutabelle
 bulwahn parents: 
42361diff
changeset | 277 |  @{const_name transfer_morphism},
 | 
| 
c3d880b13aa9
adding two further code-generator internal constants to the blacklist of Mutabelle
 bulwahn parents: 
42361diff
changeset | 278 |  @{const_name enum_prod_inst.enum_all_prod},
 | 
| 
c3d880b13aa9
adding two further code-generator internal constants to the blacklist of Mutabelle
 bulwahn parents: 
42361diff
changeset | 279 |  @{const_name enum_prod_inst.enum_ex_prod}
 | 
| 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: 
40381diff
changeset | 280 |  (*@{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: 
40381diff
changeset | 281 | |
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 282 | 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: 
40381diff
changeset | 283 | [ | 
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 284 |    (@{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: 
40381diff
changeset | 285 |    (@{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: 
40381diff
changeset | 286 |    (@{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: 
40381diff
changeset | 287 |    (@{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: 
40381diff
changeset | 288 |    (@{const_name "Groups.times_class.times"}, @{typ "prop => prop => prop"}),
 | 
| 44064 
5bce8ff0d9ae
moved division ring stuff from Rings.thy to Fields.thy
 huffman parents: 
43883diff
changeset | 289 |    (@{const_name "Fields.inverse_class.divide"}, @{typ "prop => prop => prop"}),
 | 
| 44845 | 290 |    (@{const_name "Lattices.inf_class.inf"}, @{typ "prop => prop => prop"}),
 | 
| 291 |    (@{const_name "Lattices.sup_class.sup"}, @{typ "prop => prop => prop"}),
 | |
| 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: 
40381diff
changeset | 292 |    (@{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: 
40381diff
changeset | 293 |    (@{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: 
40381diff
changeset | 294 |    (@{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: 
40381diff
changeset | 295 |    (@{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: 
40381diff
changeset | 296 |    (@{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: 
40381diff
changeset | 297 |    (@{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: 
40381diff
changeset | 298 |    (@{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: 
40381diff
changeset | 299 |    (@{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: 
40381diff
changeset | 300 |    (@{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: 
40381diff
changeset | 301 |    (@{const_name "Groups.zero_class.zero"},@{typ "bool => prop"})]
 | 
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 302 | |
| 34965 | 303 | fun is_forbidden_mutant t = | 
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 304 | 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: 
40381diff
changeset | 305 | 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: 
40381diff
changeset | 306 | val consts = Term.add_consts t [] | 
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 307 | 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: 
40381diff
changeset | 308 | 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: 
40381diff
changeset | 309 | 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: 
40381diff
changeset | 310 | 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: 
40381diff
changeset | 311 | exists (member (op =) forbidden_mutant_consts) consts | 
| 34965 | 312 | end | 
| 313 | ||
| 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: 
40381diff
changeset | 314 | (* 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: 
40381diff
changeset | 315 | |
| 40248 | 316 | 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: 
40381diff
changeset | 317 | let | 
| 42361 | 318 | val ctxt = Proof_Context.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: 
40381diff
changeset | 319 | 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: 
40381diff
changeset | 320 | can (TimeLimit.timeLimit (seconds 2.0) | 
| 45159 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 321 | (Quickcheck.test_terms | 
| 45165 
f4896c792316
adding testing of quickcheck narrowing with finite types to mutabelle script; modified is_executable in mutabelle_extra
 bulwahn parents: 
45159diff
changeset | 322 | ((Context.proof_map (Quickcheck.set_active_testers ["exhaustive"]) #> | 
| 
f4896c792316
adding testing of quickcheck narrowing with finite types to mutabelle script; modified is_executable in mutabelle_extra
 bulwahn parents: 
45159diff
changeset | 323 | Config.put Quickcheck.finite_types true #> | 
| 41106 | 324 | 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: 
40381diff
changeset | 325 | Config.put Quickcheck.size 1 #> Config.put Quickcheck.iterations 1) ctxt) | 
| 45159 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 326 | (false, false) [])) (map (rpair [] o Object_Logic.atomize_term thy) | 
| 
3f1d1ce024cb
moving some common functions from quickcheck to the more HOL-specific quickcheck_common; renamed inductive_SML's configurations to more canonical names; adds automatically left and right hand sides of equations as evaluation terms
 bulwahn parents: 
44845diff
changeset | 327 | (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: 
40381diff
changeset | 328 | end | 
| 40248 | 329 | |
| 34965 | 330 | fun is_executable_thm thy th = is_executable_term thy (prop_of th) | 
| 331 | ||
| 332 | val freezeT = | |
| 333 | map_types (map_type_tvar (fn ((a, i), S) => | |
| 334 | TFree (if i = 0 then a else a ^ "_" ^ string_of_int i, S))) | |
| 335 | ||
| 336 | fun thms_of all thy = | |
| 337 | filter | |
| 338 | (fn th => (all orelse Context.theory_name (theory_of_thm th) = Context.theory_name thy) | |
| 339 | (* andalso is_executable_thm thy th *)) | |
| 340 | (map snd (filter_out is_forbidden_theorem (Mutabelle.all_unconcealed_thms_of thy))) | |
| 341 | ||
| 41409 | 342 | fun count x = (length oo filter o equal) x | 
| 34965 | 343 | |
| 42014 
75417ef605ba
simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
 wenzelm parents: 
42012diff
changeset | 344 | fun cpu_time description e = | 
| 
75417ef605ba
simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
 wenzelm parents: 
42012diff
changeset | 345 |   let val ({cpu, ...}, result) = Timing.timing e ()
 | 
| 
75417ef605ba
simplified various cpu_time clones (!): eliminated odd Exn.capture/Exn.release (no need to "stop" timing);
 wenzelm parents: 
42012diff
changeset | 346 | in (result, (description, Time.toMilliseconds cpu)) 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: 
40381diff
changeset | 347 | (* | 
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 348 | 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: 
40381diff
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: 
40381diff
changeset | 350 |     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: 
40381diff
changeset | 351 | 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: 
40381diff
changeset | 352 | 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: 
40381diff
changeset | 353 |     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: 
40381diff
changeset | 354 | 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: 
40381diff
changeset | 355 | *) | 
| 34965 | 356 | fun safe_invoke_mtd thy (mtd_name, invoke_mtd) t = | 
| 357 | let | |
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 358 |     val _ = Output.urgent_message ("Invoking " ^ mtd_name)
 | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 359 | val (res, timing) = (*cpu_time "total time" | 
| 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: 
40381diff
changeset | 360 | (fn () => *)case try (invoke_mtd thy) t of | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 361 | SOME (res, timing) => (res, timing) | 
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 362 |         | NONE => (Output.urgent_message ("**** PROBLEMS WITH " ^ Syntax.string_of_term_global thy t);
 | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 363 | (Error, [])) | 
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 364 |     val _ = Output.urgent_message (" Done")
 | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 365 | in (res, timing) end | 
| 34965 | 366 | |
| 367 | (* 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: 
40381diff
changeset | 368 | |
| 34965 | 369 | fun test_mutants_using_one_method thy mutants (mtd_name, invoke_mtd) = | 
| 370 | 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: 
40381diff
changeset | 371 | val res = map (fst o safe_invoke_mtd thy (mtd_name, invoke_mtd)) mutants | 
| 34965 | 372 | in | 
| 373 | (mtd_name, count GenuineCex res, count PotentialCex res, count NoCex res, | |
| 374 | count Donno res, count Timeout res, count Error res) | |
| 375 | end | |
| 376 | ||
| 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: 
40381diff
changeset | 377 | (* 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: 
40381diff
changeset | 378 | |
| 34965 | 379 | 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: 
36692diff
changeset | 380 | (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: 
40381diff
changeset | 381 | |
| 34965 | 382 | fun create_detailed_entry thy thm exec mutants mtds = | 
| 383 | let | |
| 384 | fun create_mutant_subentry mutant = (mutant, | |
| 385 | map (fn (mtd_name, invoke_mtd) => | |
| 386 | (mtd_name, safe_invoke_mtd thy (mtd_name, invoke_mtd) mutant)) mtds) | |
| 387 | in | |
| 36743 
ce2297415b54
prefer Thm.get_name_hint, which is closer to a user-space idea of "theorem name";
 wenzelm parents: 
36692diff
changeset | 388 | (Thm.get_name_hint thm, exec, prop_of thm, map create_mutant_subentry mutants) | 
| 34965 | 389 | end | 
| 390 | ||
| 391 | (* (theory -> thm -> bool -> term list -> mtd list -> 'a) -> theory -> mtd list -> thm -> 'a *) | |
| 392 | fun mutate_theorem create_entry thy mtds thm = | |
| 393 | let | |
| 394 | val exec = is_executable_thm thy thm | |
| 43277 | 395 | val _ = tracing (if exec then "EXEC" else "NOEXEC") | 
| 34965 | 396 | val mutants = | 
| 397 | (if num_mutations = 0 then | |
| 398 | [Thm.prop_of thm] | |
| 399 | else | |
| 400 | Mutabelle.mutate_mix (Thm.prop_of thm) thy comms forbidden | |
| 401 | 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: 
40381diff
changeset | 402 |              |> tap (fn muts => tracing ("mutants: " ^ string_of_int (length muts)))
 | 
| 34965 | 403 | |> filter_out is_forbidden_mutant | 
| 404 | val mutants = | |
| 405 | if exec then | |
| 406 | let | |
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 407 |           val _ = Output.urgent_message ("BEFORE PARTITION OF " ^
 | 
| 41491 | 408 | string_of_int (length mutants) ^ " MUTANTS") | 
| 34965 | 409 | val (execs, noexecs) = List.partition (is_executable_term thy) (take_random (20 * max_mutants) mutants) | 
| 41491 | 410 |           val _ = tracing ("AFTER PARTITION (" ^ string_of_int (length execs) ^
 | 
| 411 | " vs " ^ string_of_int (length noexecs) ^ ")") | |
| 34965 | 412 | in | 
| 413 | execs @ take_random (Int.max (0, max_mutants - length execs)) noexecs | |
| 414 | end | |
| 415 | else | |
| 416 | mutants | |
| 417 | val mutants = mutants | |
| 418 | |> map Mutabelle.freeze |> map freezeT | |
| 419 | (* |> filter (not o is_forbidden_mutant) *) | |
| 42429 | 420 | |> map_filter (try (Sign.cert_term thy)) | 
| 421 | |> filter (is_some o try (Thm.cterm_of thy)) | |
| 422 | |> filter (is_some o try (Syntax.check_term (Proof_Context.init_global thy))) | |
| 40971 
6604115019bf
adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
 bulwahn parents: 
40932diff
changeset | 423 | |> take_random max_mutants | 
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 424 |     val _ = map (fn t => Output.urgent_message ("MUTANT: " ^ Syntax.string_of_term_global thy t)) mutants
 | 
| 34965 | 425 | in | 
| 426 | create_entry thy thm exec mutants mtds | |
| 427 | end | |
| 428 | ||
| 429 | (* theory -> mtd list -> thm list -> report *) | |
| 430 | val mutate_theorems = map ooo mutate_theorem | |
| 431 | ||
| 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: 
35092diff
changeset | 432 | fun string_of_mutant_subentry thy thm_name (t, results) = | 
| 34965 | 433 | "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: 
35092diff
changeset | 434 | 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: 
35092diff
changeset | 435 | (map (fn (mtd_name, (outcome, timing)) => mtd_name ^ ": " ^ string_of_outcome outcome) results) ^ | 
| 34965 | 436 | "\n" | 
| 437 | ||
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 438 | (* string -> string *) | 
| 39555 
ccb223a4d49c
added XML.content_of convenience -- cover XML.body, which is the general situation;
 wenzelm parents: 
39324diff
changeset | 439 | val unyxml = XML.content_of o YXML.parse_body | 
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 440 | |
| 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: 
35092diff
changeset | 441 | fun string_of_mutant_subentry' thy thm_name (t, results) = | 
| 35380 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 442 | let | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 443 |    (* fun string_of_report (Quickcheck.Report {iterations = i, raised_match_errors = e,
 | 
| 35380 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 444 | satisfied_assms = s, positive_concl_tests = p}) = | 
| 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 445 | "errors: " ^ string_of_int e ^ "; conclusion tests: " ^ string_of_int p | 
| 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 446 | fun string_of_reports NONE = "" | 
| 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 447 | | string_of_reports (SOME reports) = | 
| 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 448 | cat_lines (map (fn (size, [report]) => | 
| 42089 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 449 | "size " ^ string_of_int size ^ ": " ^ string_of_report report) (rev reports))*) | 
| 
904897d0c5bd
adapting mutabelle; exporting more Quickcheck functions
 bulwahn parents: 
42032diff
changeset | 450 | fun string_of_mtd_result (mtd_name, (outcome, timing)) = | 
| 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: 
40381diff
changeset | 451 | 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: 
40381diff
changeset | 452 |       (*" 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: 
35625diff
changeset | 453 | (*^ "\n" ^ string_of_reports reports*) | 
| 35380 
6ac5b81a763d
adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
 bulwahn parents: 
35325diff
changeset | 454 | in | 
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 455 | "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: 
40381diff
changeset | 456 | ^ 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: 
35325diff
changeset | 457 | 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: 
35092diff
changeset | 458 | |
| 34965 | 459 | fun string_of_detailed_entry thy (thm_name, exec, t, mutant_subentries) = | 
| 460 | thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ": " ^ | |
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 461 | 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: 
35092diff
changeset | 462 | cat_lines (map (string_of_mutant_subentry' thy thm_name) mutant_subentries) ^ "\n" | 
| 34965 | 463 | |
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 464 | 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: 
35625diff
changeset | 465 | "lemma " ^ thm_name ^ "_" ^ string_of_int (i + 1) ^ ":\n" ^ | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 466 | "\"" ^ 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: 
40381diff
changeset | 467 | "\" \nquickcheck\noops\n" | 
| 36255 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 468 | |
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 469 | 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: 
35625diff
changeset | 470 |   "subsubsection {* mutants of " ^ thm_name ^ " *}\n\n" ^
 | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 471 | cat_lines (map_index | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 472 | (theoryfile_string_of_mutant_subentry thy thm_name) mutant_subentries) ^ "\n" | 
| 
f8b3381e1437
tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
 bulwahn parents: 
35625diff
changeset | 473 | |
| 34965 | 474 | (* subentry -> string *) | 
| 475 | fun string_for_subentry (mtd_name, genuine_cex, potential_cex, no_cex, donno, | |
| 476 | timeout, error) = | |
| 41491 | 477 | " " ^ mtd_name ^ ": " ^ string_of_int genuine_cex ^ "+ " ^ | 
| 478 | string_of_int potential_cex ^ "= " ^ string_of_int no_cex ^ "- " ^ | |
| 479 | string_of_int donno ^ "? " ^ string_of_int timeout ^ "T " ^ | |
| 480 | string_of_int 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: 
40381diff
changeset | 481 | |
| 34965 | 482 | (* entry -> string *) | 
| 483 | fun string_for_entry (thm_name, exec, subentries) = | |
| 484 | thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ":\n" ^ | |
| 485 | 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: 
40381diff
changeset | 486 | |
| 34965 | 487 | (* report -> string *) | 
| 488 | fun string_for_report report = cat_lines (map string_for_entry report) | |
| 489 | ||
| 490 | (* string -> report -> unit *) | |
| 491 | fun write_report file_name = | |
| 492 | File.write (Path.explode file_name) o string_for_report | |
| 493 | ||
| 494 | (* theory -> mtd list -> thm list -> string -> unit *) | |
| 495 | fun mutate_theorems_and_write_report thy mtds thms file_name = | |
| 496 | let | |
| 40132 
7ee65dbffa31
renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
 wenzelm parents: 
39555diff
changeset | 497 | val _ = Output.urgent_message "Starting Mutabelle..." | 
| 42361 | 498 | val ctxt = Proof_Context.init_global thy | 
| 34965 | 499 | val path = Path.explode file_name | 
| 500 | (* 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: 
40381diff
changeset | 501 | (* | 
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 502 | 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: 
40381diff
changeset | 503 | *) | 
| 
d921c97bdbd8
adding AFP tests to Mutabelle_Extra; adopting mutabelle to recent quickcheck changes; filtering strange mutants; adding solvers to mutabelle; restructuring mutabelle
 bulwahn parents: 
40381diff
changeset | 504 | (* 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: 
40381diff
changeset | 505 | 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: 
40381diff
changeset | 506 | (* 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: 
40381diff
changeset | 507 | (*val (gen_create_entry, gen_string_for_entry) = (create_detailed_entry, theoryfile_string_of_detailed_entry thy)*) | 
| 34965 | 508 | in | 
| 509 | File.write path ( | |
| 510 | "Mutation options = " ^ | |
| 511 | "max_mutants: " ^ string_of_int max_mutants ^ | |
| 512 | "; num_mutations: " ^ string_of_int num_mutations ^ "\n" ^ | |
| 513 | "QC options = " ^ | |
| 514 | (*"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: 
40381diff
changeset | 515 | "size: " ^ string_of_int (Config.get ctxt Quickcheck.size) ^ | 
| 43244 | 516 | "; iterations: " ^ string_of_int (Config.get ctxt Quickcheck.iterations) ^ "\n" ^ | 
| 517 | "Isabelle environment = ISABELLE_GHC: " ^ getenv "ISABELLE_GHC" ^ "\n"); | |
| 34965 | 518 | map (File.append path o gen_string_for_entry o mutate_theorem gen_create_entry thy mtds) thms; | 
| 519 | () | |
| 520 | end | |
| 521 | ||
| 522 | end; |