src/HOL/Tools/ATP/recon_transfer_proof.ML
author paulson
Mon, 11 Apr 2005 16:25:31 +0200
changeset 15697 681bcb7f0389
parent 15684 5ec4d21889d6
child 15700 970e0293dfb3
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
(* complete later *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     3
(******************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     4
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     5
structure Recon_Transfer =
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     6
struct
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     7
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     8
open Recon_Parse
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     9
infixr 8 ++; infixr 7 >>; infixr 6 ||;
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    10
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    11
fun not_newline ch = not (ch = "\n");
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    12
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    13
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    14
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    15
(* Versions that include type information *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    16
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    17
fun string_of_thm thm = let val _ = set show_sorts
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
    18
                                val str = string_of_thm thm
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    19
                                val no_returns =List.filter not_newline (explode str)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    20
                                val _ = reset show_sorts
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    21
                            in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    22
                                implode no_returns
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    23
                            end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    24
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    25
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    26
fun thm_of_string str = let val _ = set show_sorts
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    27
                                val term = read str
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    28
                                val propterm = HOLogic.mk_Trueprop term
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    29
                                val cterm = cterm_of Mainsign propterm
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    30
                                val _ = reset show_sorts
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    31
                            in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    32
                                assume cterm
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    33
                            end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    34
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    35
(* check separate args in the watcher program for separating strings with a * or ; or something *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    36
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    37
fun clause_strs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    38
|   clause_strs_to_string (x::xs) str = clause_strs_to_string xs (str^x^"%")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    39
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    40
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    41
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    42
fun thmvars_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    43
|   thmvars_to_string (x::xs) str = thmvars_to_string xs (str^x^"%")
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
fun proofstep_to_string Axiom = "Axiom()"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    47
|   proofstep_to_string  (Binary ((a,b), (c,d)))= "Binary"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    48
|   proofstep_to_string (Factor (a,b,c)) = "Factor"^"("^(string_of_int a)^","^(string_of_int b)^","^(string_of_int c)^")"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    49
|   proofstep_to_string  (Para ((a,b), (c,d)))= "Para"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    50
|   proofstep_to_string  (MRR ((a,b), (c,d)))= "MRR"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    51
|   proofstep_to_string (Rewrite((a,b),(c,d))) = "Rewrite"^"("^"("^(string_of_int a)^","^(string_of_int b)^")"^","^"("^(string_of_int c)^","^(string_of_int d)^")"^")"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    52
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    53
fun list_to_string [] liststr = liststr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    54
|   list_to_string (x::[]) liststr = liststr^(string_of_int x)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    55
|   list_to_string (x::xs) liststr = list_to_string xs (liststr^(string_of_int x)^",")
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 proof_to_string (num,(step,clause_strs, thmvars)) = (string_of_int num)^(proofstep_to_string step)^"["^(clause_strs_to_string clause_strs "")^"]"^"["^(thmvars_to_string thmvars "")^"]"
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
fun proofs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    62
|   proofs_to_string (x::xs) str = let val newstr = proof_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    63
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    64
                                       proofs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    65
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    66
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    67
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    68
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    69
fun init_proofstep_to_string (num, step, clause_strs) = (string_of_int num)^" "^(proofstep_to_string step)^" "^(clause_strs_to_string clause_strs "")^" "
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    70
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    71
fun init_proofsteps_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    72
|   init_proofsteps_to_string (x::xs) str = let val newstr = init_proofstep_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    73
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    74
                                       init_proofsteps_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    75
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    76
  
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
(*** get a string representing the Isabelle ordered axioms ***)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    80
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    81
fun origAx_to_string (num,(meta,thmvars)) =let val clause_strs = get_meta_lits_bracket meta
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    82
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    83
                                            (string_of_int num)^"OrigAxiom()"^"["^(clause_strs_to_string clause_strs "")^"]"^"["^(thmvars_to_string thmvars "")^"]"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    84
                                         end
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
fun  origAxs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    88
|   origAxs_to_string (x::xs) str = let val newstr = origAx_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    89
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    90
                                       origAxs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    91
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    92
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    93
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    94
(*** get a string representing the Isabelle ordered axioms not used in the spass proof***)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    95
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    96
fun extraAx_to_string (num, (meta,thmvars)) = let val clause_strs = get_meta_lits_bracket meta
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    97
                                           in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    98
                                              (string_of_int num)^"ExtraAxiom()"^"["^(clause_strs_to_string clause_strs "")^"]"^"["^(thmvars_to_string thmvars "")^"]"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    99
                                           end
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
fun  extraAxs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   104
|   extraAxs_to_string (x::xs) str = let val newstr = extraAx_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   105
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   106
                                       extraAxs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   107
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   108
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   109
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   110
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
fun is_axiom ( num:int,Axiom, str) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   115
|   is_axiom (num, _,_) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   116
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   117
fun get_init_axioms xs = List.filter (is_axiom) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   118
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   119
fun get_step_nums [] nums = nums
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   120
|   get_step_nums (( num:int,Axiom, str)::xs) nums = get_step_nums xs (nums@[num])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   121
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   122
fun assoc_snd a [] = raise Recon_Base.Noassoc
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   123
  | assoc_snd a ((x, y)::t) = if a = y then x else assoc_snd a t;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   124
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   125
(* change to be something using check_order  instead of a = y --> returns true if ASSERTION not raised in checkorder, false otherwise *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   126
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   127
(*fun get_assoc_snds [] xs assocs= assocs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   128
|   get_assoc_snds (x::xs) ys assocs = get_assoc_snds xs ys (assocs@[((assoc_snd x ys))])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   129
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   130
(*FIX - should this have vars in it? *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   131
fun there_out_of_order xs ys = let val foo = (checkorder xs ys [] ([],[],[])) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   132
                                   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   133
                               in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   134
                                   true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   135
                              end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   136
                              handle EXCEP => false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   137
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   138
fun assoc_out_of_order a [] = raise Recon_Base.Noassoc
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   139
|   assoc_out_of_order a ((b,c)::t) = if there_out_of_order a c then b else assoc_out_of_order a t;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   140
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   141
fun get_assoc_snds [] xs assocs= assocs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   142
|   get_assoc_snds (x::xs) ys assocs = get_assoc_snds xs ys (assocs@[((assoc_out_of_order x ys))])
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
fun add_if_not_inlist [] xs newlist = newlist
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   148
|   add_if_not_inlist (y::ys) xs newlist = if (not (inlist y xs)) then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   149
                                      add_if_not_inlist ys xs (y::newlist)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   150
                                        else add_if_not_inlist ys xs (newlist)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   151
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   152
fun onestr [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   153
|   onestr (x::xs) str = onestr xs (str^(concat x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   154
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   155
fun thmstrings [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   156
|   thmstrings (x::xs) str = thmstrings xs (str^(string_of_thm x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   157
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   158
fun onelist [] newlist = newlist
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   159
|   onelist (x::xs) newlist = onelist xs (newlist@x)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   160
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   161
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   162
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   163
val prop_of = #prop o rep_thm;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   164
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   165
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   166
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   167
 fun get_axioms_used proof_steps thmstring = let 
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   168
                                             val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_ax_thmstr")))                                                                      
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   169
                                             val _ = TextIO.output (outfile, thmstring)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   170
                                             
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   171
                                             val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   172
                                            (* not sure why this is necessary again, but seems to be *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   173
                                            val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   174
                                            val axioms = get_init_axioms proof_steps
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   175
                                            val step_nums = get_step_nums axioms []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   176
                                            val thm = thm_of_string thmstring
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   177
                                            val clauses = make_clauses [thm]
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   178
                                            
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   179
                                            val vars = map thm_vars clauses
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   180
                                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   181
                                            val distvars = distinct (fold append vars [])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   182
                                            val clause_terms = map prop_of clauses  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   183
                                            val clause_frees = onelist (map term_frees clause_terms) []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   184
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   185
                                            val frees = map lit_string_with_nums clause_frees;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   186
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   187
                                            val distfrees = distinct frees
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   188
15697
681bcb7f0389 removal of Main and other tidying up
paulson
parents: 15684
diff changeset
   189
                                            val metas = map Meson.make_meta_clause clauses
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   190
                                            val ax_strs = map #3 axioms
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   191
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   192
                                            (* literals of -all- axioms, not just those used by spass *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   193
                                            val meta_strs = map get_meta_lits metas
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   194
                                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   195
                                            val metas_and_strs = zip  metas meta_strs
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   196
                                             val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_clauses")));                                                                       
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   197
                                             val _ = TextIO.output (outfile, (onestr ax_strs ""))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   198
                                             
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   199
                                             val _ =  TextIO.closeOut outfile
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   200
                                             val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_metastrs")));                                                                       
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   201
                                             val _ = TextIO.output (outfile, (onestr meta_strs ""))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   202
                                             val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   203
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   204
                                            (* get list of axioms as thms with their variables *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   205
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   206
                                            val ax_metas = get_assoc_snds ax_strs metas_and_strs []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   207
                                            val ax_vars = map thm_vars ax_metas
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   208
                                            val ax_with_vars = zip ax_metas ax_vars
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   209
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   210
                                            (* get list of extra axioms as thms with their variables *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   211
                                            val extra_metas = add_if_not_inlist metas ax_metas []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   212
                                            val extra_vars = map thm_vars extra_metas
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   213
                                            val extra_with_vars = if (not (extra_metas = []) ) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   214
                                                                  then
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   215
 									 zip extra_metas extra_vars
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   216
                                                                  else
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   217
                                                                         []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   218
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   219
                                           (* val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   220
                                           val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_metas")))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   221
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   222
                                           val _ = TextIO.output (outfile, ((thmstrings ax_metas "")))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   223
                                           val _ =  TextIO.closeOut outfile
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   224
                                          val foo_metas =  File.sysify_path(File.tmp_path (Path.basic "foo_metas"))
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   225
                                          val foo_metas2 =   File.sysify_path(File.tmp_path (Path.basic "foo_metas2"))
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   226
                                            val execperl = Unix.execute("/usr/bin/perl", ["remchars.pl", "  <", foo_metas, "  >", foo_metas2])
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   227
                                         val infile = TextIO.openIn(File.sysify_path(File.tmp_path (Path.basic "foo_metas2")))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   228
                                        val ax_metas_str = TextIO.inputLine (infile)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   229
                                        val _ = TextIO.closeIn infile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   230
                                           val _= (print_mode := (["xsymbols", "symbols"] @ ! print_mode))*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   231
                                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   232
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   233
                                            (distfrees,distvars, extra_with_vars,ax_with_vars, (zip step_nums ax_metas))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   234
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   235
                                        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   236
fun thmstrings [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   237
|   thmstrings (x::xs) str = thmstrings xs (str^(string_of_thm x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   238
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   239
fun numclstr (vars, []) str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   240
|   numclstr ( vars, ((num, thm)::rest)) str = let val newstr = str^(string_of_int num)^" "^(string_of_thm thm)^" "
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   241
                               in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   242
                                   numclstr  (vars,rest) newstr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   243
                               end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   244
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   245
(*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   246
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   247
val proofstr = "Did parsing on Here is a proof with depth 4, length 9 :\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   248
\1[0:Inp] || v_P(tconst_fun(typ__da_a,tconst_bool),v_x)*+ -> v_P(tconst_fun(typ__da_a,tconst_bool),U)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   249
\3[0:Inp] || v_P(tconst_fun(typ__da_a,tconst_bool),U)*+ -> v_P(tconst_fun(typ__da_a,tconst_bool),v_x)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   250
\5[0:Inp] ||  -> v_P(tconst_fun(typ__da_a,tconst_bool),U)* v_P(tconst_fun(typ__da_a,tconst_bool),v_xa)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   251
\7[0:Inp] || v_P(tconst_fun(typ__da_a,tconst_bool),U)*+ v_P(tconst_fun(typ__da_a,tconst_bool),v_xb)* -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   252
\9[0:Fac:5.0,5.1] ||  -> v_P(tconst_fun(typ__da_a,tconst_bool),v_xa)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   253
\10[0:Res:9.0,3.0] ||  -> v_P(tconst_fun(typ__da_a,tconst_bool),v_x)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   254
\11[0:Res:10.0,1.0] ||  -> v_P(tconst_fun(typ__da_a,tconst_bool),U)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   255
\12[0:Fac:7.0,7.1] || v_P(tconst_fun(typ__da_a,tconst_bool),v_xb)* -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   256
\14[0:Res:11.0,12.0] ||  -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   257
\Formulae used in the proof :"
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
fun addvars  c (a,b)  = (a,b,c)
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
(* Pass in spass string of proof and string version of isabelle goal *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   268
(* Get out reconstruction steps as a string to be sent to Isabelle   *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   269
(*********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   270
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   271
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   272
(*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   273
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   274
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   275
val proofstr = "Here is a proof with depth 2, length 5 :\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   276
\1[0:Inp] ||  -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   277
\3[0:Inp] || v_Q(tconst_fun(typ__asc39_a,tconst_bool),U)* -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   278
\5[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)* -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa).\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   279
\7[0:Res:1.0,5.0] ||  -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   280
\9[0:Res:7.0,3.0] ||  -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   281
\Formulae used in the proof :"
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
val proofstr = "Here is a proof with depth 4, length 9 :\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   285
\1[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)*+ -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   286
\3[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*+ -> v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   287
\5[0:Inp] ||  -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)* v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xa)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   288
\7[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*+ v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xb)* -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   289
\9[0:Fac:5.0,5.1] ||  -> v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xa)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   290
\10[0:Res:9.0,3.0] ||  -> v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   291
\11[0:Res:10.0,1.0] ||  -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   292
\12[0:Fac:7.0,7.1] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_xb)* -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   293
\14[0:Res:11.0,12.0] ||  -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   294
\Formulae used in the proof :";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   295
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   296
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   297
val thmstring = " (~ (P::'a::type => bool) (x::'a::type) | P (U::'a::type)) & (~ (P::'a::type => bool) (U::'a::type) | P (x::'a::type)) & ((P::'a::type => bool) (xa::'a::type) | P (U::'a::type)) & (~ (P::'a::type => bool) (U::'a::type) | ~ P (xb::'a::type))";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   298
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   299
val thmstring = "(ALL xb::'a::type.   (~ (P::'a::type => bool) ((x::'a::type => 'a::type) xb) |    (Q::'a::type => bool) ((xa::'a::type => 'a::type) xb)) &   P xb & ~ Q xb)"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   300
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   301
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   302
val thmstring ="(ALL xb::'a::type.   (~ (P::'a::type => bool) ((x::'a::type => 'a::type) xb) |    (Q::'a::type => bool) ((xa::'a::type => 'a::type) xb)) &   P xb & ~ Q xb)"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   303
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   304
val proofstr = "Did parsing on Here is a proof with depth 2, length 5 :\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   305
\1[0:Inp] ||  -> v_P(tconst_fun(typ__asc39_a,tconst_bool),U)*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   306
\3[0:Inp] || v_Q(tconst_fun(typ__asc39_a,tconst_bool),U)* -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   307
\5[0:Inp] || v_P(tconst_fun(typ__asc39_a,tconst_bool),v_x(tconst_fun(typ__asc39_a,typ__asc39_a),U))* -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa(tconst_fun(typ__asc39_a,typ__asc39_a),U)).\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   308
\7[0:Res:1.0,5.0] ||  -> v_Q(tconst_fun(typ__asc39_a,tconst_bool),v_xa(tconst_fun(typ__asc39_a,typ__asc39_a),U))*.\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   309
\9[0:Res:7.0,3.0] ||  -> .\
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   310
\Formulae used in the proof :";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   311
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
fun spassString_to_reconString proofstr thmstring = 
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   316
                                              let val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "thmstringfile")));                                                                                      val _= warning("proofstr is: "^proofstr);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   317
                                                  val _ = warning ("thmstring is: "^thmstring);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   318
                                                  val _ = TextIO.output (outfile, (thmstring))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   319
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   320
                                                  val proofextract = extract_proof proofstr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   321
                                                  val tokens = fst(lex proofextract)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   322
                                                     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   323
                                              (***********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   324
                                              (* parse spass proof into datatype *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   325
                                              (***********************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   326
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   327
                                                  val proof_steps1 = parse tokens
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   328
                                                  val proof_steps = just_change_space proof_steps1
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   329
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   330
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_parse")));                                                                                          val _ = TextIO.output (outfile, ("Did parsing on "^proofstr))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   331
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   332
                                                
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   333
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_thmstring_at_parse")));                                                                             val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   334
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   335
                                              (************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   336
                                              (* recreate original subgoal as thm *)
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
                                                  (* get axioms as correctly numbered clauses w.r.t. the Spass proof *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   340
                                                  val (frees,vars,extra_with_vars ,ax_with_vars,numcls) = get_axioms_used proof_steps thmstring
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   341
                                                  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   342
                                                  (*val numcls_string = numclstr ( vars, numcls) ""*)
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   343
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_axiom")));                                                                            val _ = TextIO.output (outfile,"got axioms")
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   344
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   345
                                                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   346
                                              (************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   347
                                              (* translate proof                  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   348
                                              (************************************)
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   349
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_steps")));                                                          val _ = TextIO.output (outfile, ("about to translate proof, steps: "^(init_proofsteps_to_string proof_steps "")))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   350
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   351
                                                  val (newthm,proof) = translate_proof numcls  proof_steps vars
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   352
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_steps2")));                                                                         val _ = TextIO.output (outfile, ("translated proof, steps: "^(init_proofsteps_to_string proof_steps "")))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   353
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   354
                                              (***************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   355
                                              (* transfer necessary steps as strings to Isabelle *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   356
                                              (***************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   357
                                                  (* turn the proof into a string *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   358
                                                  val reconProofStr = proofs_to_string proof ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   359
                                                  (* do the bit for the Isabelle ordered axioms at the top *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   360
                                                  val ax_nums = map fst numcls
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   361
                                                  val ax_strs = map get_meta_lits_bracket (map snd numcls)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   362
                                                  val numcls_strs = zip ax_nums ax_strs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   363
                                                  val num_cls_vars =  map (addvars vars) numcls_strs;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   364
                                                  val reconIsaAxStr = origAxs_to_string (zip ax_nums ax_with_vars) ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   365
                                                  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   366
                                                  val extra_nums = if (not (extra_with_vars = [])) then (1 upto (length extra_with_vars)) else []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   367
                                                  val reconExtraAxStr = extraAxs_to_string ( zip extra_nums extra_with_vars) ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   368
                                                  val frees_str = "["^(thmvars_to_string frees "")^"]"
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   369
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "reconstringfile")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   370
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   371
                                                  val _ = TextIO.output (outfile, (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   372
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   373
                                              in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   374
                                                   (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   375
                                              end
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   376
                                              handle _ => (let val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_handler")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   377
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   378
                                                  val _ = TextIO.output (outfile, ("In exception handler"));
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   379
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   380
                                              in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   381
                                                 "Proof found but translation failed!"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   382
                                              end)
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
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   387
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   388
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   389
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   390
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   391
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   392
(**********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   393
(* At other end, want to turn back into datatype so can apply reconstruct_proof.  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   394
(* This will be done by the signal handler                                        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   395
(**********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   396
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   397
(* Parse in the string version of the proof steps for reconstruction *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   398
(* Isar format: cl1 [BINARY 0 cl2 0];cl1 [PARAMOD 0 cl2 0]; cl1 [DEMOD 0 cl2];cl1 [FACTOR 1 2];*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   399
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   400
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   401
 val term_numstep =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   402
        (number ++ (a (Other ",")) ++ number) >> (fn (a, (_, c)) => (a, c))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   403
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   404
val extraaxiomstep = (a (Word "ExtraAxiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   405
            >> (fn (_) => ExtraAxiom)
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
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   409
val origaxiomstep = (a (Word "OrigAxiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   410
            >> (fn (_) => OrigAxiom)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   411
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   412
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   413
 val axiomstep = (a (Word "Axiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   414
            >> (fn (_) => Axiom)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   415
     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   416
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   417
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   418
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   419
 val binarystep = (a (Word "Binary")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   420
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   421
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   422
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Binary (c,e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   423
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   424
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   425
 val parastep = (a (Word "Para")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   426
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   427
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   428
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Para(c, e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   429
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   430
 val mrrstep = (a (Word "MRR")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   431
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   432
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   433
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => MRR(c, e))
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
 val factorstep = (a (Word "Factor")) ++ (a (Other "("))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   437
                    ++ number ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   438
                       ++ number ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   439
                       ++ number ++  (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   440
                   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   441
            >> (fn (_, (_, (c, (_, (e,(_,(f,_))))))) =>  Factor (c,e,f))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   442
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   443
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   444
val rewritestep = (a (Word "Rewrite"))  ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   445
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   446
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   447
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Rewrite (c,e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   448
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   449
val obviousstep = (a (Word "Obvious")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   450
                   ++ term_numstep  ++ (a (Other ")")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   451
            >> (fn (_, (_, (c,_))) => Obvious (c))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   452
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   453
 val methodstep = extraaxiomstep || origaxiomstep || axiomstep ||binarystep || factorstep|| parastep || mrrstep || rewritestep || obviousstep
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   454
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   455
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   456
 val number_list_step =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   457
        ( number ++ many ((a (Other ",") ++ number)>> snd))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   458
        >> (fn (a,b) => (a::b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   459
        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   460
 val numberlist_step = a (Other "[")  ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   461
                        >>(fn (_,_) => ([]:int list))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   462
                       || a (Other "[") ++ number_list_step ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   463
                        >>(fn (_,(a,_)) => a)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   464
                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   465
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   466
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   467
(** change this to allow P (x U) *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   468
 fun arglist_step input = ( word ++ many  word >> (fn (a, b) => (a^" "^(implode_with_space b)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   469
                           ||word >> (fn (a) => (a)))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   470
                
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   471
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   472
fun literal_step input = (word ++ a (Other "(") ++ arglist_step ++  a (Other ")")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   473
                                          >>(fn (a, (b, (c,d))) => (a^" ("^(c)^")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   474
                        || arglist_step >> (fn (a) => (a)))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   475
                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   476
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   477
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   478
(* fun term_step input = (a (Other "~") ++ arglist_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   479
                     ||  arglist_step ++ a (Other "%")>> (fn (a,b) => a ))input
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
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   483
 fun term_step input = (a (Other "~") ++ literal_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   484
                     ||  literal_step ++ a (Other "%")>> (fn (a,b) => a ))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   485
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   486
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   487
         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   488
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   489
 val term_list_step =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   490
        (  term_step ++ many ( term_step))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   491
        >> (fn (a,b) => (a::b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   492
        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   493
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   494
val term_lists_step = a (Other "[")  ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   495
                        >>(fn (_,_) => ([]:string list))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   496
                       || a (Other "[") ++ term_list_step ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   497
                        >>(fn (_,(a,_)) => a)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   498
                     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   499
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   500
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   501
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   502
fun anytoken_step input  = (word>> (fn (a) => a)  ) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   503
                       handle NOPARSE_WORD => (number>> (fn (a) => string_of_int a)  ) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   504
                      handle NOPARSE_NUMBER => (other_char >> (fn(a) => a)) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   505
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   506
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   507
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   508
fun goalstring_step input= (anytoken_step ++ many (anytoken_step )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   509
                  >> (fn (a,b) =>  (a^" "^(implode b)))) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   510
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   511
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   512
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   513
 val linestep = number ++ methodstep ++ term_lists_step ++ term_lists_step
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   514
                >> (fn (a, (b, (c,d))) => (a,(b,c,d)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   515
    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   516
 val lines_step = many linestep
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   517
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   518
 val alllines_step = (term_lists_step ++ lines_step ) ++ finished >> fst
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   519
    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   520
 val parse_step = fst o alllines_step
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   521
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   522
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   523
 (*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   524
val reconstr ="[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]%(EX x::'a::type. ALL y::'a::type. (P::'a::type => bool) x = P y) -->(EX x::'a::type. P x) = (ALL y::'a::type. P y)"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   525
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   526
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   527
(************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   528
(* Construct an Isar style proof from a list of proof steps *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   529
(************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   530
(* want to assume all axioms, then do haves for the other clauses*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   531
(* then show for the last step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   532
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   533
(* replace ~ by not here *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   534
fun change_nots [] = []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   535
|   change_nots (x::xs) = if x = "~" 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   536
                          then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   537
                             ["\\", "<", "n", "o", "t", ">"]@(change_nots xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   538
                          else (x::(change_nots xs))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   539
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   540
(*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   541
fun clstrs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   542
|   clstrs_to_string (x::[]) str = str^x
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   543
|   clstrs_to_string (x::xs) str = clstrs_to_string xs (str^(x^"; "))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   544
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   545
fun clstrs_to_string [] str = implode (change_nots (explode str))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   546
|   clstrs_to_string (x::[]) str = implode (change_nots (explode (str^x)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   547
|   clstrs_to_string (x::xs) str = implode (change_nots (explode (clstrs_to_string xs (str^(x^"; ")))))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   548
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   549
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   550
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   551
fun thmvars_to_quantstring [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   552
|   thmvars_to_quantstring (x::[]) str =str^x^". "
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   553
|   thmvars_to_quantstring (x::xs) str = thmvars_to_quantstring xs (str^(x^" "))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   554
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   555
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   556
fun clause_strs_to_isar clstrs [] =  "\"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> "^" \\<Longrightarrow> False\""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   557
|   clause_strs_to_isar clstrs thmvars = "\"\\<And>"^(thmvars_to_quantstring thmvars "")^"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> "^"\\<Longrightarrow> False\""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   558
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   559
fun frees_to_string [] str = implode (change_nots (explode str))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   560
|   frees_to_string (x::[]) str = implode (change_nots (explode (str^x)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   561
|   frees_to_string  (x::xs) str = implode (change_nots (explode (frees_to_string xs (str^(x^" ")))))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   562
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   563
fun frees_to_isar_str [] =  ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   564
|   frees_to_isar_str  clstrs = (frees_to_string clstrs "")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   565
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   566
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   567
(***********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   568
(* functions for producing assumptions for the Isabelle ordered axioms *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   569
(***********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   570
(*val str = "[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]";       
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   571
num, rule, clausestrs, vars*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   572
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   573
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   574
(* assume the extra clauses - not used in Spass proof *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   575
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   576
fun is_extraaxiom_step ( num:int,(ExtraAxiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   577
|   is_extraaxiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   578
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   579
fun get_extraaxioms xs = List.filter (is_extraaxiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   580
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   581
fun assume_isar_extraaxiom [] str  = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   582
|   assume_isar_extraaxiom ((numb,(step, clstr, thmvars))::xs) str  = assume_isar_extraaxiom xs (str^"and cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstr thmvars)^"\n " )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   583
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   584
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   585
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   586
fun assume_isar_extraaxioms  [] = ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   587
|assume_isar_extraaxioms ((numb,(step, clstrs, thmstrs))::xs) = let val str = "assume cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstrs thmstrs)^"\n" 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   588
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   589
                                             assume_isar_extraaxiom xs str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   590
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   591
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   592
(* assume the Isabelle ordered clauses *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   593
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   594
fun is_origaxiom_step ( num:int,(OrigAxiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   595
|   is_origaxiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   596
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   597
fun get_origaxioms xs = List.filter (is_origaxiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   598
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   599
fun assume_isar_origaxiom [] str  = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   600
|   assume_isar_origaxiom ((numb,(step, clstr, thmvars))::xs) str  = assume_isar_origaxiom xs (str^"and cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstr thmvars)^"\n " )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   601
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   602
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   603
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   604
fun assume_isar_origaxioms ((numb,(step, clstrs, thmstrs))::xs) = let val str = "assume cl"^(string_of_int numb)^"': "^(clause_strs_to_isar clstrs thmstrs)^"\n" 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   605
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   606
                                             assume_isar_origaxiom xs str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   607
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   608
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   609
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   610
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   611
fun is_axiom_step ( num:int,(Axiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   612
|   is_axiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   613
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   614
fun get_axioms xs = List.filter  (is_axiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   615
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   616
fun have_isar_axiomline (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   617
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   618
fun  by_isar_axiomline (numb,(step, clstrs, thmstrs))="by (rule cl"^ (string_of_int numb)^"') \n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   619
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   620
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   621
fun isar_axiomline (numb, (step, clstrs, thmstrs))  = (have_isar_axiomline (numb,(step,clstrs, thmstrs )))^( by_isar_axiomline(numb,(step,clstrs, thmstrs )) )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   622
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   623
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   624
fun isar_axiomlines [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   625
|   isar_axiomlines (x::xs) str = isar_axiomlines xs (str^(isar_axiomline x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   626
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   627
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   628
fun have_isar_line (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   629
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   630
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   631
fun  by_isar_line ((Binary ((a,b), (c,d))))="by(rule cl"^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   632
                                                  (string_of_int a)^" [BINARY "^(string_of_int b)^" "^"cl"^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   633
                                                  (string_of_int c)^" "^(string_of_int d)^"])"^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   634
|   by_isar_line ( (Para ((a,b), (c,d)))) ="by (rule cl"^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   635
                                                  (string_of_int a)^" [PARAMOD "^(string_of_int b)^" "^"cl"^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   636
                                                  (string_of_int c)^" "^(string_of_int d)^"])"^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   637
|   by_isar_line ((Factor ((a,b,c)))) =    "by (rule cl"^(string_of_int a)^" [FACTOR "^(string_of_int b)^" "^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   638
                                                  (string_of_int c)^" "^"])"^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   639
|   by_isar_line ( (Rewrite ((a,b),(c,d)))) =  "by (rule cl"^(string_of_int a)^" [DEMOD "^(string_of_int b)^" "^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   640
                                                  (string_of_int c)^" "^(string_of_int d)^" "^"])"^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   641
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   642
|   by_isar_line ( (Obvious ((a,b)))) =  "by (rule cl"^(string_of_int a)^" [OBVIOUS "^(string_of_int b)^" ])"^"\n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   643
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   644
fun isar_line (numb, (step, clstrs, thmstrs))  = (have_isar_line (numb,(step,clstrs, thmstrs )))^( by_isar_line step)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   645
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   646
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   647
fun isar_lines [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   648
|   isar_lines (x::xs) str = isar_lines xs (str^(isar_line x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   649
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   650
fun last_isar_line (numb,( step, clstrs,thmstrs)) = "show \"False\"\n"^(by_isar_line step)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   651
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   652
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   653
fun to_isar_proof (frees, xs, goalstring) = let val extraaxioms = get_extraaxioms xs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   654
                           val extraax_num = length extraaxioms
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   655
                           val origaxioms_and_steps = drop (extraax_num) xs  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   656
                          
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   657
  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   658
                           val origaxioms = get_origaxioms origaxioms_and_steps
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   659
                           val origax_num = length origaxioms
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   660
                           val axioms_and_steps = drop (origax_num + extraax_num) xs  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   661
                           val axioms = get_axioms axioms_and_steps
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   662
                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   663
                           val steps = drop origax_num axioms_and_steps
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   664
                           val firststeps = butlast steps
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   665
                           val laststep = last steps
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   666
                           val goalstring = implode(butlast(explode goalstring))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   667
                        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   668
                           val isar_proof = 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   669
                           ("show \""^goalstring^"\"\n")^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   670
                           ("proof (rule ccontr,skolemize, make_clauses) \n")^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   671
                           ("fix "^(frees_to_isar_str frees)^"\n")^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   672
                           (assume_isar_extraaxioms extraaxioms)^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   673
                           (assume_isar_origaxioms origaxioms)^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   674
                           (isar_axiomlines axioms "")^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   675
                           (isar_lines firststeps "")^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   676
                           (last_isar_line laststep)^
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   677
                           ("qed")
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   678
                          val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "isar_proof_file")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   679
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   680
                                                  val _ = TextIO.output (outfile, isar_proof)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   681
                                                  val _ =  TextIO.closeOut outfile
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   682
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   683
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   684
                       in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   685
                           isar_proof
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   686
                       end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   687
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   688
(* get fix vars from axioms - all Frees *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   689
(* check each clause for meta-vars and /\ over them at each step*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   690
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   691
(*******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   692
(* This assumes the thm list  "numcls" is still there  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   693
(* In reality, should probably label it with an        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   694
(* ID number identifying the subgoal.  This could      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   695
(* be passed over to the watcher, e.g.  numcls25       *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   696
(*******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   697
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   698
(* val str = "[S%x%P%R%Q%]1ExtraAxiom()[~ Q U%~ R U%][U%]2ExtraAxiom()[~ Q U%~ P U%][U%]3ExtraAxiom()[Q U%R U%][U%]1OrigAxiom()[S x%][]2OrigAxiom()[P U%R U%][U%]6OrigAxiom()[~ S U%~ P U%][U%]7OrigAxiom()[~ S U%~ R U%][U%]1Axiom()[S x%][]2Axiom()[R U%P U%][U%]6Axiom()[~ P U%~ S U%][U%]7Axiom()[~ R U%~ S U%][U%]8Binary((6,1),(1,0))[~ P x%][]9Binary((7,1),(1,0))[~ R x%][]19Binary((9,0),(2,0))[P x%][]25Binary((8,0),(19,0))[][]";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   699
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   700
val str = "[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   701
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   702
val reconstr = "[P%Q%x%xa%]1OrigAxiom()[~ P U%][U%]3OrigAxiom()[Q U%][U%]5OrigAxiom()[P (x U)%~ Q (xa U)%][U%]9Binary((7,0),(3,0))[][]7Binary((1,0),(5,0))[~ Q (xa U)%][U%]5Axiom()[P (x U)%~ Q (xa U)%][U%]3Axiom()[Q U%][U%]1Axiom()[~ P U%][U%](ALL xb::'a::type.   (~ (P::'a::type => bool) ((x::'a::type => 'a::type) xb) |    (Q::'a::type => bool) ((xa::'a::type => 'a::type) xb)) &   P xb & ~ Q xb)";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   703
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   704
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   705
val reconstr = "[P%x%xa%xb%]1OrigAxiom()[P x%~ P U%][U%]3OrigAxiom()[P U%~ P x%][U%]5OrigAxiom()[~ P xa%~ P U%][U%]7OrigAxiom()[P U%P xb%][U%]1Axiom()[P x%~ P U%][U%]3Axiom()[P U%~ P x%][U%]5Axiom()[~ P U%~ P xa%][U%]7Axiom()[P U%P xb%][U%]9Factor(5,0,1)[~ P xa%][]10Binary((9,0),(3,0))[~ P x%][]11Binary((10,0),(1,0))[~ P U%][U%]12Factor(7,0,1)[P xb%][]14Binary((11,0),(12,0))[][]";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   706
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   707
val thmstring = " (ALL xa::'a::type.   (~ (P::'a::type => bool) (x::'a::type) | P xa) & (~ P xa | P x)) & (((P::'a::type => bool) (xa::'a::type) | (ALL x::'a::type. P x)) &((ALL x::'a::type. ~ P x) | ~ P (xb::'a::type)))";
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   708
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   709
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   710
fun apply_res_thm str goalstring  = let val tokens = fst (lex str);
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   711
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   712
                                   val (frees,recon_steps) = parse_step tokens 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   713
                                   val isar_str = to_isar_proof (frees, recon_steps, goalstring)
15658
2edb384bf61f watcher.ML and watcher.sig changed. Debug files now write to tmp.
quigley
parents: 15642
diff changeset
   714
                                   val foo =   TextIO.openOut (File.sysify_path(File.tmp_path (Path.basic "foobar")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   715
                               in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   716
                                  TextIO.output(foo,(isar_str));TextIO.closeOut foo;Pretty.writeln(Pretty.str  isar_str); () 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   717
                               end 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   718
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   719
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   720
end;