src/HOL/Tools/ATP/recon_translate_proof.ML
changeset 15697 681bcb7f0389
parent 15684 5ec4d21889d6
child 15736 1bb0399a9517
equal deleted inserted replaced
15696:1da4ce092c0b 15697:681bcb7f0389
     1 
     1 
     2 fun take n [] = []
       
     3 |   take n (x::xs) = (if n = 0 then [] else (x::(take (n - 1) xs)))
       
     4 
       
     5 fun drop n [] = []
       
     6 |   drop n (x::xs) = (if n = 0 then (x::xs) else drop (n-1) xs)
       
     7 
       
     8 fun remove n [] = []
       
     9 |   remove n (x::xs) = List.filter (not_equal n) (x::xs);
       
    10 
       
    11 fun remove_nth n [] = []
       
    12 |   remove_nth n (x::xs) = (take (n -1) (x::xs))@(drop n (x::xs))
       
    13 
       
    14 fun get_nth n (x::xs) = hd (drop (n-1) (x::xs))
       
    15 
     2 
    16 fun add_in_order (x:string) [] = [x]
     3 fun add_in_order (x:string) [] = [x]
    17 |   add_in_order (x:string) ((y:string)::ys) = if (x < y) 
     4 |   add_in_order (x:string) ((y:string)::ys) = if (x < y) 
    18                              then 
     5                              then 
    19                                   (x::(y::ys))
     6                                   (x::(y::ys))
    67 
    54 
    68 fun is_alpha_space_digit_or_neg ch = (ch = "~") orelse (is_alpha ch) orelse (is_digit ch) orelse ( ch = " ")
    55 fun is_alpha_space_digit_or_neg ch = (ch = "~") orelse (is_alpha ch) orelse (is_digit ch) orelse ( ch = " ")
    69 
    56 
    70 
    57 
    71 
    58 
    72 fun lit_string_with_nums t = let val termstr = (Sign.string_of_term Mainsign) t
    59 fun lit_string_with_nums t = let val termstr = Term.string_of_term t
    73                                  val exp_term = explode termstr
    60                                  val exp_term = explode termstr
    74                              in
    61                              in
    75                                  implode(List.filter is_alpha_space_digit_or_neg exp_term)
    62                                  implode(List.filter is_alpha_space_digit_or_neg exp_term)
    76                              end
    63                              end
    77 
    64 
   156 
   143 
   157 fun follow_factor clause lit1 lit2 allvars thml clause_strs= 
   144 fun follow_factor clause lit1 lit2 allvars thml clause_strs= 
   158                           let 
   145                           let 
   159                             val th =  Recon_Base.assoc clause thml
   146                             val th =  Recon_Base.assoc clause thml
   160                             val prems = prems_of th
   147                             val prems = prems_of th
       
   148                             val sign = sign_of_thm th
   161                             val fac1 = get_nth (lit1+1) prems
   149                             val fac1 = get_nth (lit1+1) prems
   162                             val fac2 = get_nth (lit2+1) prems
   150                             val fac2 = get_nth (lit2+1) prems
   163                             val unif_env = Unify.unifiers (Mainsign,Envir.empty 0, [(fac1, fac2)])
   151                             val unif_env = Unify.unifiers (Mainsign,Envir.empty 0, [(fac1, fac2)])
   164                             val newenv = getnewenv unif_env
   152                             val newenv = getnewenv unif_env
   165                             val envlist = Envir.alist_of newenv
   153                             val envlist = Envir.alist_of newenv
   166                             
   154                             
   167                             val newsubsts = mksubstlist envlist []
   155                             val (t1,t2)::_ = mksubstlist envlist []
   168                           in 
   156                           in 
   169                             if (is_Var (fst(hd(newsubsts))))
   157                             if (is_Var t1)
   170                             then
   158                             then
   171                                 let 
   159                                 let 
   172                                    val str1 = lit_string_with_nums (fst (hd newsubsts));
   160                                    val str1 = lit_string_with_nums t1;
   173                                    val str2 = lit_string_with_nums (snd (hd newsubsts));
   161                                    val str2 = lit_string_with_nums t2;
   174                                    val facthm = read_instantiate [(str1,str2)] th;
   162                                    val facthm = read_instantiate [(str1,str2)] th;
   175                                    val res = hd (Seq.list_of(delete_assump_tac  facthm (lit1 + 1)))
   163                                    val res = hd (Seq.list_of(delete_assump_tac  facthm (lit1 + 1)))
   176                                    val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
   164                                    val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
   177                                    val thmvars = thm_vars res'
   165                                    val thmvars = thm_vars res'
   178                                 in 
   166                                 in 
   179                                        (res',((Factor (clause,  lit1, lit2)),clause_strs,thmvars))
   167                                        (res',((Factor (clause,  lit1, lit2)),clause_strs,thmvars))
   180                                 end
   168                                 end
   181                             else
   169                             else
   182                                 let
   170                                 let
   183                                    val str2 = lit_string_with_nums (fst (hd newsubsts));
   171                                    val str2 = lit_string_with_nums t1;
   184                                    val str1 = lit_string_with_nums (snd (hd newsubsts));
   172                                    val str1 = lit_string_with_nums t2;
   185                                    val facthm = read_instantiate [(str1,str2)] th;
   173                                    val facthm = read_instantiate [(str1,str2)] th;
   186                                    val res = hd (Seq.list_of(delete_assump_tac  facthm (lit1 + 1)))
   174                                    val res = hd (Seq.list_of(delete_assump_tac  facthm (lit1 + 1)))
   187                                    val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
   175                                    val (res', numlist, symlist, nsymlist) = (rearrange_clause res clause_strs allvars)
   188                                   val thmvars = thm_vars res'
   176                                   val thmvars = thm_vars res'
   189                                 in 
   177                                 in 
   280      let  val eq_lit_th = select_literal (lit1+1) cl1
   268      let  val eq_lit_th = select_literal (lit1+1) cl1
   281           val mod_lit_th = select_literal (lit2+1) cl2
   269           val mod_lit_th = select_literal (lit2+1) cl2
   282           val eqsubst = eq_lit_th RSN (2,rev_subst)
   270           val eqsubst = eq_lit_th RSN (2,rev_subst)
   283           val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
   271           val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
   284 eqsubst)
   272 eqsubst)
   285      in negated_asm_of_head newth end;
   273      in Meson.negated_asm_of_head newth end;
   286 
   274 
   287 val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
   275 val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 
   288 eqsubst)
   276 eqsubst)
   289 
   277 
   290 val mod_lit_th' = mod_lit_th RS not_sym
   278 val mod_lit_th' = mod_lit_th RS not_sym