65 val arity_clause_prefix : string |
63 val arity_clause_prefix : string |
66 val tfree_clause_prefix : string |
64 val tfree_clause_prefix : string |
67 val lam_fact_prefix : string |
65 val lam_fact_prefix : string |
68 val typed_helper_suffix : string |
66 val typed_helper_suffix : string |
69 val untyped_helper_suffix : string |
67 val untyped_helper_suffix : string |
70 val type_tag_idempotence_helper_name : string |
|
71 val predicator_name : string |
68 val predicator_name : string |
72 val app_op_name : string |
69 val app_op_name : string |
73 val type_guard_name : string |
70 val type_guard_name : string |
74 val type_tag_name : string |
71 val type_tag_name : string |
75 val native_type_prefix : string |
72 val native_type_prefix : string |
117 open ATP_Util |
114 open ATP_Util |
118 open ATP_Problem |
115 open ATP_Problem |
119 |
116 |
120 type name = string * string |
117 type name = string * string |
121 |
118 |
122 val type_tag_idempotence = |
|
123 Attrib.setup_config_bool @{binding atp_type_tag_idempotence} (K false) |
|
124 val type_tag_arguments = |
|
125 Attrib.setup_config_bool @{binding atp_type_tag_arguments} (K false) |
|
126 |
|
127 val no_lamsN = "no_lams" (* used internally; undocumented *) |
119 val no_lamsN = "no_lams" (* used internally; undocumented *) |
128 val hide_lamsN = "hide_lams" |
120 val hide_lamsN = "hide_lams" |
129 val liftingN = "lifting" |
121 val liftingN = "lifting" |
130 val combsN = "combs" |
122 val combsN = "combs" |
131 val combs_and_liftingN = "combs_and_lifting" |
123 val combs_and_liftingN = "combs_and_lifting" |
176 val tfree_clause_prefix = "tfree_" |
168 val tfree_clause_prefix = "tfree_" |
177 |
169 |
178 val lam_fact_prefix = "ATP.lambda_" |
170 val lam_fact_prefix = "ATP.lambda_" |
179 val typed_helper_suffix = "_T" |
171 val typed_helper_suffix = "_T" |
180 val untyped_helper_suffix = "_U" |
172 val untyped_helper_suffix = "_U" |
181 val type_tag_idempotence_helper_name = helper_prefix ^ "ti_idem" |
|
182 |
173 |
183 val predicator_name = "pp" |
174 val predicator_name = "pp" |
184 val app_op_name = "aa" |
175 val app_op_name = "aa" |
185 val type_guard_name = "gg" |
176 val type_guard_name = "gg" |
186 val type_tag_name = "tt" |
177 val type_tag_name = "tt" |
1669 |
1660 |
1670 fun rank_of_fact_num n j = min_rank + (max_rank - min_rank) * j div n |
1661 fun rank_of_fact_num n j = min_rank + (max_rank - min_rank) * j div n |
1671 |
1662 |
1672 val type_tag = `(make_fixed_const NONE) type_tag_name |
1663 val type_tag = `(make_fixed_const NONE) type_tag_name |
1673 |
1664 |
1674 fun type_tag_idempotence_fact type_enc = |
|
1675 let |
|
1676 fun var s = ATerm (`I s, []) |
|
1677 fun tag tm = ATerm (type_tag, [var "A", tm]) |
|
1678 val tagged_var = tag (var "X") |
|
1679 in |
|
1680 Formula (type_tag_idempotence_helper_name, Axiom, |
|
1681 eq_formula type_enc [] [] false (tag tagged_var) tagged_var, |
|
1682 NONE, isabelle_info spec_eqN helper_rank) |
|
1683 end |
|
1684 |
|
1685 fun should_specialize_helper type_enc t = |
1665 fun should_specialize_helper type_enc t = |
1686 polymorphism_of_type_enc type_enc <> Polymorphic andalso |
1666 polymorphism_of_type_enc type_enc <> Polymorphic andalso |
1687 level_of_type_enc type_enc <> No_Types andalso |
1667 level_of_type_enc type_enc <> No_Types andalso |
1688 not (null (Term.hidden_polymorphism t)) |
1668 not (null (Term.hidden_polymorphism t)) |
1689 |
1669 |
2359 eq (tag_with res_T (cst bounds)) (cst tagged_bounds), |
2339 eq (tag_with res_T (cst bounds)) (cst tagged_bounds), |
2360 NONE, isabelle_info spec_eqN helper_rank)) |
2340 NONE, isabelle_info spec_eqN helper_rank)) |
2361 end |
2341 end |
2362 else |
2342 else |
2363 I |
2343 I |
2364 fun add_formula_for_arg k = |
2344 in [] |> not pred_sym ? add_formula_for_res end |
2365 let val arg_T = nth arg_Ts k in |
|
2366 if should_encode arg_T then |
|
2367 case chop k bounds of |
|
2368 (bounds1, bound :: bounds2) => |
|
2369 cons (Formula (ident_base ^ "_arg" ^ string_of_int (k + 1), kind, |
|
2370 eq (cst (bounds1 @ tag_with arg_T bound :: bounds2)) |
|
2371 (cst bounds), |
|
2372 NONE, isabelle_info spec_eqN helper_rank)) |
|
2373 | _ => raise Fail "expected nonempty tail" |
|
2374 else |
|
2375 I |
|
2376 end |
|
2377 in |
|
2378 [] |> not pred_sym ? add_formula_for_res |
|
2379 |> (Config.get ctxt type_tag_arguments andalso |
|
2380 grain = Positively_Naked_Vars) |
|
2381 ? fold add_formula_for_arg (ary - 1 downto 0) |
|
2382 end |
|
2383 |
2345 |
2384 fun result_type_of_decl (_, _, T, _, ary, _) = chop_fun ary T |> snd |
2346 fun result_type_of_decl (_, _, T, _, ary, _) = chop_fun ary T |> snd |
2385 |
2347 |
2386 fun rationalize_decls ctxt (decls as decl :: (decls' as _ :: _)) = |
2348 fun rationalize_decls ctxt (decls as decl :: (decls' as _ :: _)) = |
2387 let |
2349 let |
2504 ? Symtab.fold_rev |
2466 ? Symtab.fold_rev |
2505 (pair_append |
2467 (pair_append |
2506 o uncurried_alias_lines_for_sym ctxt monom_constrs format |
2468 o uncurried_alias_lines_for_sym ctxt monom_constrs format |
2507 conj_sym_kind mono type_enc sym_tab0 sym_tab) sym_tab |
2469 conj_sym_kind mono type_enc sym_tab0 sym_tab) sym_tab |
2508 |
2470 |
2509 fun needs_type_tag_idempotence ctxt (Tags (poly, level)) = |
|
2510 Config.get ctxt type_tag_idempotence andalso |
|
2511 is_type_level_monotonicity_based level andalso |
|
2512 poly <> Mangled_Monomorphic |
|
2513 | needs_type_tag_idempotence _ _ = false |
|
2514 |
|
2515 val implicit_declsN = "Should-be-implicit typings" |
2471 val implicit_declsN = "Should-be-implicit typings" |
2516 val explicit_declsN = "Explicit typings" |
2472 val explicit_declsN = "Explicit typings" |
2517 val uncurried_alias_eqsN = "Uncurried aliases" |
2473 val uncurried_alias_eqsN = "Uncurried aliases" |
2518 val factsN = "Relevant facts" |
2474 val factsN = "Relevant facts" |
2519 val class_relsN = "Class relationships" |
2475 val class_relsN = "Class relationships" |
2657 (0 upto num_facts - 1 ~~ facts) |
2613 (0 upto num_facts - 1 ~~ facts) |
2658 val helper_lines = |
2614 val helper_lines = |
2659 0 upto length helpers - 1 ~~ helpers |
2615 0 upto length helpers - 1 ~~ helpers |
2660 |> map (formula_line_for_fact ctxt polym_constrs format helper_prefix I |
2616 |> map (formula_line_for_fact ctxt polym_constrs format helper_prefix I |
2661 false true mono type_enc (K default_rank)) |
2617 false true mono type_enc (K default_rank)) |
2662 |> (if needs_type_tag_idempotence ctxt type_enc then |
|
2663 cons (type_tag_idempotence_fact type_enc) |
|
2664 else |
|
2665 I) |
|
2666 (* Reordering these might confuse the proof reconstruction code or the SPASS |
2618 (* Reordering these might confuse the proof reconstruction code or the SPASS |
2667 FLOTTER hack. *) |
2619 FLOTTER hack. *) |
2668 val problem = |
2620 val problem = |
2669 [(explicit_declsN, class_decl_lines @ sym_decl_lines), |
2621 [(explicit_declsN, class_decl_lines @ sym_decl_lines), |
2670 (uncurried_alias_eqsN, uncurried_alias_eq_lines), |
2622 (uncurried_alias_eqsN, uncurried_alias_eq_lines), |