src/HOL/Mutabelle/mutabelle_extra.ML
changeset 41190 0bdc6fac5f48
parent 41106 09037a02f5ec
child 41408 08a072ca6348
equal deleted inserted replaced
41189:ba1eac745c5a 41190:0bdc6fac5f48
    25 val solve_direct_mtd : mtd
    25 val solve_direct_mtd : mtd
    26 val try_mtd : mtd
    26 val try_mtd : mtd
    27 (*
    27 (*
    28 val sledgehammer_mtd : mtd
    28 val sledgehammer_mtd : mtd
    29 *)
    29 *)
       
    30 val nitpick_mtd : mtd
       
    31 
    30 (*
    32 (*
    31 val refute_mtd : mtd
    33 val refute_mtd : mtd
    32 val nitpick_mtd : mtd
       
    33 *)
    34 *)
    34 
    35 
    35 val freezeT : term -> term
    36 val freezeT : term -> term
    36 val thms_of : bool -> theory -> thm list
    37 val thms_of : bool -> theory -> thm list
    37 
    38 
   184          (error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^
   185          (error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^
   185                    "."))
   186                    "."))
   186 val refute_mtd = ("refute", invoke_refute)
   187 val refute_mtd = ("refute", invoke_refute)
   187 *)
   188 *)
   188 
   189 
   189 (*
   190 (** nitpick **)
   190 open Nitpick_Util
       
   191 open Nitpick_Rep
       
   192 open Nitpick_Nut
       
   193 
   191 
   194 fun invoke_nitpick thy t =
   192 fun invoke_nitpick thy t =
   195   let
   193   let
   196     val ctxt = ProofContext.init_global thy
   194     val ctxt = ProofContext.init_global thy
   197     val state = Proof.init ctxt
   195     val state = Proof.init ctxt
   198   in
   196     val (res, _) = Nitpick.pick_nits_in_term state
   199     let
   197       (Nitpick_Isar.default_params thy []) false 1 1 1 [] [] t
   200       val (res, _) = Nitpick.pick_nits_in_term state (Nitpick_Isar.default_params thy []) false [] t
   198     val _ = Output.urgent_message ("Nitpick: " ^ res)
   201       val _ = Output.urgent_message ("Nitpick: " ^ res)
   199   in
   202     in
   200     rpair ([], NONE) (case res of
   203       case res of
   201       "genuine" => GenuineCex
   204         "genuine" => GenuineCex
   202     | "likely_genuine" => GenuineCex
   205       | "likely_genuine" => GenuineCex
   203     | "potential" => PotentialCex
   206       | "potential" => PotentialCex
   204     | "none" => NoCex
   207       | "none" => NoCex
   205     | "unknown" => Donno
   208       | "unknown" => Donno
   206     | _ => Error)
   209       | _ => Error
   207   end
   210     end
   208 
   211     handle ARG (loc, details) =>
       
   212            (error ("Bad argument(s) to " ^ quote loc ^ ": " ^ details ^ "."))
       
   213          | BAD (loc, details) =>
       
   214            (error ("Internal error (" ^ quote loc ^ "): " ^ details ^ "."))
       
   215          | LIMIT (_, details) =>
       
   216            (warning ("Limit reached: " ^ details ^ "."); Donno)
       
   217          | NOT_SUPPORTED details =>
       
   218            (warning ("Unsupported case: " ^ details ^ "."); Donno)
       
   219          | NUT (loc, us) =>
       
   220            (error ("Invalid nut" ^ plural_s_for_list us ^
       
   221                    " (" ^ quote loc ^ "): " ^
       
   222                   commas (map (string_for_nut ctxt) us) ^ "."))
       
   223          | REP (loc, Rs) =>
       
   224            (error ("Invalid representation" ^ plural_s_for_list Rs ^
       
   225                    " (" ^ quote loc ^ "): " ^
       
   226                    commas (map string_for_rep Rs) ^ "."))
       
   227          | TERM (loc, ts) =>
       
   228            (error ("Invalid term" ^ plural_s_for_list ts ^
       
   229                    " (" ^ quote loc ^ "): " ^
       
   230                    commas (map (Syntax.string_of_term ctxt) ts) ^ "."))
       
   231          | TYPE (loc, Ts, ts) =>
       
   232            (error ("Invalid type" ^ plural_s_for_list Ts ^
       
   233                    (if null ts then
       
   234                       ""
       
   235                     else
       
   236                       " for term" ^ plural_s_for_list ts ^ " " ^
       
   237                       commas (map (quote o Syntax.string_of_term ctxt) ts)) ^
       
   238                    " (" ^ quote loc ^ "): " ^
       
   239                    commas (map (Syntax.string_of_typ ctxt) Ts) ^ "."))
       
   240          | Kodkod.SYNTAX (_, details) =>
       
   241            (warning ("Ill-formed Kodkodi output: " ^ details ^ "."); Error)
       
   242          | Refute.REFUTE (loc, details) =>
       
   243            (error ("Unhandled Refute error (" ^ quote loc ^ "): " ^ details ^
       
   244                    "."))
       
   245          | Exn.Interrupt => raise Exn.Interrupt  (* FIXME violates Isabelle/ML exception model *)
       
   246          | _ => (Output.urgent_message ("Unknown error in Nitpick"); Error)
       
   247   end
       
   248 val nitpick_mtd = ("nitpick", invoke_nitpick)
   209 val nitpick_mtd = ("nitpick", invoke_nitpick)
   249 *)
       
   250 
   210 
   251 (* filtering forbidden theorems and mutants *)
   211 (* filtering forbidden theorems and mutants *)
   252 
   212 
   253 val comms = [@{const_name HOL.eq}, @{const_name HOL.disj}, @{const_name HOL.conj}]
   213 val comms = [@{const_name HOL.eq}, @{const_name HOL.disj}, @{const_name HOL.conj}]
   254 
   214