src/HOL/Tools/Sledgehammer/sledgehammer.ML
changeset 38102 019a49759829
parent 38100 e458a0dd3dc1
child 38105 373351f5f834
equal deleted inserted replaced
38101:34b75b71235d 38102:019a49759829
    67 open Sledgehammer_Proof_Reconstruct
    67 open Sledgehammer_Proof_Reconstruct
    68 
    68 
    69 
    69 
    70 (** The Sledgehammer **)
    70 (** The Sledgehammer **)
    71 
    71 
       
    72 (* Identifier to distinguish Sledgehammer from other tools using
       
    73    "Async_Manager". *)
    72 val das_Tool = "Sledgehammer"
    74 val das_Tool = "Sledgehammer"
       
    75 
       
    76 (* Freshness almost guaranteed! *)
       
    77 val sledgehammer_weak_prefix = "Sledgehammer:"
    73 
    78 
    74 fun kill_atps () = Async_Manager.kill_threads das_Tool "ATPs"
    79 fun kill_atps () = Async_Manager.kill_threads das_Tool "ATPs"
    75 fun running_atps () = Async_Manager.running_threads das_Tool "ATPs"
    80 fun running_atps () = Async_Manager.running_threads das_Tool "ATPs"
    76 val messages = Async_Manager.thread_messages das_Tool "ATP"
    81 val messages = Async_Manager.thread_messages das_Tool "ATP"
    77 
    82 
   232 fun presimplify_term thy =
   237 fun presimplify_term thy =
   233   Skip_Proof.make_thm thy
   238   Skip_Proof.make_thm thy
   234   #> Meson.presimplify
   239   #> Meson.presimplify
   235   #> prop_of
   240   #> prop_of
   236 
   241 
   237 (* Freshness almost guaranteed! *)
   242 fun concealed_bound_name j = sledgehammer_weak_prefix ^ Int.toString j
   238 fun concealed_bound_name j = das_Tool ^ Int.toString j
       
   239 fun conceal_bounds Ts t =
   243 fun conceal_bounds Ts t =
   240   subst_bounds (map (Free o apfst concealed_bound_name)
   244   subst_bounds (map (Free o apfst concealed_bound_name)
   241                     (length Ts - 1 downto 0 ~~ rev Ts), t)
   245                     (0 upto length Ts - 1 ~~ Ts), t)
   242 fun reveal_bounds Ts =
   246 fun reveal_bounds Ts =
   243   subst_atomic (map (fn (j, T) => (Free (concealed_bound_name j, T), Bound j))
   247   subst_atomic (map (fn (j, T) => (Free (concealed_bound_name j, T), Bound j))
   244                     (0 upto length Ts - 1 ~~ Ts))
   248                     (0 upto length Ts - 1 ~~ Ts))
   245 
   249 
   246 fun introduce_combinators_in_term ctxt kind t =
   250 fun introduce_combinators_in_term ctxt kind t =
   285 fun freeze_term t =
   289 fun freeze_term t =
   286   let
   290   let
   287     fun aux (t $ u) = aux t $ aux u
   291     fun aux (t $ u) = aux t $ aux u
   288       | aux (Abs (s, T, t)) = Abs (s, T, aux t)
   292       | aux (Abs (s, T, t)) = Abs (s, T, aux t)
   289       | aux (Var ((s, i), T)) =
   293       | aux (Var ((s, i), T)) =
   290         Free (das_Tool ^ "_" ^ s ^ "_" ^ string_of_int i, T)
   294         Free (sledgehammer_weak_prefix ^ s ^ "_" ^ string_of_int i, T)
   291       | aux t = t
   295       | aux t = t
   292   in t |> exists_subterm is_Var t ? aux end
   296   in t |> exists_subterm is_Var t ? aux end
   293 
   297 
   294 (* making axiom and conjecture formulas *)
   298 (* making axiom and conjecture formulas *)
   295 fun make_formula ctxt presimp (formula_name, kind, t) =
   299 fun make_formula ctxt presimp (formula_name, kind, t) =