src/HOL/Tools/ATP/res_clasimpset.ML
author wenzelm
Thu, 15 Sep 2005 13:35:21 +0200
changeset 17405 e4dc583a2d79
parent 17305 6cef3aedd661
child 17412 e26cb20ef0cc
permissions -rw-r--r--
extend: NameSpace.default_naming;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
     1
(*  ID:      $Id$
15789
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15782
diff changeset
     2
    Author:     Claire Quigley
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15782
diff changeset
     3
    Copyright   2004  University of Cambridge
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15782
diff changeset
     4
*)
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15782
diff changeset
     5
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
     6
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
     7
structure ReduceAxiomsN =
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
     8
(* Author: Jia Meng, Cambridge University Computer Laboratory
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
     9
   Remove irrelevant axioms used for a proof of a goal, with with iteration control
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
    10
   
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
    11
   Initial version. Needs elaboration. *)
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    12
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    13
struct
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    14
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    15
fun add_term_consts_rm ncs (Const(c, _)) cs = 
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    16
    if (c mem ncs) then cs else (c ins_string cs)
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    17
  | add_term_consts_rm ncs (t $ u) cs =
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    18
      add_term_consts_rm ncs t (add_term_consts_rm ncs u cs)
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    19
  | add_term_consts_rm ncs (Abs(_,_,t)) cs = add_term_consts_rm ncs t cs
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    20
  | add_term_consts_rm ncs _ cs = cs;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    21
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    22
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    23
fun term_consts_rm ncs t = add_term_consts_rm ncs t [];
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    24
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    25
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    26
fun thm_consts_rm ncs thm = term_consts_rm ncs (prop_of thm);
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    27
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    28
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    29
fun consts_of_thm (n,thm) = thm_consts_rm ["Trueprop","==>","all","Ex","op &", "op |", "Not", "All", "op -->", "op =", "==", "True", "False"] thm;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    30
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    31
fun consts_of_term term = term_consts_rm ["Trueprop","==>","all","Ex","op &", "op |", "Not", "All", "op -->", "op =", "==", "True", "False"] term;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    32
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    33
fun make_pairs [] _ = []
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    34
  | make_pairs (x::xs) y = (x,y)::(make_pairs xs y);
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    35
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    36
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    37
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    38
fun const_thm_list_aux [] cthms = cthms
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    39
  | const_thm_list_aux (thm::thms) cthms =
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    40
    let val consts = consts_of_thm thm
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    41
	val cthms' = make_pairs consts thm 
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    42
    in
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    43
	const_thm_list_aux thms (cthms' @ cthms)
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    44
    end;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    45
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    46
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    47
fun const_thm_list thms = const_thm_list_aux thms [];
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    48
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    49
fun make_thm_table thms  = 
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    50
    let val consts_thms = const_thm_list thms
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    51
    in
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    52
	Symtab.make_multi consts_thms
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    53
    end;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    54
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    55
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    56
fun consts_in_goal goal = consts_of_term goal;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    57
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    58
fun axioms_having_consts_aux [] tab thms = thms
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    59
  | axioms_having_consts_aux (c::cs) tab thms =
17261
193b84a70ca4 curried_lookup/update;
wenzelm
parents: 17234
diff changeset
    60
    let val thms1 = Symtab.curried_lookup tab c
193b84a70ca4 curried_lookup/update;
wenzelm
parents: 17234
diff changeset
    61
      val thms2 = 
193b84a70ca4 curried_lookup/update;
wenzelm
parents: 17234
diff changeset
    62
          case thms1 of (SOME x) => x
193b84a70ca4 curried_lookup/update;
wenzelm
parents: 17234
diff changeset
    63
                      | NONE => []
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    64
    in
17261
193b84a70ca4 curried_lookup/update;
wenzelm
parents: 17234
diff changeset
    65
      axioms_having_consts_aux cs tab (thms2 union thms)
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    66
    end;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    67
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    68
fun axioms_having_consts cs tab = axioms_having_consts_aux cs tab [];
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    69
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    70
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    71
fun relevant_axioms goal thmTab n =  
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    72
    let val consts = consts_in_goal goal
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    73
	fun relevant_axioms_aux1 cs k =
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    74
	    let val thms1 = axioms_having_consts cs thmTab
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    75
		val cs1 = ResLib.flat_noDup (map consts_of_thm thms1)
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    76
	    in
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    77
		if ((cs1 subset cs) orelse n <= k) then (k,thms1) 
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    78
		else (relevant_axioms_aux1 (cs1 union cs) (k+1))
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    79
	    end
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    80
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    81
    in  relevant_axioms_aux1 consts 1  end;
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    82
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    83
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    84
fun relevant_filter n goal thms = 
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    85
    if n<=0 then thms 
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
    86
    else #2 (relevant_axioms goal (make_thm_table thms) n);
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    87
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    88
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    89
(* find the thms from thy that contain relevant constants, n is the iteration number *)
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    90
fun find_axioms_n thy goal n =
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    91
    let val clasetR = ResAxioms.claset_rules_of_thy thy
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    92
	val simpsetR = ResAxioms.simpset_rules_of_thy thy	  
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    93
	val table = make_thm_table (clasetR @ simpsetR)	
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    94
    in
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    95
	relevant_axioms goal table n
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    96
    end;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    97
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    98
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
    99
fun find_axioms_n_c thy goal n =
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   100
    let val current_thms = PureThy.thms_of thy
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   101
	val table = make_thm_table current_thms
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   102
    in
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   103
	relevant_axioms goal table n
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   104
    end;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   105
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   106
end;
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   107
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   108
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   109
signature RES_CLASIMP = 
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   110
  sig
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
   111
  val relevant : int ref
16950
e7f0f41d513a Added flag ResClasimp.use_simpset to allow exclusion of simpset rules from ATP problem files
quigley
parents: 16906
diff changeset
   112
  val use_simpset: bool ref
16957
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   113
  val use_nameless: bool ref
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   114
  val get_clasimp_lemmas : 
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   115
         theory -> term -> 
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   116
         (ResClause.clause * thm) Array.array * int * ResClause.clause list 
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   117
  end;
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   118
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   119
structure ResClasimp : RES_CLASIMP =
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   120
struct
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   121
val use_simpset = ref false;   (*Performance is much better without simprules*)
16957
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   122
val use_nameless = ref false;  (*Because most are useless [iff] rules*)
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   123
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   124
val relevant = ref 0;  (*Relevance filtering is off by default*)
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
   125
16956
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   126
(*The "name" of a theorem is its statement, if nothing else is available.*)
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   127
val plain_string_of_thm =
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   128
    setmp show_question_marks false 
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   129
      (setmp print_mode [] 
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   130
	(Pretty.setmp_margin 999 string_of_thm));
16957
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   131
	
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   132
fun fake_thm_name th = 
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   133
    Context.theory_name (theory_of_thm th) ^ "." ^ 
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   134
    ResLib.trim_ends (plain_string_of_thm th);
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   135
16957
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   136
fun put_name_pair ("",th) = if !use_nameless then (fake_thm_name th, th)
8dcd14e8db7a nameless theorems: better names, flag to omit them
paulson
parents: 16956
diff changeset
   137
                            else ("HOL.TrueI",TrueI)
16956
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   138
  | put_name_pair (a,th)  = (a,th);
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15956
diff changeset
   139
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   140
(* changed, now it also finds out the name of the theorem. *)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   141
(* convert a theorem into CNF and then into Clause.clause format. *)
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15956
diff changeset
   142
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15956
diff changeset
   143
(* outputs a list of (thm,clause) pairs *)
15643
5829f30fc20a *** empty log message ***
quigley
parents:
diff changeset
   144
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   145
fun multi x 0 xlist = xlist
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   146
   |multi x n xlist = multi x (n-1) (x::xlist);
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   147
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   148
fun clause_numbering ((clause, theorem), num_of_cls) = 
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   149
    let val numbers = 0 upto (num_of_cls - 1)
16172
629ba53a072f small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents: 16156
diff changeset
   150
    in 
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   151
	multi (clause, theorem) num_of_cls []
16172
629ba53a072f small tweaks; also now write_out_clasimp takes the current theory as argument
paulson
parents: 16156
diff changeset
   152
    end;
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
   153
    
16950
e7f0f41d513a Added flag ResClasimp.use_simpset to allow exclusion of simpset rules from ATP problem files
quigley
parents: 16906
diff changeset
   154
16741
7a6c17b826c0 inserted basic relevance-checking code, WHICH ONLY WORKS FOR 1ST SUBGOAL
paulson
parents: 16357
diff changeset
   155
(*Write out the claset and simpset rules of the supplied theory.
16906
74eddde1de2f dead code removal
paulson
parents: 16897
diff changeset
   156
  FIXME: argument "goal" is a hack to allow relevance filtering.
74eddde1de2f dead code removal
paulson
parents: 16897
diff changeset
   157
  To reduce the number of clauses produced, set ResClasimp.relevant:=1*)
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   158
fun get_clasimp_lemmas thy goal = 
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
   159
    let val claset_rules = 
16956
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   160
              map put_name_pair
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   161
	        (ReduceAxiomsN.relevant_filter (!relevant) goal 
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   162
		  (ResAxioms.claset_rules_of_thy thy));
5b413c866593 invents theorem names; also patches write_out_clasimp
paulson
parents: 16950
diff changeset
   163
	val claset_cls_thms = #1 (ResAxioms.clausify_rules_pairs claset_rules []);
15643
5829f30fc20a *** empty log message ***
quigley
parents:
diff changeset
   164
16795
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
   165
	val simpset_rules =
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
   166
	      ReduceAxiomsN.relevant_filter (!relevant) goal 
b400b53d8f7d relevance filtering is now optional
paulson
parents: 16741
diff changeset
   167
                (ResAxioms.simpset_rules_of_thy thy);
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
   168
	val named_simpset = map put_name_pair simpset_rules
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   169
	val simpset_cls_thms = #1 (ResAxioms.clausify_rules_pairs named_simpset []);
15643
5829f30fc20a *** empty log message ***
quigley
parents:
diff changeset
   170
17234
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
   171
	val cls_thms = if !use_simpset then (claset_cls_thms@simpset_cls_thms) 
12a9393c5d77 further tidying up of Isabelle-ATP link
paulson
parents: 17150
diff changeset
   172
	               else claset_cls_thms;
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   173
	val cls_thms_list = List.concat cls_thms;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   174
	(*************************************************)
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   175
	(* Identify the set of clauses to be written out *)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   176
	(*************************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   177
	val clauses = map #1(cls_thms_list);
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   178
	val cls_nums = map ResClause.num_of_clauses clauses;
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   179
        val whole_list = List.concat 
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   180
              (map clause_numbering (ListPair.zip (cls_thms_list, cls_nums)));
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   181
 
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   182
        (*********************************************************)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   183
	(* create array and put clausename, number pairs into it *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   184
	(*********************************************************)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   185
	val clause_arr = Array.fromList whole_list;
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   186
  in
17305
6cef3aedd661 axioms now included in tptp files, no /bin/cat and various tidying
paulson
parents: 17261
diff changeset
   187
	(clause_arr, List.length whole_list, clauses)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   188
  end;
15643
5829f30fc20a *** empty log message ***
quigley
parents:
diff changeset
   189
16950
e7f0f41d513a Added flag ResClasimp.use_simpset to allow exclusion of simpset rules from ATP problem files
quigley
parents: 16906
diff changeset
   190
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15907
diff changeset
   191
end;
16039
dfe264950511 Moved some of the clausify functions from ATP/res_clasimpset.ML to res_axioms.ML.
quigley
parents: 15956
diff changeset
   192
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   193
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16061
diff changeset
   194