52 val rm_clasimp : unit -> unit |
52 val rm_clasimp : unit -> unit |
53 end; |
53 end; |
54 |
54 |
55 structure ResAtp = |
55 structure ResAtp = |
56 struct |
56 struct |
|
57 |
|
58 fun timestamp s = Output.debug ("At " ^ Time.toString (Time.now()) ^ ": " ^ s); |
57 |
59 |
58 (********************************************************************) |
60 (********************************************************************) |
59 (* some settings for both background automatic ATP calling procedure*) |
61 (* some settings for both background automatic ATP calling procedure*) |
60 (* and also explicit ATP invocation methods *) |
62 (* and also explicit ATP invocation methods *) |
61 (********************************************************************) |
63 (********************************************************************) |
505 | hashw_term ((Var(_,_)), w) = w |
507 | hashw_term ((Var(_,_)), w) = w |
506 | hashw_term ((Bound i), w) = Polyhash.hashw_int(i,w) |
508 | hashw_term ((Bound i), w) = Polyhash.hashw_int(i,w) |
507 | hashw_term ((Abs(_,_,t)), w) = hashw_term (t, w) |
509 | hashw_term ((Abs(_,_,t)), w) = hashw_term (t, w) |
508 | hashw_term ((P$Q), w) = hashw_term (Q, (hashw_term (P, w))); |
510 | hashw_term ((P$Q), w) = hashw_term (Q, (hashw_term (P, w))); |
509 |
511 |
510 fun hashw_pred (P,w) = |
512 fun hash_literal (Const("Not",_)$P) = Word.notb(hashw_term(P,0w0)) |
511 let val (p,args) = strip_comb P |
513 | hash_literal P = hashw_term(P,0w0); |
512 in |
|
513 List.foldl hashw_term w (p::args) |
|
514 end; |
|
515 |
|
516 fun hash_literal (Const("Not",_)$P) = Word.notb(hashw_pred(P,0w0)) |
|
517 | hash_literal P = hashw_pred(P,0w0); |
|
518 |
514 |
519 |
515 |
520 fun get_literals (Const("Trueprop",_)$P) lits = get_literals P lits |
516 fun get_literals (Const("Trueprop",_)$P) lits = get_literals P lits |
521 | get_literals (Const("op |",_)$P$Q) lits = get_literals Q (get_literals P lits) |
517 | get_literals (Const("op |",_)$P$Q) lits = get_literals Q (get_literals P lits) |
522 | get_literals lit lits = (lit::lits); |
518 | get_literals lit lits = (lit::lits); |
523 |
|
524 |
519 |
525 fun hash_term t = Word.toIntX (xor_words (map hash_literal (get_literals t []))); |
520 fun hash_term t = Word.toIntX (xor_words (map hash_literal (get_literals t []))); |
526 |
521 |
527 (*Versions ONLY for "faking" a theorem name. Here we take variable names into account |
522 (*Versions ONLY for "faking" a theorem name. Here we take variable names into account |
528 so that similar theorems don't collide. FIXME: this entire business of "faking" |
523 so that similar theorems don't collide. FIXME: this entire business of "faking" |
554 (*Use a hash table to eliminate duplicates from xs. Argument is a list of |
549 (*Use a hash table to eliminate duplicates from xs. Argument is a list of |
555 (thm * (string * int)) tuples. The theorems are hashed into the table. *) |
550 (thm * (string * int)) tuples. The theorems are hashed into the table. *) |
556 fun make_unique xs = |
551 fun make_unique xs = |
557 let val ht = mk_clause_table 7000 |
552 let val ht = mk_clause_table 7000 |
558 in |
553 in |
|
554 Output.debug("make_unique gets " ^ Int.toString (length xs) ^ " clauses"); |
559 app (ignore o Polyhash.peekInsert ht) xs; |
555 app (ignore o Polyhash.peekInsert ht) xs; |
560 Polyhash.listItems ht |
556 Polyhash.listItems ht |
561 end; |
557 end; |
562 |
558 |
563 (*Remove existing axiom clauses from the conjecture clauses, as this can dramatically |
559 (*Remove existing axiom clauses from the conjecture clauses, as this can dramatically |
619 end; |
615 end; |
620 |
616 |
621 (*Remove lemmas that are banned from the backlist. Also remove duplicates. *) |
617 (*Remove lemmas that are banned from the backlist. Also remove duplicates. *) |
622 fun blacklist_filter thms = |
618 fun blacklist_filter thms = |
623 if !run_blacklist_filter then |
619 if !run_blacklist_filter then |
624 let val banned = make_banned_test (map #1 thms) |
620 let val _ = Output.debug("blacklist filter gets " ^ Int.toString (length thms) ^ " theorems") |
|
621 val banned = make_banned_test (map #1 thms) |
625 fun ok (a,_) = not (banned a) |
622 fun ok (a,_) = not (banned a) |
626 in filter ok thms end |
623 val okthms = filter ok thms |
|
624 val _ = Output.debug("...and returns " ^ Int.toString (length okthms)) |
|
625 in okthms end |
627 else thms; |
626 else thms; |
628 |
627 |
629 |
628 |
630 (***************************************************************) |
629 (***************************************************************) |
631 (* ATP invocation methods setup *) |
630 (* ATP invocation methods setup *) |
783 | Hol => HOL |
782 | Hol => HOL |
784 val (included_thms,white_thms) = get_clasimp_atp_lemmas ctxt [] |
783 val (included_thms,white_thms) = get_clasimp_atp_lemmas ctxt [] |
785 val included_cls = included_thms |> blacklist_filter |
784 val included_cls = included_thms |> blacklist_filter |
786 |> ResAxioms.cnf_rules_pairs |> make_unique |
785 |> ResAxioms.cnf_rules_pairs |> make_unique |
787 |> restrict_to_logic logic |
786 |> restrict_to_logic logic |
|
787 val _ = Output.debug ("clauses = " ^ Int.toString(length included_cls)) |
788 val white_cls = ResAxioms.cnf_rules_pairs white_thms |
788 val white_cls = ResAxioms.cnf_rules_pairs white_thms |
789 (*clauses relevant to goal gl*) |
789 (*clauses relevant to goal gl*) |
790 val axcls_list = map (fn gl => get_relevant_clauses thy included_cls white_cls [gl]) |
790 val axcls_list = map (fn gl => get_relevant_clauses thy included_cls white_cls [gl]) |
791 goals |
791 goals |
792 val _ = Output.debug ("clauses = " ^ Int.toString(length included_cls)) |
792 val _ = app (fn axcls => Output.debug ("filtered clauses = " ^ Int.toString(length axcls))) |
|
793 axcls_list |
793 val keep_types = if is_fol_logic logic then !ResClause.keep_types |
794 val keep_types = if is_fol_logic logic then !ResClause.keep_types |
794 else is_typed_hol () |
795 else is_typed_hol () |
795 val classrel_clauses = if keep_types then ResClause.classrel_clauses_thy thy |
796 val classrel_clauses = if keep_types then ResClause.classrel_clauses_thy thy |
796 else [] |
797 else [] |
797 val _ = Output.debug ("classrel clauses = " ^ |
798 val _ = Output.debug ("classrel clauses = " ^ |