src/HOL/Tools/ATP/atp_translate.ML
changeset 44786 815afb08c079
parent 44785 f4975fa4a2f8
child 44810 c1c05a578c1a
equal deleted inserted replaced
44785:f4975fa4a2f8 44786:815afb08c079
  1359   in add true end
  1359   in add true end
  1360 fun add_fact_syms_to_table ctxt explicit_apply =
  1360 fun add_fact_syms_to_table ctxt explicit_apply =
  1361   K (add_iterm_syms_to_table ctxt explicit_apply)
  1361   K (add_iterm_syms_to_table ctxt explicit_apply)
  1362   |> formula_fold NONE |> fact_lift
  1362   |> formula_fold NONE |> fact_lift
  1363 
  1363 
  1364 val default_sym_tab_entries : (string * sym_info) list =
  1364 fun default_sym_tab_entries type_enc =
  1365   (prefixed_predicator_name,
       
  1366    {pred_sym = true, min_ary = 1, max_ary = 1, types = []})
       
  1367        (* FIXME: needed? *) ::
       
  1368   (make_fixed_const NONE @{const_name undefined},
  1365   (make_fixed_const NONE @{const_name undefined},
  1369    {pred_sym = false, min_ary = 0, max_ary = 0, types = []}) ::
  1366                    {pred_sym = false, min_ary = 0, max_ary = 0, types = []}) ::
  1370   ([tptp_false, tptp_true]
  1367   ([tptp_false, tptp_true]
  1371    |> map (rpair {pred_sym = true, min_ary = 0, max_ary = 0, types = []})) @
  1368    |> map (rpair {pred_sym = true, min_ary = 0, max_ary = 0, types = []})) @
  1372   ([tptp_equal, tptp_old_equal]
  1369   ([tptp_equal, tptp_old_equal]
  1373    |> map (rpair {pred_sym = true, min_ary = 2, max_ary = 2, types = []}))
  1370    |> map (rpair {pred_sym = true, min_ary = 2, max_ary = 2, types = []}))
  1374 
  1371   |> not (is_type_enc_higher_order type_enc)
  1375 fun sym_table_for_facts ctxt explicit_apply facts =
  1372      ? cons (prefixed_predicator_name,
       
  1373              {pred_sym = true, min_ary = 1, max_ary = 1, types = []})
       
  1374 
       
  1375 fun sym_table_for_facts ctxt type_enc explicit_apply facts =
  1376   ((false, []), Symtab.empty)
  1376   ((false, []), Symtab.empty)
  1377   |> fold (add_fact_syms_to_table ctxt explicit_apply) facts |> snd
  1377   |> fold (add_fact_syms_to_table ctxt explicit_apply) facts |> snd
  1378   |> fold Symtab.update default_sym_tab_entries
  1378   |> fold Symtab.update (default_sym_tab_entries type_enc)
  1379 
  1379 
  1380 fun min_ary_of sym_tab s =
  1380 fun min_ary_of sym_tab s =
  1381   case Symtab.lookup sym_tab s of
  1381   case Symtab.lookup sym_tab s of
  1382     SOME ({min_ary, ...} : sym_info) => min_ary
  1382     SOME ({min_ary, ...} : sym_info) => min_ary
  1383   | NONE =>
  1383   | NONE =>
  1871     Symtab.empty
  1871     Symtab.empty
  1872     |> is_type_enc_fairly_sound type_enc
  1872     |> is_type_enc_fairly_sound type_enc
  1873        ? (fold (add_fact_syms true) conjs
  1873        ? (fold (add_fact_syms true) conjs
  1874           #> fold (add_fact_syms false) facts
  1874           #> fold (add_fact_syms false) facts
  1875           #> (case type_enc of
  1875           #> (case type_enc of
  1876                 Simple_Types (_, poly, _) =>
  1876                 Simple_Types (First_Order, Polymorphic, _) => add_TYPE_const ()
  1877                 if poly = Polymorphic then add_TYPE_const () else I
  1877               | Simple_Types _ => I
  1878               | _ => fold add_undefined_const (var_types ())))
  1878               | _ => fold add_undefined_const (var_types ())))
  1879   end
  1879   end
  1880 
  1880 
  1881 (* We add "bool" in case the helper "True_or_False" is included later. *)
  1881 (* We add "bool" in case the helper "True_or_False" is included later. *)
  1882 fun default_mono level =
  1882 fun default_mono level =
  2203         error ("Unknown lambda translation method: " ^
  2203         error ("Unknown lambda translation method: " ^
  2204                quote lambda_trans ^ ".")
  2204                quote lambda_trans ^ ".")
  2205     val (fact_names, classes, conjs, facts, class_rel_clauses, arity_clauses) =
  2205     val (fact_names, classes, conjs, facts, class_rel_clauses, arity_clauses) =
  2206       translate_formulas ctxt format prem_kind type_enc trans_lambdas preproc
  2206       translate_formulas ctxt format prem_kind type_enc trans_lambdas preproc
  2207                          hyp_ts concl_t facts
  2207                          hyp_ts concl_t facts
  2208     val sym_tab = conjs @ facts |> sym_table_for_facts ctxt explicit_apply
  2208     val sym_tab =
       
  2209       conjs @ facts |> sym_table_for_facts ctxt type_enc explicit_apply
  2209     val mono = conjs @ facts |> mononotonicity_info_for_facts ctxt type_enc
  2210     val mono = conjs @ facts |> mononotonicity_info_for_facts ctxt type_enc
  2210     val firstorderize = firstorderize_fact thy format type_enc sym_tab
  2211     val firstorderize = firstorderize_fact thy format type_enc sym_tab
  2211     val (conjs, facts) = (conjs, facts) |> pairself (map firstorderize)
  2212     val (conjs, facts) = (conjs, facts) |> pairself (map firstorderize)
  2212     val sym_tab = conjs @ facts |> sym_table_for_facts ctxt (SOME false)
  2213     val sym_tab =
       
  2214       conjs @ facts |> sym_table_for_facts ctxt type_enc (SOME false)
  2213     val helpers =
  2215     val helpers =
  2214       sym_tab |> helper_facts_for_sym_table ctxt format type_enc
  2216       sym_tab |> helper_facts_for_sym_table ctxt format type_enc
  2215               |> map firstorderize
  2217               |> map firstorderize
  2216     val mono_Ts =
  2218     val mono_Ts =
  2217       helpers @ conjs @ facts
  2219       helpers @ conjs @ facts