133 else if File.exists (File.unpack_platform_path (!destdir)) |
133 else if File.exists (File.unpack_platform_path (!destdir)) |
134 then !destdir ^ "/" ^ file |
134 then !destdir ^ "/" ^ file |
135 else error ("No such directory: " ^ !destdir) |
135 else error ("No such directory: " ^ !destdir) |
136 end; |
136 end; |
137 |
137 |
138 val include_all = ref false; |
138 val include_all = ref true; |
139 val include_simpset = ref false; |
139 val include_simpset = ref false; |
140 val include_claset = ref false; |
140 val include_claset = ref false; |
141 val include_atpset = ref true; |
141 val include_atpset = ref true; |
142 |
142 |
143 (*Tests show that follow_defs gives VERY poor results with "include_all"*) |
143 (*Tests show that follow_defs gives VERY poor results with "include_all"*) |
552 fun mk_clause_table n = |
552 fun mk_clause_table n = |
553 Polyhash.mkTable (hash_term o prop_of, equal_thm) |
553 Polyhash.mkTable (hash_term o prop_of, equal_thm) |
554 (n, HASH_CLAUSE); |
554 (n, HASH_CLAUSE); |
555 |
555 |
556 (*Use a hash table to eliminate duplicates from xs. Argument is a list of |
556 (*Use a hash table to eliminate duplicates from xs. Argument is a list of |
557 (name, theorem) pairs, but the theorems are hashed into the table. *) |
557 (thm * (string * int)) tuples. The theorems are hashed into the table. *) |
558 fun make_unique xs = |
558 fun make_unique xs = |
|
559 let val ht = mk_clause_table 7000 |
|
560 in |
|
561 app (ignore o Polyhash.peekInsert ht) xs; |
|
562 Polyhash.listItems ht |
|
563 end; |
|
564 |
|
565 (*Remove existing axiom clauses from the conjecture clauses, as this can dramatically |
|
566 boost an ATP's performance (for some reason)*) |
|
567 fun subtract_cls c_clauses ax_clauses = |
559 let val ht = mk_clause_table 2200 |
568 let val ht = mk_clause_table 2200 |
|
569 fun known x = isSome (Polyhash.peek ht x) |
560 in |
570 in |
561 (app (ignore o Polyhash.peekInsert ht) (map swap xs); |
571 app (ignore o Polyhash.peekInsert ht) ax_clauses; |
562 map swap (Polyhash.listItems ht)) |
572 filter (not o known) c_clauses |
563 end; |
573 end; |
564 |
574 |
565 (*FIXME: SLOW!!!*) |
575 (*Filter axiom clauses, but keep supplied clauses and clauses in whitelist. |
566 fun mem_thm th [] = false |
576 Duplicates are removed later.*) |
567 | mem_thm th ((th',_)::thms_names) = equal_thm (th,th') orelse mem_thm th thms_names; |
|
568 |
|
569 (*FIXME: SLOW!!! These two functions are called only by get_relevant_clauses. |
|
570 It would be faster to compare names, rather than theorems, and to use |
|
571 a symbol table or hash table.*) |
|
572 fun insert_thms [] thms_names = thms_names |
|
573 | insert_thms ((thm,name)::thms_names) thms_names' = |
|
574 if mem_thm thm thms_names' then insert_thms thms_names thms_names' |
|
575 else insert_thms thms_names ((thm,name)::thms_names'); |
|
576 |
|
577 (* filter axiom clauses, but keep supplied clauses and clauses in whitelist *) |
|
578 fun get_relevant_clauses thy cls_thms white_cls goals = |
577 fun get_relevant_clauses thy cls_thms white_cls goals = |
579 insert_thms white_cls (ReduceAxiomsN.relevance_filter thy cls_thms goals); |
578 white_cls @ (ReduceAxiomsN.relevance_filter thy cls_thms goals); |
580 |
579 |
581 (*This name is cryptic but short. Unlike gensym, we get the same name each time.*) |
580 (*This name is cryptic but short. Unlike gensym, we get the same name each time.*) |
582 fun fake_thm_name th = |
581 fun fake_thm_name th = |
583 Context.theory_name (theory_of_thm th) ^ "." ^ Word.toString (full_hash_thm th); |
582 Context.theory_name (theory_of_thm th) ^ "." ^ Word.toString (full_hash_thm th); |
584 |
583 |
668 Auto => problem_logic_goals [map prop_of goal_cls] |
667 Auto => problem_logic_goals [map prop_of goal_cls] |
669 | Fol => FOL |
668 | Fol => FOL |
670 | Hol => HOL |
669 | Hol => HOL |
671 val (included_thms,user_rules) = get_clasimp_atp_lemmas ctxt user_thms |
670 val (included_thms,user_rules) = get_clasimp_atp_lemmas ctxt user_thms |
672 val cla_simp_atp_clauses = included_thms |> blacklist_filter |
671 val cla_simp_atp_clauses = included_thms |> blacklist_filter |
673 |> make_unique |> ResAxioms.cnf_rules_pairs |
672 |> ResAxioms.cnf_rules_pairs |> make_unique |
674 |> restrict_to_logic logic |
673 |> restrict_to_logic logic |
675 val user_cls = ResAxioms.cnf_rules_pairs user_rules |
674 val user_cls = ResAxioms.cnf_rules_pairs user_rules |
676 val thy = ProofContext.theory_of ctxt |
675 val thy = ProofContext.theory_of ctxt |
677 val axclauses = get_relevant_clauses thy cla_simp_atp_clauses |
676 val axclauses = get_relevant_clauses thy cla_simp_atp_clauses |
678 user_cls (map prop_of goal_cls) |
677 user_cls (map prop_of goal_cls) |> make_unique |
679 val keep_types = if is_fol_logic logic then !fol_keep_types else is_typed_hol () |
678 val keep_types = if is_fol_logic logic then !fol_keep_types else is_typed_hol () |
680 val classrel_clauses = if keep_types then ResClause.classrel_clauses_thy thy else [] |
679 val classrel_clauses = if keep_types then ResClause.classrel_clauses_thy thy else [] |
681 val arity_clauses = if keep_types then ResClause.arity_clause_thy thy else [] |
680 val arity_clauses = if keep_types then ResClause.arity_clause_thy thy else [] |
682 val writer = if dfg then dfg_writer else tptp_writer |
681 val writer = if dfg then dfg_writer else tptp_writer |
683 and file = atp_input_file() |
682 and file = atp_input_file() |
785 Auto => problem_logic_goals (map ((map prop_of)) goal_cls) |
784 Auto => problem_logic_goals (map ((map prop_of)) goal_cls) |
786 | Fol => FOL |
785 | Fol => FOL |
787 | Hol => HOL |
786 | Hol => HOL |
788 val (included_thms,white_thms) = get_clasimp_atp_lemmas ctxt [] |
787 val (included_thms,white_thms) = get_clasimp_atp_lemmas ctxt [] |
789 val included_cls = included_thms |> blacklist_filter |
788 val included_cls = included_thms |> blacklist_filter |
790 |> make_unique |> ResAxioms.cnf_rules_pairs |
789 |> ResAxioms.cnf_rules_pairs |> make_unique |
791 |> restrict_to_logic logic |
790 |> restrict_to_logic logic |
792 val white_cls = ResAxioms.cnf_rules_pairs white_thms |
791 val white_cls = ResAxioms.cnf_rules_pairs white_thms |
793 (*clauses relevant to goal gl*) |
792 (*clauses relevant to goal gl*) |
794 val axcls_list = map (fn gl => get_relevant_clauses thy included_cls white_cls [gl]) |
793 val axcls_list = map (fn gl => get_relevant_clauses thy included_cls white_cls [gl]) |
795 goals |
794 goals |
804 else [] |
803 else [] |
805 val _ = Output.debug ("arity clauses = " ^ Int.toString (length arity_clauses)) |
804 val _ = Output.debug ("arity clauses = " ^ Int.toString (length arity_clauses)) |
806 val writer = if !prover = "spass" then dfg_writer else tptp_writer |
805 val writer = if !prover = "spass" then dfg_writer else tptp_writer |
807 fun write_all [] [] _ = [] |
806 fun write_all [] [] _ = [] |
808 | write_all (ccls::ccls_list) (axcls::axcls_list) k = |
807 | write_all (ccls::ccls_list) (axcls::axcls_list) k = |
809 (writer logic ccls (probfile k) (axcls,classrel_clauses,arity_clauses) [], |
808 let val fname = probfile k |
810 probfile k) |
809 val axcls = make_unique axcls |
811 :: write_all ccls_list axcls_list (k+1) |
810 val ccls = subtract_cls ccls axcls |
|
811 val clnames = writer logic ccls fname (axcls,classrel_clauses,arity_clauses) [] |
|
812 in (clnames,fname) :: write_all ccls_list axcls_list (k+1) end |
812 val (clnames::_, filenames) = ListPair.unzip (write_all goal_cls axcls_list 1) |
813 val (clnames::_, filenames) = ListPair.unzip (write_all goal_cls axcls_list 1) |
813 val thm_names = Array.fromList clnames |
814 val thm_names = Array.fromList clnames |
814 val _ = if !Output.show_debug_msgs |
815 val _ = if !Output.show_debug_msgs |
815 then trace_array "thm_names" thm_names else () |
816 then trace_array "thm_names" thm_names else () |
816 in |
817 in |