src/HOL/Tools/res_atp.ML
author quigley
Thu, 31 Mar 2005 20:12:54 +0200
changeset 15644 f2ef8c258fa4
parent 15608 f161fa6f8fd5
child 15653 3549ff7158f3
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
     1
(*  Author: Jia Meng, Cambridge University Computer Laboratory
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
     2
    ID: $Id$
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
     3
    Copyright 2004 University of Cambridge
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     4
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     5
ATPs with TPTP format input.
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     6
*)
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
     7
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
     8
(*Jia: changed: isar_atp now processes entire proof context.  fetch thms from delta simpset/claset*)
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
     9
(*Claire: changed: added actual watcher calls *)
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    10
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    11
signature RES_ATP = 
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    12
sig
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    13
val trace_res : bool ref
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    14
val axiom_file : Path.T
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    15
val hyps_file : Path.T
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    16
val isar_atp : ProofContext.context * Thm.thm -> unit
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    17
(*val prob_file : Path.T*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    18
(*val atp_ax_tac : Thm.thm list -> int -> Tactical.tactic*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    19
(*val atp_tac : int -> Tactical.tactic*)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    20
val debug: bool ref
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    21
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    22
end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    23
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    24
structure ResAtp : RES_ATP =
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    25
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    26
struct
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    27
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    28
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    29
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    30
(* used for debug *)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    31
val debug = ref false;
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    32
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    33
fun debug_tac tac = (warning "testing";tac);
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    34
(* default value is false *)
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    35
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    36
val trace_res = ref false;
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    37
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    38
val skolem_tac = skolemize_tac;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    39
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    40
val num_of_clauses = ref 0;
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    41
val clause_arr = Array.array(3500, ("empty", 0));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    42
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    43
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    44
val atomize_tac =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    45
    SUBGOAL
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    46
     (fn (prop,_) =>
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    47
	 let val ts = Logic.strip_assums_hyp prop
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    48
	 in EVERY1 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    49
		[METAHYPS
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    50
		     (fn hyps => (cut_facts_tac (map (ObjectLogic.atomize_thm o forall_intr_vars) hyps) 1)),
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    51
	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    52
     end);
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    53
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    54
(* temporarily use these files, which will be loaded by Vampire *)
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    55
val file_id_num =ref 0;
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    56
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    57
fun new_prob_file () =  (file_id_num := (!file_id_num) + 1;"prob"^(string_of_int (!file_id_num)));
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    58
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    59
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    60
val axiom_file = File.tmp_path (Path.basic "axioms");
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    61
val clasimp_file = File.tmp_path (Path.basic "clasimp");
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    62
val hyps_file = File.tmp_path (Path.basic "hyps");
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    63
val prob_file = File.tmp_path (Path.basic "prob");
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    64
val dummy_tac = PRIMITIVE(fn thm => thm );
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    65
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    66
 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    67
fun concat_with_and [] str = str
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    68
|   concat_with_and (x::[]) str = str^" ("^x^")"
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    69
|   concat_with_and (x::xs) str = (concat_with_and xs (str^"("^x^")"^" & "))
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    70
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    71
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    72
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    73
(**** for Isabelle/ML interface  ****)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    74
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    75
fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126) andalso (not ((ord ch ) = 63))) orelse (ch = " ")
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    76
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    77
fun proofstring x = let val exp = explode x 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    78
                    in
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    79
                        List.filter (is_proof_char ) exp
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    80
                    end
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    81
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    82
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    83
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    84
(*
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    85
fun call_atp_tac thms n = (tptp_inputs thms ; dummy_tac);
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    86
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
    87
*)
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    88
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    89
(**** For running in Isar ****)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    90
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    91
(* same function as that in res_axioms.ML *)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    92
fun repeat_RS thm1 thm2 =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    93
    let val thm1' =  thm1 RS thm2 handle THM _ => thm1
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    94
    in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    95
	if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    96
    end;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    97
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    98
(* a special version of repeat_RS *)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
    99
fun repeat_someI_ex thm = repeat_RS thm someI_ex;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   100
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   101
(*********************************************************************)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   102
(* convert clauses from "assume" to conjecture. write to file "hyps" *)
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   103
(* hypotheses of the goal currently being proved                     *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   104
(*********************************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   105
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   106
fun isar_atp_h thms =
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   107
        
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   108
    let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   109
        val prems' = map repeat_someI_ex prems
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   110
        val prems'' = make_clauses prems'
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   111
        val prems''' = ResAxioms.rm_Eps [] prems''
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   112
        val clss = map ResClause.make_conjecture_clause prems'''
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   113
	val (tptp_clss,tfree_litss) = ResLib.unzip (map ResClause.clause2tptp clss) 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   114
	val tfree_lits = ResLib.flat_noDup tfree_litss
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   115
	val tfree_clss = map ResClause.tfree_clause tfree_lits 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   116
        val hypsfile = File.sysify_path hyps_file
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   117
	val out = TextIO.openOut(hypsfile)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   118
    in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   119
	((ResLib.writeln_strs out (tfree_clss @ tptp_clss); TextIO.closeOut out; if !trace_res then (warning hypsfile) else ());tfree_lits) 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   120
    end;
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   121
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   122
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   123
(*********************************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   124
(* write out a subgoal as tptp clauses to the file "probN"           *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   125
(* where N is the number of this subgoal                             *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   126
(*********************************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   127
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   128
fun tptp_inputs_tfrees thms n tfrees = 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   129
    let val clss = map (ResClause.make_conjecture_clause_thm) thms
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   130
	val (tptp_clss,tfree_litss) = ResLib.unzip (map ResClause.clause2tptp clss)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   131
	val tfree_clss = map ResClause.tfree_clause ((ResLib.flat_noDup tfree_litss) \\ tfrees) 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   132
        val probfile = (File.sysify_path prob_file) ^ "_" ^ (string_of_int n)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   133
	val out = TextIO.openOut(probfile)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   134
    in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   135
	(ResLib.writeln_strs out (tfree_clss @ tptp_clss); TextIO.closeOut out; (if !trace_res then (warning probfile) else ()))
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   136
    end;
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   137
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   138
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   139
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   140
(*********************************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   141
(* call SPASS with settings and problem file for the current subgoal *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   142
(* should be modified to allow other provers to be called            *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   143
(*********************************************************************)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   144
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   145
fun call_resolve_tac thms sg_term (childin, childout,pid)  = let
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   146
                            val newprobfile = new_prob_file ()
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   147
                             val thmstring = concat_with_and (map string_of_thm thms) ""
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   148
                           val _ = warning ("thmstring in call_res is: "^thmstring)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   149
                            val goalstr = Sign.string_of_term Mainsign sg_term 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   150
                            val goalproofstring = proofstring goalstr
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   151
                               val no_returns =List.filter not_newline ( goalproofstring)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   152
                            val goalstring = implode no_returns
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   153
                            val _ = warning ("goalstring in call_res is: "^goalstring)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   154
        
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   155
                            val prob_file =File.tmp_path (Path.basic newprobfile); 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   156
                             val clauses = make_clauses thms
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   157
                            (*val _ = tptp_inputs clauses prob_file*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   158
                            val thmstring = concat_with_and (map string_of_thm thms) ""
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   159
                           
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   160
                            val goalstr = Sign.string_of_term Mainsign sg_term 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   161
                            val goalproofstring = proofstring goalstr
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   162
                             val no_returns =List.filter not_newline ( goalproofstring)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   163
                            val goalstring = implode no_returns
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   164
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   165
                            val thmproofstring = proofstring ( thmstring)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   166
                            val no_returns =List.filter   not_newline ( thmproofstring)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   167
                            val thmstr = implode no_returns
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   168
                            
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   169
                            val prob_path = File.sysify_path prob_file
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   170
                            val outfile = TextIO.openOut("/home/clq20/Jia_Code/hellofile")
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   171
                            val _ = TextIO.output(outfile, "prob file path is "^prob_path^" thmstring is "^thmstr^" goalstring is "^goalstring);
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   172
                            val _ = TextIO.flushOut outfile;
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   173
                            val _ =  TextIO.closeOut outfile
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   174
                          in
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   175
                           (* without paramodulation *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   176
                           (*(warning ("goalstring in call_res_tac is: "^goalstring));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   177
                           (warning ("prob path in cal_res_tac is: "^prob_path));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   178
                            Watcher.callResProvers(childout,
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   179
                            [("spass",thmstr,goalstring,"/homes/clq20/bin/SPASS",  
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   180
                             "-FullRed=0%-Auto=0%-ISRe%-ISFc%-RTaut%-RFSub%-RBSub%-DocProof", 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   181
                             prob_path)]);*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   182
                           (* with paramodulation *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   183
                           (*Watcher.callResProvers(childout,
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   184
                                  [("spass",thmstr,goalstring,"/homes/clq20/bin/SPASS",
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   185
                                  "-FullRed=0%-ISPm=1%-Split=0%-PObv=0%-DocProof", 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   186
                                    prob_path)]); *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   187
                           Watcher.callResProvers(childout,
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   188
                           [("spass",thmstr,goalstring,"/homes/clq20/bin/SPASS", 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   189
                           "-DocProof",  prob_path)]);
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   190
                           dummy_tac
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   191
                         end
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   192
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   193
(************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   194
(* pass in subgoal as a term and watcher info   *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   195
(* process subgoal into skolemized, negated form*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   196
(* then call call_resolve_tac to send to ATP    *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   197
(************************************************)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   198
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   199
fun resolve_tac sg_term  (childin, childout,pid) = 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   200
   let val _ = warning ("in resolve_tac ")
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   201
   in
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   202
   SELECT_GOAL
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   203
  (EVERY1 [rtac ccontr,atomize_tac,skolemize_tac,  METAHYPS(fn negs => (warning ("calling call_resolve_tac next ");call_resolve_tac negs sg_term (childin, childout,pid)))])
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   204
   end;
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   205
15603
27a706e3a53d code reformatted
webertj
parents: 15572
diff changeset
   206
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   207
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   208
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   209
(* Need to replace call_atp_tac_tfrees with call res_provers as it's the dummy one *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   210
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   211
(**********************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   212
(* write out the current subgoal as a tptp file, probN,   *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   213
(* then call dummy_tac - should be call_res_tac           *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   214
(**********************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   215
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   216
fun call_atp_tac_tfrees thms n tfrees sg_term (childin, childout,pid) = 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   217
                                         (tptp_inputs_tfrees (make_clauses thms) n tfrees; 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   218
                                          resolve_tac sg_term (childin, childout, pid);
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   219
  					  dummy_tac);
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   220
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   221
fun atp_tac_tfrees tfrees sg_term (childin, childout,pid)  n  = 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   222
let val _ = (warning ("in atp_tac_tfrees "))
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   223
   in
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   224
SELECT_GOAL
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   225
  (EVERY1 [rtac ccontr,atomize_tac, skolemize_tac, 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   226
  METAHYPS(fn negs => (call_atp_tac_tfrees (negs) n tfrees sg_term (childin, childout,pid)))]) n
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   227
end;
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   228
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   229
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   230
fun isar_atp_g tfrees sg_term (childin, childout, pid)  = 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   231
                                        
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   232
(	(warning("in isar_atp_g"));atp_tac_tfrees tfrees sg_term (childin, childout, pid));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   233
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   234
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   235
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   236
(**********************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   237
(* recursively call atp_tac_g on all subgoals *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   238
(* sg_term is the nth subgoal as a term - used*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   239
(* in proof reconstruction                    *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   240
(**********************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   241
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   242
fun isar_atp_goal' thm k n tfree_lits  (childin, childout, pid) = 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   243
                  	if (k > n) 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   244
                        then () 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   245
	  		else 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   246
                           (let val  prems = prems_of thm 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   247
                                val sg_term = get_nth n prems
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   248
                            in   
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   249
                                 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   250
                		(warning("in isar_atp_goal'"));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   251
 				 isar_atp_g tfree_lits  sg_term (childin, childout, pid) k thm; 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   252
                                 isar_atp_goal' thm (k+1) n tfree_lits  (childin, childout, pid) 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   253
                            end);
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   254
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   255
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   256
fun isar_atp_goal thm n_subgoals tfree_lits   (childin, childout, pid) = (if (!debug) then warning (string_of_thm thm) else (isar_atp_goal' thm 1 n_subgoals tfree_lits  (childin, childout, pid) ));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   257
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   258
(**************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   259
(* convert clauses from "assume" to conjecture.   *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   260
(* i.e. apply make_clauses and then get tptp for  *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   261
(* any hypotheses in the goal                     *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   262
(* write to file "hyps"                           *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   263
(**************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   264
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   265
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   266
fun isar_atp_aux thms thm n_subgoals  (childin, childout, pid) = 
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   267
    let val tfree_lits = isar_atp_h thms 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   268
    in
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   269
	(warning("in isar_atp_aux"));isar_atp_goal thm n_subgoals tfree_lits   (childin, childout, pid)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   270
    end;
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   271
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   272
(******************************************************************)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   273
(* called in Isar automatically                                   *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   274
(* writes out the current clasimpset to a tptp file               *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   275
(* passes all subgoals on to isar_atp_aux for further processing  *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   276
(* turns off xsymbol at start of function, restoring it at end    *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   277
(******************************************************************)
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   278
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   279
fun isar_atp' (thms, thm) =
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   280
    let val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   281
        val _= (warning ("in isar_atp'"))
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   282
        val prems = prems_of thm
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   283
        val thms_string =concat_with_and (map  string_of_thm thms) ""
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   284
        val thmstring = string_of_thm thm
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   285
        val prems_string = concat_with_and (map (Sign.string_of_term Mainsign) prems) ""
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   286
        (* set up variables for writing out the clasimps to a tptp file *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   287
        (* val _ = write_out_clasimp (File.sysify_path axiom_file)*)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   288
        (* cq: add write out clasimps to file *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   289
        (* cq:create watcher and pass to isar_atp_aux *)                    
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   290
        val (childin,childout,pid) = Watcher.createWatcher(thm)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   291
        val pidstring = string_of_int(Word.toInt (Word.fromLargeWord ( Posix.Process.pidToWord pid )))
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   292
    in
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   293
	case prems of [] => () 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   294
		    | _ => ((warning ("initial thms: "^thms_string)); 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   295
                           (warning ("initial thm: "^thmstring));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   296
                           (warning ("subgoals: "^prems_string));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   297
                           (warning ("pid: "^ pidstring))); 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   298
                            isar_atp_aux thms thm (length prems) (childin, childout, pid) ;
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   299
                           
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   300
                           print_mode := (["xsymbols", "symbols"] @ ! print_mode)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   301
    end;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   302
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   303
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   304
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   305
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   306
local
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   307
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   308
fun get_thms_cs claset =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   309
    let val clsset = rep_cs claset
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   310
	val safeEs = #safeEs clsset
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   311
	val safeIs = #safeIs clsset
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   312
	val hazEs = #hazEs clsset
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   313
	val hazIs = #hazIs clsset
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   314
    in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   315
	safeEs @ safeIs @ hazEs @ hazIs
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   316
    end;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   317
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   318
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   319
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   320
fun append_name name [] _ = []
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   321
  | append_name name (thm::thms) k = (Thm.name_thm ((name ^ "_" ^ (string_of_int k)),thm)) :: (append_name name thms (k+1));
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   322
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   323
fun append_names (name::names) (thms::thmss) =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   324
    let val thms' = append_name name thms 0
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   325
    in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   326
	thms'::(append_names names thmss)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   327
    end;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   328
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   329
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   330
fun get_thms_ss [] = []
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   331
  | get_thms_ss thms =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   332
    let val names = map Thm.name_of_thm thms 
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   333
        val thms' = map (mksimps mksimps_pairs) thms
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   334
        val thms'' = append_names names thms'
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   335
    in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   336
	ResLib.flat_noDup thms''
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   337
    end;
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   338
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   339
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   340
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   341
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   342
in
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   343
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   344
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   345
(* convert locally declared rules to axiom clauses *)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   346
(* write axiom clauses to ax_file *)
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   347
(* what about clasimpset - it should already be in the ax file - perhaps append to ax file rather than just *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   348
(* write out ? Or keep as a separate file and then cat them all together in the watcher, like we do with the *)
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   349
(*claset file and prob file*)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   350
fun isar_local_thms (delta_cs, delta_ss_thms) =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   351
    let val thms_cs = get_thms_cs delta_cs
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   352
	val thms_ss = get_thms_ss delta_ss_thms
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   353
	val thms_clauses = ResLib.flat_noDup (map ResAxioms.clausify_axiom (thms_cs @ thms_ss))
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   354
	val clauses_strs = ResLib.flat_noDup (map ResClause.tptp_clause thms_clauses) (*string list*)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   355
	val ax_file = File.sysify_path axiom_file
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   356
	val out = TextIO.openOut ax_file
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   357
    in
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   358
	(ResLib.writeln_strs out clauses_strs; (warning ("axiom file is: "^ax_file));TextIO.closeOut out)
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   359
    end;
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   360
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   361
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   362
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   363
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   364
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   365
(* called in Isar automatically *)
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   366
fun isar_atp (ctxt,thm) =
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   367
    let val prems = ProofContext.prems_of ctxt
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   368
        val d_cs = Classical.get_delta_claset ctxt 
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   369
        val d_ss_thms = Simplifier.get_delta_simpset ctxt
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   370
        val thmstring = string_of_thm thm
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   371
        val prem_no = length prems
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   372
        val prems_string = concat_with_and (map string_of_thm prems) ""
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   373
    in
15644
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   374
         
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   375
          (warning ("initial thm in isar_atp: "^thmstring));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   376
          (warning ("subgoals in isar_atp: "^prems_string));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   377
    	   (warning ("number of subgoals in isar_atp: "^(string_of_int prem_no)));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   378
          (isar_local_thms (d_cs,d_ss_thms); (warning("about to call isar_atp'"));
f2ef8c258fa4 *** empty log message ***
quigley
parents: 15608
diff changeset
   379
           isar_atp' (prems, thm))
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   380
    end;
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   381
15608
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   382
end
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   383
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   384
f161fa6f8fd5 bug fixes involving typechecking clauses
paulson
parents: 15603
diff changeset
   385
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   386
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   387
end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   388
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   389
Proof.atp_hook := ResAtp.isar_atp;