src/HOL/Tools/ATP/recon_transfer_proof.ML
author quigley
Fri, 10 Jun 2005 16:15:36 +0200
changeset 16357 f1275d2a1dee
parent 16259 aed1a8ae4b23
child 16478 d0a1f6231e2f
permissions -rw-r--r--
All subgoals sent to the watcher at once now. Rules added to parser for Spass proofs. If parsing or translation fails on a proof, the Spass proof is printed out in PG.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15789
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     1
(*  ID:         $Id$
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
     2
    Author:     Claire Quigley
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
     3
    Copyright   2004  University of Cambridge
15789
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     4
*)
4cb16144c81b added hearder lines and deleted some redundant material
paulson
parents: 15787
diff changeset
     5
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     6
(******************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     7
(* complete later *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     8
(******************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
     9
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    10
structure Recon_Transfer =
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    11
struct
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    12
open Recon_Parse
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    13
infixr 8 ++; infixr 7 >>; infixr 6 ||;
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    14
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    15
fun not_newline ch = not (ch = "\n");
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    16
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    17
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    18
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    19
(*
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    20
fun fill_cls_array array n [] = ()
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    21
|   fill_cls_array array n (x::xs) = let val _ = Array.update (array, n,x)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    22
                                     in
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    23
                                        fill_cls_array array (n+1) (xs)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    24
                                     end;
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    25
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    26
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    27
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    28
fun memo_add_clauses ((name:string, (cls:Thm.thm list)), symtable)=
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    29
                        symtable := Symtab.update((name , cls), !symtable);
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    30
      	       
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    31
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    32
fun memo_add_all ([], symtable) = ()
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    33
|   memo_add_all ((x::xs),symtable) = let val _ = memo_add_clauses (x, symtable)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    34
                           in
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    35
                               memo_add_all (xs, symtable)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    36
                           end
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    37
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    38
fun memo_find_clause (name, (symtable: Thm.thm list Symtab.table ref)) = case Symtab.lookup (!symtable,name) of
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    39
      	        NONE =>  []
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    40
                |SOME cls  => cls ;
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    41
      	        	
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    42
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    43
fun retrieve_clause array symtable clausenum = let
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    44
                                                  val (name, clnum) = Array.sub(array, clausenum)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    45
                                                  val clauses = memo_find_clause (name, symtable)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    46
                                                  val clause = get_nth clnum clauses
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    47
                                               in
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    48
                                                  (name, clause)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    49
                                               end
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    50
 *)                                             
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
    51
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    52
(* Versions that include type information *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    53
 
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    54
fun string_of_thm thm =
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    55
  let val _ = set show_sorts
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    56
      val str = Display.string_of_thm thm
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    57
      val no_returns =List.filter not_newline (explode str)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    58
      val _ = reset show_sorts
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    59
  in 
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    60
      implode no_returns
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    61
  end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    62
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    63
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    64
(* check separate args in the watcher program for separating strings with a * or ; or something *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    65
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    66
fun clause_strs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    67
|   clause_strs_to_string (x::xs) str = clause_strs_to_string xs (str^x^"%")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    68
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    69
fun thmvars_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    70
|   thmvars_to_string (x::xs) str = thmvars_to_string xs (str^x^"%")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    71
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    72
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    73
fun proofstep_to_string Axiom = "Axiom()"
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    74
|   proofstep_to_string  (Binary ((a,b), (c,d)))=
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    75
      "Binary(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    76
|   proofstep_to_string (Factor (a,b,c)) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    77
      "Factor("^(string_of_int a)^","^(string_of_int b)^","^(string_of_int c)^")"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    78
|   proofstep_to_string  (Para ((a,b), (c,d)))= 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    79
      "Para(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    80
|   proofstep_to_string  (MRR ((a,b), (c,d))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    81
      "MRR(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    82
|   proofstep_to_string (Rewrite((a,b),(c,d))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    83
      "Rewrite(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    84
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    85
fun list_to_string [] liststr = liststr
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    86
|   list_to_string (x::[]) liststr = liststr^(string_of_int x)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    87
|   list_to_string (x::xs) liststr = list_to_string xs (liststr^(string_of_int x)^",")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    88
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    89
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    90
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 "")^"]"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    91
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    92
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    93
fun proofs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    94
|   proofs_to_string (x::xs) str = let val newstr = proof_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    95
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    96
                                       proofs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    97
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    98
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    99
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   100
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   101
fun 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
   102
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   103
fun init_proofsteps_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   104
|   init_proofsteps_to_string (x::xs) str = let val newstr = init_proofstep_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   105
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   106
                                       init_proofsteps_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
(*** get a string representing the Isabelle ordered axioms ***)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   112
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   113
fun origAx_to_string (num,(meta,thmvars)) =
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   114
    let val clause_strs = ReconOrderClauses.get_meta_lits_bracket meta
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   115
    in
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   116
       (string_of_int num)^"OrigAxiom()["^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   117
       (clause_strs_to_string clause_strs "")^"]["^
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   118
       (thmvars_to_string thmvars "")^"]"
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   119
    end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   120
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   121
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   122
fun  origAxs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   123
|   origAxs_to_string (x::xs) str = let val newstr = origAx_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   124
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   125
                                       origAxs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   126
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   127
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   128
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   129
(*** get a string representing the Isabelle ordered axioms not used in the spass proof***)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   130
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   131
fun extraAx_to_string (num, (meta,thmvars)) =
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   132
   let val clause_strs = ReconOrderClauses.get_meta_lits_bracket meta
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   133
   in
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   134
      (string_of_int num)^"ExtraAxiom()["^
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   135
      (clause_strs_to_string clause_strs "")^"]"^
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   136
      "["^(thmvars_to_string thmvars "")^"]"
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   137
   end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   138
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   139
fun extraAxs_to_string [] str = str
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   140
|   extraAxs_to_string (x::xs) str =
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   141
      let val newstr = extraAx_to_string x 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   142
      in
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   143
	  extraAxs_to_string xs (str^newstr)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   144
      end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   145
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   146
fun is_axiom ( num:int,Axiom, str) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   147
|   is_axiom (num, _,_) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   148
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   149
fun get_init_axioms xs = List.filter (is_axiom) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   150
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   151
fun get_step_nums [] nums = nums
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   152
|   get_step_nums (( num:int,Axiom, str)::xs) nums = get_step_nums xs (nums@[num])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   153
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   154
exception Noassoc;
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   155
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   156
fun assoc_snd a [] = raise Noassoc
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   157
  | assoc_snd a ((x, y)::t) = if a = y then x else assoc_snd a t;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   158
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   159
(* 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
   160
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   161
(*fun get_assoc_snds [] xs assocs= assocs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   162
|   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
   163
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   164
(*FIX - should this have vars in it? *)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   165
fun there_out_of_order xs ys = (ReconOrderClauses.checkorder xs ys [] ([],[],[]); true) 
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   166
                               handle _ => false
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   167
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   168
fun assoc_out_of_order a [] = raise Noassoc
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   169
|   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
   170
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   171
fun get_assoc_snds [] xs assocs= assocs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   172
|   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
   173
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   174
fun add_if_not_inlist [] xs newlist = newlist
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   175
|   add_if_not_inlist (y::ys) xs newlist = if (not (y mem xs)) then 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   176
                                      add_if_not_inlist ys xs (y::newlist)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   177
                                        else add_if_not_inlist ys xs (newlist)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   178
15700
970e0293dfb3 tweaks mainly to achieve sml/nj compatibility
paulson
parents: 15697
diff changeset
   179
(*Flattens a list of list of strings to one string*)
970e0293dfb3 tweaks mainly to achieve sml/nj compatibility
paulson
parents: 15697
diff changeset
   180
fun onestr ls = String.concat (map String.concat ls);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   181
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   182
fun thmstrings [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   183
|   thmstrings (x::xs) str = thmstrings xs (str^(string_of_thm x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   184
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   185
fun is_clasimp_ax clasimp_num n = n <=clasimp_num 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   186
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   187
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   188
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   189
fun retrieve_axioms clause_arr  [] = []
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   190
|   retrieve_axioms clause_arr  (x::xs) =  [Array.sub(clause_arr, x)]@
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   191
 						     (retrieve_axioms clause_arr  xs)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   192
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   193
fun subone x = x - 1
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   194
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   195
fun numstr [] = ""
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   196
|   numstr (x::xs) = (string_of_int x)^"%"^(numstr xs)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   197
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   198
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   199
(* retrieve the axioms that were obtained from the clasimpset *)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   200
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   201
fun get_clasimp_cls clause_arr clasimp_num step_nums = 
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   202
    let val realnums = map subone step_nums	
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   203
	val clasimp_nums = List.filter (is_clasimp_ax (clasimp_num - 1)) realnums
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   204
	val axnums = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "axnums")))     
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   205
	val _ = TextIO.output(axnums,(numstr clasimp_nums))
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   206
	val _ = TextIO.closeOut(axnums)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   207
    in
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   208
	retrieve_axioms clause_arr  clasimp_nums
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   209
    end
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   210
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   211
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   212
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   213
(*****************************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   214
(* get names of clasimp axioms used                  *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   215
(*****************************************************)
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   216
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   217
 fun get_axiom_names proof_steps thms (clause_arr:(ResClause.clause * thm) Array.array) num_of_clauses  =
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   218
   let 
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   219
     (* not sure why this is necessary again, but seems to be *)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   220
      val _ = (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   221
      val axioms = get_init_axioms proof_steps
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   222
      val step_nums = get_step_nums axioms []
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   223
  
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   224
     (***********************************************)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   225
     (* here need to add the clauses from clause_arr*)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   226
     (***********************************************)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   227
  
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   228
      val (clasimp_names_cls) = get_clasimp_cls clause_arr num_of_clauses step_nums 
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   229
      val clasimp_names = map (#1 o ResClause.clause_info o #1) clasimp_names_cls
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   230
  
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   231
      val _ = File.write (File.tmp_path (Path.basic "clasimp_names"))                                                               
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   232
                         (concat clasimp_names)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   233
      val _ = (print_mode := (["xsymbols", "symbols"] @ ! print_mode))
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   234
   in
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   235
      clasimp_names
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   236
   end
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   237
    
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   238
 fun get_axiom_names_vamp proof_steps thms (clause_arr:(ResClause.clause * thm) Array.array) num_of_clauses  =
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   239
   let 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   240
     (* not sure why this is necessary again, but seems to be *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   241
      val _ = (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   242
      val axioms = get_init_axioms proof_steps
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   243
      val step_nums = get_step_nums axioms []
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   244
  
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   245
     (***********************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   246
     (* here need to add the clauses from clause_arr*)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   247
     (***********************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   248
  
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   249
      val (clasimp_names_cls) = get_clasimp_cls clause_arr num_of_clauses step_nums 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   250
      val clasimp_names = map (#1 o ResClause.clause_info o #1) clasimp_names_cls
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   251
  
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   252
      val _ = File.write (File.tmp_path (Path.basic "clasimp_names"))                                                               
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   253
                         (concat clasimp_names)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   254
      val _ = (print_mode := (["xsymbols", "symbols"] @ ! print_mode))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   255
   in
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   256
      clasimp_names
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   257
   end
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   258
    
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   259
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   260
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   261
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   262
(***********************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   263
(* get axioms for reconstruction               *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   264
(***********************************************)
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   265
fun numclstr (vars, []) str = str
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   266
|   numclstr ( vars, ((num, thm)::rest)) str =
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   267
      let val newstr = str^(string_of_int num)^" "^(string_of_thm thm)^" "
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   268
      in
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   269
        numclstr  (vars,rest) newstr
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   270
      end
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   271
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   272
fun addvars c (a,b)  = (a,b,c)
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   273
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   274
 fun get_axioms_used proof_steps thms clause_arr num_of_clauses  =
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   275
     let 
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   276
	 (*val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_ax_thmstr")))                                                                      
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   277
	 val _ = TextIO.output (outfile, thmstring)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   278
	 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   279
	 val _ =  TextIO.closeOut outfile*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   280
	(* not sure why this is necessary again, but seems to be *)
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   281
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   282
	val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   283
	val axioms = get_init_axioms proof_steps
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   284
	val step_nums = get_step_nums axioms []
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   285
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   286
       (***********************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   287
       (* here need to add the clauses from clause_arr*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   288
       (***********************************************)
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   289
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   290
       (* val clasimp_names_cls = get_clasimp_cls clause_arr   num_of_clauses step_nums   
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   291
	val clasimp_names = map #1 clasimp_names_cls
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   292
	val clasimp_cls = map #2 clasimp_names_cls
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   293
	val  outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "clasimp_names")))                                                            val clasimp_namestr = concat clasimp_names                            
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   294
	 val _ = TextIO.output (outfile,clasimp_namestr)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   295
	 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   296
	 val _ =  TextIO.closeOut outfile
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   297
*)
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   298
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   299
	val clauses =(*(clasimp_cls)@*)( make_clauses thms)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   300
	
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   301
	val vars = map thm_vars clauses
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   302
       
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   303
	val distvars = distinct (fold append vars [])
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   304
	val clause_terms = map prop_of clauses  
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   305
	val clause_frees = List.concat (map term_frees clause_terms)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   306
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   307
	val frees = map lit_string_with_nums clause_frees;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   308
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   309
	val distfrees = distinct frees
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   310
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   311
	val metas = map Meson.make_meta_clause clauses
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   312
	val ax_strs = map #3 axioms
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   313
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   314
	(* literals of -all- axioms, not just those used by spass *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   315
	val meta_strs = map ReconOrderClauses.get_meta_lits metas
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   316
       
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   317
	val metas_and_strs = ListPair.zip (metas,meta_strs)
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   318
	 val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_clauses")));                                                                       
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   319
	 val _ = TextIO.output (outfile, onestr ax_strs)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   320
	 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   321
	 val _ =  TextIO.closeOut outfile
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   322
	 val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_metastrs")));                                                                       
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   323
	 val _ = TextIO.output (outfile, onestr meta_strs)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   324
	 val _ =  TextIO.closeOut outfile
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   325
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   326
	(* get list of axioms as thms with their variables *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   327
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   328
	val ax_metas = get_assoc_snds ax_strs metas_and_strs []
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   329
	val ax_vars = map thm_vars ax_metas
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   330
	val ax_with_vars = ListPair.zip (ax_metas,ax_vars)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   331
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   332
	(* get list of extra axioms as thms with their variables *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   333
	val extra_metas = add_if_not_inlist metas ax_metas []
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   334
	val extra_vars = map thm_vars extra_metas
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   335
	val extra_with_vars = if (not (extra_metas = []) ) 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   336
			      then
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   337
				     ListPair.zip (extra_metas,extra_vars)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   338
			      else
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   339
				     []
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   340
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   341
       (* val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   342
       val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_metas")))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   343
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   344
       val _ = TextIO.output (outfile, ((thmstrings ax_metas "")))
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   345
       val _ =  TextIO.closeOut outfile
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   346
      val foo_metas =  File.platform_path(File.tmp_path (Path.basic "foo_metas"))
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   347
      val foo_metas2 =   File.platform_path(File.tmp_path (Path.basic "foo_metas2"))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   348
	val execperl = Unix.execute("/usr/bin/perl", ["remchars.pl", "  <", foo_metas, "  >", foo_metas2])
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   349
     val infile = TextIO.openIn(File.platform_path(File.tmp_path (Path.basic "foo_metas2")))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   350
    val ax_metas_str = TextIO.inputLine (infile)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   351
    val _ = TextIO.closeIn infile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   352
       val _= (print_mode := (["xsymbols", "symbols"] @ ! print_mode))*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   353
       
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   354
     in
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   355
	(distfrees,distvars, extra_with_vars,ax_with_vars, (*clasimp_names*)(ListPair.zip (step_nums,ax_metas)))
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   356
     end
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   357
    
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   358
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   359
                                        
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   360
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   361
(*********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   362
(* Pass in spass string of proof and string version of isabelle goal *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   363
(* Get out reconstruction steps as a string to be sent to Isabelle   *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   364
(*********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   365
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   366
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   367
fun rules_to_string [] str = str
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   368
|   rules_to_string [x] str = str^x
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   369
|   rules_to_string (x::xs) str = rules_to_string xs (str^x^"   ")
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   370
                                  
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   371
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   372
val dummy_tac = PRIMITIVE(fn thm => thm );
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   373
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   374
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   375
(*val  proofstr = "1242[0:Inp] ||  -> equal(const_List_Orev(tconst_fun(tconst_List_Olist(U),tconst_List_Olist(U)),const_List_Olist_ONil),const_List_Olist_ONil)**.\
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   376
\1279[0:Inp] ||  -> equal(const_Nat_Osize(tconst_fun(tconst_List_Olist(U),tconst_nat),const_List_Olist_ONil),const_0)**.\
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   377
\1430[0:Inp] || equal(const_Nat_Osize(tconst_fun(tconst_List_Olist(typ__Ha),tconst_nat),const_List_Orev(tconst_fun(tconst_List_Olist(typ__Ha),tconst_List_Olist(typ__Ha)),const_List_Olist_ONil)),const_Nat_Osize(tconst_fun(tconst_List_Olist(typ__Ha),tconst_nat),const_List_Olist_ONil))** -> .\
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   378
\1453[0:Rew:1279.0,1430.0,1242.0,1430.0,1279.0,1430.0] || equal(const_0,const_0)* -> .\
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   379
\1454[0:Obv:1453.0] ||  -> .";*)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   380
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   381
fun remove_linebreaks str = let val strlist = explode str
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   382
	                        val nonewlines = filter (not_equal "\n") strlist
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   383
	                    in
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   384
				implode nonewlines
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   385
			    end
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   386
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   387
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   388
fun subst_for a b [] = ""
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   389
|   subst_for a b (x::xs) = if (x = a)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   390
				   then 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   391
					(b^(subst_for a b  xs))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   392
				   else
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   393
					x^(subst_for a b xs)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   394
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   395
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   396
fun remove_linebreaks str = let val strlist = explode str
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   397
			    in
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   398
				subst_for "\n" "\t" strlist
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   399
			    end
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   400
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   401
fun restore_linebreaks str = let val strlist = explode str
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   402
			     in
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   403
				subst_for "\t" "\n" strlist
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   404
			     end
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   405
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   406
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   407
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   408
fun spassString_to_lemmaString proofstr thmstring goalstring toParent ppid thms clause_arr  num_of_clauses  = 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   409
           let 	val  outfile = TextIO.openAppend( File.platform_path(File.tmp_path (Path.basic"thmstringfile")));          
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   410
		val _ = TextIO.output (outfile, ("thmstring is: "^thmstring^"\n proofstr is: "^proofstr^"\n goalstr is: "^goalstring^" \n  num of clauses is: "^(string_of_int num_of_clauses)))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   411
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   412
              	val _ =  TextIO.closeOut outfile
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   413
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   414
                 (***********************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   415
                 (* parse spass proof into datatype *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   416
                 (***********************************)
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   417
         
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   418
                  val tokens = #1(lex proofstr)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   419
                  val proof_steps1 = parse tokens
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   420
                  val proof_steps = just_change_space proof_steps1
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   421
                  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_parse")));        val _ = TextIO.output (outfile, ("Did parsing on "^proofstr))
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   422
                                                  val _ =  TextIO.closeOut outfile
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   423
                                                
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   424
                                                  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_thmstring_at_parse")));                                        val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring))
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   425
                                                  val _ =  TextIO.closeOut outfile
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   426
                                              (************************************)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   427
                                              (* recreate original subgoal as thm *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   428
                                              (************************************)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   429
                                                
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   430
                                                  (* get axioms as correctly numbered clauses w.r.t. the Spass proof *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   431
                                                  (* need to get prems_of thm, then get right one of the prems, relating to whichever*)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   432
                                                  (* subgoal this is, and turn it into meta_clauses *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   433
                                                  (* should prob add array and table here, so that we can get axioms*)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   434
                                                  (* produced from the clasimpset rather than the problem *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   435
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   436
                                                  val (axiom_names) = get_axiom_names proof_steps  thms clause_arr  num_of_clauses
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   437
                                                  val ax_str = "Rules from clasimpset used in proof found by SPASS: "^(rules_to_string axiom_names "")
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   438
                                                  val  outfile = TextIO.openAppend(File.platform_path(File.tmp_path (Path.basic "reconstrfile")));                                                     val _ = TextIO.output (outfile, ("reconstring is: "^ax_str^"  "^goalstring))
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   439
                                                  val _ =  TextIO.closeOut outfile
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   440
                                                   
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   441
                                              in 
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   442
                                                   TextIO.output (toParent, ax_str^"\n");
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   443
                                                   TextIO.flushOut toParent;
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   444
                                        	   TextIO.output (toParent, "goalstring: "^goalstring^"\n");
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   445
                                         	   TextIO.flushOut toParent;
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   446
                                         	   TextIO.output (toParent, "thmstring: "^thmstring^"\n");
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   447
                                         	   TextIO.flushOut toParent;
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   448
                                          
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   449
                                         	   Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   450
                                         	  (* Attempt to prevent several signals from turning up simultaneously *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   451
                                         	   Posix.Process.sleep(Time.fromSeconds 1) ; dummy_tac
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   452
                                              end
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   453
                                              handle _ => (let val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_handler")));
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   454
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   455
                                                  val _ = TextIO.output (outfile, ("In exception handler"));
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   456
                                                  val _ =  TextIO.closeOut outfile
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   457
                                              in 
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   458
                                                 TextIO.output (toParent,"Proof found but parsing failed for resolution proof: "^(remove_linebreaks proofstr) ^"\n");
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   459
                                                  TextIO.flushOut toParent;
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   460
						   TextIO.output (toParent, thmstring^"\n");
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   461
                                         	   TextIO.flushOut toParent;
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   462
                                         	   TextIO.output (toParent, goalstring^"\n");
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   463
                                         	   TextIO.flushOut toParent;
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   464
            					  Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   465
                                         	  (* Attempt to prevent several signals from turning up simultaneously *)
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   466
                                         	  Posix.Process.sleep(Time.fromSeconds 1) ;dummy_tac
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   467
                                              end)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   468
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   469
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   470
(*fun vampString_to_lemmaString proofstr thmstring goalstring toParent ppid thms clause_arr  num_of_clauses  = 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   471
           let val  outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "thmstringfile")));     						  val _ = TextIO.output (outfile, (" thmstring is: "^thmstring^"proofstr is: "^proofstr^"goalstr is: "^goalstring^" num of clauses is: "^(string_of_int num_of_clauses)))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   472
                                                  val _ =  TextIO.closeOut outfile
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   473
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   474
                                              (***********************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   475
                                              (* parse spass proof into datatype *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   476
                                              (***********************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   477
         
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   478
                                                  val tokens = #1(lex proofstr)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   479
                                                  val proof_steps = VampParse.parse tokens
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   480
                                                  (*val proof_steps = just_change_space proof_steps1*)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   481
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_parse")));                                                     val _ = TextIO.output (outfile, ("Did parsing on "^proofstr))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   482
                                                  val _ =  TextIO.closeOut outfile
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   483
                                                
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   484
                                                  val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_thmstring_at_parse")));                                        val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   485
                                                  val _ =  TextIO.closeOut outfile
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   486
                                              (************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   487
                                              (* recreate original subgoal as thm *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   488
                                              (************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   489
                                                
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   490
                                                  (* get axioms as correctly numbered clauses w.r.t. the Spass proof *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   491
                                                  (* need to get prems_of thm, then get right one of the prems, relating to whichever*)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   492
                                                  (* subgoal this is, and turn it into meta_clauses *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   493
                                                  (* should prob add array and table here, so that we can get axioms*)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   494
                                                  (* produced from the clasimpset rather than the problem *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   495
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   496
                                                  val (axiom_names) = get_axiom_names_vamp proof_steps  thms clause_arr  num_of_clauses
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   497
                                                  val ax_str = "Rules from clasimpset used in proof found by SPASS: "^(rules_to_string axiom_names "")
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   498
                                                  val  outfile = TextIO.openAppend(File.sysify_path(File.tmp_path (Path.basic "reconstrfile")));                                                     val _ = TextIO.output (outfile, ("reconstring is: "^ax_str^"  "^goalstring))
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   499
                                                  val _ =  TextIO.closeOut outfile
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   500
                                                   
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   501
                                              in 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   502
                                                   TextIO.output (toParent, ax_str^"\n");
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   503
                                                   TextIO.flushOut toParent;
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   504
                                        	   TextIO.output (toParent, "goalstring: "^goalstring^"\n");
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   505
                                         	   TextIO.flushOut toParent;fdsa
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   506
                                         	   TextIO.output (toParent, "thmstring: "^thmstring^"\n");
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   507
                                         	   TextIO.flushOut toParent;
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   508
                                          
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   509
                                         	   Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   510
                                         	  (* Attempt to prevent several signals from turning up simultaneously *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   511
                                         	   Posix.Process.sleep(Time.fromSeconds 1) ; dummy_tac
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   512
                                              end
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   513
                                              handle _ => (let val  outfile = TextIO.openOut(File.sysify_path(File.tmp_path (Path.basic "foo_handler")));
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   514
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   515
                                                  val _ = TextIO.output (outfile, ("In exception handler"));
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   516
                                                  val _ =  TextIO.closeOut outfile
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   517
                                              in 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   518
                                                  TextIO.output (toParent,"Proof found but translation failed for resolution proof: \n"^(remove_linebreaks proofstr) ^"\n");
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   519
                                                  TextIO.flushOut toParent;
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   520
						   TextIO.output (toParent, thmstring^"\n");
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   521
                                         	   TextIO.flushOut toParent;
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   522
                                         	   TextIO.output (toParent, goalstring^"\n");
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   523
                                         	   TextIO.flushOut toParent;
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   524
            					  Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   525
                                         	  (* Attempt to prevent several signals from turning up simultaneously *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   526
                                         	  Posix.Process.sleep(Time.fromSeconds 1) ;dummy_tac
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   527
                                              end)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   528
*)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   529
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   530
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   531
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   532
(* val proofstr = "1582[0:Inp] || -> v_P*.\
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   533
                 \1583[0:Inp] || v_P* -> .\
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   534
		 \1584[0:MRR:1583.0,1582.0] || -> ."; *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   535
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   536
fun spassString_to_reconString proofstr thmstring goalstring toParent ppid thms clause_arr  num_of_clauses  = 
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   537
      let val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "thmstringfile")));                                        
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   538
	  (* val sign = sign_of_thm thm
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   539
	 val prems = prems_of thm
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   540
	 val prems_string =  concat_with_and (map (Sign.string_of_term sign) prems) "" 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   541
	  val _ = warning ("thmstring is: "^thmstring);(*("thm in spassStrtoRec: "^(concat_with_and (map string_of_thm thms) "")^*)*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   542
	  val _ = TextIO.output (outfile, (" thmstring is: "^thmstring^"proofstr is: "^proofstr))
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   543
(*val _ = TextIO.output (outfile, (("in spassStrto Reconstr")));*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   544
	  val _ =  TextIO.closeOut outfile
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   545
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   546
	  val tokens = #1(lex proofstr)
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   547
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   548
	    
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   549
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   550
      (***********************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   551
      (* parse spass proof into datatype *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   552
      (***********************************)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   553
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   554
	  val proof_steps1 = parse tokens
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   555
	  val proof_steps = just_change_space proof_steps1
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   556
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   557
	  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_parse")));                                                                                          val _ = TextIO.output (outfile, ("Did parsing on "^proofstr))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   558
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   559
	
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   560
	  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_thmstring_at_parse")));                                                                             val _ = TextIO.output (outfile, ("Parsing for thmstring: "^thmstring))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   561
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   562
      (************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   563
      (* recreate original subgoal as thm *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   564
      (************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   565
	
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   566
	  (* get axioms as correctly numbered clauses w.r.t. the Spass proof *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   567
	  (* need to get prems_of thm, then get right one of the prems, relating to whichever*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   568
	  (* subgoal this is, and turn it into meta_clauses *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   569
	  (* should prob add array and table here, so that we can get axioms*)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   570
	  (* produced from the clasimpset rather than the problem *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   571
	  val (frees,vars,extra_with_vars ,ax_with_vars,numcls) = get_axioms_used proof_steps  thms clause_arr  num_of_clauses
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   572
	  
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   573
	  (*val numcls_string = numclstr ( vars, numcls) ""*)
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   574
	  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_axiom")));                                                                            val _ = TextIO.output (outfile,"got axioms")
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   575
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   576
	    
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   577
      (************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   578
      (* translate proof                  *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   579
      (************************************)
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   580
	  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_steps")));                                                          val _ = TextIO.output (outfile, ("about to translate proof, steps: "^(init_proofsteps_to_string proof_steps "")))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   581
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   582
	  val (newthm,proof) = translate_proof numcls  proof_steps vars
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   583
	  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_steps2")));                                                                         val _ = TextIO.output (outfile, ("translated proof, steps: "^(init_proofsteps_to_string proof_steps "")))
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   584
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   585
      (***************************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   586
      (* transfer necessary steps as strings to Isabelle *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   587
      (***************************************************)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   588
	  (* turn the proof into a string *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   589
	  val reconProofStr = proofs_to_string proof ""
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   590
	  (* do the bit for the Isabelle ordered axioms at the top *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   591
	  val ax_nums = map #1 numcls
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   592
	  val ax_strs = map ReconOrderClauses.get_meta_lits_bracket (map #2 numcls)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   593
	  val numcls_strs = ListPair.zip (ax_nums,ax_strs)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   594
	  val num_cls_vars =  map (addvars vars) numcls_strs;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   595
	  val reconIsaAxStr = origAxs_to_string (ListPair.zip (ax_nums,ax_with_vars)) ""
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   596
	  
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   597
	  val extra_nums = if (not (extra_with_vars = [])) then (1 upto (length extra_with_vars)) else []
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   598
	  val reconExtraAxStr = extraAxs_to_string ( ListPair.zip (extra_nums,extra_with_vars)) ""
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   599
	  val frees_str = "["^(thmvars_to_string frees "")^"]"
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   600
	  val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "reconstringfile")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   601
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   602
	  val _ = TextIO.output (outfile, (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr))
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   603
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   604
	  val reconstr = (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   605
      in 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   606
	   TextIO.output (toParent, reconstr^"\n");
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   607
	   TextIO.flushOut toParent;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   608
	   TextIO.output (toParent, thmstring^"\n");
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   609
	   TextIO.flushOut toParent;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   610
	   TextIO.output (toParent, goalstring^"\n");
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   611
	   TextIO.flushOut toParent;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   612
  
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   613
	   Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   614
	  (* Attempt to prevent several signals from turning up simultaneously *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   615
	   Posix.Process.sleep(Time.fromSeconds 1) ; dummy_tac
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   616
      end
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   617
      handle _ => (let val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "foo_handler")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   618
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   619
	  val _ = TextIO.output (outfile, ("In exception handler"));
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   620
	  val _ =  TextIO.closeOut outfile
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   621
      in 
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   622
	   TextIO.output (toParent,"Proof found but translation failed for resolution proof: \n"^proofstr ^"\n");
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   623
	  TextIO.flushOut toParent;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   624
	TextIO.output (toParent, thmstring^"\n");
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   625
	   TextIO.flushOut toParent;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   626
	   TextIO.output (toParent, goalstring^"\n");
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   627
	   TextIO.flushOut toParent;
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   628
	  Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   629
	  (* Attempt to prevent several signals from turning up simultaneously *)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   630
	  Posix.Process.sleep(Time.fromSeconds 1) ;dummy_tac
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   631
      end)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   632
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   633
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   634
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   635
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   636
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   637
(**********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   638
(* At other end, want to turn back into datatype so can apply reconstruct_proof.  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   639
(* This will be done by the signal handler                                        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   640
(**********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   641
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   642
(* Parse in the string version of the proof steps for reconstruction *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   643
(* 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
   644
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   645
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   646
 val term_numstep =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   647
        (number ++ (a (Other ",")) ++ number) >> (fn (a, (_, c)) => (a, c))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   648
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   649
val extraaxiomstep = (a (Word "ExtraAxiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   650
            >> (fn (_) => ExtraAxiom)
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
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   654
val origaxiomstep = (a (Word "OrigAxiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   655
            >> (fn (_) => OrigAxiom)
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 axiomstep = (a (Word "Axiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   659
            >> (fn (_) => Axiom)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   660
     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   661
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   662
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   663
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   664
 val binarystep = (a (Word "Binary")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   665
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   666
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   667
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Binary (c,e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   668
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   669
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   670
 val parastep = (a (Word "Para")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   671
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   672
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   673
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Para(c, e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   674
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   675
 val mrrstep = (a (Word "MRR")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   676
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   677
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   678
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => MRR(c, e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   679
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   680
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   681
 val factorstep = (a (Word "Factor")) ++ (a (Other "("))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   682
                    ++ number ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   683
                       ++ number ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   684
                       ++ number ++  (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   685
                   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   686
            >> (fn (_, (_, (c, (_, (e,(_,(f,_))))))) =>  Factor (c,e,f))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   687
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   688
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   689
val rewritestep = (a (Word "Rewrite"))  ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   690
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   691
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   692
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Rewrite (c,e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   693
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   694
val obviousstep = (a (Word "Obvious")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   695
                   ++ term_numstep  ++ (a (Other ")")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   696
            >> (fn (_, (_, (c,_))) => Obvious (c))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   697
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   698
 val methodstep = extraaxiomstep || origaxiomstep || axiomstep ||binarystep || factorstep|| parastep || mrrstep || rewritestep || obviousstep
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   699
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   700
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   701
 val number_list_step =
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   702
        ( number ++ many ((a (Other ",") ++ number)>> #2))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   703
        >> (fn (a,b) => (a::b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   704
        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   705
 val numberlist_step = a (Other "[")  ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   706
                        >>(fn (_,_) => ([]:int list))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   707
                       || a (Other "[") ++ number_list_step ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   708
                        >>(fn (_,(a,_)) => a)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   709
                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   710
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   711
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   712
(** change this to allow P (x U) *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   713
 fun arglist_step input = ( word ++ many  word >> (fn (a, b) => (a^" "^(implode_with_space b)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   714
                           ||word >> (fn (a) => (a)))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   715
                
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   716
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   717
fun literal_step input = (word ++ a (Other "(") ++ arglist_step ++  a (Other ")")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   718
                                          >>(fn (a, (b, (c,d))) => (a^" ("^(c)^")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   719
                        || arglist_step >> (fn (a) => (a)))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   720
                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   721
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   722
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   723
(* fun term_step input = (a (Other "~") ++ arglist_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   724
                     ||  arglist_step ++ a (Other "%")>> (fn (a,b) => a ))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   725
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   726
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   727
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   728
 fun term_step input = (a (Other "~") ++ literal_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   729
                     ||  literal_step ++ a (Other "%")>> (fn (a,b) => a ))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   730
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   731
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   732
         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   733
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   734
 val term_list_step =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   735
        (  term_step ++ many ( term_step))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   736
        >> (fn (a,b) => (a::b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   737
        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   738
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   739
val term_lists_step = a (Other "[")  ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   740
                        >>(fn (_,_) => ([]:string list))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   741
                       || a (Other "[") ++ term_list_step ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   742
                        >>(fn (_,(a,_)) => a)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   743
                     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   744
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   745
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   746
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   747
fun anytoken_step input  = (word>> (fn (a) => a)  ) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   748
                       handle NOPARSE_WORD => (number>> (fn (a) => string_of_int a)  ) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   749
                      handle NOPARSE_NUMBER => (other_char >> (fn(a) => a)) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   750
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   751
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   752
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   753
fun goalstring_step input= (anytoken_step ++ many (anytoken_step )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   754
                  >> (fn (a,b) =>  (a^" "^(implode b)))) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   755
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   756
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   757
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   758
 val linestep = number ++ methodstep ++ term_lists_step ++ term_lists_step
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   759
                >> (fn (a, (b, (c,d))) => (a,(b,c,d)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   760
    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   761
 val lines_step = many linestep
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   762
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   763
 val alllines_step = (term_lists_step ++ lines_step ) ++ finished >> #1
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   764
    
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   765
 val parse_step = #1 o alllines_step
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   766
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   767
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   768
 (*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   769
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
   770
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   771
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   772
(************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   773
(* Construct an Isar style proof from a list of proof steps *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   774
(************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   775
(* want to assume all axioms, then do haves for the other clauses*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   776
(* then show for the last step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   777
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   778
(* replace ~ by not here *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   779
fun change_nots [] = []
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   780
|   change_nots (x::xs) = if x = "~" 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   781
                          then 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   782
                             ["\\", "<", "n", "o", "t", ">"]@(change_nots xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   783
                          else (x::(change_nots xs))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   784
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   785
(*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   786
fun clstrs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   787
|   clstrs_to_string (x::[]) str = str^x
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   788
|   clstrs_to_string (x::xs) str = clstrs_to_string xs (str^(x^"; "))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   789
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   790
fun clstrs_to_string [] str = implode (change_nots (explode str))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   791
|   clstrs_to_string (x::[]) str = implode (change_nots (explode (str^x)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   792
|   clstrs_to_string (x::xs) str = implode (change_nots (explode (clstrs_to_string xs (str^(x^"; ")))))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   793
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   794
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   795
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   796
fun thmvars_to_quantstring [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   797
|   thmvars_to_quantstring (x::[]) str =str^x^". "
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   798
|   thmvars_to_quantstring (x::xs) str = thmvars_to_quantstring xs (str^(x^" "))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   799
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   800
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   801
fun clause_strs_to_isar clstrs [] =  "\"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> \\<Longrightarrow> False\""
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   802
|   clause_strs_to_isar clstrs thmvars = "\"\\<And>"^(thmvars_to_quantstring thmvars "")^"\\<lbrakk>"^(clstrs_to_string clstrs "")^"\\<rbrakk> \\<Longrightarrow> False\""
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   803
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   804
fun frees_to_string [] str = implode (change_nots (explode str))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   805
|   frees_to_string (x::[]) str = implode (change_nots (explode (str^x)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   806
|   frees_to_string  (x::xs) str = implode (change_nots (explode (frees_to_string xs (str^(x^" ")))))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   807
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   808
fun frees_to_isar_str [] =  ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   809
|   frees_to_isar_str  clstrs = (frees_to_string clstrs "")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   810
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   811
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   812
(***********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   813
(* functions for producing assumptions for the Isabelle ordered axioms *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   814
(***********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   815
(*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
   816
num, rule, clausestrs, vars*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   817
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   818
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   819
(* assume the extra clauses - not used in Spass proof *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   820
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   821
fun is_extraaxiom_step ( num:int,(ExtraAxiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   822
|   is_extraaxiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   823
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   824
fun get_extraaxioms xs = List.filter (is_extraaxiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   825
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   826
fun assume_isar_extraaxiom [] str  = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   827
|   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
   828
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   829
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   830
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   831
fun assume_isar_extraaxioms  [] = ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   832
|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
   833
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   834
                                             assume_isar_extraaxiom xs str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   835
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   836
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   837
(* assume the Isabelle ordered clauses *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   838
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   839
fun is_origaxiom_step ( num:int,(OrigAxiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   840
|   is_origaxiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   841
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   842
fun get_origaxioms xs = List.filter (is_origaxiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   843
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   844
fun assume_isar_origaxiom [] str  = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   845
|   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
   846
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   847
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   848
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   849
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
   850
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   851
                                             assume_isar_origaxiom xs str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   852
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   853
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   854
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   855
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   856
fun is_axiom_step ( num:int,(Axiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   857
|   is_axiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   858
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   859
fun get_axioms xs = List.filter  (is_axiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   860
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   861
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
   862
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   863
fun  by_isar_axiomline (numb,(step, clstrs, thmstrs))="by (rule cl"^ (string_of_int numb)^"') \n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   864
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   865
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   866
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
   867
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   868
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   869
fun isar_axiomlines [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   870
|   isar_axiomlines (x::xs) str = isar_axiomlines xs (str^(isar_axiomline x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   871
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   872
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   873
fun have_isar_line (numb,(step, clstrs, thmstrs))="have cl"^(string_of_int numb)^": "^(clause_strs_to_isar clstrs thmstrs)^"\n"
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   874
(*FIX: ask Larry to add and mrr attribute *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   875
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   876
fun by_isar_line ((Binary ((a,b), (c,d)))) = 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   877
    "by(rule cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   878
		(string_of_int a)^" [binary "^(string_of_int b)^" cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   879
		(string_of_int c)^" "^(string_of_int d)^"])\n"
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   880
|by_isar_line ((MRR ((a,b), (c,d)))) = 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   881
    "by(rule cl"^
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   882
		(string_of_int a)^" [binary "^(string_of_int b)^" cl"^
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   883
		(string_of_int c)^" "^(string_of_int d)^"])\n"
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   884
|   by_isar_line ( (Para ((a,b), (c,d)))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   885
    "by (rule cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   886
		(string_of_int a)^" [paramod "^(string_of_int b)^" cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   887
		(string_of_int c)^" "^(string_of_int d)^"])\n"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   888
|   by_isar_line ((Factor ((a,b,c)))) = 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   889
    "by (rule cl"^(string_of_int a)^" [factor "^(string_of_int b)^" "^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   890
		(string_of_int c)^" ])\n"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   891
|   by_isar_line ( (Rewrite ((a,b),(c,d)))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   892
    "by (rule cl"^(string_of_int a)^" [demod "^(string_of_int b)^" "^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   893
		(string_of_int c)^" "^(string_of_int d)^" ])\n"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   894
|   by_isar_line ( (Obvious ((a,b)))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   895
    "by (rule cl"^(string_of_int a)^" [obvious "^(string_of_int b)^" ])\n"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   896
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   897
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
   898
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   899
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   900
fun isar_lines [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   901
|   isar_lines (x::xs) str = isar_lines xs (str^(isar_line x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   902
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   903
fun last_isar_line (numb,( step, clstrs,thmstrs)) = "show \"False\"\n"^(by_isar_line step)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   904
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   905
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   906
fun to_isar_proof (frees, xs, goalstring) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   907
    let val extraaxioms = get_extraaxioms xs
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   908
	val extraax_num = length extraaxioms
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   909
	val origaxioms_and_steps = Library.drop (extraax_num, xs)  
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   910
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   911
	val origaxioms = get_origaxioms origaxioms_and_steps
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   912
	val origax_num = length origaxioms
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   913
	val axioms_and_steps = Library.drop (origax_num + extraax_num, xs)  
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   914
	val axioms = get_axioms axioms_and_steps
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   915
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   916
	val steps = Library.drop (origax_num, axioms_and_steps)
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   917
	val firststeps = ReconOrderClauses.butlast steps
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   918
	val laststep = ReconOrderClauses.last steps
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   919
	val goalstring = implode(ReconOrderClauses.butlast(explode goalstring))
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   920
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   921
	val isar_proof = 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   922
		("show \""^goalstring^"\"\n")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   923
		("proof (rule ccontr,skolemize, make_clauses) \n")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   924
		("fix "^(frees_to_isar_str frees)^"\n")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   925
		(assume_isar_extraaxioms extraaxioms)^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   926
		(assume_isar_origaxioms origaxioms)^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   927
		(isar_axiomlines axioms "")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   928
		(isar_lines firststeps "")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   929
		(last_isar_line laststep)^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   930
		("qed")
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   931
	val  outfile = TextIO.openOut(File.platform_path(File.tmp_path (Path.basic "isar_proof_file")));
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   932
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   933
	val _ = TextIO.output (outfile, isar_proof)
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   934
	val _ =  TextIO.closeOut outfile
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   935
    in
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   936
	isar_proof
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   937
    end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   938
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   939
(* get fix vars from axioms - all Frees *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   940
(* check each clause for meta-vars and /\ over them at each step*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   941
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   942
(*******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   943
(* This assumes the thm list  "numcls" is still there  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   944
(* In reality, should probably label it with an        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   945
(* ID number identifying the subgoal.  This could      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   946
(* be passed over to the watcher, e.g.  numcls25       *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   947
(*******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   948
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   949
(* 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
   950
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   951
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
   952
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   953
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
   954
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   955
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   956
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
   957
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   958
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
   959
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   960
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   961
fun apply_res_thm str goalstring  = let val tokens = #1 (lex str);
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   962
				val _ = File.append (File.tmp_path (Path.basic "applyres")) 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   963
			           ("str is: "^str^" goalstr is: "^goalstring^"\n")	
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   964
                                   val (frees,recon_steps) = parse_step tokens 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   965
                                   val isar_str = to_isar_proof (frees, recon_steps, goalstring)
16259
aed1a8ae4b23 File.platform_path;
wenzelm
parents: 16157
diff changeset
   966
                                   val foo =   TextIO.openOut (File.platform_path(File.tmp_path (Path.basic "foobar")));
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   967
                               in 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   968
                                  TextIO.output(foo,(isar_str));TextIO.closeOut foo;Pretty.writeln(Pretty.str  isar_str); () 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   969
                               end 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   970
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   971
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   972
(* val reconstr = reconstr^"[P%]51Axiom()[~P%]52Axiom[P%][]53MRR((52,0),(51,0))[][]";
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   973
*)
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   974
end;