src/HOL/Tools/ATP/recon_translate_proof.ML
author paulson
Thu, 21 Apr 2005 15:05:24 +0200
changeset 15789 4cb16144c81b
parent 15774 9df37a0e935d
child 15794 5de27a5fc5ed
permissions -rw-r--r--
added hearder lines and deleted some redundant material
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15789
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15774
diff changeset
     1
(*  ID:         $Id$
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15774
diff changeset
     2
    Author:     Claire Quigley
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15774
diff changeset
     3
    Copyright   2004  University of Cambridge
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15774
diff changeset
     4
*)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     5
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     6
fun add_in_order (x:string) [] = [x]
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     7
|   add_in_order (x:string) ((y:string)::ys) = if (x < y) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     8
                             then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     9
                                  (x::(y::ys))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    10
                             else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    11
                                  (y::(add_in_order x ys))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    12
fun add_once x [] = [x]
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    13
|   add_once x (y::ys) = if (inlist x (y::ys)) then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    14
                            (y::ys)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    15
                        else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    16
                            add_in_order x (y::ys)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    17
     
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    18
fun thm_vars thm = map (fn ((name,ix),_) => name) (Drule.vars_of thm);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    19
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    20
Goal "False ==> False";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    21
by Auto_tac;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    22
qed "False_imp";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    23
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    24
exception Reflex_equal;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    25
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    26
(********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    27
(* Proofstep datatype           *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    28
(********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    29
(* Assume rewrite steps have only two clauses in them just now, but lcl109-5 has Rew[5,3,5,3]  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    30
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    31
datatype Side = Left |Right
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    32
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    33
 datatype Proofstep = ExtraAxiom
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    34
                     |OrigAxiom
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    35
                     | Axiom
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    36
                     | Binary of (int * int) * (int * int)   (* (clause1,lit1), (clause2, lit2) *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    37
                     | MRR of (int * int) * (int * int) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    38
                     | Factor of (int * int * int)           (* (clause,lit1, lit2) *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    39
                     | Para of (int * int) * (int * int) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    40
                     | Rewrite of (int * int) * (int * int)  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    41
                     | Obvious of (int * int)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    42
                     (*| Hyper of int list*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    43
                     | Unusedstep of unit
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    44
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    45
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    46
datatype Clausesimp = Binary_s of int * int
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    47
                      | Factor_s of unit
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    48
                      | Demod_s of (int * int) list
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    49
                      | Hyper_s of int list
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    50
                      | Unusedstep_s of unit
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    51
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    52
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    53
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    54
datatype Step_label = T_info
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    55
                     |P_info
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    56
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    57
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    58
fun is_alpha_space_digit_or_neg ch = (ch = "~") orelse (is_alpha ch) orelse (is_digit ch) orelse ( ch = " ")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    59
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    60
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    61
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
    62
fun lit_string_with_nums t = let val termstr = Term.string_of_term t
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    63
                                 val exp_term = explode termstr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    64
                             in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    65
                                 implode(List.filter is_alpha_space_digit_or_neg exp_term)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    66
                             end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    67
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    68
fun reconstruction_failed fname = error (fname ^ ": reconstruction failed")
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    69
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    70
(****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    71
(* Reconstruct an axiom resolution step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    72
(****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    73
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    74
fun follow_axiom clauses  allvars (clausenum:int) thml clause_strs =  
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    75
                                     let val this_axiom = valOf (assoc (clauses,clausenum))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    76
                                         val (res, numlist, symlist, nsymlist) = (rearrange_clause this_axiom clause_strs allvars)         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    77
                                         val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    78
                                     in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    79
                                         (res, (Axiom,clause_strs,thmvars )  )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    80
                                     end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    81
                                     handle Option => reconstruction_failed "follow_axiom"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    82
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    83
(****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    84
(* Reconstruct a binary resolution step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    85
(****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    86
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    87
                 (* numbers of clauses and literals*) (*vars*) (*list of current thms*) (* literal strings as parsed from spass *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    88
fun follow_binary ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    89
        = let
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    90
              val thm1 =  select_literal (lit1 + 1) (valOf (assoc (thml,clause1)))
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    91
              val thm2 =  valOf (assoc (thml,clause2))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    92
              val res =   thm1 RSN ((lit2 +1), thm2)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    93
              val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    94
              val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    95
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    96
             (res',  ((Binary ((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars) )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    97
          end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
    98
	  handle Option => reconstruction_failed "follow_binary"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    99
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   100
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   101
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   102
(******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   103
(* Reconstruct a matching replacement resolution step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   104
(******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   105
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   106
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   107
fun follow_mrr ((clause1, lit1), (clause2 , lit2))  allvars thml clause_strs 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   108
        = let
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   109
              val thm1 =  select_literal (lit1 + 1) (valOf (assoc (thml,clause1)))
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   110
              val thm2 =  valOf (assoc (thml,clause2))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   111
              val res =   thm1 RSN ((lit2 +1), thm2)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   112
              val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   113
              val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   114
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   115
             (res',  ((MRR ((clause1, lit1), (clause2 , lit2))) ,clause_strs,thmvars))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   116
          end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   117
	  handle Option => reconstruction_failed "follow_mrr"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   118
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   119
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   120
(*******************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   121
(* Reconstruct a factoring resolution step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   122
(*******************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   123
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   124
fun mksubstlist [] sublist = sublist
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   125
   |mksubstlist ((a,b)::rest) sublist = let val vartype = type_of b 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   126
                                          val avar = Var(a,vartype)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   127
                                          val newlist = ((avar,b)::sublist) in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   128
                                          mksubstlist rest newlist
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   129
                                      end;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   130
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   131
(* based on Tactic.distinct_subgoals_tac *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   132
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   133
fun delete_assump_tac state lit =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   134
    let val (frozth,thawfn) = freeze_thaw state
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   135
        val froz_prems = cprems_of frozth
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   136
        val assumed = implies_elim_list frozth (map assume froz_prems)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   137
        val new_prems = remove_nth lit froz_prems
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   138
        val implied = implies_intr_list new_prems assumed
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   139
    in  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   140
        Seq.single (thawfn implied)  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   141
    end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   142
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   143
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   144
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   145
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   146
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   147
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   148
(* Reconstruct a factoring step      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   149
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   150
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15736
diff changeset
   151
(*FIXME: share code with that in Tools/reconstruction.ML*)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   152
fun follow_factor clause lit1 lit2 allvars thml clause_strs= 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   153
                          let 
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   154
                            val th =  valOf (assoc (thml,clause))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   155
                            val prems = prems_of th
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   156
                            val sign = sign_of_thm th
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   157
                            val fac1 = get_nth (lit1+1) prems
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   158
                            val fac2 = get_nth (lit2+1) prems
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15736
diff changeset
   159
                            val unif_env = Unify.unifiers (sign,Envir.empty 0, [(fac1, fac2)])
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   160
                            val newenv = getnewenv unif_env
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   161
                            val envlist = Envir.alist_of newenv
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   162
                            
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   163
                            val (t1,t2)::_ = mksubstlist envlist []
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   164
                          in 
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   165
                            if (is_Var t1)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   166
                            then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   167
                                let 
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   168
                                   val str1 = lit_string_with_nums t1;
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   169
                                   val str2 = lit_string_with_nums t2;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   170
                                   val facthm = read_instantiate [(str1,str2)] th;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   171
                                   val res = hd (Seq.list_of(delete_assump_tac  facthm (lit1 + 1)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   172
                                   val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   173
                                   val thmvars = thm_vars res'
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   174
                                in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   175
                                       (res',((Factor (clause,  lit1, lit2)),clause_strs,thmvars))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   176
                                end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   177
                            else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   178
                                let
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   179
                                   val str2 = lit_string_with_nums t1;
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   180
                                   val str1 = lit_string_with_nums t2;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   181
                                   val facthm = read_instantiate [(str1,str2)] th;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   182
                                   val res = hd (Seq.list_of(delete_assump_tac  facthm (lit1 + 1)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   183
                                   val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   184
                                  val thmvars = thm_vars res'
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   185
                                in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   186
                                       (res', ((Factor (clause,  lit1, lit2)),clause_strs, thmvars))         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   187
                                end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   188
                         end
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   189
                         handle Option => reconstruction_failed "follow_factor"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   190
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   191
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   192
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   193
fun get_unif_comb t eqterm =
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   194
    if ((type_of t) = (type_of eqterm))
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   195
    then t
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   196
    else
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   197
        let val _ $ rand = t
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   198
        in get_unif_comb rand eqterm end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   199
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   200
fun get_unif_lit t eqterm =
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   201
    if (can HOLogic.dest_eq t)
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   202
    then
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   203
	let val (lhs,rhs) = HOLogic.dest_eq(HOLogic.dest_Trueprop eqterm)
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   204
	in lhs end
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   205
    else
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   206
	get_unif_comb t eqterm;
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   207
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   208
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   209
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   210
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   211
(* Reconstruct a paramodulation step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   212
(*************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   213
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   214
val rev_subst = rotate_prems 1 subst;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   215
val rev_ssubst = rotate_prems 1 ssubst;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   216
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   217
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   218
fun follow_standard_para ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs= 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   219
                          let 
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   220
                            val th1 =  valOf (assoc (thml,clause1))
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   221
                            val th2 =  valOf (assoc (thml,clause2)) 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   222
                            val eq_lit_th = select_literal (lit1+1) th1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   223
                            val mod_lit_th = select_literal (lit2+1) th2
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   224
                            val eqsubst = eq_lit_th RSN (2,rev_subst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   225
                            val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 eqsubst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   226
			    val newth' =negate_head newth 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   227
                            val (res, numlist, symlist, nsymlist)  = (rearrange_clause newth' clause_strs allvars 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   228
                                handle Not_in_list => let 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   229
                                                  val mod_lit_th' = mod_lit_th RS not_sym
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   230
                                                   val newth = Seq.hd (biresolution false [(false, mod_lit_th')] 1 eqsubst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   231
			                           val newth' =negate_head newth 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   232
                                               in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   233
                                                  (rearrange_clause newth' clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   234
                                               end)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   235
                            val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   236
                         in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   237
                           (res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   238
                         end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   239
			 handle Option => reconstruction_failed "follow_standard_para"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   240
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   241
(*              
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   242
fun follow_standard_para ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs= 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   243
                          let 
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   244
                            val th1 =  valOf (assoc (thml,clause1))
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   245
                            val th2 =  valOf (assoc (thml,clause2)) 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   246
                            val eq_lit_th = select_literal (lit1+1) th1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   247
                            val mod_lit_th = select_literal (lit2+1) th2
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   248
                            val eqsubst = eq_lit_th RSN (2,rev_subst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   249
                            val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 eqsubst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   250
			    val newth' =negate_nead newth 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   251
                            val (res, numlist, symlist, nsymlist)  = (rearrange_clause newth' clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   252
                            val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   253
                         in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   254
                           (res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   255
                         end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   256
			 handle Option => reconstruction_failed "follow_standard_para"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   257
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   258
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   259
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   260
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   261
(********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   262
(* Reconstruct a rewriting step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   263
(********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   264
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   265
(*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   266
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   267
val rev_subst = rotate_prems 1 subst;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   268
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   269
fun paramod_rule ((cl1, lit1), (cl2 , lit2)) =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   270
     let  val eq_lit_th = select_literal (lit1+1) cl1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   271
          val mod_lit_th = select_literal (lit2+1) cl2
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   272
          val eqsubst = eq_lit_th RSN (2,rev_subst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   273
          val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   274
eqsubst)
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   275
     in Meson.negated_asm_of_head newth end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   276
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   277
val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   278
eqsubst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   279
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   280
val mod_lit_th' = mod_lit_th RS not_sym
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   281
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   282
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   283
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   284
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   285
fun delete_assumps 0 th = th 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   286
|   delete_assumps n th = let val th_prems = length (prems_of th)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   287
                              val th' = hd (Seq.list_of(delete_assump_tac  th (th_prems -1)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   288
                          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   289
                              delete_assumps (n-1) th'
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   290
                          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   291
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   292
(* extra conditions from the equality turn up as 2nd to last literals of result.  Need to delete them *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   293
(* changed negate_nead to negate_head here too*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   294
                    (* clause1, lit1 is thing to rewrite with *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   295
fun follow_rewrite ((clause1, lit1), (clause2, lit2)) allvars thml clause_strs= 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   296
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   297
                          let val th1 =  valOf (assoc (thml,clause1))
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   298
                              val th2 = valOf (assoc (thml,clause2))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   299
                              val eq_lit_th = select_literal (lit1+1) th1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   300
                              val mod_lit_th = select_literal (lit2+1) th2
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   301
                              val eqsubst = eq_lit_th RSN (2,rev_subst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   302
                              val eq_lit_prem_num = length (prems_of eq_lit_th)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   303
                              val sign = Sign.merge (sign_of_thm th1, sign_of_thm th2)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   304
                              val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   305
eqsubst)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   306
                         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   307
                              val newthm = negate_head newth
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   308
                              val newthm' = delete_assumps eq_lit_prem_num newthm
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   309
                              val (res, numlist, symlist, nsymlist) =(rearrange_clause newthm clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   310
                              val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   311
                           in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   312
                               (res, ((Rewrite ((clause1, lit1),  (clause2, lit2))),clause_strs,thmvars))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   313
                           end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   314
			   handle Option => reconstruction_failed "follow_rewrite"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   315
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   316
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   317
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   318
(*****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   319
(* Reconstruct an obvious reduction step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   320
(*****************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   321
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   322
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   323
fun follow_obvious  (clause1, lit1)  allvars thml clause_strs= 
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   324
                           let val th1 =  valOf (assoc (thml,clause1))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   325
                               val prems1 = prems_of th1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   326
                               val newthm = refl RSN ((lit1+ 1), th1)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   327
                                               handle THM _ =>  hd (Seq.list_of(delete_assump_tac  th1 (lit1 + 1)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   328
                               val (res, numlist, symlist, nsymlist) =(rearrange_clause newthm clause_strs allvars)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   329
                               val thmvars = thm_vars res
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   330
                           in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   331
                               (res, ((Obvious (clause1, lit1)),clause_strs,thmvars))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   332
                           end
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   333
  	 		   handle Option => reconstruction_failed "follow_obvious"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   334
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   335
(**************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   336
(* reconstruct a single line of the res. proof - depending on what sort of proof step it was*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   337
(**************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   338
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   339
 fun follow_proof clauses allvars  clausenum thml  (Axiom ) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   340
        = follow_axiom clauses allvars  clausenum thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   341
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   342
      | follow_proof clauses  allvars clausenum  thml (Binary (a, b)) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   343
        = follow_binary  (a, b)  allvars thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   344
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   345
      | follow_proof clauses  allvars clausenum  thml (MRR (a, b)) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   346
        = follow_mrr (a, b)  allvars thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   347
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   348
      | follow_proof clauses  allvars clausenum  thml (Factor (a, b, c)) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   349
         = follow_factor a b c  allvars thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   350
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   351
      | follow_proof clauses  allvars clausenum  thml (Para (a, b)) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   352
        = follow_standard_para (a, b) allvars  thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   353
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   354
      | follow_proof clauses  allvars clausenum thml (Rewrite (a,b)) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   355
        = follow_rewrite (a,b)  allvars thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   356
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   357
      | follow_proof clauses  allvars clausenum thml (Obvious (a,b)) clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   358
        = follow_obvious (a,b)  allvars thml clause_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   359
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   360
      (*| follow_proof clauses  clausenum thml (Hyper l)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   361
        = follow_hyper l thml*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   362
      | follow_proof clauses  allvars clausenum  thml _ _ =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   363
          raise ASSERTION  "proof step not implemented"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   364
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   365
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   366
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   367
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   368
(**************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   369
(* reconstruct a single line of the res. proof - at the moment do only inference steps*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   370
(**************************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   371
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   372
    fun follow_line clauses  allvars thml (clause_num, proof_step, clause_strs) recons
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   373
        = let
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   374
            val (thm, recon_fun) = follow_proof clauses  allvars clause_num thml proof_step clause_strs 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   375
            val recon_step = (recon_fun)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   376
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   377
            (((clause_num, thm)::thml), ((clause_num,recon_step)::recons))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   378
          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   379
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   380
(***************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   381
(* follow through the res. proof, creating an Isabelle theorem *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   382
(***************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   383
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   384
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   385
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   386
(*fun is_proof_char ch = (case ch of 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   387
                       
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   388
                        "(" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   389
                       |  ")" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   390
                         | ":" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   391
                        |  "'" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   392
                        |  "&" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   393
                        | "|" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   394
                        | "~" => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   395
                        |  "." => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   396
                        |(is_alpha ) => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   397
                       |(is_digit) => true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   398
                         | _ => false)*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   399
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   400
fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126)) orelse (ch = " ")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   401
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   402
fun proofstring x = let val exp = explode x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   403
                    in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   404
                        List.filter (is_proof_char ) exp
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   405
                    end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   406
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   407
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   408
fun not_newline ch = not (ch = "\n");
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   409
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   410
(*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   411
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   412
fun follow clauses [] allvars thml recons = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   413
                             let (* val _ = reset show_sorts*)
15736
1bb0399a9517 more tidying up of the SPASS interface
paulson
parents: 15697
diff changeset
   414
                              val thmstring = Meson.concat_with_and (map string_of_thm (map snd thml))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   415
                              val thmproofstring = proofstring ( thmstring)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   416
                            val no_returns =List.filter  not_newline ( thmproofstring)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   417
                            val thmstr = implode no_returns
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   418
                               val outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "thml_file")))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   419
                               val _ = TextIO.output(outfile, "thmstr is "^thmstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   420
                               val _ = TextIO.flushOut outfile;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   421
                               val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   422
                                 (*val _ = set show_sorts*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   423
                             in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   424
                                  ((snd( hd thml)), recons)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   425
                             end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   426
      | follow clauses (h::t) allvars thml recons 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   427
        = let
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   428
            val (thml', recons') = follow_line clauses allvars  thml h recons
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   429
            val  (thm, recons_list) = follow clauses t  allvars thml' recons'
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   430
            
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   431
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   432
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   433
             (thm,recons_list)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   434
          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   435
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   436
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   437
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   438
fun replace_clause_strs [] recons newrecons= (newrecons)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   439
|   replace_clause_strs ((thmnum, thm)::thml)  ((clausenum,(step,clause_strs,thmvars))::recons) newrecons = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   440
                           let val new_clause_strs = get_meta_lits_bracket thm
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   441
                           in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   442
                               replace_clause_strs thml recons ((clausenum,(step,new_clause_strs,thmvars))::newrecons)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   443
                           end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   444
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   445
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   446
fun follow clauses [] allvars thml recons = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   447
                             let 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   448
                                 val new_recons = replace_clause_strs thml recons []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   449
                             in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   450
                                  ((snd( hd thml)), new_recons)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   451
                             end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   452
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   453
 |  follow clauses (h::t) allvars thml recons 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   454
        = let
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   455
            val (thml', recons') = follow_line clauses allvars  thml h recons
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   456
            val  (thm, recons_list) = follow clauses t  allvars thml' recons'     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   457
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   458
             (thm,recons_list)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   459
          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   460
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   461
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   462
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   463
(* Assume we have the cnf clauses as a list of (clauseno, clause) *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   464
 (* and the proof as a list of the proper datatype *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   465
(* take the cnf clauses of the goal and the proof from the res. prover *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   466
(* as a list of type Proofstep and return the thm goal ==> False *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   467
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   468
fun first_pair (a,b,c) = (a,b);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   469
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   470
fun second_pair (a,b,c) = (b,c);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   471
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   472
(* takes original axioms, proof_steps parsed from spass, variables *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   473
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   474
fun translate_proof clauses proof allvars
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   475
        = let val (thm, recons) = follow clauses proof allvars [] []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   476
          in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   477
             (thm, (recons))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   478
          end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   479
  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   480
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   481
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   482
fun remove_tinfo [] = []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   483
|   remove_tinfo ( (clausenum, step, T_info, newstrs)::xs) = (clausenum, step , newstrs)::(remove_tinfo xs)