src/HOL/Tools/Sledgehammer/sledgehammer_atp_translate.ML
changeset 43017 944b19ab6003
parent 43001 f3492698dfc7
child 43039 b967219cec78
equal deleted inserted replaced
43016:42330f25142c 43017:944b19ab6003
   336 fun unmangled_const s =
   336 fun unmangled_const s =
   337   let val ss = space_explode mangled_type_sep s in
   337   let val ss = space_explode mangled_type_sep s in
   338     (hd ss, map unmangled_type (tl ss))
   338     (hd ss, map unmangled_type (tl ss))
   339   end
   339   end
   340 
   340 
   341 fun introduce_proxies format type_sys tm =
   341 fun introduce_proxies format type_sys =
   342   let
   342   let
   343     fun aux ary top_level (CombApp (tm1, tm2)) =
   343     fun intro top_level (CombApp (tm1, tm2)) =
   344         CombApp (aux (ary + 1) top_level tm1, aux 0 false tm2)
   344         CombApp (intro top_level tm1, intro false tm2)
   345       | aux ary top_level (CombConst (name as (s, _), T, T_args)) =
   345       | intro top_level (CombConst (name as (s, _), T, T_args)) =
   346         (case proxify_const s of
   346         (case proxify_const s of
   347            SOME (proxy_ary, proxy_base) =>
   347            SOME (_, proxy_base) =>
   348            if top_level orelse is_setting_higher_order format type_sys then
   348            if top_level orelse is_setting_higher_order format type_sys then
   349              case (top_level, s) of
   349              case (top_level, s) of
   350                (_, "c_False") => (`I tptp_false, [])
   350                (_, "c_False") => (`I tptp_false, [])
   351              | (_, "c_True") => (`I tptp_true, [])
   351              | (_, "c_True") => (`I tptp_true, [])
   352              | (false, "c_Not") => (`I tptp_not, [])
   352              | (false, "c_Not") => (`I tptp_not, [])
   353              | (false, "c_conj") => (`I tptp_and, [])
   353              | (false, "c_conj") => (`I tptp_and, [])
   354              | (false, "c_disj") => (`I tptp_or, [])
   354              | (false, "c_disj") => (`I tptp_or, [])
   355              | (false, "c_implies") => (`I tptp_implies, [])
   355              | (false, "c_implies") => (`I tptp_implies, [])
   356              | (false, s) =>
   356              | (false, s) =>
   357                (* Proxies are not needed in THF, but we generate them for "="
   357                if is_tptp_equal s then (`I tptp_equal, [])
   358                   when it is not fully applied to work around parsing bugs in
   358                else (proxy_base |>> prefix const_prefix, T_args)
   359                   the provers ("= @ x @ x" is challenging to some). *)
       
   360                if is_tptp_equal s andalso ary = proxy_ary then
       
   361                  (`I tptp_equal, [])
       
   362                else
       
   363                  (proxy_base |>> prefix const_prefix, T_args)
       
   364              | _ => (name, [])
   359              | _ => (name, [])
   365            else
   360            else
   366              (proxy_base |>> prefix const_prefix, T_args)
   361              (proxy_base |>> prefix const_prefix, T_args)
   367           | NONE => (name, T_args))
   362           | NONE => (name, T_args))
   368         |> (fn (name, T_args) => CombConst (name, T, T_args))
   363         |> (fn (name, T_args) => CombConst (name, T, T_args))
   369       | aux _ _ tm = tm
   364       | intro _ tm = tm
   370   in aux 0 true tm end
   365   in intro true end
   371 
   366 
   372 fun combformula_from_prop thy format type_sys eq_as_iff =
   367 fun combformula_from_prop thy format type_sys eq_as_iff =
   373   let
   368   let
   374     fun do_term bs t atomic_types =
   369     fun do_term bs t atomic_types =
   375       combterm_from_term thy bs (Envir.eta_contract t)
   370       combterm_from_term thy bs (Envir.eta_contract t)