src/HOL/Mutabelle/lib/Tools/mutabelle
changeset 46453 9e83b7c24b05
parent 46452 e4f1cda51df6
child 46454 d72ab6bf6e6d
equal deleted inserted replaced
46452:e4f1cda51df6 46453:9e83b7c24b05
    15   echo "  Options are:"
    15   echo "  Options are:"
    16   echo "    -L LOGIC     parent logic to use (default $MUTABELLE_LOGIC)"
    16   echo "    -L LOGIC     parent logic to use (default $MUTABELLE_LOGIC)"
    17   echo "    -T THEORY    parent theory to use (default $MUTABELLE_IMPORT_THEORY)"
    17   echo "    -T THEORY    parent theory to use (default $MUTABELLE_IMPORT_THEORY)"
    18   echo "    -O DIR       output directory for test data (default $MUTABELLE_OUTPUT_PATH)"
    18   echo "    -O DIR       output directory for test data (default $MUTABELLE_OUTPUT_PATH)"
    19   echo "    -N NUMBER    number of lemmas to choose randomly, if not given all lemmas are chosen"
    19   echo "    -N NUMBER    number of lemmas to choose randomly, if not given all lemmas are chosen"
       
    20   echo "    -M NUMBER    number of mutants for each lemma (default $MUTABELLE_NUMBER_OF_MUTANTS)"
    20   echo
    21   echo
    21   echo "  THEORY is the name of the theory of which all theorems should be"
    22   echo "  THEORY is the name of the theory of which all theorems should be"
    22   echo "  mutated and tested."
    23   echo "  mutated and tested."
    23   echo
    24   echo
    24   exit 1
    25   exit 1
    29 
    30 
    30 # options
    31 # options
    31 
    32 
    32 MUTABELLE_IMPORTS=""
    33 MUTABELLE_IMPORTS=""
    33 
    34 
    34 while getopts "L:T:O:N:" OPT
    35 while getopts "L:T:O:N:M:" OPT
    35 do
    36 do
    36   case "$OPT" in
    37   case "$OPT" in
    37     L)
    38     L)
    38       MUTABELLE_LOGIC="$OPTARG"
    39       MUTABELLE_LOGIC="$OPTARG"
    39       ;;
    40       ;;
    43     O)      
    44     O)      
    44       MUTABELLE_OUTPUT_PATH="$OPTARG"
    45       MUTABELLE_OUTPUT_PATH="$OPTARG"
    45       ;;
    46       ;;
    46     N)
    47     N)
    47       NUMBER_OF_LEMMAS="$OPTARG"
    48       NUMBER_OF_LEMMAS="$OPTARG"
       
    49       ;;
       
    50     M)
       
    51       MUTABELLE_NUMBER_OF_MUTANTS="$OPTARG"
    48       ;;
    52       ;;
    49     \?)
    53     \?)
    50       usage
    54       usage
    51       ;;
    55       ;;
    52   esac
    56   esac
    93 declare [[quickcheck_timeout = 30]]
    97 declare [[quickcheck_timeout = 30]]
    94 
    98 
    95 ML {*
    99 ML {*
    96 val mtds = [
   100 val mtds = [
    97   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"random\"])) \"random\",
   101   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"random\"])) \"random\",
       
   102   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"random\"]) #> Config.put Quickcheck.finite_types false) \"random_int\",
    98   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"exhaustive\"])) \"exhaustive\",
   103   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"exhaustive\"])) \"exhaustive\",
    99   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"exhaustive\"]) #> Config.put Quickcheck.finite_types false) \"exhaustive_no_finite_types\",
   104   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"exhaustive\"]) #> Config.put Quickcheck.finite_types false) \"exhaustive_int\",
   100   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"narrowing\"]) #> Config.put Quickcheck.finite_types true) \"narrowing\",
   105   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"narrowing\"]) #> Config.put Quickcheck.finite_types true) \"narrowing\",
   101   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"narrowing\"]) #> Config.put Quickcheck.finite_types false) \"narrowing_no_finite_types\",
   106   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"narrowing\"]) #> Config.put Quickcheck.finite_types false) \"narrowing_int\",
   102   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"narrowing\"]) #> Config.put Quickcheck.finite_types false
   107   MutabelleExtra.quickcheck_mtd (Context.proof_map (Quickcheck.set_active_testers [\"narrowing\"]) #> Config.put Quickcheck.finite_types false
   103     #> Context.proof_map (Quickcheck.map_test_params (apfst (K [@{typ nat}])))) \"narrowing_nat\"
   108     #> Context.proof_map (Quickcheck.map_test_params (apfst (K [@{typ nat}])))) \"narrowing_nat\"
   104 
       
   105 (*, MutabelleExtra.refute_mtd, *)
   109 (*, MutabelleExtra.refute_mtd, *)
   106   , MutabelleExtra.nitpick_mtd
   110   , MutabelleExtra.nitpick_mtd
   107 
   111 
   108 ]
   112 ]
   109 *}
   113 *}
   111 ML {*
   115 ML {*
   112 fun mutation_testing_of thy =
   116 fun mutation_testing_of thy =
   113   (MutabelleExtra.random_seed := 1.0;
   117   (MutabelleExtra.random_seed := 1.0;
   114   MutabelleExtra.thms_of false thy $MUTABELLE_FILTER 
   118   MutabelleExtra.thms_of false thy $MUTABELLE_FILTER 
   115   |> (fn thms => MutabelleExtra.mutate_theorems_and_write_report
   119   |> (fn thms => MutabelleExtra.mutate_theorems_and_write_report
   116          @{theory} mtds thms (\"$MUTABELLE_OUTPUT_PATH/log\")))
   120          @{theory} $MUTABELLE_NUMBER_OF_MUTANTS mtds thms (\"$MUTABELLE_OUTPUT_PATH/log\")))
   117 *}
   121 *}
   118 
   122 
   119 ML {*
   123 ML {*
   120   mutation_testing_of @{theory $MUTABELLE_TEST_THEORY}
   124   mutation_testing_of @{theory $MUTABELLE_TEST_THEORY}
   121 *}
   125 *}