src/HOL/Tools/ATP/recon_transfer_proof.ML
author paulson
Thu, 22 Sep 2005 14:09:48 +0200
changeset 17583 c272b91b619f
parent 17569 c1143a96f6d7
child 17690 8ba7c3cd24a8
permissions -rw-r--r--
removal of "sleep" to stop looping in Poly/ML, and replacement of funny codes by tracing statements
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
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     6
structure Recon_Transfer =
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     7
struct
16803
wenzelm
parents: 16548
diff changeset
     8
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
     9
open Recon_Parse
16803
wenzelm
parents: 16548
diff changeset
    10
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    11
infixr 8 ++; infixr 7 >>; infixr 6 ||;
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
    12
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    13
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    14
(* Versions that include type information *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    15
 
16803
wenzelm
parents: 16548
diff changeset
    16
(* FIXME rename to str_of_thm *)
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
    17
fun string_of_thm thm =
16803
wenzelm
parents: 16548
diff changeset
    18
  setmp show_sorts true (Pretty.str_of o Display.pretty_thm) thm;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    19
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    20
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    21
(* check separate args in the watcher program for separating strings with a * or ; or something *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    22
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    23
fun clause_strs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    24
|   clause_strs_to_string (x::xs) str = clause_strs_to_string xs (str^x^"%")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    25
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    26
fun thmvars_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    27
|   thmvars_to_string (x::xs) str = thmvars_to_string xs (str^x^"%")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    28
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    29
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    30
fun proofstep_to_string Axiom = "Axiom()"
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    31
|   proofstep_to_string  (Binary ((a,b), (c,d)))=
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    32
      "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
    33
|   proofstep_to_string (Factor (a,b,c)) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    34
      "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
    35
|   proofstep_to_string  (Para ((a,b), (c,d)))= 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    36
      "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
    37
|   proofstep_to_string  (MRR ((a,b), (c,d))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    38
      "MRR(("^(string_of_int a)^","^(string_of_int b)^"),("^(string_of_int c)^","^(string_of_int d)^"))"
16548
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
    39
(*|   proofstep_to_string (Rewrite((a,b),(c,d))) =
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
    40
      "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
    41
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    42
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
    43
fun proof_to_string (num,(step,clause_strs, thmvars)) =
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
    44
 (string_of_int num)^(proofstep_to_string step)^
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
    45
 "["^(clause_strs_to_string clause_strs "")^"]["^(thmvars_to_string thmvars "")^"]"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    46
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    47
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    48
fun proofs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    49
|   proofs_to_string (x::xs) str = let val newstr = proof_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    50
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    51
                                       proofs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    52
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    53
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    54
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    55
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
    56
fun init_proofstep_to_string (num, step, clause_strs) =
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
    57
 (string_of_int num)^" "^(proofstep_to_string step)^" "^
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
    58
 (clause_strs_to_string clause_strs "")^" "
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    59
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    60
fun init_proofsteps_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    61
|   init_proofsteps_to_string (x::xs) str = let val newstr = init_proofstep_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    62
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    63
                                       init_proofsteps_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    64
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    65
  
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    66
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    67
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    68
(*** get a string representing the Isabelle ordered axioms ***)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    69
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    70
fun origAx_to_string (num,(meta,thmvars)) =
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    71
    let val clause_strs = ReconOrderClauses.get_meta_lits_bracket meta
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    72
    in
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    73
       (string_of_int num)^"OrigAxiom()["^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    74
       (clause_strs_to_string clause_strs "")^"]["^
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    75
       (thmvars_to_string thmvars "")^"]"
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    76
    end
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    77
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    78
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    79
fun  origAxs_to_string [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    80
|   origAxs_to_string (x::xs) str = let val newstr = origAx_to_string x 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    81
                                   in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    82
                                       origAxs_to_string xs (str^newstr)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    83
                                   end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    84
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    85
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    86
(*** get a string representing the Isabelle ordered axioms not used in the spass proof***)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    87
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    88
fun extraAx_to_string (num, (meta,thmvars)) =
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    89
   let val clause_strs = ReconOrderClauses.get_meta_lits_bracket meta
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    90
   in
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
    91
      (string_of_int num)^"ExtraAxiom()["^
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    92
      (clause_strs_to_string clause_strs "")^"]"^
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    93
      "["^(thmvars_to_string thmvars "")^"]"
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    94
   end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
    95
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    96
fun extraAxs_to_string [] str = str
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    97
|   extraAxs_to_string (x::xs) str =
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    98
      let val newstr = extraAx_to_string x 
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
    99
      in
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   100
	  extraAxs_to_string xs (str^newstr)
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   101
      end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   102
17312
159783c74f75 yet more tidying of Isabelle-ATP link
paulson
parents: 17306
diff changeset
   103
fun is_axiom (_,Axiom,str) = true
159783c74f75 yet more tidying of Isabelle-ATP link
paulson
parents: 17306
diff changeset
   104
|   is_axiom (_,_,_) = false
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   105
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   106
fun get_step_nums [] nums = nums
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   107
|   get_step_nums (( num:int,Axiom, str)::xs) nums = get_step_nums xs (nums@[num])
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   108
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   109
exception Noassoc;
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   110
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   111
fun assoc_snd a [] = raise Noassoc
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   112
  | assoc_snd a ((x, y)::t) = if a = y then x else assoc_snd a t;
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   113
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   114
(* 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
   115
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   116
(*fun get_assoc_snds [] xs assocs= assocs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   117
|   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
   118
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   119
(*FIX - should this have vars in it? *)
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   120
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
   121
                               handle _ => false
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   122
15774
9df37a0e935d more tidying of libraries in Reconstruction
paulson
parents: 15739
diff changeset
   123
fun assoc_out_of_order a [] = raise Noassoc
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   124
|   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
   125
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   126
fun get_assoc_snds [] xs assocs= assocs
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   127
|   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
   128
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   129
fun add_if_not_inlist [] xs newlist = newlist
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   130
|   add_if_not_inlist (y::ys) xs newlist = if (not (y mem xs)) then 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   131
                                      add_if_not_inlist ys xs (y::newlist)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   132
                                        else add_if_not_inlist ys xs (newlist)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   133
15700
970e0293dfb3 tweaks mainly to achieve sml/nj compatibility
paulson
parents: 15697
diff changeset
   134
(*Flattens a list of list of strings to one string*)
970e0293dfb3 tweaks mainly to achieve sml/nj compatibility
paulson
parents: 15697
diff changeset
   135
fun onestr ls = String.concat (map String.concat ls);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   136
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   137
fun is_clasimp_ax clasimp_num n = n <= clasimp_num 
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   138
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   139
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
   140
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   141
fun numstr [] = ""
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   142
|   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
   143
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   144
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   145
(* 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
   146
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   147
fun get_clasimp_cls (clause_arr: (ResClause.clause * thm) array) step_nums = 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   148
    let val clasimp_nums = List.filter (is_clasimp_ax (Array.length clause_arr - 1)) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   149
	                   (map subone step_nums)
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   150
(*	val _ = File.write (File.tmp_path (Path.basic "axnums")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   151
                     (numstr clasimp_nums) *)
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   152
    in
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   153
	map (fn x =>  Array.sub(clause_arr, x)) clasimp_nums
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   154
    end
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   155
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   156
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   157
(*****************************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   158
(* get names of clasimp axioms used                  *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   159
(*****************************************************)
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   160
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   161
 fun get_axiom_names step_nums clause_arr =
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   162
   let 
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   163
     (* not sure why this is necessary again, but seems to be *)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   164
      val _ = (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   165
  
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   166
     (***********************************************)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   167
     (* here need to add the clauses from clause_arr*)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   168
     (***********************************************)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   169
  
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   170
      val clasimp_names_cls = get_clasimp_cls clause_arr step_nums 
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   171
      val clasimp_names = map (ResClause.get_axiomName o #1) clasimp_names_cls
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   172
      val _ = File.write (File.tmp_path (Path.basic "clasimp_names"))                                                               
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   173
                         (concat clasimp_names)
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   174
      val _ = (print_mode := (["xsymbols", "symbols"] @ ! print_mode))
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   175
   in
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   176
      clasimp_names
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   177
   end
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17235
diff changeset
   178
   
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   179
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   180
fun get_axiom_names_spass proofstr clause_arr =
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   181
  let (* parse spass proof into datatype *)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   182
      val _ = File.write (File.tmp_path (Path.basic "parsing_progress")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   183
                         ("Started parsing:\n" ^ proofstr)
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   184
      val tokens = #1(lex proofstr)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   185
      val proof_steps = parse tokens
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   186
      val _ = File.append (File.tmp_path (Path.basic "parsing_progress")) "\nFinished!"
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   187
      (* get axioms as correctly numbered clauses w.r.t. the Spass proof *)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   188
  in
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   189
    get_axiom_names (get_step_nums (List.filter is_axiom proof_steps) []) clause_arr
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   190
  end;
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   191
    
17569
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   192
 (*String contains multiple lines.
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   193
  A list consisting of the first number in each line is returned. *)
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   194
fun get_linenums proofstr = 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   195
  let val numerics = String.tokens (not o Char.isDigit)
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   196
      fun firstno [] = NONE
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   197
        | firstno (x::xs) = Int.fromString x
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   198
      val lines = String.tokens (fn c => c = #"\n") proofstr
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   199
  in  List.mapPartial (firstno o numerics) lines  end
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   200
17569
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   201
fun get_axiom_names_e proofstr clause_arr  =
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   202
   get_axiom_names (get_linenums proofstr) clause_arr;
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17235
diff changeset
   203
    
17569
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   204
 (*String contains multiple lines. We want those of the form 
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   205
     "*********** [448, input] ***********".
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   206
  A list consisting of the first number in each line is returned. *)
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   207
fun get_vamp_linenums proofstr = 
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   208
  let val toks = String.tokens (not o Char.isAlphaNum)
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   209
      fun inputno [n,"input"] = Int.fromString n
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   210
        | inputno _ = NONE
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   211
      val lines = String.tokens (fn c => c = #"\n") proofstr
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   212
  in  List.mapPartial (inputno o toks) lines  end
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   213
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   214
fun get_axiom_names_vamp proofstr clause_arr  =
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   215
   get_axiom_names (get_vamp_linenums proofstr) clause_arr;
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   216
    
17235
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17122
diff changeset
   217
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   218
(***********************************************)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   219
(* get axioms for reconstruction               *)
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   220
(***********************************************)
16156
2f6fc19aba1e Fixed array containing clasimpset rules. Added flags to turn on and off reconstruction and full spass
quigley
parents: 16091
diff changeset
   221
fun numclstr (vars, []) str = str
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   222
|   numclstr ( vars, ((num, thm)::rest)) str =
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   223
      let val newstr = str^(string_of_int num)^" "^(string_of_thm thm)^" "
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   224
      in
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   225
        numclstr  (vars,rest) newstr
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   226
      end
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   227
16157
1764cc98bafd minor tidying and sml/nj compatibility
paulson
parents: 16156
diff changeset
   228
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
   229
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   230
fun get_axioms_used proof_steps thms clause_arr  =
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   231
  let 
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   232
     val _=  (print_mode := (Library.gen_rems (op =) (! print_mode, ["xsymbols", "symbols"])))
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   233
     val axioms = (List.filter is_axiom) proof_steps
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   234
     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
   235
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   236
     val clauses = make_clauses thms    (*FIXME: must this be repeated??*)
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   237
     
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   238
     val vars = map thm_vars clauses
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   239
    
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   240
     val distvars = distinct (fold append vars [])
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   241
     val clause_terms = map prop_of clauses  
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   242
     val clause_frees = List.concat (map term_frees clause_terms)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   243
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   244
     val frees = map lit_string_with_nums clause_frees;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   245
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   246
     val distfrees = distinct frees
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   247
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   248
     val metas = map Meson.make_meta_clause clauses
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   249
     val ax_strs = map #3 axioms
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   250
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   251
     (* literals of -all- axioms, not just those used by spass *)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   252
     val meta_strs = map ReconOrderClauses.get_meta_lits metas
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   253
    
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   254
     val metas_and_strs = ListPair.zip (metas,meta_strs)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   255
     val _ = File.write(File.tmp_path (Path.basic "foo_clauses")) (onestr ax_strs)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   256
     val _ = File.write(File.tmp_path (Path.basic "foo_metastrs")) (onestr meta_strs)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   257
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   258
     (* get list of axioms as thms with their variables *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   259
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   260
     val ax_metas = get_assoc_snds ax_strs metas_and_strs []
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   261
     val ax_vars = map thm_vars ax_metas
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   262
     val ax_with_vars = ListPair.zip (ax_metas,ax_vars)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   263
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   264
     (* get list of extra axioms as thms with their variables *)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   265
     val extra_metas = add_if_not_inlist metas ax_metas []
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   266
     val extra_vars = map thm_vars extra_metas
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   267
     val extra_with_vars = if (not (extra_metas = []) ) 
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   268
			   then ListPair.zip (extra_metas,extra_vars)
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   269
			   else []
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   270
  in
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   271
     (distfrees,distvars, extra_with_vars,ax_with_vars, ListPair.zip (step_nums,ax_metas))
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   272
  end;
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   273
                                            
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   274
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   275
(*********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   276
(* Pass in spass string of proof and string version of isabelle goal *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   277
(* Get out reconstruction steps as a string to be sent to Isabelle   *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   278
(*********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   279
17122
278eb6251dc0 nicer list of axioms used
paulson
parents: 16905
diff changeset
   280
fun rules_to_string [] = "NONE"
278eb6251dc0 nicer list of axioms used
paulson
parents: 16905
diff changeset
   281
  | rules_to_string xs = "[" ^ space_implode ", " xs ^ "]"
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   282
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   283
fun subst_for a b = String.translate (fn c => str (if c=a then b else c));
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   284
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   285
val remove_linebreaks = subst_for #"\n" #"\t";
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   286
val restore_linebreaks = subst_for #"\t" #"\n";
16357
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   287
16478
d0a1f6231e2f Added VampCommunication.ML.
quigley
parents: 16357
diff changeset
   288
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   289
fun prover_lemma_list_aux getax proofstr goalstring toParent ppid clause_arr = 
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   290
 let val _ = File.append(File.tmp_path (Path.basic "prover_lemmastring"))
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   291
               ("proofstr is " ^ proofstr ^
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   292
                "\ngoalstr is " ^ goalstring ^
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   293
                "\nnum of clauses is " ^ string_of_int (Array.length clause_arr))
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   294
     val axiom_names = getax proofstr clause_arr
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   295
     val ax_str = rules_to_string axiom_names
17235
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17122
diff changeset
   296
    in 
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   297
	 File.append(File.tmp_path (Path.basic "prover_lemmastring"))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   298
	            ("\nlemma list is: " ^ ax_str);
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   299
         TextIO.output (toParent, "Success. Lemmas used in automatic proof: " ^
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   300
                  ax_str ^ "\n");
17312
159783c74f75 yet more tidying of Isabelle-ATP link
paulson
parents: 17306
diff changeset
   301
	 TextIO.output (toParent, "goalstring: "^goalstring^"\n");
17235
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17122
diff changeset
   302
	 TextIO.flushOut toParent;
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17122
diff changeset
   303
17583
c272b91b619f removal of "sleep" to stop looping in Poly/ML, and replacement of funny codes by tracing statements
paulson
parents: 17569
diff changeset
   304
	 Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2)
17235
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17122
diff changeset
   305
    end
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   306
    handle exn => (*FIXME: exn handler is too general!*)
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   307
     (File.write(File.tmp_path (Path.basic "proverString_handler")) 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   308
         ("In exception handler: " ^ Toplevel.exn_message exn);
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   309
      TextIO.output (toParent, "Translation failed for the proof: " ^ 
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   310
                     remove_linebreaks proofstr ^ "\n");
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   311
      TextIO.output (toParent, remove_linebreaks goalstring ^ "\n");
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   312
      TextIO.flushOut toParent;
17583
c272b91b619f removal of "sleep" to stop looping in Poly/ML, and replacement of funny codes by tracing statements
paulson
parents: 17569
diff changeset
   313
      Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2));
17235
8e55ad29b690 Added ECommunication.ML and modified res_atp.ML, Reconstruction.thy, and
quigley
parents: 17122
diff changeset
   314
17569
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   315
val e_lemma_list = prover_lemma_list_aux get_axiom_names_e;
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   316
c1143a96f6d7 improved proof parsing
paulson
parents: 17488
diff changeset
   317
val vamp_lemma_list = prover_lemma_list_aux get_axiom_names_vamp;
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   318
17488
67376a311a2b further simplification of the Isabelle-ATP linkup
paulson
parents: 17484
diff changeset
   319
val spass_lemma_list = prover_lemma_list_aux get_axiom_names_spass;
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   320
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   321
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   322
(**** Full proof reconstruction for SPASS (not really working) ****)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   323
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   324
fun spass_reconstruct proofstr goalstring toParent ppid thms clause_arr = 
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   325
  let val _ = File.write(File.tmp_path (Path.basic "prover_reconstruction")) 
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   326
                 ("proofstr is: "^proofstr)
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   327
      val tokens = #1(lex proofstr)
15782
a1863ea9052b Corrected the problem with the ATP directory.
quigley
parents: 15774
diff changeset
   328
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   329
  (***********************************)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   330
  (* parse spass proof into datatype *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   331
  (***********************************)
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17235
diff changeset
   332
      val proof_steps = parse tokens
15919
b30a35432f5a Replaced reference to SPASS with general one - set SPASS_HOME in settings file.
quigley
parents: 15817
diff changeset
   333
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   334
      val _ = File.append (File.tmp_path (Path.basic "prover_reconstruction"))
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   335
                      ("Did parsing on "^proofstr)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   336
    
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   337
  (************************************)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   338
  (* recreate original subgoal as thm *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   339
  (************************************)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   340
      (* get axioms as correctly numbered clauses w.r.t. the Spass proof *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   341
      (* need to get prems_of thm, then get right one of the prems, relating to whichever*)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   342
      (* subgoal this is, and turn it into meta_clauses *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   343
      (* should prob add array and table here, so that we can get axioms*)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   344
      (* produced from the clasimpset rather than the problem *)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   345
      val (frees,vars,extra_with_vars ,ax_with_vars,numcls) = get_axioms_used proof_steps  thms clause_arr
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   346
      
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   347
      (*val numcls_string = numclstr ( vars, numcls) ""*)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   348
      val _ = File.append (File.tmp_path (Path.basic "prover_reconstruction")) "got axioms"
16061
8a139c1557bf A new structure and reduced indentation
paulson
parents: 16039
diff changeset
   349
	
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   350
  (************************************)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   351
  (* translate proof                  *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   352
  (************************************)
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   353
      val _ = File.append (File.tmp_path (Path.basic "prover_reconstruction"))                                                                           
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   354
                       ("about to translate proof, steps: "
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   355
                       ^(init_proofsteps_to_string proof_steps ""))
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   356
      val (newthm,proof) = translate_proof numcls  proof_steps vars
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   357
      val _ = File.append (File.tmp_path (Path.basic "prover_reconstruction"))                                                                       
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   358
                       ("translated proof, steps: "^(init_proofsteps_to_string proof_steps ""))
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   359
  (***************************************************)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   360
  (* transfer necessary steps as strings to Isabelle *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   361
  (***************************************************)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   362
      (* turn the proof into a string *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   363
      val reconProofStr = proofs_to_string proof ""
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   364
      (* do the bit for the Isabelle ordered axioms at the top *)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   365
      val ax_nums = map #1 numcls
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   366
      val ax_strs = map ReconOrderClauses.get_meta_lits_bracket (map #2 numcls)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   367
      val numcls_strs = ListPair.zip (ax_nums,ax_strs)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   368
      val num_cls_vars =  map (addvars vars) numcls_strs;
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   369
      val reconIsaAxStr = origAxs_to_string (ListPair.zip (ax_nums,ax_with_vars)) ""
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   370
      
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   371
      val extra_nums = if (not (extra_with_vars = [])) then (1 upto (length extra_with_vars))
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   372
                       else []
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   373
      val reconExtraAxStr = extraAxs_to_string ( ListPair.zip (extra_nums,extra_with_vars)) ""
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   374
      val frees_str = "["^(thmvars_to_string frees "")^"]"
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   375
      val _ = File.write (File.tmp_path (Path.basic "reconstringfile"))
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   376
                          (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   377
      val reconstr = (frees_str^reconExtraAxStr^reconIsaAxStr^reconProofStr)
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   378
  in 
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   379
       TextIO.output (toParent, reconstr^"\n");
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   380
       TextIO.output (toParent, goalstring^"\n");
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   381
       TextIO.flushOut toParent;
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   382
       Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2);
17583
c272b91b619f removal of "sleep" to stop looping in Poly/ML, and replacement of funny codes by tracing statements
paulson
parents: 17569
diff changeset
   383
       all_tac
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   384
  end
17484
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   385
  handle exn => (*FIXME: exn handler is too general!*)
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   386
   (File.append(File.tmp_path (Path.basic "prover_reconstruction"))
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   387
       ("In exception handler: " ^ Toplevel.exn_message exn);
f6a225f97f0a simplification of the Isabelle-ATP code; hooks for batch generation of problems
paulson
parents: 17422
diff changeset
   388
    TextIO.output (toParent,"Translation failed for the proof:"^
17422
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   389
         (remove_linebreaks proofstr) ^"\n");
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   390
    TextIO.output (toParent, goalstring^"\n");
3b237822985d massive tidy-up and simplification
paulson
parents: 17317
diff changeset
   391
    TextIO.flushOut toParent;
17583
c272b91b619f removal of "sleep" to stop looping in Poly/ML, and replacement of funny codes by tracing statements
paulson
parents: 17569
diff changeset
   392
    Posix.Process.kill(Posix.Process.K_PROC ppid, Posix.Signal.usr2); all_tac)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   393
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   394
(**********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   395
(* At other end, want to turn back into datatype so can apply reconstruct_proof.  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   396
(* This will be done by the signal handler                                        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   397
(**********************************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   398
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   399
(* Parse in the string version of the proof steps for reconstruction *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   400
(* 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
   401
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   402
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   403
 val term_numstep =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   404
        (number ++ (a (Other ",")) ++ number) >> (fn (a, (_, c)) => (a, c))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   405
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   406
val extraaxiomstep = (a (Word "ExtraAxiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   407
            >> (fn (_) => ExtraAxiom)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   408
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   409
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   410
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   411
val origaxiomstep = (a (Word "OrigAxiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   412
            >> (fn (_) => OrigAxiom)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   413
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   414
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   415
 val axiomstep = (a (Word "Axiom"))++ (a (Other "(")) ++(a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   416
            >> (fn (_) => Axiom)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   417
     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   418
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   419
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   420
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   421
 val binarystep = (a (Word "Binary")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   422
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   423
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   424
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Binary (c,e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   425
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   426
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   427
 val parastep = (a (Word "Para")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   428
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   429
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   430
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Para(c, e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   431
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   432
 val mrrstep = (a (Word "MRR")) ++ (a (Other "(")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   433
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   434
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   435
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => MRR(c, e))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   436
      
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   437
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   438
 val factorstep = (a (Word "Factor")) ++ (a (Other "("))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   439
                    ++ number ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   440
                       ++ number ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   441
                       ++ number ++  (a (Other ")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   442
                   
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   443
            >> (fn (_, (_, (c, (_, (e,(_,(f,_))))))) =>  Factor (c,e,f))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   444
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   445
16548
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
   446
(*val rewritestep = (a (Word "Rewrite"))  ++ (a (Other "(")) ++ (a (Other "(")) 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   447
                   ++ term_numstep  ++ (a (Other ")")) ++ (a (Other ","))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   448
                   ++ (a (Other "(")) ++ term_numstep ++ (a (Other ")")) ++ (a (Other ")"))
16548
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
   449
            >> (fn (_, (_, (_, (c, (_,(_,(_, (e,(_,_))))))))) => Rewrite (c,e))*)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   450
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   451
val obviousstep = (a (Word "Obvious")) ++ (a (Other "(")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   452
                   ++ term_numstep  ++ (a (Other ")")) 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   453
            >> (fn (_, (_, (c,_))) => Obvious (c))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   454
16548
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
   455
 val methodstep = extraaxiomstep || origaxiomstep || axiomstep ||binarystep || factorstep|| parastep || mrrstep || (*rewritestep ||*) obviousstep
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   456
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   457
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   458
 val number_list_step =
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   459
        ( number ++ many ((a (Other ",") ++ number)>> #2))
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   460
        >> (fn (a,b) => (a::b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   461
        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   462
 val numberlist_step = a (Other "[")  ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   463
                        >>(fn (_,_) => ([]:int list))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   464
                       || a (Other "[") ++ number_list_step ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   465
                        >>(fn (_,(a,_)) => a)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   466
                    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   467
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   468
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   469
(** change this to allow P (x U) *)
17306
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17235
diff changeset
   470
 fun arglist_step input = 
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17235
diff changeset
   471
   ( word ++ many word >> (fn (a, b) => (a^" "^(space_implode " " b)))
5cde710a8a23 Progress on eprover linkup, also massive tidying
paulson
parents: 17235
diff changeset
   472
    ||word >> (fn (a) => (a)))input
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   473
                
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   474
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   475
fun literal_step input = (word ++ a (Other "(") ++ arglist_step ++  a (Other ")")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   476
                                          >>(fn (a, (b, (c,d))) => (a^" ("^(c)^")"))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   477
                        || arglist_step >> (fn (a) => (a)))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   478
                           
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   479
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   480
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   481
(* fun term_step input = (a (Other "~") ++ arglist_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   482
                     ||  arglist_step ++ a (Other "%")>> (fn (a,b) => a ))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   483
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   484
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   485
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   486
 fun term_step input = (a (Other "~") ++ literal_step ++ a (Other "%")>> (fn (a,(b,c)) => ("~ "^b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   487
                     ||  literal_step ++ a (Other "%")>> (fn (a,b) => a ))input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   488
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   489
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   490
         
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   491
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   492
 val term_list_step =
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   493
        (  term_step ++ many ( term_step))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   494
        >> (fn (a,b) => (a::b))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   495
        
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   496
 
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   497
val term_lists_step = a (Other "[")  ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   498
                        >>(fn (_,_) => ([]:string list))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   499
                       || a (Other "[") ++ term_list_step ++ a (Other "]")
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   500
                        >>(fn (_,(a,_)) => a)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   501
                     
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   502
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   503
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   504
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   505
fun anytoken_step input  = (word>> (fn (a) => a)  ) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   506
                       handle NOPARSE_WORD => (number>> (fn (a) => string_of_int a)  ) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   507
                      handle NOPARSE_NUMBER => (other_char >> (fn(a) => a)) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   508
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   509
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   510
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   511
fun goalstring_step input= (anytoken_step ++ many (anytoken_step )
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   512
                  >> (fn (a,b) =>  (a^" "^(implode b)))) input
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   513
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   514
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   515
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   516
 val linestep = number ++ methodstep ++ term_lists_step ++ term_lists_step
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   517
                >> (fn (a, (b, (c,d))) => (a,(b,c,d)))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   518
    
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   519
 val lines_step = many linestep
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   520
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   521
 val alllines_step = (term_lists_step ++ lines_step ) ++ finished >> #1
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   522
    
15739
bb2acfed8212 yet more tidying up: removal of some references to Main
paulson
parents: 15700
diff changeset
   523
 val parse_step = #1 o alllines_step
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   524
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   525
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   526
 (*
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   527
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
   528
*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   529
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   530
(************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   531
(* Construct an Isar style proof from a list of proof steps *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   532
(************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   533
(* want to assume all axioms, then do haves for the other clauses*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   534
(* then show for the last step *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   535
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   536
(* replace ~ by not here *)
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   537
val change_nots = String.translate (fn c => if c = #"~" then "\\<not>" else str c);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   538
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   539
fun clstrs_to_string xs = space_implode "; " (map change_nots xs);
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   540
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   541
fun thmvars_to_quantstring [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   542
|   thmvars_to_quantstring (x::[]) str =str^x^". "
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   543
|   thmvars_to_quantstring (x::xs) str = thmvars_to_quantstring xs (str^(x^" "))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   544
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   545
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   546
fun clause_strs_to_isar clstrs [] =
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   547
      "\"\\<lbrakk>"^(clstrs_to_string clstrs)^"\\<rbrakk> \\<Longrightarrow> False\""
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   548
|   clause_strs_to_isar clstrs thmvars =
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   549
      "\"\\<And>"^(thmvars_to_quantstring thmvars "")^
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   550
      "\\<lbrakk>"^(clstrs_to_string clstrs)^"\\<rbrakk> \\<Longrightarrow> False\""
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   551
17317
3f12de2e2e6e Isabelle-ATP link: sortable axiom names; no spaces in switches; general tidying
paulson
parents: 17315
diff changeset
   552
fun frees_to_isar_str clstrs = space_implode " " (map change_nots clstrs)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   553
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   554
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   555
(***********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   556
(* functions for producing assumptions for the Isabelle ordered axioms *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   557
(***********************************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   558
(*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
   559
num, rule, clausestrs, vars*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   560
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   561
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   562
(* assume the extra clauses - not used in Spass proof *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   563
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   564
fun is_extraaxiom_step ( num:int,(ExtraAxiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   565
|   is_extraaxiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   566
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   567
fun get_extraaxioms xs = List.filter (is_extraaxiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   568
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   569
fun assume_isar_extraaxiom [] str  = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   570
|   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
   571
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   572
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   573
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   574
fun assume_isar_extraaxioms  [] = ""
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   575
|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
   576
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   577
                                             assume_isar_extraaxiom xs str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   578
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   579
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   580
(* assume the Isabelle ordered clauses *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   581
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   582
fun is_origaxiom_step ( num:int,(OrigAxiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   583
|   is_origaxiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   584
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   585
fun get_origaxioms xs = List.filter (is_origaxiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   586
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   587
fun assume_isar_origaxiom [] str  = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   588
|   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
   589
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   590
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   591
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   592
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
   593
                                         in
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   594
                                             assume_isar_origaxiom xs str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   595
                                         end
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   596
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   597
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   598
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   599
fun is_axiom_step ( num:int,(Axiom, str, tstr)) = true
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   600
|   is_axiom_step (num, _) = false
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   601
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   602
fun get_axioms xs = List.filter  (is_axiom_step) ( xs)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   603
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   604
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
   605
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   606
fun  by_isar_axiomline (numb,(step, clstrs, thmstrs))="by (rule cl"^ (string_of_int numb)^"') \n"
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   607
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   608
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   609
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
   610
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   611
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   612
fun isar_axiomlines [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   613
|   isar_axiomlines (x::xs) str = isar_axiomlines xs (str^(isar_axiomline x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   614
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   615
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   616
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
   617
(*FIX: ask Larry to add and mrr attribute *)
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   618
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   619
fun by_isar_line ((Binary ((a,b), (c,d)))) = 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   620
    "by(rule cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   621
		(string_of_int a)^" [binary "^(string_of_int b)^" cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   622
		(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
   623
|by_isar_line ((MRR ((a,b), (c,d)))) = 
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   624
    "by(rule cl"^
f1275d2a1dee All subgoals sent to the watcher at once now.
quigley
parents: 16259
diff changeset
   625
		(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
   626
		(string_of_int c)^" "^(string_of_int d)^"])\n"
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   627
|   by_isar_line ( (Para ((a,b), (c,d)))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   628
    "by (rule cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   629
		(string_of_int a)^" [paramod "^(string_of_int b)^" cl"^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   630
		(string_of_int c)^" "^(string_of_int d)^"])\n"
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   631
|   by_isar_line ((Factor ((a,b,c)))) = 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   632
    "by (rule cl"^(string_of_int a)^" [factor "^(string_of_int b)^" "^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   633
		(string_of_int c)^" ])\n"
16548
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
   634
(*|   by_isar_line ( (Rewrite ((a,b),(c,d)))) =
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   635
    "by (rule cl"^(string_of_int a)^" [demod "^(string_of_int b)^" "^
16548
aa36ae6b955e Temporarily removed Rewrite from the translation code so that parsing with work on lists of numbers.
quigley
parents: 16520
diff changeset
   636
		(string_of_int c)^" "^(string_of_int d)^" ])\n"*)
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   637
|   by_isar_line ( (Obvious ((a,b)))) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   638
    "by (rule cl"^(string_of_int a)^" [obvious "^(string_of_int b)^" ])\n"
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   639
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   640
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
   641
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   643
fun isar_lines [] str = str
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   644
|   isar_lines (x::xs) str = isar_lines xs (str^(isar_line x))
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   645
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   646
fun last_isar_line (numb,( step, clstrs,thmstrs)) = "show \"False\"\n"^(by_isar_line step)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   647
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   648
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   649
fun to_isar_proof (frees, xs, goalstring) =
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   650
    let val extraaxioms = get_extraaxioms xs
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   651
	val extraax_num = length extraaxioms
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   652
	val origaxioms_and_steps = Library.drop (extraax_num, xs)  
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   653
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   654
	val origaxioms = get_origaxioms origaxioms_and_steps
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   655
	val origax_num = length origaxioms
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   656
	val axioms_and_steps = Library.drop (origax_num + extraax_num, xs)  
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   657
	val axioms = get_axioms axioms_and_steps
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   658
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   659
	val steps = Library.drop (origax_num, axioms_and_steps)
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   660
	val firststeps = ReconOrderClauses.butlast steps
17312
159783c74f75 yet more tidying of Isabelle-ATP link
paulson
parents: 17306
diff changeset
   661
	val laststep = List.last steps
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   662
	val goalstring = implode(ReconOrderClauses.butlast(explode goalstring))
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   663
	
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   664
	val isar_proof = 
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   665
		("show \""^goalstring^"\"\n")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   666
		("proof (rule ccontr,skolemize, make_clauses) \n")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   667
		("fix "^(frees_to_isar_str frees)^"\n")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   668
		(assume_isar_extraaxioms extraaxioms)^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   669
		(assume_isar_origaxioms origaxioms)^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   670
		(isar_axiomlines axioms "")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   671
		(isar_lines firststeps "")^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   672
		(last_isar_line laststep)^
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   673
		("qed")
16905
fa26952fa7b6 reformatting and tidying
paulson
parents: 16803
diff changeset
   674
	val _ = File.write (File.tmp_path (Path.basic "isar_proof_file")) isar_proof
16091
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   675
    in
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   676
	isar_proof
3683f0486a11 further tweaks to the SPASS setup
paulson
parents: 16061
diff changeset
   677
    end;
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   678
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   679
(* get fix vars from axioms - all Frees *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   680
(* check each clause for meta-vars and /\ over them at each step*)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   681
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   682
(*******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   683
(* This assumes the thm list  "numcls" is still there  *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   684
(* In reality, should probably label it with an        *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   685
(* ID number identifying the subgoal.  This could      *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   686
(* be passed over to the watcher, e.g.  numcls25       *)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   687
(*******************************************************)
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   688
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   689
fun apply_res_thm str goalstring  = 
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   690
  let val tokens = #1 (lex str);
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   691
      val _ = File.append (File.tmp_path (Path.basic "apply_res_1")) 
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   692
	 ("str is: "^str^" goalstr is: "^goalstring^"\n")	
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   693
      val (frees,recon_steps) = parse_step tokens 
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   694
  in 
17583
c272b91b619f removal of "sleep" to stop looping in Poly/ML, and replacement of funny codes by tracing statements
paulson
parents: 17569
diff changeset
   695
      to_isar_proof (frees, recon_steps, goalstring)
17315
5bf0e0aacc24 consolidation of duplicate code in Isabelle-ATP linkup
paulson
parents: 17312
diff changeset
   696
  end 
15642
028059faa963 *** empty log message ***
quigley
parents:
diff changeset
   697
15684
5ec4d21889d6 Reconstruction code, now packaged to avoid name clashes
paulson
parents: 15658
diff changeset
   698
end;