43 val skolem_const_prefix : string |
43 val skolem_const_prefix : string |
44 val old_skolem_const_prefix : string |
44 val old_skolem_const_prefix : string |
45 val new_skolem_const_prefix : string |
45 val new_skolem_const_prefix : string |
46 val type_decl_prefix : string |
46 val type_decl_prefix : string |
47 val sym_decl_prefix : string |
47 val sym_decl_prefix : string |
48 val preds_sym_formula_prefix : string |
48 val guards_sym_formula_prefix : string |
49 val lightweight_tags_sym_formula_prefix : string |
49 val lightweight_tags_sym_formula_prefix : string |
50 val fact_prefix : string |
50 val fact_prefix : string |
51 val conjecture_prefix : string |
51 val conjecture_prefix : string |
52 val helper_prefix : string |
52 val helper_prefix : string |
53 val class_rel_clause_prefix : string |
53 val class_rel_clause_prefix : string |
552 ("simple", (NONE, _, Lightweight)) => |
552 ("simple", (NONE, _, Lightweight)) => |
553 Simple_Types (First_Order, level) |
553 Simple_Types (First_Order, level) |
554 | ("simple_higher", (NONE, _, Lightweight)) => |
554 | ("simple_higher", (NONE, _, Lightweight)) => |
555 if level = Noninf_Nonmono_Types then raise Same.SAME |
555 if level = Noninf_Nonmono_Types then raise Same.SAME |
556 else Simple_Types (Higher_Order, level) |
556 else Simple_Types (Higher_Order, level) |
557 | ("preds", (SOME poly, _, _)) => Preds (poly, level, heaviness) |
557 | ("guards", (SOME poly, _, _)) => Guards (poly, level, heaviness) |
558 | ("tags", (SOME Polymorphic, _, _)) => |
558 | ("tags", (SOME Polymorphic, _, _)) => |
559 Tags (Polymorphic, level, heaviness) |
559 Tags (Polymorphic, level, heaviness) |
560 | ("tags", (SOME poly, _, _)) => Tags (poly, level, heaviness) |
560 | ("tags", (SOME poly, _, _)) => Tags (poly, level, heaviness) |
561 | ("args", (SOME poly, All_Types (* naja *), Lightweight)) => |
561 | ("args", (SOME poly, All_Types (* naja *), Lightweight)) => |
562 Preds (poly, Const_Arg_Types, Lightweight) |
562 Guards (poly, Const_Arg_Types, Lightweight) |
563 | ("erased", (NONE, All_Types (* naja *), Lightweight)) => |
563 | ("erased", (NONE, All_Types (* naja *), Lightweight)) => |
564 Preds (Polymorphic, No_Types, Lightweight) |
564 Guards (Polymorphic, No_Types, Lightweight) |
565 | _ => raise Same.SAME) |
565 | _ => raise Same.SAME) |
566 handle Same.SAME => error ("Unknown type system: " ^ quote s ^ ".") |
566 handle Same.SAME => error ("Unknown type system: " ^ quote s ^ ".") |
567 |
567 |
568 fun is_type_enc_higher_order (Simple_Types (Higher_Order, _)) = true |
568 fun is_type_enc_higher_order (Simple_Types (Higher_Order, _)) = true |
569 | is_type_enc_higher_order _ = false |
569 | is_type_enc_higher_order _ = false |
570 |
570 |
571 fun polymorphism_of_type_enc (Simple_Types _) = Mangled_Monomorphic |
571 fun polymorphism_of_type_enc (Simple_Types _) = Mangled_Monomorphic |
572 | polymorphism_of_type_enc (Preds (poly, _, _)) = poly |
572 | polymorphism_of_type_enc (Guards (poly, _, _)) = poly |
573 | polymorphism_of_type_enc (Tags (poly, _, _)) = poly |
573 | polymorphism_of_type_enc (Tags (poly, _, _)) = poly |
574 |
574 |
575 fun level_of_type_enc (Simple_Types (_, level)) = level |
575 fun level_of_type_enc (Simple_Types (_, level)) = level |
576 | level_of_type_enc (Preds (_, level, _)) = level |
576 | level_of_type_enc (Guards (_, level, _)) = level |
577 | level_of_type_enc (Tags (_, level, _)) = level |
577 | level_of_type_enc (Tags (_, level, _)) = level |
578 |
578 |
579 fun heaviness_of_type_enc (Simple_Types _) = Heavyweight |
579 fun heaviness_of_type_enc (Simple_Types _) = Heavyweight |
580 | heaviness_of_type_enc (Preds (_, _, heaviness)) = heaviness |
580 | heaviness_of_type_enc (Guards (_, _, heaviness)) = heaviness |
581 | heaviness_of_type_enc (Tags (_, _, heaviness)) = heaviness |
581 | heaviness_of_type_enc (Tags (_, _, heaviness)) = heaviness |
582 |
582 |
583 fun is_type_level_virtually_sound level = |
583 fun is_type_level_virtually_sound level = |
584 level = All_Types orelse level = Noninf_Nonmono_Types |
584 level = All_Types orelse level = Noninf_Nonmono_Types |
585 val is_type_enc_virtually_sound = |
585 val is_type_enc_virtually_sound = |
593 if member (op =) formats THF then |
593 if member (op =) formats THF then |
594 (THF, Simple_Types (order, level)) |
594 (THF, Simple_Types (order, level)) |
595 else if member (op =) formats TFF then |
595 else if member (op =) formats TFF then |
596 (TFF, Simple_Types (First_Order, level)) |
596 (TFF, Simple_Types (First_Order, level)) |
597 else |
597 else |
598 choose_format formats (Preds (Mangled_Monomorphic, level, Heavyweight)) |
598 choose_format formats (Guards (Mangled_Monomorphic, level, Heavyweight)) |
599 | choose_format formats type_enc = |
599 | choose_format formats type_enc = |
600 (case hd formats of |
600 (case hd formats of |
601 CNF_UEQ => |
601 CNF_UEQ => |
602 (CNF_UEQ, case type_enc of |
602 (CNF_UEQ, case type_enc of |
603 Preds stuff => |
603 Guards stuff => |
604 (if is_type_enc_fairly_sound type_enc then Tags else Preds) |
604 (if is_type_enc_fairly_sound type_enc then Tags else Guards) |
605 stuff |
605 stuff |
606 | _ => type_enc) |
606 | _ => type_enc) |
607 | format => (format, type_enc)) |
607 | format => (format, type_enc)) |
608 |
608 |
609 type translated_formula = |
609 type translated_formula = |
1754 Decl (sym_decl_prefix ^ s, (s, s'), |
1754 Decl (sym_decl_prefix ^ s, (s, s'), |
1755 (T_arg_Ts ---> (T |> homogenized_type ctxt nonmono_Ts level ary)) |
1755 (T_arg_Ts ---> (T |> homogenized_type ctxt nonmono_Ts level ary)) |
1756 |> ho_type_from_typ format type_enc pred_sym (length T_arg_Ts + ary)) |
1756 |> ho_type_from_typ format type_enc pred_sym (length T_arg_Ts + ary)) |
1757 end |
1757 end |
1758 |
1758 |
1759 fun formula_line_for_preds_sym_decl ctxt format conj_sym_kind nonmono_Ts |
1759 fun formula_line_for_guards_sym_decl ctxt format conj_sym_kind nonmono_Ts |
1760 poly_nonmono_Ts type_enc n s j (s', T_args, T, _, ary, in_conj) = |
1760 poly_nonmono_Ts type_enc n s j (s', T_args, T, _, ary, in_conj) = |
1761 let |
1761 let |
1762 val (kind, maybe_negate) = |
1762 val (kind, maybe_negate) = |
1763 if in_conj then (conj_sym_kind, conj_sym_kind = Conjecture ? mk_anot) |
1763 if in_conj then (conj_sym_kind, conj_sym_kind = Conjecture ? mk_anot) |
1764 else (Axiom, I) |
1764 else (Axiom, I) |
1773 sym_needs_arg_types orelse |
1773 sym_needs_arg_types orelse |
1774 not (should_predicate_on_type ctxt nonmono_Ts type_enc (K false) T) |
1774 not (should_predicate_on_type ctxt nonmono_Ts type_enc (K false) T) |
1775 val bound_Ts = |
1775 val bound_Ts = |
1776 arg_Ts |> map (fn T => if should_keep_arg_type T then SOME T else NONE) |
1776 arg_Ts |> map (fn T => if should_keep_arg_type T then SOME T else NONE) |
1777 in |
1777 in |
1778 Formula (preds_sym_formula_prefix ^ s ^ |
1778 Formula (guards_sym_formula_prefix ^ s ^ |
1779 (if n > 1 then "_" ^ string_of_int j else ""), kind, |
1779 (if n > 1 then "_" ^ string_of_int j else ""), kind, |
1780 IConst ((s, s'), T, T_args) |
1780 IConst ((s, s'), T, T_args) |
1781 |> fold (curry (IApp o swap)) bounds |
1781 |> fold (curry (IApp o swap)) bounds |
1782 |> type_pred_iterm ctxt format type_enc res_T |
1782 |> type_pred_iterm ctxt format type_enc res_T |
1783 |> AAtom |> mk_aquant AForall (bound_names ~~ bound_Ts) |
1783 |> AAtom |> mk_aquant AForall (bound_names ~~ bound_Ts) |