changeset 45639 | a7bc1bdb8bb4 |
parent 45618 | 265174356212 |
child 45641 | 3b1b4d805441 |
45638:233f30abb040 | 45639:a7bc1bdb8bb4 |
---|---|
20 Local | Assum | Chained |
20 Local | Assum | Chained |
21 |
21 |
22 datatype order = First_Order | Higher_Order |
22 datatype order = First_Order | Higher_Order |
23 datatype polymorphism = Polymorphic | Raw_Monomorphic | Mangled_Monomorphic |
23 datatype polymorphism = Polymorphic | Raw_Monomorphic | Mangled_Monomorphic |
24 datatype soundness = Sound_Modulo_Infiniteness | Sound |
24 datatype soundness = Sound_Modulo_Infiniteness | Sound |
25 datatype uniformity = Uniform | Nonuniform |
|
25 datatype type_level = |
26 datatype type_level = |
26 All_Types | |
27 All_Types | |
27 Noninf_Nonmono_Types of soundness | |
28 Noninf_Nonmono_Types of soundness * uniformity | |
28 Fin_Nonmono_Types | |
29 Fin_Nonmono_Types of uniformity | |
29 Const_Arg_Types | |
30 Const_Arg_Types | |
30 No_Types |
31 No_Types |
31 datatype type_uniformity = Uniform | Nonuniform |
|
32 |
32 |
33 datatype type_enc = |
33 datatype type_enc = |
34 Simple_Types of order * polymorphism * type_level | |
34 Simple_Types of order * polymorphism * type_level | |
35 Guards of polymorphism * type_level * type_uniformity | |
35 Guards of polymorphism * type_level | |
36 Tags of polymorphism * type_level * type_uniformity |
36 Tags of polymorphism * type_level |
37 |
37 |
38 val type_tag_idempotence : bool Config.T |
38 val type_tag_idempotence : bool Config.T |
39 val type_tag_arguments : bool Config.T |
39 val type_tag_arguments : bool Config.T |
40 val no_lambdasN : string |
40 val no_lambdasN : string |
41 val concealedN : string |
41 val concealedN : string |
84 val invert_const : string -> string |
84 val invert_const : string -> string |
85 val unproxify_const : string -> string |
85 val unproxify_const : string -> string |
86 val new_skolem_var_name_from_const : string -> string |
86 val new_skolem_var_name_from_const : string -> string |
87 val atp_irrelevant_consts : string list |
87 val atp_irrelevant_consts : string list |
88 val atp_schematic_consts_of : term -> typ list Symtab.table |
88 val atp_schematic_consts_of : term -> typ list Symtab.table |
89 val type_enc_from_string : soundness -> string -> type_enc |
|
90 val is_type_enc_higher_order : type_enc -> bool |
89 val is_type_enc_higher_order : type_enc -> bool |
91 val polymorphism_of_type_enc : type_enc -> polymorphism |
90 val polymorphism_of_type_enc : type_enc -> polymorphism |
92 val level_of_type_enc : type_enc -> type_level |
91 val level_of_type_enc : type_enc -> type_level |
93 val is_type_enc_quasi_sound : type_enc -> bool |
92 val is_type_enc_quasi_sound : type_enc -> bool |
94 val is_type_enc_fairly_sound : type_enc -> bool |
93 val is_type_enc_fairly_sound : type_enc -> bool |
94 val type_enc_from_string : soundness -> string -> type_enc |
|
95 val adjust_type_enc : tptp_format -> type_enc -> type_enc |
95 val adjust_type_enc : tptp_format -> type_enc -> type_enc |
96 val mk_aconns : |
96 val mk_aconns : |
97 connective -> ('a, 'b, 'c) formula list -> ('a, 'b, 'c) formula |
97 connective -> ('a, 'b, 'c) formula list -> ('a, 'b, 'c) formula |
98 val unmangled_const : string -> string * (string, 'b) ho_term list |
98 val unmangled_const : string -> string * (string, 'b) ho_term list |
99 val unmangled_const_name : string -> string |
99 val unmangled_const_name : string -> string |
535 Local | Assum | Chained |
535 Local | Assum | Chained |
536 |
536 |
537 datatype order = First_Order | Higher_Order |
537 datatype order = First_Order | Higher_Order |
538 datatype polymorphism = Polymorphic | Raw_Monomorphic | Mangled_Monomorphic |
538 datatype polymorphism = Polymorphic | Raw_Monomorphic | Mangled_Monomorphic |
539 datatype soundness = Sound_Modulo_Infiniteness | Sound |
539 datatype soundness = Sound_Modulo_Infiniteness | Sound |
540 datatype uniformity = Uniform | Nonuniform |
|
540 datatype type_level = |
541 datatype type_level = |
541 All_Types | |
542 All_Types | |
542 Noninf_Nonmono_Types of soundness | |
543 Noninf_Nonmono_Types of soundness * uniformity | |
543 Fin_Nonmono_Types | |
544 Fin_Nonmono_Types of uniformity | |
544 Const_Arg_Types | |
545 Const_Arg_Types | |
545 No_Types |
546 No_Types |
546 datatype type_uniformity = Uniform | Nonuniform |
|
547 |
547 |
548 datatype type_enc = |
548 datatype type_enc = |
549 Simple_Types of order * polymorphism * type_level | |
549 Simple_Types of order * polymorphism * type_level | |
550 Guards of polymorphism * type_level * type_uniformity | |
550 Guards of polymorphism * type_level | |
551 Tags of polymorphism * type_level * type_uniformity |
551 Tags of polymorphism * type_level |
552 |
|
553 fun is_type_enc_higher_order (Simple_Types (Higher_Order, _, _)) = true |
|
554 | is_type_enc_higher_order _ = false |
|
555 |
|
556 fun polymorphism_of_type_enc (Simple_Types (_, poly, _)) = poly |
|
557 | polymorphism_of_type_enc (Guards (poly, _)) = poly |
|
558 | polymorphism_of_type_enc (Tags (poly, _)) = poly |
|
559 |
|
560 fun level_of_type_enc (Simple_Types (_, _, level)) = level |
|
561 | level_of_type_enc (Guards (_, level)) = level |
|
562 | level_of_type_enc (Tags (_, level)) = level |
|
563 |
|
564 fun is_level_uniform (Noninf_Nonmono_Types (_, Nonuniform)) = false |
|
565 | is_level_uniform (Fin_Nonmono_Types Nonuniform) = false |
|
566 | is_level_uniform _ = true |
|
567 |
|
568 fun is_type_level_quasi_sound All_Types = true |
|
569 | is_type_level_quasi_sound (Noninf_Nonmono_Types _) = true |
|
570 | is_type_level_quasi_sound _ = false |
|
571 val is_type_enc_quasi_sound = is_type_level_quasi_sound o level_of_type_enc |
|
572 |
|
573 fun is_type_level_fairly_sound (Fin_Nonmono_Types _) = true |
|
574 | is_type_level_fairly_sound level = is_type_level_quasi_sound level |
|
575 val is_type_enc_fairly_sound = is_type_level_fairly_sound o level_of_type_enc |
|
576 |
|
577 fun is_type_level_monotonicity_based (Noninf_Nonmono_Types _) = true |
|
578 | is_type_level_monotonicity_based (Fin_Nonmono_Types _) = true |
|
579 | is_type_level_monotonicity_based _ = false |
|
552 |
580 |
553 fun try_unsuffixes ss s = |
581 fun try_unsuffixes ss s = |
554 fold (fn s' => fn NONE => try (unsuffix s') s | some => some) ss NONE |
582 fold (fn s' => fn NONE => try (unsuffix s') s | some => some) ss NONE |
583 |
|
584 val queries = ["?", "_query"] |
|
585 val bangs = ["!", "_bang"] |
|
555 |
586 |
556 fun type_enc_from_string soundness s = |
587 fun type_enc_from_string soundness s = |
557 (case try (unprefix "poly_") s of |
588 (case try (unprefix "poly_") s of |
558 SOME s => (SOME Polymorphic, s) |
589 SOME s => (SOME Polymorphic, s) |
559 | NONE => |
590 | NONE => |
564 SOME s => (SOME Mangled_Monomorphic, s) |
595 SOME s => (SOME Mangled_Monomorphic, s) |
565 | NONE => (NONE, s)) |
596 | NONE => (NONE, s)) |
566 ||> (fn s => |
597 ||> (fn s => |
567 (* "_query" and "_bang" are for the ASCII-challenged Metis and |
598 (* "_query" and "_bang" are for the ASCII-challenged Metis and |
568 Mirabelle. *) |
599 Mirabelle. *) |
569 case try_unsuffixes ["?", "_query"] s of |
600 case try_unsuffixes queries s of |
570 SOME s => (Noninf_Nonmono_Types soundness, s) |
601 SOME s => |
602 (case try_unsuffixes queries s of |
|
603 SOME s => (Noninf_Nonmono_Types (soundness, Nonuniform), s) |
|
604 | NONE => (Noninf_Nonmono_Types (soundness, Uniform), s)) |
|
571 | NONE => |
605 | NONE => |
572 case try_unsuffixes ["!", "_bang"] s of |
606 case try_unsuffixes bangs s of |
573 SOME s => (Fin_Nonmono_Types, s) |
607 SOME s => |
608 (case try_unsuffixes bangs s of |
|
609 SOME s => (Fin_Nonmono_Types Nonuniform, s) |
|
610 | NONE => (Fin_Nonmono_Types Uniform, s)) |
|
574 | NONE => (All_Types, s)) |
611 | NONE => (All_Types, s)) |
575 ||> apsnd (fn s => |
612 |> (fn (poly, (level, core)) => |
576 case try (unsuffix "_uniform") s of |
613 case (core, (poly, level)) of |
577 SOME s => (Uniform, s) |
614 ("simple", (SOME poly, _)) => |
578 | NONE => (Nonuniform, s)) |
|
579 |> (fn (poly, (level, (uniformity, core))) => |
|
580 case (core, (poly, level, uniformity)) of |
|
581 ("simple", (SOME poly, _, Nonuniform)) => |
|
582 (case (poly, level) of |
615 (case (poly, level) of |
583 (Polymorphic, All_Types) => |
616 (Polymorphic, All_Types) => |
584 Simple_Types (First_Order, Polymorphic, All_Types) |
617 Simple_Types (First_Order, Polymorphic, All_Types) |
585 | (Mangled_Monomorphic, _) => |
618 | (Mangled_Monomorphic, _) => |
586 Simple_Types (First_Order, Mangled_Monomorphic, level) |
619 if is_level_uniform level then |
620 Simple_Types (First_Order, Mangled_Monomorphic, level) |
|
621 else |
|
622 raise Same.SAME |
|
587 | _ => raise Same.SAME) |
623 | _ => raise Same.SAME) |
588 | ("simple_higher", (SOME poly, _, Nonuniform)) => |
624 | ("simple_higher", (SOME poly, _)) => |
589 (case (poly, level) of |
625 (case (poly, level) of |
590 (Polymorphic, All_Types) => |
626 (Polymorphic, All_Types) => |
591 Simple_Types (Higher_Order, Polymorphic, All_Types) |
627 Simple_Types (Higher_Order, Polymorphic, All_Types) |
592 | (_, Noninf_Nonmono_Types _) => raise Same.SAME |
628 | (_, Noninf_Nonmono_Types _) => raise Same.SAME |
593 | (Mangled_Monomorphic, _) => |
629 | (Mangled_Monomorphic, _) => |
594 Simple_Types (Higher_Order, Mangled_Monomorphic, level) |
630 if is_level_uniform level then |
631 Simple_Types (Higher_Order, Mangled_Monomorphic, level) |
|
632 else |
|
633 raise Same.SAME |
|
595 | _ => raise Same.SAME) |
634 | _ => raise Same.SAME) |
596 | ("guards", (SOME poly, _, _)) => Guards (poly, level, uniformity) |
635 | ("guards", (SOME poly, _)) => Guards (poly, level) |
597 | ("tags", (SOME Polymorphic, _, _)) => |
636 | ("tags", (SOME Polymorphic, _)) => Tags (Polymorphic, level) |
598 Tags (Polymorphic, level, uniformity) |
637 | ("tags", (SOME poly, _)) => Tags (poly, level) |
599 | ("tags", (SOME poly, _, _)) => Tags (poly, level, uniformity) |
638 | ("args", (SOME poly, All_Types (* naja *))) => |
600 | ("args", (SOME poly, All_Types (* naja *), Nonuniform)) => |
639 Guards (poly, Const_Arg_Types) |
601 Guards (poly, Const_Arg_Types, Nonuniform) |
640 | ("erased", (NONE, All_Types (* naja *))) => |
602 | ("erased", (NONE, All_Types (* naja *), Nonuniform)) => |
641 Guards (Polymorphic, No_Types) |
603 Guards (Polymorphic, No_Types, Nonuniform) |
|
604 | _ => raise Same.SAME) |
642 | _ => raise Same.SAME) |
605 handle Same.SAME => error ("Unknown type system: " ^ quote s ^ ".") |
643 handle Same.SAME => error ("Unknown type system: " ^ quote s ^ ".") |
606 |
|
607 fun is_type_enc_higher_order (Simple_Types (Higher_Order, _, _)) = true |
|
608 | is_type_enc_higher_order _ = false |
|
609 |
|
610 fun polymorphism_of_type_enc (Simple_Types (_, poly, _)) = poly |
|
611 | polymorphism_of_type_enc (Guards (poly, _, _)) = poly |
|
612 | polymorphism_of_type_enc (Tags (poly, _, _)) = poly |
|
613 |
|
614 fun level_of_type_enc (Simple_Types (_, _, level)) = level |
|
615 | level_of_type_enc (Guards (_, level, _)) = level |
|
616 | level_of_type_enc (Tags (_, level, _)) = level |
|
617 |
|
618 fun uniformity_of_type_enc (Simple_Types _) = Uniform |
|
619 | uniformity_of_type_enc (Guards (_, _, uniformity)) = uniformity |
|
620 | uniformity_of_type_enc (Tags (_, _, uniformity)) = uniformity |
|
621 |
|
622 fun is_type_level_quasi_sound All_Types = true |
|
623 | is_type_level_quasi_sound (Noninf_Nonmono_Types _) = true |
|
624 | is_type_level_quasi_sound _ = false |
|
625 val is_type_enc_quasi_sound = |
|
626 is_type_level_quasi_sound o level_of_type_enc |
|
627 |
|
628 fun is_type_level_fairly_sound level = |
|
629 is_type_level_quasi_sound level orelse level = Fin_Nonmono_Types |
|
630 val is_type_enc_fairly_sound = is_type_level_fairly_sound o level_of_type_enc |
|
631 |
|
632 fun is_type_level_monotonicity_based (Noninf_Nonmono_Types _) = true |
|
633 | is_type_level_monotonicity_based Fin_Nonmono_Types = true |
|
634 | is_type_level_monotonicity_based _ = false |
|
635 |
644 |
636 fun adjust_type_enc (THF (TPTP_Monomorphic, _, _)) |
645 fun adjust_type_enc (THF (TPTP_Monomorphic, _, _)) |
637 (Simple_Types (order, _, level)) = |
646 (Simple_Types (order, _, level)) = |
638 Simple_Types (order, Mangled_Monomorphic, level) |
647 Simple_Types (order, Mangled_Monomorphic, level) |
639 | adjust_type_enc (THF _) type_enc = type_enc |
648 | adjust_type_enc (THF _) type_enc = type_enc |
640 | adjust_type_enc (TFF (TPTP_Monomorphic, _)) (Simple_Types (_, _, level)) = |
649 | adjust_type_enc (TFF (TPTP_Monomorphic, _)) (Simple_Types (_, _, level)) = |
641 Simple_Types (First_Order, Mangled_Monomorphic, level) |
650 Simple_Types (First_Order, Mangled_Monomorphic, level) |
642 | adjust_type_enc (TFF _) (Simple_Types (_, poly, level)) = |
651 | adjust_type_enc (TFF _) (Simple_Types (_, poly, level)) = |
643 Simple_Types (First_Order, poly, level) |
652 Simple_Types (First_Order, poly, level) |
644 | adjust_type_enc format (Simple_Types (_, poly, level)) = |
653 | adjust_type_enc format (Simple_Types (_, poly, level)) = |
645 adjust_type_enc format (Guards (poly, level, Uniform)) |
654 adjust_type_enc format (Guards (poly, level)) |
646 | adjust_type_enc CNF_UEQ (type_enc as Guards stuff) = |
655 | adjust_type_enc CNF_UEQ (type_enc as Guards stuff) = |
647 (if is_type_enc_fairly_sound type_enc then Tags else Guards) stuff |
656 (if is_type_enc_fairly_sound type_enc then Tags else Guards) stuff |
648 | adjust_type_enc _ type_enc = type_enc |
657 | adjust_type_enc _ type_enc = type_enc |
649 |
658 |
650 fun lift_lambdas ctxt type_enc = |
659 fun lift_lambdas ctxt type_enc = |
696 Mangled_Type_Args of bool | |
705 Mangled_Type_Args of bool | |
697 No_Type_Args |
706 No_Type_Args |
698 |
707 |
699 fun should_drop_arg_type_args (Simple_Types _) = false |
708 fun should_drop_arg_type_args (Simple_Types _) = false |
700 | should_drop_arg_type_args type_enc = |
709 | should_drop_arg_type_args type_enc = |
701 level_of_type_enc type_enc = All_Types andalso |
710 level_of_type_enc type_enc = All_Types |
702 uniformity_of_type_enc type_enc = Uniform |
|
703 |
711 |
704 fun type_arg_policy type_enc s = |
712 fun type_arg_policy type_enc s = |
705 if s = type_tag_name then |
713 if s = type_tag_name then |
706 (if polymorphism_of_type_enc type_enc = Mangled_Monomorphic then |
714 (if polymorphism_of_type_enc type_enc = Mangled_Monomorphic then |
707 Mangled_Type_Args |
715 Mangled_Type_Args |
708 else |
716 else |
709 Explicit_Type_Args) false |
717 Explicit_Type_Args) false |
710 else case type_enc of |
718 else case type_enc of |
711 Tags (_, All_Types, Uniform) => No_Type_Args |
719 Tags (_, All_Types) => No_Type_Args |
712 | _ => |
720 | _ => |
713 let val level = level_of_type_enc type_enc in |
721 let val level = level_of_type_enc type_enc in |
714 if level = No_Types orelse s = @{const_name HOL.eq} orelse |
722 if level = No_Types orelse s = @{const_name HOL.eq} orelse |
715 (s = app_op_name andalso level = Const_Arg_Types) then |
723 (s = app_op_name andalso level = Const_Arg_Types) then |
716 No_Type_Args |
724 No_Type_Args |
1152 models in first-order logic (via Löwenheim-Skolem). *) |
1160 models in first-order logic (via Löwenheim-Skolem). *) |
1153 |
1161 |
1154 fun should_encode_type _ (_ : monotonicity_info) All_Types _ = true |
1162 fun should_encode_type _ (_ : monotonicity_info) All_Types _ = true |
1155 | should_encode_type ctxt {maybe_finite_Ts, surely_infinite_Ts, |
1163 | should_encode_type ctxt {maybe_finite_Ts, surely_infinite_Ts, |
1156 maybe_nonmono_Ts, ...} |
1164 maybe_nonmono_Ts, ...} |
1157 (Noninf_Nonmono_Types soundness) T = |
1165 (Noninf_Nonmono_Types (soundness, _)) T = |
1158 exists (type_intersect ctxt T) maybe_nonmono_Ts andalso |
1166 exists (type_intersect ctxt T) maybe_nonmono_Ts andalso |
1159 not (exists (type_instance ctxt T) surely_infinite_Ts orelse |
1167 not (exists (type_instance ctxt T) surely_infinite_Ts orelse |
1160 (not (member (type_aconv ctxt) maybe_finite_Ts T) andalso |
1168 (not (member (type_aconv ctxt) maybe_finite_Ts T) andalso |
1161 is_type_kind_of_surely_infinite ctxt soundness surely_infinite_Ts T)) |
1169 is_type_kind_of_surely_infinite ctxt soundness surely_infinite_Ts T)) |
1162 | should_encode_type ctxt {surely_finite_Ts, maybe_infinite_Ts, |
1170 | should_encode_type ctxt {surely_finite_Ts, maybe_infinite_Ts, |
1163 maybe_nonmono_Ts, ...} |
1171 maybe_nonmono_Ts, ...} |
1164 Fin_Nonmono_Types T = |
1172 (Fin_Nonmono_Types _) T = |
1165 exists (type_intersect ctxt T) maybe_nonmono_Ts andalso |
1173 exists (type_intersect ctxt T) maybe_nonmono_Ts andalso |
1166 (exists (type_generalization ctxt T) surely_finite_Ts orelse |
1174 (exists (type_generalization ctxt T) surely_finite_Ts orelse |
1167 (not (member (type_aconv ctxt) maybe_infinite_Ts T) andalso |
1175 (not (member (type_aconv ctxt) maybe_infinite_Ts T) andalso |
1168 is_type_surely_finite ctxt T)) |
1176 is_type_surely_finite ctxt T)) |
1169 | should_encode_type _ _ _ _ = false |
1177 | should_encode_type _ _ _ _ = false |
1170 |
1178 |
1171 fun should_guard_type ctxt mono (Guards (_, level, uniformity)) should_guard_var |
1179 fun should_guard_type ctxt mono (Guards (_, level)) should_guard_var T = |
1172 T = |
1180 (is_level_uniform level orelse should_guard_var ()) andalso |
1173 (uniformity = Uniform orelse should_guard_var ()) andalso |
|
1174 should_encode_type ctxt mono level T |
1181 should_encode_type ctxt mono level T |
1175 | should_guard_type _ _ _ _ _ = false |
1182 | should_guard_type _ _ _ _ _ = false |
1176 |
1183 |
1177 fun is_maybe_universal_var (IConst ((s, _), _, _)) = |
1184 fun is_maybe_universal_var (IConst ((s, _), _, _)) = |
1178 String.isPrefix bound_var_prefix s orelse |
1185 String.isPrefix bound_var_prefix s orelse |
1184 Top_Level of bool option | |
1191 Top_Level of bool option | |
1185 Eq_Arg of bool option | |
1192 Eq_Arg of bool option | |
1186 Elsewhere |
1193 Elsewhere |
1187 |
1194 |
1188 fun should_tag_with_type _ _ _ (Top_Level _) _ _ = false |
1195 fun should_tag_with_type _ _ _ (Top_Level _) _ _ = false |
1189 | should_tag_with_type ctxt mono (Tags (_, level, uniformity)) site u T = |
1196 | should_tag_with_type ctxt mono (Tags (_, level)) site u T = |
1190 (case uniformity of |
1197 (if is_level_uniform level then |
1191 Uniform => should_encode_type ctxt mono level T |
1198 should_encode_type ctxt mono level T |
1192 | Nonuniform => |
1199 else case (site, is_maybe_universal_var u) of |
1193 case (site, is_maybe_universal_var u) of |
1200 (Eq_Arg _, true) => should_encode_type ctxt mono level T |
1194 (Eq_Arg _, true) => should_encode_type ctxt mono level T |
1201 | _ => false) |
1195 | _ => false) |
|
1196 | should_tag_with_type _ _ _ _ _ _ = false |
1202 | should_tag_with_type _ _ _ _ _ _ = false |
1197 |
1203 |
1198 fun fused_type ctxt mono level = |
1204 fun fused_type ctxt mono level = |
1199 let |
1205 let |
1200 val should_encode = should_encode_type ctxt mono level |
1206 val should_encode = should_encode_type ctxt mono level |
1634 fun should_guard_var_in_formula pos phi (SOME true) name = |
1640 fun should_guard_var_in_formula pos phi (SOME true) name = |
1635 formula_fold pos (is_var_positively_naked_in_term name) phi false |
1641 formula_fold pos (is_var_positively_naked_in_term name) phi false |
1636 | should_guard_var_in_formula _ _ _ _ = true |
1642 | should_guard_var_in_formula _ _ _ _ = true |
1637 |
1643 |
1638 fun should_generate_tag_bound_decl _ _ _ (SOME true) _ = false |
1644 fun should_generate_tag_bound_decl _ _ _ (SOME true) _ = false |
1639 | should_generate_tag_bound_decl ctxt mono (Tags (_, level, Nonuniform)) _ T = |
1645 | should_generate_tag_bound_decl ctxt mono (Tags (_, level)) _ T = |
1640 should_encode_type ctxt mono level T |
1646 not (is_level_uniform level) andalso should_encode_type ctxt mono level T |
1641 | should_generate_tag_bound_decl _ _ _ _ _ = false |
1647 | should_generate_tag_bound_decl _ _ _ _ _ = false |
1642 |
1648 |
1643 fun mk_aterm format type_enc name T_args args = |
1649 fun mk_aterm format type_enc name T_args args = |
1644 ATerm (name, map_filter (ho_term_for_type_arg format type_enc) T_args @ args) |
1650 ATerm (name, map_filter (ho_term_for_type_arg format type_enc) T_args @ args) |
1645 |
1651 |
1868 {maybe_finite_Ts = [@{typ bool}], |
1874 {maybe_finite_Ts = [@{typ bool}], |
1869 surely_finite_Ts = [@{typ bool}], |
1875 surely_finite_Ts = [@{typ bool}], |
1870 maybe_infinite_Ts = known_infinite_types, |
1876 maybe_infinite_Ts = known_infinite_types, |
1871 surely_infinite_Ts = |
1877 surely_infinite_Ts = |
1872 case level of |
1878 case level of |
1873 Noninf_Nonmono_Types Sound => [] |
1879 Noninf_Nonmono_Types (Sound, _) => [] |
1874 | _ => known_infinite_types, |
1880 | _ => known_infinite_types, |
1875 maybe_nonmono_Ts = [@{typ bool}]} |
1881 maybe_nonmono_Ts = [@{typ bool}]} |
1876 |
1882 |
1877 (* This inference is described in section 2.3 of Claessen et al.'s "Sorting it |
1883 (* This inference is described in section 2.3 of Claessen et al.'s "Sorting it |
1878 out with monotonicity" paper presented at CADE 2011. *) |
1884 out with monotonicity" paper presented at CADE 2011. *) |
1881 (IApp (IApp (IConst ((s, _), Type (_, [T, _]), _), tm1), tm2)) |
1887 (IApp (IApp (IConst ((s, _), Type (_, [T, _]), _), tm1), tm2)) |
1882 (mono as {maybe_finite_Ts, surely_finite_Ts, maybe_infinite_Ts, |
1888 (mono as {maybe_finite_Ts, surely_finite_Ts, maybe_infinite_Ts, |
1883 surely_infinite_Ts, maybe_nonmono_Ts}) = |
1889 surely_infinite_Ts, maybe_nonmono_Ts}) = |
1884 if is_tptp_equal s andalso exists is_maybe_universal_var [tm1, tm2] then |
1890 if is_tptp_equal s andalso exists is_maybe_universal_var [tm1, tm2] then |
1885 case level of |
1891 case level of |
1886 Noninf_Nonmono_Types soundness => |
1892 Noninf_Nonmono_Types (soundness, _) => |
1887 if exists (type_instance ctxt T) surely_infinite_Ts orelse |
1893 if exists (type_instance ctxt T) surely_infinite_Ts orelse |
1888 member (type_aconv ctxt) maybe_finite_Ts T then |
1894 member (type_aconv ctxt) maybe_finite_Ts T then |
1889 mono |
1895 mono |
1890 else if is_type_kind_of_surely_infinite ctxt soundness |
1896 else if is_type_kind_of_surely_infinite ctxt soundness |
1891 surely_infinite_Ts T then |
1897 surely_infinite_Ts T then |
1898 {maybe_finite_Ts = maybe_finite_Ts |> insert (type_aconv ctxt) T, |
1904 {maybe_finite_Ts = maybe_finite_Ts |> insert (type_aconv ctxt) T, |
1899 surely_finite_Ts = surely_finite_Ts, |
1905 surely_finite_Ts = surely_finite_Ts, |
1900 maybe_infinite_Ts = maybe_infinite_Ts, |
1906 maybe_infinite_Ts = maybe_infinite_Ts, |
1901 surely_infinite_Ts = surely_infinite_Ts, |
1907 surely_infinite_Ts = surely_infinite_Ts, |
1902 maybe_nonmono_Ts = maybe_nonmono_Ts |> insert_type ctxt I T} |
1908 maybe_nonmono_Ts = maybe_nonmono_Ts |> insert_type ctxt I T} |
1903 | Fin_Nonmono_Types => |
1909 | Fin_Nonmono_Types _ => |
1904 if exists (type_instance ctxt T) surely_finite_Ts orelse |
1910 if exists (type_instance ctxt T) surely_finite_Ts orelse |
1905 member (type_aconv ctxt) maybe_infinite_Ts T then |
1911 member (type_aconv ctxt) maybe_infinite_Ts T then |
1906 mono |
1912 mono |
1907 else if is_type_surely_finite ctxt T then |
1913 else if is_type_surely_finite ctxt T then |
1908 {maybe_finite_Ts = maybe_finite_Ts, |
1914 {maybe_finite_Ts = maybe_finite_Ts, |
2087 fun problem_lines_for_sym_decls ctxt format conj_sym_kind mono type_enc |
2093 fun problem_lines_for_sym_decls ctxt format conj_sym_kind mono type_enc |
2088 (s, decls) = |
2094 (s, decls) = |
2089 case type_enc of |
2095 case type_enc of |
2090 Simple_Types _ => |
2096 Simple_Types _ => |
2091 decls |> map (decl_line_for_sym ctxt format mono type_enc s) |
2097 decls |> map (decl_line_for_sym ctxt format mono type_enc s) |
2092 | Guards (_, level, _) => |
2098 | Guards (_, level) => |
2093 let |
2099 let |
2094 val decls = |
2100 val decls = |
2095 case decls of |
2101 case decls of |
2096 decl :: (decls' as _ :: _) => |
2102 decl :: (decls' as _ :: _) => |
2097 let val T = result_type_of_decl decl in |
2103 let val T = result_type_of_decl decl in |
2109 in |
2115 in |
2110 (0 upto length decls - 1, decls) |
2116 (0 upto length decls - 1, decls) |
2111 |-> map2 (formula_line_for_guards_sym_decl ctxt format conj_sym_kind mono |
2117 |-> map2 (formula_line_for_guards_sym_decl ctxt format conj_sym_kind mono |
2112 type_enc n s) |
2118 type_enc n s) |
2113 end |
2119 end |
2114 | Tags (_, _, uniformity) => |
2120 | Tags (_, level) => |
2115 (case uniformity of |
2121 if is_level_uniform level then |
2116 Uniform => [] |
2122 [] |
2117 | Nonuniform => |
2123 else |
2118 let val n = length decls in |
2124 let val n = length decls in |
2119 (0 upto n - 1 ~~ decls) |
2125 (0 upto n - 1 ~~ decls) |
2120 |> maps (formula_lines_for_nonuniform_tags_sym_decl ctxt format |
2126 |> maps (formula_lines_for_nonuniform_tags_sym_decl ctxt format |
2121 conj_sym_kind mono type_enc n s) |
2127 conj_sym_kind mono type_enc n s) |
2122 end) |
2128 end |
2123 |
2129 |
2124 fun problem_lines_for_sym_decl_table ctxt format conj_sym_kind mono type_enc |
2130 fun problem_lines_for_sym_decl_table ctxt format conj_sym_kind mono type_enc |
2125 mono_Ts sym_decl_tab = |
2131 mono_Ts sym_decl_tab = |
2126 let |
2132 let |
2127 val syms = sym_decl_tab |> Symtab.dest |> sort_wrt fst |
2133 val syms = sym_decl_tab |> Symtab.dest |> sort_wrt fst |
2131 fold_rev (append o problem_lines_for_sym_decls ctxt format conj_sym_kind |
2137 fold_rev (append o problem_lines_for_sym_decls ctxt format conj_sym_kind |
2132 mono type_enc) |
2138 mono type_enc) |
2133 syms [] |
2139 syms [] |
2134 in mono_lines @ decl_lines end |
2140 in mono_lines @ decl_lines end |
2135 |
2141 |
2136 fun needs_type_tag_idempotence ctxt (Tags (poly, level, uniformity)) = |
2142 fun needs_type_tag_idempotence ctxt (Tags (poly, level)) = |
2137 Config.get ctxt type_tag_idempotence andalso |
2143 Config.get ctxt type_tag_idempotence andalso |
2138 poly <> Mangled_Monomorphic andalso |
2144 is_type_level_monotonicity_based level andalso |
2139 ((level = All_Types andalso uniformity = Nonuniform) orelse |
2145 poly <> Mangled_Monomorphic |
2140 is_type_level_monotonicity_based level) |
|
2141 | needs_type_tag_idempotence _ _ = false |
2146 | needs_type_tag_idempotence _ _ = false |
2142 |
2147 |
2143 fun offset_of_heading_in_problem _ [] j = j |
2148 fun offset_of_heading_in_problem _ [] j = j |
2144 | offset_of_heading_in_problem needle ((heading, lines) :: problem) j = |
2149 | offset_of_heading_in_problem needle ((heading, lines) :: problem) j = |
2145 if heading = needle then j |
2150 if heading = needle then j |