equal
deleted
inserted
replaced
639 |
639 |
640 (** "hBOOL" and "hAPP" **) |
640 (** "hBOOL" and "hAPP" **) |
641 |
641 |
642 type repair_info = {pred_sym: bool, min_arity: int, max_arity: int} |
642 type repair_info = {pred_sym: bool, min_arity: int, max_arity: int} |
643 |
643 |
644 fun consider_combterm_for_repair explicit_apply = |
644 fun add_combterm_to_sym_table explicit_apply = |
645 let |
645 let |
646 fun aux top_level tm = |
646 fun aux top_level tm = |
647 let val (head, args) = strip_combterm_comb tm in |
647 let val (head, args) = strip_combterm_comb tm in |
648 (case head of |
648 (case head of |
649 CombConst ((s, _), _, _) => |
649 CombConst ((s, _), _, _) => |
663 | _ => I) |
663 | _ => I) |
664 #> fold (aux false) args |
664 #> fold (aux false) args |
665 end |
665 end |
666 in aux true end |
666 in aux true end |
667 |
667 |
668 fun consider_fact_for_repair explicit_apply = |
668 val add_fact_to_sym_table = fact_lift o formula_fold o add_combterm_to_sym_table |
669 fact_lift (formula_fold (consider_combterm_for_repair explicit_apply)) |
|
670 |
669 |
671 (* The "equal" entry is needed for helper facts if the problem otherwise does |
670 (* The "equal" entry is needed for helper facts if the problem otherwise does |
672 not involve equality. The "$false" and $"true" entries are needed to ensure |
671 not involve equality. The "$false" and $"true" entries are needed to ensure |
673 that no "hBOOL" is introduced for them. The "hBOOL" entry is needed to ensure |
672 that no "hBOOL" is introduced for them. The "hBOOL" entry is needed to ensure |
674 that no "hAPP"s are introduced for passing arguments to it. *) |
673 that no "hAPP"s are introduced for passing arguments to it. *) |
679 (make_fixed_const boolify_base, |
678 (make_fixed_const boolify_base, |
680 {pred_sym = true, min_arity = 1, max_arity = 1})] |
679 {pred_sym = true, min_arity = 1, max_arity = 1})] |
681 |
680 |
682 fun sym_table_for_facts explicit_apply facts = |
681 fun sym_table_for_facts explicit_apply facts = |
683 Symtab.empty |> fold Symtab.default default_sym_table_entries |
682 Symtab.empty |> fold Symtab.default default_sym_table_entries |
684 |> fold (consider_fact_for_repair explicit_apply) facts |
683 |> fold (add_fact_to_sym_table explicit_apply) facts |
685 |
684 |
686 fun min_arity_of sym_tab s = |
685 fun min_arity_of sym_tab s = |
687 case Symtab.lookup sym_tab s of |
686 case Symtab.lookup sym_tab s of |
688 SOME ({min_arity, ...} : repair_info) => min_arity |
687 SOME ({min_arity, ...} : repair_info) => min_arity |
689 | NONE => |
688 | NONE => |
871 val helper_facts = |
870 val helper_facts = |
872 problem |> maps (map_filter (fn Formula (_, _, _, phi, _, _) => SOME phi |
871 problem |> maps (map_filter (fn Formula (_, _, _, phi, _, _) => SOME phi |
873 | _ => NONE) o snd) |
872 | _ => NONE) o snd) |
874 |> get_helper_facts ctxt type_sys |
873 |> get_helper_facts ctxt type_sys |
875 |>> map (repair_fact type_sys sym_tab) |
874 |>> map (repair_fact type_sys sym_tab) |
876 val sym_tab = sym_table_for_facts explicit_apply (conjs @ facts) |
875 val sym_tab = sym_table_for_facts false (conjs @ facts) |
877 val const_tab = const_table_for_facts type_sys sym_tab (conjs @ facts) |
876 val const_tab = const_table_for_facts type_sys sym_tab (conjs @ facts) |
878 val sym_decl_lines = |
877 val sym_decl_lines = |
879 Symtab.fold_rev (append o problem_lines_for_const ctxt type_sys sym_tab) |
878 Symtab.fold_rev (append o problem_lines_for_const ctxt type_sys sym_tab) |
880 const_tab [] |
879 const_tab [] |
881 val helper_lines = |
880 val helper_lines = |