src/HOL/Mutabelle/Mutabelle.thy
author wenzelm
Mon Feb 27 16:56:25 2012 +0100 (2012-02-27)
changeset 46711 f745bcc4a1e5
parent 42361 23f352990944
child 48891 c0eafbd55de3
permissions -rw-r--r--
more explicit Long_Name operations (NB: analyzing qualifiers is inherently fragile);
wenzelm@46711
     1
(* FIXME dead code!?!? *)
wenzelm@46711
     2
bulwahn@34965
     3
theory Mutabelle
bulwahn@34965
     4
imports Main
bulwahn@34965
     5
uses "mutabelle.ML"
bulwahn@34965
     6
begin
bulwahn@34965
     7
bulwahn@34965
     8
ML {*
haftmann@38864
     9
val comms = [@{const_name HOL.eq}, @{const_name HOL.disj}, @{const_name HOL.conj}];
bulwahn@34965
    10
bulwahn@34965
    11
val forbidden =
haftmann@34974
    12
 [(@{const_name Power.power}, "'a"),
haftmann@34974
    13
  (@{const_name HOL.induct_equal}, "'a"),
haftmann@34974
    14
  (@{const_name HOL.induct_implies}, "'a"),
haftmann@34974
    15
  (@{const_name HOL.induct_conj}, "'a"),
haftmann@34974
    16
  (@{const_name HOL.undefined}, "'a"),
haftmann@34974
    17
  (@{const_name HOL.default}, "'a"),
haftmann@34974
    18
  (@{const_name dummy_pattern}, "'a::{}"),
haftmann@35267
    19
  (@{const_name Groups.uminus}, "'a"),
haftmann@34974
    20
  (@{const_name Nat.size}, "'a"),
haftmann@35092
    21
  (@{const_name Groups.abs}, "'a")];
bulwahn@34965
    22
bulwahn@34965
    23
val forbidden_thms =
bulwahn@34965
    24
 ["finite_intvl_succ_class",
bulwahn@34965
    25
  "nibble"];
bulwahn@34965
    26
bulwahn@34965
    27
val forbidden_consts =
bulwahn@34965
    28
 [@{const_name nibble_pair_of_char}];
bulwahn@34965
    29
bulwahn@34965
    30
fun is_forbidden s th =
wenzelm@46711
    31
 exists (fn s' => s' mem Long_Name.explode s) forbidden_thms orelse
bulwahn@34965
    32
 exists (fn s' => s' mem (Term.add_const_names (prop_of th) [])) forbidden_consts;
bulwahn@34965
    33
bulwahn@34965
    34
fun test j = List.app (fn i =>
bulwahn@34965
    35
 Mutabelle.mutqc_thystat_mix is_forbidden
bulwahn@34965
    36
   @{theory List} @{theory Main} comms forbidden 1 [] i j ("list_" ^ string_of_int i ^ ".txt"))
bulwahn@34965
    37
 (1 upto 10);
bulwahn@34965
    38
bulwahn@34965
    39
fun get_numbers xs =
bulwahn@34965
    40
 let
bulwahn@34965
    41
   val (_, xs1) = take_prefix (not o equal ":") xs;
bulwahn@34965
    42
   val (_, xs2) = take_prefix (fn ":" => true | " " => true | _ => false) xs1;
bulwahn@34965
    43
   val (xs3, xs4) = take_prefix Symbol.is_digit xs2;
bulwahn@34965
    44
   val (_, xs5) = take_prefix (equal " ") xs4;
bulwahn@34965
    45
   val (xs6, xs7) = take_prefix Symbol.is_digit xs5
bulwahn@34965
    46
 in
bulwahn@34965
    47
   case (xs3, xs6) of
bulwahn@34965
    48
     ([], _) => NONE
bulwahn@34965
    49
   | (_, []) => NONE
bulwahn@34965
    50
   | (ys, zs) => SOME (fst (read_int ys), fst (read_int zs), xs7)
bulwahn@34965
    51
 end;
bulwahn@34965
    52
bulwahn@34965
    53
fun add_numbers s =
bulwahn@34965
    54
 let
bulwahn@34965
    55
   fun strip ("\n" :: "\n" :: "\n" :: xs) = xs
bulwahn@34965
    56
     | strip (_ :: xs) = strip xs;
bulwahn@34965
    57
bulwahn@34965
    58
   fun add (i, j) xs = (case get_numbers xs of
bulwahn@34965
    59
         NONE => (i, j)
bulwahn@34965
    60
       | SOME (i', j', xs') => add (i+i', j+j') xs')
bulwahn@34965
    61
 in add (0,0) (strip (explode s)) end;
bulwahn@34965
    62
*}
bulwahn@34965
    63
bulwahn@34965
    64
(*
bulwahn@34965
    65
ML {*
wenzelm@42361
    66
Quickcheck.test_term (Proof_Context.init_global @{theory})
bulwahn@34965
    67
 false (SOME "SML") 1 1 (prop_of (hd @{thms nibble_pair_of_char_simps}))
bulwahn@34965
    68
*}
bulwahn@34965
    69
bulwahn@34965
    70
ML {*
bulwahn@34965
    71
fun is_executable thy th = can (Quickcheck.test_term
wenzelm@42361
    72
 (Proof_Context.init_global thy) false (SOME "SML") 1 1) (prop_of th);
bulwahn@34965
    73
bulwahn@34965
    74
fun is_executable_term thy t = can (Quickcheck.test_term
wenzelm@42361
    75
 (Proof_Context.init_global thy) false (SOME "SML") 1 1) t;
bulwahn@34965
    76
bulwahn@34965
    77
fun thms_of thy = filter (fn (_, th) => not (Thm.is_internal th) andalso
bulwahn@34965
    78
   Context.theory_name (theory_of_thm th) = Context.theory_name thy andalso
bulwahn@34965
    79
   is_executable thy th)
wenzelm@39557
    80
 (Global_Theory.all_thms_of thy);
bulwahn@34965
    81
bulwahn@34965
    82
fun find_thm thy = find_first (fn (_, th) => not (Thm.is_internal th) andalso
bulwahn@34965
    83
   Context.theory_name (theory_of_thm th) = Context.theory_name thy andalso
bulwahn@34965
    84
   is_executable thy th)
wenzelm@39557
    85
 (Global_Theory.all_thms_of thy);
bulwahn@34965
    86
*}
bulwahn@34965
    87
bulwahn@34965
    88
ML {*
bulwahn@34965
    89
is_executable @{theory} (hd @{thms nibble_pair_of_char_simps})
bulwahn@34965
    90
*}
bulwahn@34965
    91
*)
bulwahn@34965
    92
bulwahn@34965
    93
ML {*
bulwahn@34965
    94
Mutabelle.mutate_mix @{term "Suc x \<noteq> 0"} @{theory} comms forbidden 1
bulwahn@34965
    95
*}
bulwahn@34965
    96
bulwahn@34965
    97
ML {*
bulwahn@34965
    98
Mutabelle.mutqc_thystat_mix is_forbidden @{theory Nat} @{theory} comms forbidden 1 [] 10 5 "/tmp/muta.out"
bulwahn@34965
    99
*}
bulwahn@34965
   100
bulwahn@34965
   101
end