src/HOL/Tools/ATP/recon_translate_proof.ML
changeset 17312 159783c74f75
parent 16803 014090d1e64b
child 17374 63e0ab9f2ea9
equal deleted inserted replaced
17311:5b1d47d920ce 17312:159783c74f75
   257    in 
   257    in 
   258      (res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars))
   258      (res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars))
   259    end
   259    end
   260    handle Option => reconstruction_failed "follow_standard_para"
   260    handle Option => reconstruction_failed "follow_standard_para"
   261 
   261 
   262 (*              
       
   263 fun follow_standard_para ((clause1, lit1), (clause2 , lit2)) allvars thml clause_strs= 
       
   264                           let 
       
   265                             val th1 =  valOf (assoc (thml,clause1))
       
   266                             val th2 =  valOf (assoc (thml,clause2)) 
       
   267                             val eq_lit_th = select_literal (lit1+1) th1
       
   268                             val mod_lit_th = select_literal (lit2+1) th2
       
   269                             val eqsubst = eq_lit_th RSN (2,rev_subst)
       
   270                             val newth = Seq.hd (biresolution false [(false, mod_lit_th)] 1 eqsubst)
       
   271 			    val newth' =negate_nead newth 
       
   272                             val (res, numlist, symlist, nsymlist)  = (rearrange_clause newth' clause_strs allvars)
       
   273                             val thmvars = thm_vars res
       
   274                          in 
       
   275                            (res, ((Para((clause1, lit1), (clause2 , lit2))),clause_strs,thmvars))
       
   276                          end
       
   277 			 handle Option => reconstruction_failed "follow_standard_para"
       
   278 
       
   279 *)
       
   280 
       
   281 
   262 
   282 (********************************)
   263 (********************************)
   283 (* Reconstruct a rewriting step *)
   264 (* Reconstruct a rewriting step *)
   284 (********************************)
   265 (********************************)
   285  
   266  
   399 
   380 
   400 (***************************************************************)
   381 (***************************************************************)
   401 (* follow through the res. proof, creating an Isabelle theorem *)
   382 (* follow through the res. proof, creating an Isabelle theorem *)
   402 (***************************************************************)
   383 (***************************************************************)
   403 
   384 
   404 
       
   405 
       
   406 (*fun is_proof_char ch = (case ch of 
       
   407                        
       
   408                         "(" => true
       
   409                        |  ")" => true
       
   410                          | ":" => true
       
   411                         |  "'" => true
       
   412                         |  "&" => true
       
   413                         | "|" => true
       
   414                         | "~" => true
       
   415                         |  "." => true
       
   416                         |(is_alpha ) => true
       
   417                        |(is_digit) => true
       
   418                          | _ => false)*)
       
   419 
       
   420 fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126)) orelse (ch = " ")
   385 fun is_proof_char ch = ((33 <= (ord ch)) andalso ((ord ch ) <= 126)) orelse (ch = " ")
   421 
   386 
   422 fun proofstring x = let val exp = explode x 
   387 fun proofstring x = let val exp = explode x 
   423                     in
   388                     in
   424                         List.filter (is_proof_char ) exp
   389                         List.filter (is_proof_char ) exp
   425                     end
   390                     end
   426 
       
   427 
       
   428 (*
       
   429 
       
   430 fun follow clauses [] allvars thml recons = 
       
   431                              let (* val _ = reset show_sorts*)
       
   432                               val thmstring = Meson.concat_with_and (map string_of_thm (map snd thml))
       
   433                               val thmproofstring = proofstring ( thmstring)
       
   434                             val no_returns = no_lines thmproofstring
       
   435                             val thmstr = implode no_returns
       
   436                                val outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "thml_file")))
       
   437                                val _ = TextIO.output(outfile, "thmstr is "^thmstr)
       
   438                                val _ = TextIO.flushOut outfile;
       
   439                                val _ =  TextIO.closeOut outfile
       
   440                                  (*val _ = set show_sorts*)
       
   441                              in
       
   442                                   ((snd( hd thml)), recons)
       
   443                              end
       
   444       | follow clauses (h::t) allvars thml recons 
       
   445         = let
       
   446             val (thml', recons') = follow_line clauses allvars  thml h recons
       
   447             val  (thm, recons_list) = follow clauses t  allvars thml' recons'
       
   448             
       
   449 
       
   450           in
       
   451              (thm,recons_list)
       
   452           end
       
   453 
       
   454 *)
       
   455 
   391 
   456 fun replace_clause_strs [] recons newrecons = (newrecons)
   392 fun replace_clause_strs [] recons newrecons = (newrecons)
   457 |   replace_clause_strs ((thmnum, thm)::thml)    
   393 |   replace_clause_strs ((thmnum, thm)::thml)    
   458                   ((clausenum,(step,clause_strs,thmvars))::recons) newrecons = 
   394                   ((clausenum,(step,clause_strs,thmvars))::recons) newrecons = 
   459     let val new_clause_strs = ReconOrderClauses.get_meta_lits_bracket thm
   395     let val new_clause_strs = ReconOrderClauses.get_meta_lits_bracket thm
   475 	val  (thm, recons_list) = follow clauses t  allvars thml' recons'     
   411 	val  (thm, recons_list) = follow clauses t  allvars thml' recons'     
   476       in
   412       in
   477 	 (thm,recons_list)
   413 	 (thm,recons_list)
   478       end
   414       end
   479 
   415 
   480 
       
   481 
       
   482 (* Assume we have the cnf clauses as a list of (clauseno, clause) *)
   416 (* Assume we have the cnf clauses as a list of (clauseno, clause) *)
   483  (* and the proof as a list of the proper datatype *)
   417  (* and the proof as a list of the proper datatype *)
   484 (* take the cnf clauses of the goal and the proof from the res. prover *)
   418 (* take the cnf clauses of the goal and the proof from the res. prover *)
   485 (* as a list of type Proofstep and return the thm goal ==> False *)
   419 (* as a list of type Proofstep and return the thm goal ==> False *)
   486 
       
   487 fun first_pair (a,b,c) = (a,b);
       
   488 
       
   489 fun second_pair (a,b,c) = (b,c);
       
   490 
   420 
   491 (* takes original axioms, proof_steps parsed from spass, variables *)
   421 (* takes original axioms, proof_steps parsed from spass, variables *)
   492 
   422 
   493 fun translate_proof clauses proof allvars
   423 fun translate_proof clauses proof allvars
   494         = let val (thm, recons) = follow clauses proof allvars [] []
   424         = let val (thm, recons) = follow clauses proof allvars [] []
   495           in
   425           in
   496              (thm, (recons))
   426              (thm, (recons))
   497           end
   427           end
   498   
   428   
   499 
       
   500 
       
   501 fun remove_tinfo [] = []
       
   502   | remove_tinfo ( (clausenum, step, T_info, newstrs)::xs) =
       
   503       (clausenum, step , newstrs)::(remove_tinfo xs)
       
   504 
       
   505 end;
   429 end;