src/HOL/Mutabelle/mutabelle.ML
changeset 34967 4b068e52ab3f
parent 34965 3b4762c1052c
child 35408 b48ab741683b
equal deleted inserted replaced
34966:52f30b06938a 34967:4b068e52ab3f
     1 (*
     1 (*
     2     Title:      HOL/Mutabelle/mutabelle.ML
     2     Title:      HOL/Mutabelle/mutabelle.ML
     3     Author:     Stefan Berghofer, TU Muenchen
     3     Author:     Veronika Ortner, TU Muenchen
     4 
     4 
     5     Mutation of theorems
     5     Mutation of theorems
     6 *)
     6 *)
     7 signature MUTABELLE =
     7 signature MUTABELLE =
     8 sig
     8 sig
    51  val canonize_term: term -> string list -> term
    51  val canonize_term: term -> string list -> term
    52  
    52  
    53  val all_unconcealed_thms_of : theory -> (string * thm) list
    53  val all_unconcealed_thms_of : theory -> (string * thm) list
    54 end;
    54 end;
    55 
    55 
    56 val bar = Unsynchronized.ref ([] : term list);
       
    57 val bla = Unsynchronized.ref (Bound 0);
       
    58 fun store x = (bla := x; x);
       
    59 
       
    60 structure Mutabelle : MUTABELLE = 
    56 structure Mutabelle : MUTABELLE = 
    61 struct
    57 struct
    62 
    58 
    63 val testgen_name = Unsynchronized.ref "SML";
    59 val testgen_name = Unsynchronized.ref "SML";
    64 
       
    65 (*
       
    66 fun is_executable thy th = can (Quickcheck.test_term
       
    67  (ProofContext.init thy) false (SOME (!testgen_name)) 1 1) (prop_of th);
       
    68 *)
       
    69 
    60 
    70 fun all_unconcealed_thms_of thy =
    61 fun all_unconcealed_thms_of thy =
    71   let
    62   let
    72     val facts = PureThy.facts_of thy
    63     val facts = PureThy.facts_of thy
    73   in
    64   in
   513     (priority ("not executable: " ^ s); false);
   504     (priority ("not executable: " ^ s); false);
   514 
   505 
   515 fun qc_recursive usedthy [] insts sz qciter acc = rev acc
   506 fun qc_recursive usedthy [] insts sz qciter acc = rev acc
   516  | qc_recursive usedthy (x::xs) insts sz qciter acc = qc_recursive usedthy xs insts sz qciter 
   507  | qc_recursive usedthy (x::xs) insts sz qciter acc = qc_recursive usedthy xs insts sz qciter 
   517      (priority ("qc_recursive: " ^ string_of_int (length xs)); ((x, pretty (the_default [] (Quickcheck.test_term
   508      (priority ("qc_recursive: " ^ string_of_int (length xs)); ((x, pretty (the_default [] (Quickcheck.test_term
   518        (ProofContext.init usedthy) false (SOME (!testgen_name)) sz qciter (store (preprocess usedthy insts x))))) :: acc))
   509        (ProofContext.init usedthy) false (SOME (!testgen_name)) sz qciter (preprocess usedthy insts x)))) :: acc))
   519           handle ERROR msg => (priority msg; qc_recursive usedthy xs insts sz qciter acc);
   510           handle ERROR msg => (priority msg; qc_recursive usedthy xs insts sz qciter acc);
   520 
   511 
   521 
   512 
   522 (*quickcheck-test the mutants created by function mutate with type-instantiation insts, 
   513 (*quickcheck-test the mutants created by function mutate with type-instantiation insts, 
   523 quickcheck-theory usedthy and qciter quickcheck-iterations *)
   514 quickcheck-theory usedthy and qciter quickcheck-iterations *)
   736    |   mutthmrec ((name,thm)::xs) =
   727    |   mutthmrec ((name,thm)::xs) =
   737      let          
   728      let          
   738        val _ = priority ("mutthmrec: " ^ name);
   729        val _ = priority ("mutthmrec: " ^ name);
   739        val mutated = mutate option (prop_of thm) usedthy
   730        val mutated = mutate option (prop_of thm) usedthy
   740            commutatives forbidden_funs iter
   731            commutatives forbidden_funs iter
   741        val _ = (bar := mutated);
       
   742        val (passednum,_,cenum,_) = qc_test mutated insts usedthy sz qciter
   732        val (passednum,_,cenum,_) = qc_test mutated insts usedthy sz qciter
   743        val thmname =  "\ntheorem " ^ name ^ ":"
   733        val thmname =  "\ntheorem " ^ name ^ ":"
   744        val pnumstring = string_of_int passednum
   734        val pnumstring = string_of_int passednum
   745        val cenumstring = string_of_int cenum
   735        val cenumstring = string_of_int cenum
   746      in
   736      in