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