src/HOL/Tools/res_reconstruct.ML
author wenzelm
Thu, 29 Oct 2009 16:08:23 +0100
changeset 33310 44f9665c2091
parent 33243 17014b1b9353
child 33316 6a72af4e84b8
permissions -rw-r--r--
proper header; tuned whitespace;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
     1
(*  Title:      HOL/Tools/res_reconstruct.ML
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
     2
    Author:     Lawrence C Paulson and Claire Quigley, Cambridge University Computer Laboratory
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
     3
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
     4
Transfer of proofs from external provers.
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
     5
*)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
     6
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
     7
signature RES_RECONSTRUCT =
24425
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
     8
sig
25492
4cc7976948ac Chained theorems are no longer mentioned in metis calls and (if used) they prevent the
paulson
parents: 25414
diff changeset
     9
  val chained_hint: string
28477
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
    10
24425
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    11
  val fix_sorts: sort Vartab.table -> term -> term
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    12
  val invert_const: string -> string
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    13
  val invert_type_const: string -> string
33243
17014b1b9353 normalized basic type abbreviations;
wenzelm
parents: 33042
diff changeset
    14
  val num_typargs: theory -> string -> int
24425
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    15
  val make_tvar: string -> typ
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    16
  val strip_prefix: string -> string -> string option
33243
17014b1b9353 normalized basic type abbreviations;
wenzelm
parents: 33042
diff changeset
    17
  val setup: theory -> theory
28477
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
    18
  (* extracting lemma list*)
30874
34927a1e0ae8 reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents: 30857
diff changeset
    19
  val find_failure: string -> string option
31840
beeaa1ed1f47 check if conjectures have been used in proof
immler@in.tum.de
parents: 31479
diff changeset
    20
  val lemma_list: bool -> string ->
33243
17014b1b9353 normalized basic type abbreviations;
wenzelm
parents: 33042
diff changeset
    21
    string * string vector * (int * int) * Proof.context * thm * int -> string * string list
28477
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
    22
  (* structured proofs *)
31840
beeaa1ed1f47 check if conjectures have been used in proof
immler@in.tum.de
parents: 31479
diff changeset
    23
  val structured_proof: string ->
33243
17014b1b9353 normalized basic type abbreviations;
wenzelm
parents: 33042
diff changeset
    24
    string * string vector * (int * int) * Proof.context * thm * int -> string * string list
24425
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    25
end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    26
24425
ca97c6f3d9cd Returning both a "one-line" proof and a structured proof
paulson
parents: 24387
diff changeset
    27
structure ResReconstruct : RES_RECONSTRUCT =
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    28
struct
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    29
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    30
val trace_path = Path.basic "atp_trace";
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    31
32955
4a78daeb012b local channels for tracing/debugging;
wenzelm
parents: 32952
diff changeset
    32
fun trace s =
4a78daeb012b local channels for tracing/debugging;
wenzelm
parents: 32952
diff changeset
    33
  if ! ResAxioms.trace then File.append (File.tmp_path trace_path) s
4a78daeb012b local channels for tracing/debugging;
wenzelm
parents: 32952
diff changeset
    34
  else ();
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    35
32091
30e2ffbba718 proper context for Display.pretty_thm etc. or old-style versions Display.pretty_thm_global, Display.pretty_thm_without_context etc.;
wenzelm
parents: 31866
diff changeset
    36
fun string_of_thm ctxt = PrintMode.setmp [] (Display.string_of_thm ctxt);
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
    37
25710
4cdf7de81e1b Replaced refs by config params; finer critical section in mets method
paulson
parents: 25492
diff changeset
    38
(*For generating structured proofs: keep every nth proof line*)
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
    39
val (modulus, modulus_setup) = Attrib.config_int "sledgehammer_modulus" 1;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    40
25710
4cdf7de81e1b Replaced refs by config params; finer critical section in mets method
paulson
parents: 25492
diff changeset
    41
(*Indicates whether to include sort information in generated proofs*)
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
    42
val (recon_sorts, recon_sorts_setup) = Attrib.config_bool "sledgehammer_sorts" true;
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
    43
28477
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
    44
(*Indicated whether to generate full proofs or just lemma lists - now via setup of atps*)
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
    45
(* val (full_proofs, full_proofs_setup) = Attrib.config_bool "sledgehammer_full" false; *)
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
    46
28477
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
    47
val setup = modulus_setup #> recon_sorts_setup;
22044
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
    48
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    49
(**** PARSING OF TSTP FORMAT ****)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    50
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    51
(*Syntax trees, either termlist or formulae*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    52
datatype stree = Int of int | Br of string * stree list;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    53
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    54
fun atom x = Br(x,[]);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    55
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    56
fun scons (x,y) = Br("cons", [x,y]);
30190
479806475f3c use long names for old-style fold combinators;
wenzelm
parents: 29597
diff changeset
    57
val listof = List.foldl scons (atom "nil");
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    58
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    59
(*Strings enclosed in single quotes, e.g. filenames*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    60
val quoted = $$"'" |-- Scan.repeat (~$$"'") --| $$"'" >> implode;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    61
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    62
(*Intended for $true and $false*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    63
fun tf s = "c_" ^ str (Char.toUpper (String.sub(s,0))) ^ String.extract(s,1,NONE);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    64
val truefalse = $$"$" |-- Symbol.scan_id >> (atom o tf);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    65
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    66
(*Integer constants, typically proof line numbers*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    67
fun is_digit s = Char.isDigit (String.sub(s,0));
33035
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 32994
diff changeset
    68
val integer = Scan.many1 is_digit >> (the o Int.fromString o implode);
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    69
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    70
(*Generalized FO terms, which include filenames, numbers, etc.*)
25999
f8bcd311d501 added ::: / @@@ scanner combinators;
wenzelm
parents: 25718
diff changeset
    71
fun termlist x = (term ::: Scan.repeat ($$"," |-- term)) x
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    72
and term x = (quoted >> atom || integer>>Int || truefalse ||
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    73
              Symbol.scan_id -- Scan.optional ($$"(" |-- termlist --| $$")") [] >> Br ||
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    74
              $$"(" |-- term --| $$")" ||
24547
64c20ee76bc1 Vampire structured proofs. Better parsing; some bug fixes.
paulson
parents: 24493
diff changeset
    75
              $$"[" |-- Scan.optional termlist [] --| $$"]" >> listof) x;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    76
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    77
fun negate t = Br("c_Not", [t]);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    78
fun equate (t1,t2) = Br("c_equal", [t1,t2]);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    79
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    80
(*Apply equal or not-equal to a term*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    81
fun syn_equal (t, NONE) = t
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    82
  | syn_equal (t1, SOME (NONE, t2)) = equate (t1,t2)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    83
  | syn_equal (t1, SOME (SOME _, t2)) = negate (equate (t1,t2));
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    84
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    85
(*Literals can involve negation, = and !=.*)
24547
64c20ee76bc1 Vampire structured proofs. Better parsing; some bug fixes.
paulson
parents: 24493
diff changeset
    86
fun literal x = ($$"~" |-- literal >> negate ||
64c20ee76bc1 Vampire structured proofs. Better parsing; some bug fixes.
paulson
parents: 24493
diff changeset
    87
                 (term -- Scan.option (Scan.option ($$"!") --| $$"=" -- term) >> syn_equal)) x;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    88
25999
f8bcd311d501 added ::: / @@@ scanner combinators;
wenzelm
parents: 25718
diff changeset
    89
val literals = literal ::: Scan.repeat ($$"|" |-- literal);
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    90
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    91
(*Clause: a list of literals separated by the disjunction sign*)
24547
64c20ee76bc1 Vampire structured proofs. Better parsing; some bug fixes.
paulson
parents: 24493
diff changeset
    92
val clause = $$"(" |-- literals --| $$")" || Scan.single literal;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    93
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    94
val annotations = $$"," |-- term -- Scan.option ($$"," |-- termlist);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    95
25718
75d5d23a5c20 removed strange MacRoman character;
wenzelm
parents: 25710
diff changeset
    96
(*<cnf_annotated> ::= cnf(<name>,<formula_role>,<cnf_formula><annotations>).
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
    97
  The <name> could be an identifier, but we assume integers.*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
    98
val tstp_line = (Scan.this_string "cnf" -- $$"(") |--
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
    99
                integer --| $$"," -- Symbol.scan_id --| $$"," --
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   100
                clause -- Scan.option annotations --| $$ ")";
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   101
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   102
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   103
(**** INTERPRETATION OF TSTP SYNTAX TREES ****)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   104
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   105
exception STREE of stree;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   106
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   107
(*If string s has the prefix s1, return the result of deleting it.*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   108
fun strip_prefix s1 s =
31038
immler@in.tum.de
parents: 31037
diff changeset
   109
  if String.isPrefix s1 s
24182
a39c5e7de6a7 Fixing the code to undo the function ascii_of
paulson
parents: 23833
diff changeset
   110
  then SOME (ResClause.undo_ascii_of (String.extract (s, size s1, NONE)))
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   111
  else NONE;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   112
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   113
(*Invert the table of translations between Isabelle and ATPs*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   114
val type_const_trans_table_inv =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   115
      Symtab.make (map swap (Symtab.dest ResClause.type_const_trans_table));
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   116
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   117
fun invert_type_const c =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   118
    case Symtab.lookup type_const_trans_table_inv c of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   119
        SOME c' => c'
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   120
      | NONE => c;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   121
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   122
fun make_tvar b = TVar(("'" ^ b, 0), HOLogic.typeS);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   123
fun make_var (b,T) = Var((b,0),T);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   124
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   125
(*Type variables are given the basic sort, HOL.type. Some will later be constrained
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   126
  by information from type literals, or by type inference.*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   127
fun type_of_stree t =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   128
  case t of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   129
      Int _ => raise STREE t
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   130
    | Br (a,ts) =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   131
        let val Ts = map type_of_stree ts
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   132
        in
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   133
          case strip_prefix ResClause.tconst_prefix a of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   134
              SOME b => Type(invert_type_const b, Ts)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   135
            | NONE =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   136
                if not (null ts) then raise STREE t  (*only tconsts have type arguments*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   137
                else
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   138
                case strip_prefix ResClause.tfree_prefix a of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   139
                    SOME b => TFree("'" ^ b, HOLogic.typeS)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   140
                  | NONE =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   141
                case strip_prefix ResClause.tvar_prefix a of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   142
                    SOME b => make_tvar b
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   143
                  | NONE => make_tvar a   (*Variable from the ATP, say X1*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   144
        end;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   145
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   146
(*Invert the table of translations between Isabelle and ATPs*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   147
val const_trans_table_inv =
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   148
      Symtab.update ("fequal", "op =")
22731
abfdccaed085 trying to make single-step proofs work better, especially if they contain
paulson
parents: 22728
diff changeset
   149
        (Symtab.make (map swap (Symtab.dest ResClause.const_trans_table)));
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   150
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   151
fun invert_const c =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   152
    case Symtab.lookup const_trans_table_inv c of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   153
        SOME c' => c'
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   154
      | NONE => c;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   155
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   156
(*The number of type arguments of a constant, zero if it's monomorphic*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   157
fun num_typargs thy s = length (Sign.const_typargs thy (s, Sign.the_const_type thy s));
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   158
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   159
(*Generates a constant, given its type arguments*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   160
fun const_of thy (a,Ts) = Const(a, Sign.const_instance thy (a,Ts));
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   161
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   162
(*First-order translation. No types are known for variables. HOLogic.typeT should allow
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   163
  them to be inferred.*)
22428
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   164
fun term_of_stree args thy t =
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   165
  case t of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   166
      Int _ => raise STREE t
22428
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   167
    | Br ("hBOOL",[t]) => term_of_stree [] thy t  (*ignore hBOOL*)
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   168
    | Br ("hAPP",[t,u]) => term_of_stree (u::args) thy t
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   169
    | Br (a,ts) =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   170
        case strip_prefix ResClause.const_prefix a of
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   171
            SOME "equal" =>
22731
abfdccaed085 trying to make single-step proofs work better, especially if they contain
paulson
parents: 22728
diff changeset
   172
              list_comb(Const ("op =", HOLogic.typeT), List.map (term_of_stree [] thy) ts)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   173
          | SOME b =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   174
              let val c = invert_const b
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   175
                  val nterms = length ts - num_typargs thy c
22428
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   176
                  val us = List.map (term_of_stree [] thy) (List.take(ts,nterms) @ args)
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   177
                  (*Extra args from hAPP come AFTER any arguments given directly to the
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   178
                    constant.*)
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   179
                  val Ts = List.map type_of_stree (List.drop(ts,nterms))
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   180
              in  list_comb(const_of thy (c, Ts), us)  end
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   181
          | NONE => (*a variable, not a constant*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   182
              let val T = HOLogic.typeT
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   183
                  val opr = (*a Free variable is typically a Skolem function*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   184
                    case strip_prefix ResClause.fixed_var_prefix a of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   185
                        SOME b => Free(b,T)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   186
                      | NONE =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   187
                    case strip_prefix ResClause.schematic_var_prefix a of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   188
                        SOME b => make_var (b,T)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   189
                      | NONE => make_var (a,T)    (*Variable from the ATP, say X1*)
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   190
              in  list_comb (opr, List.map (term_of_stree [] thy) (ts@args))  end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   191
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   192
(*Type class literal applied to a type. Returns triple of polarity, class, type.*)
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   193
fun constraint_of_stree pol (Br("c_Not",[t])) = constraint_of_stree (not pol) t
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   194
  | constraint_of_stree pol t = case t of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   195
        Int _ => raise STREE t
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   196
      | Br (a,ts) =>
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   197
            (case (strip_prefix ResClause.class_prefix a, map type_of_stree ts) of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   198
                 (SOME b, [T]) => (pol, b, T)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   199
               | _ => raise STREE t);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   200
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   201
(** Accumulate type constraints in a clause: negative type literals **)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   202
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   203
fun addix (key,z)  = Vartab.map_default (key,[]) (cons z);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   204
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   205
fun add_constraint ((false, cl, TFree(a,_)), vt) = addix ((a,~1),cl) vt
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   206
  | add_constraint ((false, cl, TVar(ix,_)), vt) = addix (ix,cl) vt
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   207
  | add_constraint (_, vt) = vt;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   208
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   209
(*False literals (which E includes in its proofs) are deleted*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   210
val nofalses = filter (not o equal HOLogic.false_const);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   211
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   212
(*Final treatment of the list of "real" literals from a clause.*)
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   213
fun finish [] = HOLogic.true_const  (*No "real" literals means only type information*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   214
  | finish lits =
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   215
      case nofalses lits of
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   216
          [] => HOLogic.false_const  (*The empty clause, since we started with real literals*)
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   217
        | xs => foldr1 HOLogic.mk_disj (rev xs);
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   218
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   219
(*Accumulate sort constraints in vt, with "real" literals in lits.*)
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   220
fun lits_of_strees _ (vt, lits) [] = (vt, finish lits)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   221
  | lits_of_strees ctxt (vt, lits) (t::ts) =
22012
adf68479ae1b Proof.context now sent to watcher and used in type inference step of proof reconstruction
paulson
parents: 21999
diff changeset
   222
      lits_of_strees ctxt (add_constraint (constraint_of_stree true t, vt), lits) ts
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   223
      handle STREE _ =>
22428
1755e6381b2c First stab at reconstructing HO problems
paulson
parents: 22372
diff changeset
   224
      lits_of_strees ctxt (vt, term_of_stree [] (ProofContext.theory_of ctxt) t :: lits) ts;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   225
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   226
(*Update TVars/TFrees with detected sort constraints.*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   227
fun fix_sorts vt =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   228
  let fun tysubst (Type (a, Ts)) = Type (a, map tysubst Ts)
33035
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 32994
diff changeset
   229
        | tysubst (TVar (xi, s)) = TVar (xi, the_default s (Vartab.lookup vt xi))
15eab423e573 standardized basic operations on type option;
wenzelm
parents: 32994
diff changeset
   230
        | tysubst (TFree (x, s)) = TFree (x, the_default s (Vartab.lookup vt (x, ~1)))
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   231
      fun tmsubst (Const (a, T)) = Const (a, tysubst T)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   232
        | tmsubst (Free (a, T)) = Free (a, tysubst T)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   233
        | tmsubst (Var (xi, T)) = Var (xi, tysubst T)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   234
        | tmsubst (t as Bound _) = t
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   235
        | tmsubst (Abs (a, T, t)) = Abs (a, tysubst T, tmsubst t)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   236
        | tmsubst (t $ u) = tmsubst t $ tmsubst u;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   237
  in fn t => if Vartab.is_empty vt then t else tmsubst t end;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   238
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   239
(*Interpret a list of syntax trees as a clause, given by "real" literals and sort constraints.
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   240
  vt0 holds the initial sort constraints, from the conjecture clauses.*)
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   241
fun clause_of_strees ctxt vt0 ts =
22728
ecbbdf50df2f simplified ProofContext.infer_types(_pats);
wenzelm
parents: 22692
diff changeset
   242
  let val (vt, dt) = lits_of_strees ctxt (vt0,[]) ts in
24680
0d355aa59e67 TypeInfer.constrain: canonical argument order;
wenzelm
parents: 24632
diff changeset
   243
    singleton (Syntax.check_terms ctxt) (TypeInfer.constrain HOLogic.boolT (fix_sorts vt dt))
22728
ecbbdf50df2f simplified ProofContext.infer_types(_pats);
wenzelm
parents: 22692
diff changeset
   244
  end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   245
29268
6aefc5ff8e63 use exists_subterm directly;
wenzelm
parents: 28572
diff changeset
   246
fun gen_all_vars t = fold_rev Logic.all (OldTerm.term_vars t) t;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   247
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   248
fun ints_of_stree_aux (Int n, ns) = n::ns
30190
479806475f3c use long names for old-style fold combinators;
wenzelm
parents: 29597
diff changeset
   249
  | ints_of_stree_aux (Br(_,ts), ns) = List.foldl ints_of_stree_aux ns ts;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   250
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   251
fun ints_of_stree t = ints_of_stree_aux (t, []);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   252
25086
729f9aad1f50 Improving the propagation of type constraints for Frees
paulson
parents: 24958
diff changeset
   253
fun decode_tstp vt0 (name, role, ts, annots) ctxt =
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   254
  let val deps = case annots of NONE => [] | SOME (source,_) => ints_of_stree source
25086
729f9aad1f50 Improving the propagation of type constraints for Frees
paulson
parents: 24958
diff changeset
   255
      val cl = clause_of_strees ctxt vt0 ts
29268
6aefc5ff8e63 use exists_subterm directly;
wenzelm
parents: 28572
diff changeset
   256
  in  ((name, role, cl, deps), fold Variable.declare_term (OldTerm.term_frees cl) ctxt)  end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   257
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   258
fun dest_tstp ((((name, role), ts), annots), chs) =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   259
  case chs of
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   260
          "."::_ => (name, role, ts, annots)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   261
        | _ => error ("TSTP line not terminated by \".\": " ^ implode chs);
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   262
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   263
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   264
(** Global sort constraints on TFrees (from tfree_tcs) are positive unit clauses. **)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   265
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   266
fun add_tfree_constraint ((true, cl, TFree(a,_)), vt) = addix ((a,~1),cl) vt
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   267
  | add_tfree_constraint (_, vt) = vt;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   268
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   269
fun tfree_constraints_of_clauses vt [] = vt
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   270
  | tfree_constraints_of_clauses vt ([lit]::tss) =
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   271
      (tfree_constraints_of_clauses (add_tfree_constraint (constraint_of_stree true lit, vt)) tss
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   272
       handle STREE _ => (*not a positive type constraint: ignore*)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   273
       tfree_constraints_of_clauses vt tss)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   274
  | tfree_constraints_of_clauses vt (_::tss) = tfree_constraints_of_clauses vt tss;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   275
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   276
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   277
(**** Translation of TSTP files to Isar Proofs ****)
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   278
22012
adf68479ae1b Proof.context now sent to watcher and used in type inference step of proof reconstruction
paulson
parents: 21999
diff changeset
   279
fun decode_tstp_list ctxt tuples =
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   280
  let val vt0 = tfree_constraints_of_clauses Vartab.empty (map #3 tuples)
25086
729f9aad1f50 Improving the propagation of type constraints for Frees
paulson
parents: 24958
diff changeset
   281
  in  #1 (fold_map (decode_tstp vt0) tuples ctxt) end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   282
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   283
(** Finding a matching assumption. The literals may be permuted, and variable names
31038
immler@in.tum.de
parents: 31037
diff changeset
   284
    may disagree. We have to try all combinations of literals (quadratic!) and
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   285
    match up the variable names consistently. **)
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   286
31038
immler@in.tum.de
parents: 31037
diff changeset
   287
fun strip_alls_aux n (Const("all",_)$Abs(a,T,t))  =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   288
      strip_alls_aux (n+1) (subst_bound (Var ((a,n), T), t))
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   289
  | strip_alls_aux _ t  =  t;
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   290
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   291
val strip_alls = strip_alls_aux 0;
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   292
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   293
exception MATCH_LITERAL;
22012
adf68479ae1b Proof.context now sent to watcher and used in type inference step of proof reconstruction
paulson
parents: 21999
diff changeset
   294
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   295
(*Ignore types: they are not to be trusted...*)
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   296
fun match_literal (t1$u1) (t2$u2) env =
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   297
      match_literal t1 t2 (match_literal u1 u2 env)
31038
immler@in.tum.de
parents: 31037
diff changeset
   298
  | match_literal (Abs (_,_,t1)) (Abs (_,_,t2)) env =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   299
      match_literal t1 t2 env
31038
immler@in.tum.de
parents: 31037
diff changeset
   300
  | match_literal (Bound i1) (Bound i2) env =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   301
      if i1=i2 then env else raise MATCH_LITERAL
31038
immler@in.tum.de
parents: 31037
diff changeset
   302
  | match_literal (Const(a1,_)) (Const(a2,_)) env =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   303
      if a1=a2 then env else raise MATCH_LITERAL
31038
immler@in.tum.de
parents: 31037
diff changeset
   304
  | match_literal (Free(a1,_)) (Free(a2,_)) env =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   305
      if a1=a2 then env else raise MATCH_LITERAL
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   306
  | match_literal (Var(ix1,_)) (Var(ix2,_)) env = insert (op =) (ix1,ix2) env
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   307
  | match_literal _ _ _ = raise MATCH_LITERAL;
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   308
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   309
(*Checking that all variable associations are unique. The list env contains no
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   310
  repetitions, but does it contain say (x,y) and (y,y)? *)
31038
immler@in.tum.de
parents: 31037
diff changeset
   311
fun good env =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   312
  let val (xs,ys) = ListPair.unzip env
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   313
  in  not (has_duplicates (op=) xs orelse has_duplicates (op=) ys)  end;
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   314
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   315
(*Match one list of literals against another, ignoring types and the order of
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   316
  literals. Sorting is unreliable because we don't have types or variable names.*)
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   317
fun matches_aux _ [] [] = true
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   318
  | matches_aux env (lit::lits) ts =
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   319
      let fun match1 us [] = false
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   320
            | match1 us (t::ts) =
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   321
                let val env' = match_literal lit t env
31038
immler@in.tum.de
parents: 31037
diff changeset
   322
                in  (good env' andalso matches_aux env' lits (us@ts)) orelse
immler@in.tum.de
parents: 31037
diff changeset
   323
                    match1 (t::us) ts
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   324
                end
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   325
                handle MATCH_LITERAL => match1 (t::us) ts
31038
immler@in.tum.de
parents: 31037
diff changeset
   326
      in  match1 [] ts  end;
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   327
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   328
(*Is this length test useful?*)
31038
immler@in.tum.de
parents: 31037
diff changeset
   329
fun matches (lits1,lits2) =
immler@in.tum.de
parents: 31037
diff changeset
   330
  length lits1 = length lits2  andalso
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   331
  matches_aux [] (map Envir.eta_contract lits1) (map Envir.eta_contract lits2);
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   332
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   333
fun permuted_clause t =
24958
ff15f76741bd rationalized redundant code
paulson
parents: 24956
diff changeset
   334
  let val lits = HOLogic.disjuncts t
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   335
      fun perm [] = NONE
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   336
        | perm (ctm::ctms) =
24958
ff15f76741bd rationalized redundant code
paulson
parents: 24956
diff changeset
   337
            if matches (lits, HOLogic.disjuncts (HOLogic.dest_Trueprop (strip_alls ctm)))
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   338
            then SOME ctm else perm ctms
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   339
  in perm end;
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   340
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   341
fun have_or_show "show " _ = "show \""
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   342
  | have_or_show have lname = have ^ lname ^ ": \""
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   343
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   344
(*ctms is a list of conjecture clauses as yielded by Isabelle. Those returned by the
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   345
  ATP may have their literals reordered.*)
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   346
fun isar_lines ctxt ctms =
28572
78ac28f80a1c ** Update from Fabian **
wenzelm
parents: 28477
diff changeset
   347
  let val string_of = PrintMode.setmp [] (fn term => Syntax.string_of_term ctxt term)
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   348
      val _ = trace ("\n\nisar_lines: start\n")
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   349
      fun doline _ (lname, t, []) =  (*No deps: it's a conjecture clause, with no proof.*)
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   350
           (case permuted_clause t ctms of
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   351
                SOME u => "assume " ^ lname ^ ": \"" ^ string_of u ^ "\"\n"
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   352
              | NONE => "assume? " ^ lname ^ ": \"" ^ string_of t ^ "\"\n")  (*no match!!*)
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   353
        | doline have (lname, t, deps) =
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   354
            have_or_show have lname ^ string_of (gen_all_vars (HOLogic.mk_Trueprop t)) ^
22372
02fc0ceb094a Now outputs metis calls
paulson
parents: 22130
diff changeset
   355
            "\"\n  by (metis " ^ space_implode " " deps ^ ")\n"
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   356
      fun dolines [(lname, t, deps)] = [doline "show " (lname, t, deps)]
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   357
        | dolines ((lname, t, deps)::lines) = doline "have " (lname, t, deps) :: dolines lines
32966
5b21661fe618 indicate CRITICAL nature of various setmp combinators;
wenzelm
parents: 32955
diff changeset
   358
  in setmp_CRITICAL show_sorts (Config.get ctxt recon_sorts) dolines end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   359
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   360
fun notequal t (_,t',_) = not (t aconv t');
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   361
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   362
(*No "real" literals means only type information*)
23519
a4ffa756d8eb bug fixes to proof reconstruction
paulson
parents: 23139
diff changeset
   363
fun eq_types t = t aconv HOLogic.true_const;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   364
22731
abfdccaed085 trying to make single-step proofs work better, especially if they contain
paulson
parents: 22728
diff changeset
   365
fun replace_dep (old:int, new) dep = if dep=old then new else [dep];
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   366
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   367
fun replace_deps (old:int, new) (lno, t, deps) =
33042
ddf1f03a9ad9 curried union as canonical list operation
haftmann
parents: 33039
diff changeset
   368
      (lno, t, List.foldl (uncurry (union (op =))) [] (map (replace_dep (old, new)) deps));
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   369
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   370
(*Discard axioms; consolidate adjacent lines that prove the same clause, since they differ
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   371
  only in type information.*)
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   372
fun add_prfline ((lno, "axiom", t, []), lines) =  (*axioms are not proof lines*)
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   373
      if eq_types t (*must be clsrel/clsarity: type information, so delete refs to it*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   374
      then map (replace_deps (lno, [])) lines
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   375
      else
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   376
       (case take_prefix (notequal t) lines of
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   377
           (_,[]) => lines                  (*no repetition of proof line*)
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   378
         | (pre, (lno', _, _) :: post) =>   (*repetition: replace later line by earlier one*)
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   379
             pre @ map (replace_deps (lno', [lno])) post)
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   380
  | add_prfline ((lno, _, t, []), lines) =  (*no deps: conjecture clause*)
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   381
      (lno, t, []) :: lines
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   382
  | add_prfline ((lno, _, t, deps), lines) =
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   383
      if eq_types t then (lno, t, deps) :: lines
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   384
      (*Type information will be deleted later; skip repetition test.*)
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   385
      else (*FIXME: Doesn't this code risk conflating proofs involving different types??*)
22044
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
   386
      case take_prefix (notequal t) lines of
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
   387
         (_,[]) => (lno, t, deps) :: lines  (*no repetition of proof line*)
32994
ccc07fbbfefd removed some unreferenced material;
wenzelm
parents: 32966
diff changeset
   388
       | (pre, (lno', t', _) :: post) =>
22044
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
   389
           (lno, t', deps) ::               (*repetition: replace later line by earlier one*)
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
   390
           (pre @ map (replace_deps (lno', [lno])) post);
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
   391
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   392
(*Recursively delete empty lines (type information) from the proof.*)
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   393
fun add_nonnull_prfline ((lno, t, []), lines) = (*no dependencies, so a conjecture clause*)
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   394
     if eq_types t (*must be type information, tfree_tcs, clsrel, clsarity: delete refs to it*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   395
     then delete_dep lno lines
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   396
     else (lno, t, []) :: lines
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   397
  | add_nonnull_prfline ((lno, t, deps), lines) = (lno, t, deps) :: lines
30190
479806475f3c use long names for old-style fold combinators;
wenzelm
parents: 29597
diff changeset
   398
and delete_dep lno lines = List.foldr add_nonnull_prfline [] (map (replace_deps (lno, [])) lines);
22470
0d52e5157124 No label on "show"; tries to remove dependencies more cleanly
paulson
parents: 22428
diff changeset
   399
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24920
diff changeset
   400
fun bad_free (Free (a,_)) = String.isPrefix "sko_" a
22731
abfdccaed085 trying to make single-step proofs work better, especially if they contain
paulson
parents: 22728
diff changeset
   401
  | bad_free _ = false;
abfdccaed085 trying to make single-step proofs work better, especially if they contain
paulson
parents: 22728
diff changeset
   402
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   403
(*TVars are forbidden in goals. Also, we don't want lines with <2 dependencies.
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   404
  To further compress proofs, setting modulus:=n deletes every nth line, and nlines
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   405
  counts the number of proof lines processed so far.
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   406
  Deleted lines are replaced by their own dependencies. Note that the "add_nonnull_prfline"
22044
6c0702a96076 More compact proof reconstruction: lines having fewer than !min_deps dependences are folded
paulson
parents: 22012
diff changeset
   407
  phase may delete some dependencies, hence this phase comes later.*)
25710
4cdf7de81e1b Replaced refs by config params; finer critical section in mets method
paulson
parents: 25492
diff changeset
   408
fun add_wanted_prfline ctxt ((lno, t, []), (nlines, lines)) =
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   409
      (nlines, (lno, t, []) :: lines)   (*conjecture clauses must be kept*)
25710
4cdf7de81e1b Replaced refs by config params; finer critical section in mets method
paulson
parents: 25492
diff changeset
   410
  | add_wanted_prfline ctxt ((lno, t, deps), (nlines, lines)) =
29272
fb3ccf499df5 use regular Term.add_XXX etc.;
wenzelm
parents: 29268
diff changeset
   411
      if eq_types t orelse not (null (Term.add_tvars t [])) orelse
29268
6aefc5ff8e63 use exists_subterm directly;
wenzelm
parents: 28572
diff changeset
   412
         exists_subterm bad_free t orelse
24937
340523598914 context-based treatment of generalization; also handling TFrees in axiom clauses
paulson
parents: 24920
diff changeset
   413
         (not (null lines) andalso   (*final line can't be deleted for these reasons*)
31038
immler@in.tum.de
parents: 31037
diff changeset
   414
          (length deps < 2 orelse nlines mod (Config.get ctxt modulus) <> 0))
22491
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   415
      then (nlines+1, map (replace_deps (lno, deps)) lines) (*Delete line*)
535fbed859da Numerous bug fixes. Type clauses distinguished from empty clauses. Working proof reduction.
paulson
parents: 22470
diff changeset
   416
      else (nlines+1, (lno, t, deps) :: lines);
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   417
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   418
(*Replace numeric proof lines by strings, either from thm_names or sequential line numbers*)
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   419
fun stringify_deps thm_names deps_map [] = []
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   420
  | stringify_deps thm_names deps_map ((lno, t, deps) :: lines) =
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   421
      if lno <= Vector.length thm_names  (*axiom*)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   422
      then (Vector.sub(thm_names,lno-1), t, []) :: stringify_deps thm_names deps_map lines
21979
80e10f181c46 Improvements to proof reconstruction. Now "fixes" is inserted
paulson
parents: 21978
diff changeset
   423
      else let val lname = Int.toString (length deps_map)
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   424
               fun fix lno = if lno <= Vector.length thm_names
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   425
                             then SOME(Vector.sub(thm_names,lno-1))
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   426
                             else AList.lookup op= deps_map lno;
32952
aeb1e44fbc19 replaced String.concat by implode;
wenzelm
parents: 32565
diff changeset
   427
           in  (lname, t, map_filter fix (distinct (op=) deps)) ::
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   428
               stringify_deps thm_names ((lno,lname)::deps_map) lines
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   429
           end;
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   430
24547
64c20ee76bc1 Vampire structured proofs. Better parsing; some bug fixes.
paulson
parents: 24493
diff changeset
   431
val proofstart = "proof (neg_clausify)\n";
21979
80e10f181c46 Improvements to proof reconstruction. Now "fixes" is inserted
paulson
parents: 21978
diff changeset
   432
80e10f181c46 Improvements to proof reconstruction. Now "fixes" is inserted
paulson
parents: 21978
diff changeset
   433
fun isar_header [] = proofstart
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   434
  | isar_header ts = proofstart ^ "fix " ^ space_implode " " ts ^ "\n";
21979
80e10f181c46 Improvements to proof reconstruction. Now "fixes" is inserted
paulson
parents: 21978
diff changeset
   435
22012
adf68479ae1b Proof.context now sent to watcher and used in type inference step of proof reconstruction
paulson
parents: 21999
diff changeset
   436
fun decode_tstp_file cnfs ctxt th sgno thm_names =
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   437
  let val _ = trace "\ndecode_tstp_file: start\n"
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   438
      val tuples = map (dest_tstp o tstp_line o explode) cnfs
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   439
      val _ = trace (Int.toString (length tuples) ^ " tuples extracted\n")
24552
bb7fdd10de9a allow TVars during type inference
paulson
parents: 24547
diff changeset
   440
      val ctxt = ProofContext.set_mode ProofContext.mode_schematic ctxt
30190
479806475f3c use long names for old-style fold combinators;
wenzelm
parents: 29597
diff changeset
   441
      val raw_lines = List.foldr add_prfline [] (decode_tstp_list ctxt tuples)
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   442
      val _ = trace (Int.toString (length raw_lines) ^ " raw_lines extracted\n")
30190
479806475f3c use long names for old-style fold combinators;
wenzelm
parents: 29597
diff changeset
   443
      val nonnull_lines = List.foldr add_nonnull_prfline [] raw_lines
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   444
      val _ = trace (Int.toString (length nonnull_lines) ^ " nonnull_lines extracted\n")
30190
479806475f3c use long names for old-style fold combinators;
wenzelm
parents: 29597
diff changeset
   445
      val (_,lines) = List.foldr (add_wanted_prfline ctxt) (0,[]) nonnull_lines
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   446
      val _ = trace (Int.toString (length lines) ^ " lines extracted\n")
32258
d91d394c4cab ResAxioms.neg_conjecture_clauses: proper context;
wenzelm
parents: 32091
diff changeset
   447
      val (ccls,fixes) = ResAxioms.neg_conjecture_clauses ctxt th sgno
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   448
      val _ = trace (Int.toString (length ccls) ^ " conjecture clauses\n")
21999
0cf192e489e2 improvements to proof reconstruction. Some files loaded in a different order
paulson
parents: 21979
diff changeset
   449
      val ccls = map forall_intr_vars ccls
32091
30e2ffbba718 proper context for Display.pretty_thm etc. or old-style versions Display.pretty_thm_global, Display.pretty_thm_without_context etc.;
wenzelm
parents: 31866
diff changeset
   450
      val _ =
32955
4a78daeb012b local channels for tracing/debugging;
wenzelm
parents: 32952
diff changeset
   451
        if ! ResAxioms.trace then app (fn th => trace ("\nccl: " ^ string_of_thm ctxt th)) ccls
32091
30e2ffbba718 proper context for Display.pretty_thm etc. or old-style versions Display.pretty_thm_global, Display.pretty_thm_without_context etc.;
wenzelm
parents: 31866
diff changeset
   452
        else ()
26333
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   453
      val ilines = isar_lines ctxt (map prop_of ccls) (stringify_deps thm_names [] lines)
68e5eee47a45 Attributes sledgehammer_full, sledgehammer_modulus, sledgehammer_sorts
paulson
parents: 25999
diff changeset
   454
      val _ = trace "\ndecode_tstp_file: finishing\n"
23139
aa899bce7c3b TextIO.inputLine: use present SML B library version;
wenzelm
parents: 23083
diff changeset
   455
  in
32952
aeb1e44fbc19 replaced String.concat by implode;
wenzelm
parents: 32565
diff changeset
   456
    isar_header (map #1 fixes) ^ implode ilines ^ "qed\n"
32258
d91d394c4cab ResAxioms.neg_conjecture_clauses: proper context;
wenzelm
parents: 32091
diff changeset
   457
  end;
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   458
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   459
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   460
(*=== EXTRACTING PROOF-TEXT === *)
31866
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   461
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   462
val begin_proof_strings = ["# SZS output start CNFRefutation.",
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   463
  "=========== Refutation ==========",
31866
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   464
  "Here is a proof"];
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   465
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   466
val end_proof_strings = ["# SZS output end CNFRefutation",
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   467
  "======= End of refutation =======",
31866
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   468
  "Formulae used in the proof"];
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   469
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   470
fun get_proof_extract proof =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   471
  let
31866
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   472
    (*splits to_split by the first possible of a list of splitters*)
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   473
    val (begin_string, end_string) =
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   474
      (find_first (fn s => String.isSubstring s proof) begin_proof_strings,
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   475
      find_first (fn s => String.isSubstring s proof) end_proof_strings)
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   476
  in
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   477
    if is_none begin_string orelse is_none end_string
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   478
    then error "Could not extract proof (no substring indicating a proof)"
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   479
    else proof |> first_field (the begin_string) |> the |> snd
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   480
               |> first_field (the end_string) |> the |> fst
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   481
  end;
31866
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   482
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   483
(* ==== CHECK IF PROOF OF E OR VAMPIRE WAS SUCCESSFUL === *)
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   484
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   485
val failure_strings_E = ["SZS status: Satisfiable","SZS status Satisfiable",
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   486
  "SZS status: ResourceOut","SZS status ResourceOut","# Cannot determine problem status"];
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   487
val failure_strings_vampire = ["Satisfiability detected", "Refutation not found", "CANNOT PROVE"];
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   488
val failure_strings_SPASS = ["SPASS beiseite: Completion found.",
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   489
  "SPASS beiseite: Ran out of time.", "SPASS beiseite: Maximal number of loops exceeded."];
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   490
val failure_strings_remote = ["Remote-script could not extract proof"];
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   491
fun find_failure proof =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   492
  let val failures =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   493
    map_filter (fn s => if String.isSubstring s proof then SOME s else NONE)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   494
      (failure_strings_E @ failure_strings_vampire @ failure_strings_SPASS @ failure_strings_remote)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   495
  val correct = null failures andalso
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   496
    exists (fn s => String.isSubstring s proof) begin_proof_strings andalso
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   497
    exists (fn s => String.isSubstring s proof) end_proof_strings
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   498
  in
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   499
    if correct then NONE
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   500
    else if null failures then SOME "Output of ATP not in proper format"
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   501
    else SOME (hd failures) end;
31866
d262a0d46246 check for correct proof output
immler@in.tum.de
parents: 31840
diff changeset
   502
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   503
(* === EXTRACTING LEMMAS === *)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   504
(* lines have the form "cnf(108, axiom, ...",
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   505
the number (108) has to be extracted)*)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   506
fun get_step_nums false proofextract =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   507
  let val toks = String.tokens (not o Char.isAlphaNum)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   508
  fun inputno ("cnf"::ntok::"axiom"::_) = Int.fromString ntok
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   509
    | inputno ("cnf"::ntok::"negated"::"conjecture"::_) = Int.fromString ntok
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   510
    | inputno _ = NONE
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   511
  val lines = split_lines proofextract
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   512
  in  map_filter (inputno o toks) lines  end
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   513
(*String contains multiple lines. We want those of the form
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   514
  "253[0:Inp] et cetera..."
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   515
  A list consisting of the first number in each line is returned. *)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   516
|  get_step_nums true proofextract =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   517
  let val toks = String.tokens (not o Char.isAlphaNum)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   518
  fun inputno (ntok::"0"::"Inp"::_) = Int.fromString ntok
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   519
    | inputno _ = NONE
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   520
  val lines = split_lines proofextract
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   521
  in  map_filter (inputno o toks) lines  end
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   522
  
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   523
(*extracting lemmas from tstp-output between the lines from above*)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   524
fun extract_lemmas get_step_nums (proof, thm_names, conj_count, _, _, _) =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   525
  let
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   526
  (* get the names of axioms from their numbers*)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   527
  fun get_axiom_names thm_names step_nums =
28477
9339d4dcec8b version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents: 27865
diff changeset
   528
    let
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   529
    val last_axiom = Vector.length thm_names
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   530
    fun is_axiom n = n <= last_axiom
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   531
    fun is_conj n = n >= fst conj_count andalso n < fst conj_count + snd conj_count
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   532
    fun getname i = Vector.sub(thm_names, i-1)
31038
immler@in.tum.de
parents: 31037
diff changeset
   533
    in
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   534
      (sort_distinct string_ord (filter (fn x => x <> "??.unknown")
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   535
        (map getname (filter is_axiom step_nums))),
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   536
      exists is_conj step_nums)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   537
    end
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   538
  val proofextract = get_proof_extract proof
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   539
  in
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   540
    get_axiom_names thm_names (get_step_nums proofextract)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   541
  end;
31410
c231efe693ce include chain-ths in every prover-call
immler@in.tum.de
parents: 31038
diff changeset
   542
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   543
(*Used to label theorems chained into the sledgehammer call*)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   544
val chained_hint = "CHAINED";
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   545
val nochained = filter_out (fn y => y = chained_hint)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   546
  
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   547
(* metis-command *)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   548
fun metis_line [] = "apply metis"
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   549
  | metis_line xs = "apply (metis " ^ space_implode " " xs ^ ")"
31038
immler@in.tum.de
parents: 31037
diff changeset
   550
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   551
(* atp_minimize [atp=<prover>] <lemmas> *)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   552
fun minimize_line _ [] = ""
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   553
  | minimize_line name lemmas = "For minimizing the number of lemmas try this command:\n" ^
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   554
        (Markup.markup Markup.sendback) ("atp_minimize [atp=" ^ name ^ "] " ^
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   555
                                         space_implode " " (nochained lemmas))
31037
ac8669134e7a added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents: 30874
diff changeset
   556
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   557
fun sendback_metis_nochained lemmas =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   558
  (Markup.markup Markup.sendback o metis_line) (nochained lemmas)
31840
beeaa1ed1f47 check if conjectures have been used in proof
immler@in.tum.de
parents: 31479
diff changeset
   559
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   560
fun lemma_list dfg name result =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   561
  let val (lemmas, used_conj) = extract_lemmas (get_step_nums dfg) result
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   562
  in (sendback_metis_nochained lemmas ^ "\n" ^ minimize_line name lemmas ^
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   563
    (if used_conj then ""
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   564
     else "\nWarning: Goal is provable because context is inconsistent."),
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   565
     nochained lemmas)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   566
  end;
31037
ac8669134e7a added Philipp Meyer's implementation of AtpMinimal
immler@in.tum.de
parents: 30874
diff changeset
   567
33310
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   568
(* === Extracting structured Isar-proof === *)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   569
fun structured_proof name (result as (proof, thm_names, conj_count, ctxt, goal, subgoalno)) =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   570
  let
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   571
  (*Could use split_lines, but it can return blank lines...*)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   572
  val lines = String.tokens (equal #"\n");
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   573
  val nospaces = String.translate (fn c => if Char.isSpace c then "" else str c)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   574
  val proofextract = get_proof_extract proof
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   575
  val cnfs = filter (String.isPrefix "cnf(") (map nospaces (lines proofextract))
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   576
  val (one_line_proof, lemma_names) = lemma_list false name result
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   577
  val structured =
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   578
    if chained_hint mem_string (String.tokens (fn c => c = #" ") one_line_proof) then ""
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   579
    else decode_tstp_file cnfs ctxt goal subgoalno thm_names
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   580
  in
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   581
  (one_line_proof ^ "\n\n" ^ Markup.markup Markup.sendback structured, lemma_names)
44f9665c2091 proper header;
wenzelm
parents: 33243
diff changeset
   582
end
21978
72c21698a055 Contains old Tools/ATP/AtpCommunication.ML, plus proof reconstruction
paulson
parents:
diff changeset
   583
31038
immler@in.tum.de
parents: 31037
diff changeset
   584
end;