src/HOL/Mutabelle/mutabelle_extra.ML
author wenzelm
Wed, 29 Dec 2010 12:22:38 +0100
changeset 41408 08a072ca6348
parent 41190 0bdc6fac5f48
child 41409 0bc364f772ef
permissions -rw-r--r--
tuned comments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37744
3daaf23b9ab4 tuned titles
haftmann
parents: 36743
diff changeset
     1
(*  Title:      HOL/Mutabelle/mutabelle_extra.ML
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
     2
    Author:     Stefan Berghofer, Jasmin Blanchette, Lukas Bulwahn, TU Muenchen
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
     3
41408
08a072ca6348 tuned comments;
wenzelm
parents: 41190
diff changeset
     4
Invokation of Counterexample generators.
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
     5
*)
41408
08a072ca6348 tuned comments;
wenzelm
parents: 41190
diff changeset
     6
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
     7
signature MUTABELLE_EXTRA =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
     8
sig
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
     9
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    10
val take_random : int -> 'a list -> 'a list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    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: 40381
diff changeset
    12
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
    13
type timing = (string * int) list
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    14
35380
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
    15
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
    16
35380
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
    17
type mutant_subentry = term * (string * (outcome * (timing * Quickcheck.report option))) list
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    18
type detailed_entry = string * bool * term * mutant_subentry list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    19
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    20
type subentry = string * int * int * int * int * int * int
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    21
type entry = string * bool * subentry list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    22
type report = entry list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    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: 40381
diff 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: 40381
diff 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: 40381
diff changeset
    26
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
    27
val try_mtd : mtd
40974
29e5cae93584 commenting out sledgehammer_mtd in Mutabelle
bulwahn
parents: 40972
diff changeset
    28
(*
40971
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
    29
val sledgehammer_mtd : mtd
40974
29e5cae93584 commenting out sledgehammer_mtd in Mutabelle
bulwahn
parents: 40972
diff changeset
    30
*)
41190
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
    31
val nitpick_mtd : mtd
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
    32
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    33
(*
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    34
val refute_mtd : mtd
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    35
*)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    36
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    37
val freezeT : term -> term
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    38
val thms_of : bool -> theory -> thm list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    39
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    40
val string_for_report : report -> string
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    41
val write_report : string -> report -> unit
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    42
val mutate_theorems_and_write_report :
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    43
  theory -> mtd list -> thm list -> string -> unit
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    44
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    45
val random_seed : real Unsynchronized.ref
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    46
end;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    47
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    48
structure MutabelleExtra : MUTABELLE_EXTRA =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    49
struct
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    50
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    51
(* Own seed; can't rely on the Isabelle one to stay the same *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    52
val random_seed = Unsynchronized.ref 1.0;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    53
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    54
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    55
(* 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
    56
(*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
    57
val num_mutations = 1*)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    58
(* 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
    59
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
    60
val num_mutations = 1
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    61
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    62
(* quickcheck options *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    63
(*val quickcheck_generator = "SML"*)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    64
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
    65
(* 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
    66
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    67
exception RANDOM;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    68
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    69
fun rmod x y = x - y * Real.realFloor (x / y);
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    70
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    71
local
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    72
  val a = 16807.0;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    73
  val m = 2147483647.0;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    74
in
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    75
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    76
fun random () = CRITICAL (fn () =>
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    77
  let val r = rmod (a * ! random_seed) m
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    78
  in (random_seed := r; r) end);
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    79
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    80
end;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    81
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    82
fun random_range l h =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    83
  if h < l orelse l < 0 then raise RANDOM
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    84
  else l + Real.floor (rmod (random ()) (real (h - l + 1)));
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
    85
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
    86
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
    87
  | 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
    88
  | 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
    89
    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
    90
      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
    91
    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
    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
(* 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
    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
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
    96
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
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
    98
  | 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
    99
  | 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
   100
  | 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
   101
  | 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
   102
  | 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
   103
  | 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
   104
  | 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
   105
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
   106
type timing = (string * int) list
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   107
35380
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   108
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
   109
35380
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   110
type mutant_subentry = term * (string * (outcome * (timing * Quickcheck.report option))) list
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   111
type detailed_entry = string * bool * term * mutant_subentry list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   112
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   113
type subentry = string * int * int * int * int * int * int
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   114
type entry = string * bool * subentry list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   115
type report = entry list
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   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
(* possible invocations *)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   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
(** quickcheck **)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   120
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
   121
fun invoke_quickcheck change_options quickcheck_generator thy t =
40931
061b8257ab9f run synchronous Auto Tools in parallel
blanchet
parents: 40920
diff changeset
   122
  TimeLimit.timeLimit (seconds (!Auto_Tools.time_limit))
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   123
      (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
   124
          case Quickcheck.test_goal_terms (change_options (ProofContext.init_global thy))
40920
977c60b622f4 adapting mutabelle
bulwahn
parents: 40906
diff changeset
   125
              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
   126
            (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
   127
          | (SOME _, _) => (GenuineCex, ([], NONE))) ()
40931
061b8257ab9f run synchronous Auto Tools in parallel
blanchet
parents: 40920
diff changeset
   128
  handle TimeLimit.TimeOut =>
40932
b9f56b4025d2 compile
blanchet
parents: 40931
diff changeset
   129
         (Timeout, ([("timelimit", Real.floor (!Auto_Tools.time_limit))], NONE))
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   130
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
   131
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
   132
  ("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
   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
(** 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
   135
 
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
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
   137
  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
   138
    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
   139
  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
   140
    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
   141
      (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
   142
    | (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
   143
  end
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   144
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
   145
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
   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
(** 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
   148
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
   149
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
   150
  let
40971
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   151
    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
   152
  in
40972
ce78ef6a909b adding timeout to try invocation in mutabelle
bulwahn
parents: 40971
diff changeset
   153
    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
   154
      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
   155
    | 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
   156
  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
   157
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
   158
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
   159
40971
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   160
(** sledgehammer **)
40974
29e5cae93584 commenting out sledgehammer_mtd in Mutabelle
bulwahn
parents: 40972
diff changeset
   161
(*
40971
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   162
fun invoke_sledgehammer thy t =
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   163
  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
   164
      (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
   165
    (Solved, ([], NONE))
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   166
  else
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   167
    (Unsolved, ([], NONE))
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   168
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   169
val sledgehammer_mtd = ("sledgehammer", invoke_sledgehammer)
40974
29e5cae93584 commenting out sledgehammer_mtd in Mutabelle
bulwahn
parents: 40972
diff changeset
   170
*)
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
   171
(*
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   172
fun invoke_refute thy t =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   173
  let
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   174
    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
   175
    val _ = Output.urgent_message ("Refute: " ^ res)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   176
  in
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   177
    case res of
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   178
      "genuine" => GenuineCex
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   179
    | "likely_genuine" => GenuineCex
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   180
    | "potential" => PotentialCex
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   181
    | "none" => NoCex
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   182
    | "unknown" => Donno
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   183
    | _ => Error
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   184
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   185
  handle MyRefute.REFUTE (loc, details) =>
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   186
         (error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   187
                   "."))
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   188
val refute_mtd = ("refute", invoke_refute)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   189
*)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   190
41190
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   191
(** nitpick **)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   192
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   193
fun invoke_nitpick thy t =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   194
  let
36610
bafd82950e24 renamed ProofContext.init to ProofContext.init_global to emphasize that this is not the real thing;
wenzelm
parents: 36255
diff changeset
   195
    val ctxt = ProofContext.init_global thy
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   196
    val state = Proof.init ctxt
41190
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   197
    val (res, _) = Nitpick.pick_nits_in_term state
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   198
      (Nitpick_Isar.default_params thy []) false 1 1 1 [] [] t
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   199
    val _ = Output.urgent_message ("Nitpick: " ^ res)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   200
  in
41190
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   201
    rpair ([], NONE) (case res of
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   202
      "genuine" => GenuineCex
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   203
    | "likely_genuine" => GenuineCex
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   204
    | "potential" => PotentialCex
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   205
    | "none" => NoCex
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   206
    | "unknown" => Donno
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   207
    | _ => Error)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   208
  end
41190
0bdc6fac5f48 reactivating nitpick in Mutabelle
bulwahn
parents: 41106
diff changeset
   209
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   210
val nitpick_mtd = ("nitpick", invoke_nitpick)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   211
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
   212
(* 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
   213
38864
4abe644fcea5 formerly unnamed infix equality now named HOL.eq
haftmann
parents: 38857
diff changeset
   214
val comms = [@{const_name HOL.eq}, @{const_name HOL.disj}, @{const_name HOL.conj}]
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   215
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   216
val forbidden =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   217
 [(* (@{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
   218
  (*(@{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
   219
  (@{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
   220
  (@{const_name induct_conj}, "'a"),*)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   221
  (@{const_name "undefined"}, "'a"),
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   222
  (@{const_name "default"}, "'a"),
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   223
  (@{const_name "dummy_pattern"}, "'a::{}"),
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   224
  (@{const_name "HOL.simp_implies"}, "prop => prop => prop"),
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   225
  (@{const_name "bot_fun_inst.bot_fun"}, "'a"),
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   226
  (@{const_name "top_fun_inst.top_fun"}, "'a"),
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   227
  (@{const_name "Pure.term"}, "'a"),
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   228
  (@{const_name "top_class.top"}, "'a"),
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   229
  (@{const_name "Quotient.Quot_True"}, "'a")(*,
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   230
  (@{const_name "uminus"}, "'a"),
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   231
  (@{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
   232
  (@{const_name "Groups.abs"}, "'a") *)]
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   233
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   234
val forbidden_thms =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   235
 ["finite_intvl_succ_class",
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   236
  "nibble"]
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   237
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   238
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
   239
 [@{const_name nibble_pair_of_char}, @{const_name "TYPE"}]
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   240
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   241
fun is_forbidden_theorem (s, th) =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   242
  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
   243
    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
   244
    exists (member (op =) forbidden_consts) consts orelse
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   245
    length (space_explode "." s) <> 2 orelse
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   246
    String.isPrefix "type_definition" (List.last (space_explode "." s)) orelse
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   247
    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
   248
    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
   249
    String.isPrefix "term_of" (List.last (space_explode "." s))
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   250
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   251
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   252
val forbidden_mutant_constnames =
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   253
 ["HOL.induct_equal",
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   254
  "HOL.induct_implies",
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   255
  "HOL.induct_conj",
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   256
 @{const_name undefined},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   257
 @{const_name default},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   258
 @{const_name dummy_pattern},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   259
 @{const_name "HOL.simp_implies"},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   260
 @{const_name "bot_fun_inst.bot_fun"},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   261
 @{const_name "top_fun_inst.top_fun"},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   262
 @{const_name "Pure.term"},
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   263
 @{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
   264
 (*@{const_name "HOL.equal"},*)
40971
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   265
 @{const_name "Quotient.Quot_True"},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   266
 @{const_name "equal_fun_inst.equal_fun"},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   267
 @{const_name "equal_bool_inst.equal_bool"},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   268
 @{const_name "ord_fun_inst.less_eq_fun"},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   269
 @{const_name "ord_fun_inst.less_fun"},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   270
 @{const_name Metis.fequal},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   271
 @{const_name Meson.skolem},
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   272
 @{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
   273
 (*@{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
   274
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
   275
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
   276
  [
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
   277
   (@{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
   278
   (@{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
   279
   (@{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
   280
   (@{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
   281
   (@{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
   282
   (@{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
   283
   (@{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
   284
   (@{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
   285
   (@{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
   286
   (@{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
   287
   (@{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
   288
   (@{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
   289
   (@{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
   290
   (@{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
   291
   (@{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
   292
   (@{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
   293
   (@{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
   294
   (@{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
   295
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   296
fun is_forbidden_mutant t =
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   297
  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
   298
    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
   299
    val consts = Term.add_consts t []
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   300
  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
   301
    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
   302
    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
   303
    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
   304
    exists (member (op =) forbidden_mutant_consts) consts
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   305
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   306
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
   307
(* 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
   308
40248
2107581b404d adapting HOL-Mutabelle to changes in quickcheck
bulwahn
parents: 40132
diff changeset
   309
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
   310
  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
   311
    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
   312
  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
   313
    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
   314
      (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
   315
        ((Config.put Quickcheck.finite_types true #>
41106
09037a02f5ec setting finite_type_size to 1 in mutabelle_extra
bulwahn
parents: 40974
diff changeset
   316
          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
   317
          Config.put Quickcheck.size 1 #> Config.put Quickcheck.iterations 1) ctxt)
40920
977c60b622f4 adapting mutabelle
bulwahn
parents: 40906
diff changeset
   318
        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
   319
  end
40248
2107581b404d adapting HOL-Mutabelle to changes in quickcheck
bulwahn
parents: 40132
diff changeset
   320
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   321
fun is_executable_thm thy th = is_executable_term thy (prop_of th)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   322
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   323
val freezeT =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   324
  map_types (map_type_tvar (fn ((a, i), S) =>
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   325
    TFree (if i = 0 then a else a ^ "_" ^ string_of_int i, S)))
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   326
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   327
fun thms_of all thy =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   328
  filter
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   329
    (fn th => (all orelse Context.theory_name (theory_of_thm th) = Context.theory_name thy)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   330
      (* andalso is_executable_thm thy th *))
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   331
    (map snd (filter_out is_forbidden_theorem (Mutabelle.all_unconcealed_thms_of thy)))
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   332
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   333
val count = length oo filter o equal
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   334
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
   335
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
   336
  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
   337
    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
   338
    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
   339
    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
   340
  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
   341
(*
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
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
   343
  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
   344
    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
   345
    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
   346
      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
   347
    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
   348
  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
   349
*)  
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   350
fun safe_invoke_mtd thy (mtd_name, invoke_mtd) t =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   351
  let
40132
7ee65dbffa31 renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents: 39555
diff changeset
   352
    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
   353
    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
   354
      (fn () => *)case try (invoke_mtd thy) t of
35380
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   355
          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
   356
        | 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
   357
           (Error, ([], NONE)))
40132
7ee65dbffa31 renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents: 39555
diff changeset
   358
    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
   359
  in (res, (timing, reports)) end
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   360
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   361
(* 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
   362
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   363
fun test_mutants_using_one_method thy mutants (mtd_name, invoke_mtd) =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   364
  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
   365
     val res = map (fst o safe_invoke_mtd thy (mtd_name, invoke_mtd)) mutants
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   366
  in
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   367
    (mtd_name, count GenuineCex res, count PotentialCex res, count NoCex res,
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   368
     count Donno res, count Timeout res, count Error res)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   369
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   370
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
   371
(* 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
   372
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   373
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
   374
  (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
   375
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   376
fun create_detailed_entry thy thm exec mutants mtds =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   377
  let
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   378
    fun create_mutant_subentry mutant = (mutant,
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   379
      map (fn (mtd_name, invoke_mtd) =>
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   380
        (mtd_name, safe_invoke_mtd thy (mtd_name, invoke_mtd) mutant)) mtds)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   381
  in
36743
ce2297415b54 prefer Thm.get_name_hint, which is closer to a user-space idea of "theorem name";
wenzelm
parents: 36692
diff changeset
   382
    (Thm.get_name_hint thm, exec, prop_of thm, map create_mutant_subentry mutants)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   383
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   384
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   385
(* (theory -> thm -> bool -> term list -> mtd list -> 'a) -> theory -> mtd list -> thm -> 'a *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   386
fun mutate_theorem create_entry thy mtds thm =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   387
  let
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   388
    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
   389
    val _ = Output.tracing (if exec then "EXEC" else "NOEXEC")
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   390
    val mutants =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   391
          (if num_mutations = 0 then
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   392
             [Thm.prop_of thm]
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   393
           else
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   394
             Mutabelle.mutate_mix (Thm.prop_of thm) thy comms forbidden
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   395
                                  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
   396
             |> tap (fn muts => tracing ("mutants: " ^ string_of_int (length muts)))
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   397
             |> filter_out is_forbidden_mutant
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   398
    val mutants =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   399
      if exec then
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   400
        let
40132
7ee65dbffa31 renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents: 39555
diff changeset
   401
          val _ = Output.urgent_message ("BEFORE PARTITION OF " ^
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   402
                            Int.toString (length mutants) ^ " MUTANTS")
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   403
          val (execs, noexecs) = List.partition (is_executable_term thy) (take_random (20 * max_mutants) mutants)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   404
          val _ = tracing ("AFTER PARTITION (" ^ Int.toString (length execs) ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   405
                           " vs " ^ Int.toString (length noexecs) ^ ")")
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   406
        in
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   407
          execs @ take_random (Int.max (0, max_mutants - length execs)) noexecs
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   408
        end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   409
      else
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   410
        mutants
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   411
    val mutants = mutants
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   412
          |> map Mutabelle.freeze |> map freezeT
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   413
(*          |> filter (not o is_forbidden_mutant) *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   414
          |> List.mapPartial (try (Sign.cert_term thy))
40971
6604115019bf adding filtering, sytactic welltyping, and sledgehammer method in mutabelle
bulwahn
parents: 40932
diff changeset
   415
          |> 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
   416
          |> 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
   417
          |> 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
   418
    val _ = map (fn t => Output.urgent_message ("MUTANT: " ^ Syntax.string_of_term_global thy t)) mutants
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   419
  in
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   420
    create_entry thy thm exec mutants mtds
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   421
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   422
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   423
(* theory -> mtd list -> thm list -> report *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   424
val mutate_theorems = map ooo mutate_theorem
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   425
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
   426
fun string_of_mutant_subentry thy thm_name (t, results) =
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   427
  "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
   428
  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
   429
    (map (fn (mtd_name, (outcome, timing)) => mtd_name ^ ": " ^ string_of_outcome outcome) results) ^
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   430
  "\n"
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   431
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   432
(* string -> string *)
39555
ccb223a4d49c added XML.content_of convenience -- cover XML.body, which is the general situation;
wenzelm
parents: 39324
diff changeset
   433
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
   434
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
   435
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
   436
  let
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   437
    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
   438
      satisfied_assms = s, positive_concl_tests = p}) =
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   439
      "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
   440
    fun string_of_reports NONE = ""
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   441
      | string_of_reports (SOME reports) =
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   442
        cat_lines (map (fn (size, [report]) =>
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   443
          "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
   444
    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
   445
      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
   446
      (*" 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
   447
      (*^ "\n" ^ string_of_reports reports*)
35380
6ac5b81a763d adopting Mutabelle to quickcheck reporting; improving quickcheck reporting
bulwahn
parents: 35325
diff changeset
   448
  in
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   449
    "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
   450
    ^ 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
   451
  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
   452
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   453
fun string_of_detailed_entry thy (thm_name, exec, t, mutant_subentries) = 
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   454
   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
   455
   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
   456
   cat_lines (map (string_of_mutant_subentry' thy thm_name) mutant_subentries) ^ "\n"
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   457
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   458
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
   459
  "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
   460
  "\"" ^ 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
   461
  "\" \nquickcheck\noops\n"
36255
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   462
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   463
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
   464
  "subsubsection {* mutants of " ^ thm_name ^ " *}\n\n" ^
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   465
  cat_lines (map_index
f8b3381e1437 tuning mutabelle; adding output of mutant theoryfile for interactive evaluation
bulwahn
parents: 35625
diff changeset
   466
    (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
   467
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   468
(* subentry -> string *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   469
fun string_for_subentry (mtd_name, genuine_cex, potential_cex, no_cex, donno,
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   470
                         timeout, error) =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   471
  "    " ^ mtd_name ^ ": " ^ Int.toString genuine_cex ^ "+ " ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   472
  Int.toString potential_cex ^ "= " ^ Int.toString no_cex ^ "- " ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   473
  Int.toString donno ^ "? " ^ Int.toString timeout ^ "T " ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   474
  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
   475
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   476
(* entry -> string *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   477
fun string_for_entry (thm_name, exec, subentries) =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   478
  thm_name ^ " " ^ (if exec then "[exe]" else "[noexe]") ^ ":\n" ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   479
  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
   480
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   481
(* report -> string *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   482
fun string_for_report report = cat_lines (map string_for_entry report)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   483
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   484
(* string -> report -> unit *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   485
fun write_report file_name =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   486
  File.write (Path.explode file_name) o string_for_report
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   487
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   488
(* theory -> mtd list -> thm list -> string -> unit *)
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   489
fun mutate_theorems_and_write_report thy mtds thms file_name =
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   490
  let
40132
7ee65dbffa31 renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents: 39555
diff changeset
   491
    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
   492
    val ctxt = ProofContext.init_global thy
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   493
    val path = Path.explode file_name
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   494
    (* 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
   495
    (*
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
   496
    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
   497
    *)
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
   498
    (* 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
   499
    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
   500
    (* 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
   501
    (*val (gen_create_entry, gen_string_for_entry) = (create_detailed_entry, theoryfile_string_of_detailed_entry thy)*)
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   502
  in
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   503
    File.write path (
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   504
    "Mutation options = "  ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   505
      "max_mutants: " ^ string_of_int max_mutants ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   506
      "; num_mutations: " ^ string_of_int num_mutations ^ "\n" ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   507
    "QC options = " ^
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   508
      (*"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
   509
      "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
   510
      "; iterations: " ^ string_of_int (Config.get ctxt Quickcheck.iterations) ^ "\n");
34965
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   511
    map (File.append path o gen_string_for_entry o mutate_theorem gen_create_entry thy mtds) thms;
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   512
    ()
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   513
  end
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   514
3b4762c1052c adding Mutabelle to repository
bulwahn
parents:
diff changeset
   515
end;