src/HOL/Tools/res_atp.ML
author paulson
Fri, 21 Jan 2005 18:00:18 +0100
changeset 15452 e2a721567f67
parent 15347 14585bc8fa09
child 15572 9c89b1adf573
permissions -rw-r--r--
Jia Meng: delta simpsets and clasets
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     1
(*  Author: Jia Meng, Cambridge University Computer Laboratory
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     2
    ID: $Id$
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
     3
    Copyright 2004 University of Cambridge
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*)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
     9
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    10
signature RES_ATP = 
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    11
sig
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    12
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    13
val trace_res : bool ref
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    14
val axiom_file : Path.T
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    15
val hyps_file : Path.T
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    16
val isar_atp : ProofContext.context * Thm.thm -> unit
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    17
val prob_file : Path.T
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    18
val atp_ax_tac : Thm.thm list -> int -> Tactical.tactic
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    19
val atp_tac : int -> Tactical.tactic
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
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 =
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    25
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
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    28
(* used for debug *)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    29
val debug = ref false;
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    30
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    31
fun debug_tac tac = (warning "testing";tac);
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    32
(* default value is false *)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    33
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    34
val trace_res = ref false;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    35
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    36
val skolem_tac = skolemize_tac;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    37
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    38
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    39
val atomize_tac =
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    40
    SUBGOAL
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    41
     (fn (prop,_) =>
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    42
	 let val ts = Logic.strip_assums_hyp prop
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    43
	 in EVERY1 
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    44
		[METAHYPS
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    45
		     (fn hyps => (cut_facts_tac (map (ObjectLogic.atomize_thm o forall_intr_vars) hyps) 1)),
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    46
	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    47
     end);
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    48
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    49
(* temporarily use these files, which will be loaded by Vampire *)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    50
val prob_file = File.tmp_path (Path.basic "prob");
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    51
val axiom_file = File.tmp_path (Path.basic "axioms");
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    52
val hyps_file = File.tmp_path (Path.basic "hyps");
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    53
val dummy_tac = PRIMITIVE(fn thm => thm );
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    54
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    55
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    56
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    57
fun tptp_inputs thms n = 
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    58
    let val clss = map (ResClause.make_conjecture_clause_thm) thms
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    59
	val tptp_clss = ResLib.flat_noDup(map ResClause.tptp_clause clss) 
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    60
        val probfile = (File.sysify_path prob_file) ^ "_" ^ (string_of_int n)
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    61
	val out = TextIO.openOut(probfile)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    62
    in
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    63
	(ResLib.writeln_strs out tptp_clss; TextIO.closeOut out; (if !trace_res then (warning probfile) else ()))
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    64
    end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    65
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    66
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    67
(**** for Isabelle/ML interface  ****)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    68
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    69
fun call_atp_tac thms n = (tptp_inputs thms n; dummy_tac);
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
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
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    73
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    74
fun atp_tac n = SELECT_GOAL
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    75
  (EVERY1 [rtac ccontr,atomize_tac, skolemize_tac, 
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
    76
  METAHYPS(fn negs => (call_atp_tac (make_clauses negs) n))]) n;
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    77
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    78
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    79
fun atp_ax_tac axioms n = 
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    80
    let val axcls = ResLib.flat_noDup(map ResAxioms.clausify_axiom axioms)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    81
	val axcls_str = ResClause.tptp_clauses2str (ResLib.flat_noDup(map ResClause.tptp_clause axcls))
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    82
	val axiomfile = File.sysify_path axiom_file
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    83
	val out = TextIO.openOut (axiomfile)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    84
    in
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    85
	(TextIO.output(out,axcls_str);TextIO.closeOut out; if !trace_res then (warning axiomfile) else (); atp_tac n)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    86
    end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    87
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    88
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    89
fun atp thm =
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    90
    let val prems = prems_of thm
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    91
    in
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    92
	case prems of [] => () 
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    93
		    | _ => (atp_tac 1 thm; ())
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    94
    end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    95
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    96
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    97
(**** For running in Isar ****)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    98
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
    99
(* same function as that in res_axioms.ML *)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   100
fun repeat_RS thm1 thm2 =
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   101
    let val thm1' =  thm1 RS thm2 handle THM _ => thm1
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   102
    in
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   103
	if eq_thm(thm1,thm1') then thm1' else (repeat_RS thm1' thm2)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   104
    end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   105
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   106
(* a special version of repeat_RS *)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   107
fun repeat_someI_ex thm = repeat_RS thm someI_ex;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   108
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   109
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   110
(* convert clauses from "assume" to conjecture. write to file "hyps" *)
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   111
fun isar_atp_h thms =
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   112
    let val prems = map (skolemize o make_nnf o ObjectLogic.atomize_thm) thms
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   113
	val prems' = map repeat_someI_ex prems
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   114
	val prems'' = make_clauses prems'
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   115
	val prems''' = ResAxioms.rm_Eps [] prems''
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   116
	val clss = map ResClause.make_conjecture_clause prems'''
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   117
	val tptp_clss = ResLib.flat_noDup (map ResClause.tptp_clause clss)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   118
        val hypsfile = File.sysify_path hyps_file
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   119
	val out = TextIO.openOut(hypsfile)
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   120
    in
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   121
	(ResLib.writeln_strs out tptp_clss; TextIO.closeOut out; if !trace_res then (warning hypsfile) else ())
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   122
    end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   123
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   124
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   125
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   126
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   127
val isar_atp_g = atp_tac;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   128
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   129
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   130
fun isar_atp_goal' thm k n = 
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   131
    if (k > n) then () else (isar_atp_g k thm; isar_atp_goal' thm (k+1) n);
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   132
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   133
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   134
fun isar_atp_goal thm n_subgoals = (if (!debug) then warning (string_of_thm thm) else (isar_atp_goal' thm 1 n_subgoals));
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   135
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   136
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   137
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   138
fun isar_atp_aux thms thm n_subgoals = 
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   139
    (isar_atp_h thms; isar_atp_goal thm n_subgoals); (* convert both to conjecture clauses, but write to different files *)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   140
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   141
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   142
fun isar_atp' (thms, thm) =
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   143
    let val prems = prems_of thm
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   144
    in
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   145
	case prems of [] => (if (!debug) then warning "entering forward, no goal" else ())
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   146
		    | _ => (isar_atp_aux thms thm (length prems))
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   147
    end;
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   148
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   149
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   150
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   151
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   152
local
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   153
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   154
fun retr_thms ([]:MetaSimplifier.rrule list) = []
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   155
	  | retr_thms (r::rs) = (#thm r)::(retr_thms rs);
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   156
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   157
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   158
fun snds [] = []
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   159
  |   snds ((x,y)::l) = y::(snds l);
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   160
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   161
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   162
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   163
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   164
fun get_thms_cs claset =
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   165
    let val clsset = rep_cs claset
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   166
	val safeEs = #safeEs clsset
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   167
	val safeIs = #safeIs clsset
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   168
	val hazEs = #hazEs clsset
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   169
	val hazIs = #hazIs clsset
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   170
    in
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   171
	safeEs @ safeIs @ hazEs @ hazIs
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   172
    end;
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   173
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   174
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   175
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   176
fun append_name name [] _ = []
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   177
  | append_name name (thm::thms) k = (Thm.name_thm ((name ^ "_" ^ (string_of_int k)),thm)) :: (append_name name thms (k+1));
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   178
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   179
fun append_names (name::names) (thms::thmss) =
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   180
    let val thms' = append_name name thms 0
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   181
    in
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   182
	thms'::(append_names names thmss)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   183
    end;
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   184
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   185
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   186
fun get_thms_ss [] = []
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   187
  | get_thms_ss thms =
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   188
    let val names = map Thm.name_of_thm thms 
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   189
        val thms' = map (mksimps mksimps_pairs) thms
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   190
        val thms'' = append_names names thms'
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   191
    in
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   192
	ResLib.flat_noDup thms''
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   193
    end;
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   194
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   195
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   196
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   197
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   198
in
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   199
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   200
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   201
(* convert locally declared rules to axiom clauses *)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   202
(* write axiom clauses to ax_file *)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   203
fun isar_local_thms (delta_cs, delta_ss_thms) =
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   204
    let val thms_cs = get_thms_cs delta_cs
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   205
	val thms_ss = get_thms_ss delta_ss_thms
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   206
	val thms_clauses = ResLib.flat_noDup (map ResAxioms.clausify_axiom (thms_cs @ thms_ss))
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   207
	val clauses_strs = ResLib.flat_noDup (map ResClause.tptp_clause thms_clauses) (*string list*)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   208
	val ax_file = File.sysify_path axiom_file
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   209
	val out = TextIO.openOut ax_file
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   210
    in
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   211
	(ResLib.writeln_strs out clauses_strs; TextIO.closeOut out)
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   212
    end;
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   213
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   214
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   215
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   216
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   217
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   218
(* called in Isar automatically *)
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   219
fun isar_atp (ctxt,thm) =
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   220
    let val prems = ProofContext.prems_of ctxt
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   221
      val d_cs = Classical.get_delta_claset ctxt
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   222
      val d_ss_thms = Simplifier.get_delta_simpset ctxt
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   223
    in
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   224
	(isar_local_thms (d_cs,d_ss_thms); isar_atp' (prems, thm))
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   225
    end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   226
15452
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   227
end
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   228
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   229
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   230
e2a721567f67 Jia Meng: delta simpsets and clasets
paulson
parents: 15347
diff changeset
   231
15347
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   232
end;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   233
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   234
Proof.atp_hook := ResAtp.isar_atp;
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   235
14585bc8fa09 resolution package tools by Jia Meng
paulson
parents:
diff changeset
   236