src/HOL/Tools/Sledgehammer/sledgehammer_atp_translate.ML
changeset 42564 d40bdf941a9a
parent 42563 e70ffe3846d0
child 42565 93f58e6a6f3e
equal deleted inserted replaced
42563:e70ffe3846d0 42564:d40bdf941a9a
   754   | strip_and_map_type _ _ _ = raise Fail "unexpected non-function"
   754   | strip_and_map_type _ _ _ = raise Fail "unexpected non-function"
   755 
   755 
   756 fun problem_line_for_typed_const ctxt type_sys sym_tab s j (s', ty_args, T) =
   756 fun problem_line_for_typed_const ctxt type_sys sym_tab s j (s', ty_args, T) =
   757   let val ary = min_arity_of sym_tab s in
   757   let val ary = min_arity_of sym_tab s in
   758     if type_sys = Many_Typed then
   758     if type_sys = Many_Typed then
   759       let
   759       let val (arg_Ts, res_T) = strip_and_map_type ary mangled_type_name T in
   760         val (arg_Ts, res_T) = strip_and_map_type ary mangled_type_name T
       
   761         val (s, s') = (s, s') |> mangled_const_name ty_args
       
   762       in
       
   763         Decl (sym_decl_prefix ^ ascii_of s, (s, s'), arg_Ts,
   760         Decl (sym_decl_prefix ^ ascii_of s, (s, s'), arg_Ts,
   764               (* ### FIXME: put that in typed_const_tab *)
   761               (* ### FIXME: put that in typed_const_tab *)
   765               if is_pred_sym sym_tab s then `I tff_bool_type else res_T)
   762               if is_pred_sym sym_tab s then `I tff_bool_type else res_T)
   766       end
   763       end
   767     else
   764     else
   768       let
   765       let
   769         val (arg_Ts, res_T) = strip_and_map_type ary I T
   766         val (arg_Ts, res_T) = strip_and_map_type ary I T
   770         val bounds =
   767         val bound_names =
   771           map (`I o make_bound_var o string_of_int) (1 upto length arg_Ts)
   768           1 upto length arg_Ts |> map (`I o make_bound_var o string_of_int)
   772           ~~ map SOME arg_Ts
       
   773         val bound_tms =
   769         val bound_tms =
   774           map (fn (name, T) => CombConst (name, the T, [])) bounds
   770           bound_names ~~ arg_Ts |> map (fn (name, T) => CombConst (name, T, []))
       
   771         val bound_Ts =
       
   772           arg_Ts |> map (case type_sys of Mangled _ => K NONE | _ => SOME)
   775         val freshener =
   773         val freshener =
   776           case type_sys of Args _ => string_of_int j ^ "_" | _ => ""
   774           case type_sys of Args _ => string_of_int j ^ "_" | _ => ""
   777       in
   775       in
   778         Formula (Fof, sym_decl_prefix ^ freshener ^ "_" ^ ascii_of s, Axiom,
   776         Formula (Fof, sym_decl_prefix ^ freshener ^ "_" ^ ascii_of s, Axiom,
   779                  CombConst ((s, s'), T, ty_args)
   777                  CombConst ((s, s'), T, ty_args)
   780                  |> fold (curry (CombApp o swap)) bound_tms
   778                  |> fold (curry (CombApp o swap)) bound_tms
   781                  |> type_pred_combatom type_sys res_T
   779                  |> type_pred_combatom type_sys res_T
   782                  |> mk_aquant AForall bounds
   780                  |> mk_aquant AForall (bound_names ~~ bound_Ts)
   783                  |> formula_from_combformula ctxt type_sys,
   781                  |> formula_from_combformula ctxt type_sys,
   784                  NONE, NONE)
   782                  NONE, NONE)
   785       end
   783       end
   786   end
   784   end
   787 fun problem_lines_for_sym_decl ctxt type_sys sym_tab (s, xs) =
   785 fun problem_lines_for_sym_decl ctxt type_sys sym_tab (s, xs) =