src/Tools/Metis/src/metis.sml
author blanchet
Mon, 13 Sep 2010 21:09:43 +0200
changeset 39348 6f9c9899f99f
child 39353 7f11d833d65b
permissions -rw-r--r--
new version of the Metis files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     1
(* ========================================================================= *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     2
(* METIS FIRST ORDER PROVER                                                  *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     3
(*                                                                           *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     4
(* Copyright (c) 2001 Joe Hurd                                               *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     5
(*                                                                           *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     6
(* Metis is free software; you can redistribute it and/or modify             *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     7
(* it under the terms of the GNU General Public License as published by      *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     8
(* the Free Software Foundation; either version 2 of the License, or         *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     9
(* (at your option) any later version.                                       *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    10
(*                                                                           *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    11
(* Metis is distributed in the hope that it will be useful,                  *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    12
(* but WITHOUT ANY WARRANTY; without even the implied warranty of            *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    13
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    14
(* GNU General Public License for more details.                              *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    15
(*                                                                           *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    16
(* You should have received a copy of the GNU General Public License         *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    17
(* along with Metis; if not, write to the Free Software                      *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    18
(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    19
(* ========================================================================= *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    20
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    21
open Useful;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    22
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    23
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    24
(* The program name and version.                                             *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    25
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    26
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    27
val PROGRAM = "metis";
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    28
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    29
val VERSION = "2.2";
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    30
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    31
val versionString = PROGRAM^" "^VERSION^" (release 20100825)"^"\n";
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    32
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    33
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    34
(* Program options.                                                          *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    35
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    36
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    37
val QUIET = ref false;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    38
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    39
val TEST = ref false;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    40
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    41
val TPTP : string option ref = ref NONE;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    42
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    43
val ITEMS = ["name","goal","clauses","size","category","proof","saturation"];
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    44
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    45
val extended_items = "all" :: ITEMS;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    46
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    47
val show_items = map (fn s => (s, ref false)) ITEMS;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    48
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    49
fun show_ref s =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    50
    case List.find (equal s o fst) show_items of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    51
      NONE => raise Bug ("item " ^ s ^ " not found")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    52
    | SOME (_,r) => r;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    53
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    54
fun show_set b = app (fn (_,r) => r := b) show_items;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    55
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    56
fun showing s = not (!QUIET) andalso (s = "status" orelse !(show_ref s));
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    57
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    58
fun notshowing s = not (showing s);
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    59
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    60
fun showing_any () = List.exists showing ITEMS;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    61
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    62
fun notshowing_any () = not (showing_any ());
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    63
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    64
fun show "all" = show_set true
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    65
  | show s = case show_ref s of r => r := true;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    66
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    67
fun hide "all" = show_set false
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    68
  | hide s = case show_ref s of r => r := false;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    69
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    70
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    71
(* Process command line arguments and environment variables.                 *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    72
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    73
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    74
local
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    75
  open Useful Options;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    76
in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    77
  val specialOptions =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    78
    [{switches = ["--show"], arguments = ["ITEM"],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    79
      description = "show ITEM (see below for list)",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    80
      processor =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    81
        beginOpt (enumOpt extended_items endOpt) (fn _ => fn s => show s)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    82
     {switches = ["--hide"], arguments = ["ITEM"],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    83
      description = "hide ITEM (see below for list)",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    84
      processor =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    85
        beginOpt (enumOpt extended_items endOpt) (fn _ => fn s => hide s)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    86
     {switches = ["--tptp"], arguments = ["DIR"],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    87
      description = "specify the TPTP installation directory",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    88
      processor =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    89
        beginOpt (stringOpt endOpt) (fn _ => fn s => TPTP := SOME s)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    90
     {switches = ["-q","--quiet"], arguments = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    91
      description = "Run quietly; indicate provability with return value",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    92
      processor = beginOpt endOpt (fn _ => QUIET := true)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    93
     {switches = ["--test"], arguments = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    94
      description = "Skip the proof search for the input problems",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    95
      processor = beginOpt endOpt (fn _ => TEST := true)}];
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    96
end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    97
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    98
val programOptions =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    99
    {name = PROGRAM,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   100
     version = versionString,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   101
     header = "usage: "^PROGRAM^" [option ...] problem.tptp ...\n" ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   102
              "Proves the input TPTP problem files.\n",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   103
     footer = "Possible ITEMs are {" ^ join "," extended_items ^ "}.\n" ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   104
              "Problems can be read from standard input using the " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   105
              "special - filename.\n",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   106
     options = specialOptions @ Options.basicOptions};
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   107
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   108
fun exit x : unit = Options.exit programOptions x;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   109
fun succeed () = Options.succeed programOptions;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   110
fun fail mesg = Options.fail programOptions mesg;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   111
fun usage mesg = Options.usage programOptions mesg;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   112
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   113
fun processOptions () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   114
    let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   115
      val args = CommandLine.arguments ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   116
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   117
      val (_,work) = Options.processOptions programOptions args
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   118
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   119
      val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   120
          case !TPTP of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   121
            SOME _ => ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   122
          | NONE => TPTP := OS.Process.getEnv "TPTP"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   123
    in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   124
      work
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   125
    end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   126
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   127
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   128
(* The core application.                                                     *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   129
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   130
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   131
(*MetisDebug
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   132
val next_cnf =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   133
    let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   134
      val cnf_counter = ref 0
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   135
    in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   136
      fn () =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   137
         let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   138
           val ref cnf_count = cnf_counter
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   139
           val () = cnf_counter := cnf_count + 1
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   140
         in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   141
           cnf_count
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   142
         end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   143
    end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   144
*)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   145
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   146
local
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   147
  fun display_sep () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   148
      if notshowing_any () then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   149
      else print (nChars #"-" (!Print.lineLength) ^ "\n");
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   150
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   151
  fun display_name filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   152
      if notshowing "name" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   153
      else print ("Problem: " ^ filename ^ "\n\n");
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   154
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   155
  fun display_goal tptp =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   156
      if notshowing "goal" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   157
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   158
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   159
          val goal = Tptp.goal tptp
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   160
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   161
          print ("Goal:\n" ^ Formula.toString goal ^ "\n\n")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   162
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   163
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   164
  fun display_clauses cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   165
      if notshowing "clauses" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   166
      else print ("Clauses:\n" ^ Problem.toString cls ^ "\n\n");
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   167
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   168
  fun display_size cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   169
      if notshowing "size" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   170
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   171
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   172
          fun plural 1 s = "1 " ^ s
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   173
            | plural n s = Int.toString n ^ " " ^ s ^ "s"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   174
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   175
          val {clauses,literals,symbols,typedSymbols} = Problem.size cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   176
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   177
          print
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   178
            ("Size: " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   179
             plural clauses "clause" ^ ", " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   180
             plural literals "literal" ^ ", " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   181
             plural symbols "symbol" ^ ", " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   182
             plural typedSymbols "typed symbol" ^ ".\n\n")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   183
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   184
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   185
  fun display_category cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   186
      if notshowing "category" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   187
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   188
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   189
          val cat = Problem.categorize cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   190
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   191
          print ("Category: " ^ Problem.categoryToString cat ^ ".\n\n")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   192
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   193
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   194
  local
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   195
    fun display_proof_start filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   196
        print ("\nSZS output start CNFRefutation for " ^ filename ^ "\n");
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   197
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   198
    fun display_proof_body problem proofs =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   199
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   200
          val comments = []
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   201
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   202
          val includes = []
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   203
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   204
          val formulas =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   205
              Tptp.fromProof
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   206
                {problem = problem,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   207
                 proofs = proofs}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   208
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   209
          val proof =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   210
              Tptp.Problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   211
                {comments = comments,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   212
                 includes = includes,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   213
                 formulas = formulas}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   214
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   215
          val mapping = Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   216
          val mapping = Tptp.addVarSetMapping mapping (Tptp.freeVars proof)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   217
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   218
          val filename = "-"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   219
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   220
          Tptp.write
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   221
            {problem = proof,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   222
             mapping = mapping,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   223
             filename = filename}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   224
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   225
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   226
    fun display_proof_end filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   227
        print ("SZS output end CNFRefutation for " ^ filename ^ "\n\n");
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   228
  in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   229
    fun display_proof filename problem proofs =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   230
        if notshowing "proof" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   231
        else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   232
          let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   233
            val () = display_proof_start filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   234
            val () = display_proof_body problem proofs
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   235
            val () = display_proof_end filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   236
          in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   237
            ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   238
          end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   239
  end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   240
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   241
  fun display_saturation filename ths =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   242
      if notshowing "saturation" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   243
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   244
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   245
(*MetisDebug
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   246
          val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   247
              let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   248
                val problem =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   249
                    Tptp.mkProblem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   250
                      {comments = ["Saturation clause set for " ^ filename],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   251
                       includes = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   252
                       names = Tptp.noClauseNames,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   253
                       roles = Tptp.noClauseRoles,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   254
                       problem = {axioms = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   255
                                  conjecture = map Thm.clause ths}}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   256
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   257
                val mapping =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   258
                    Tptp.addVarSetMapping Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   259
                      (Tptp.freeVars problem)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   260
              in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   261
                Tptp.write
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   262
                  {problem = problem,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   263
                   mapping = mapping,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   264
                   filename = "saturation.tptp"}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   265
              end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   266
*)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   267
          val () = print ("\nSZS output start Saturation for " ^ filename ^ "\n")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   268
          val () = app (fn th => print (Thm.toString th ^ "\n")) ths
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   269
          val () = print ("SZS output end Saturation for " ^ filename ^ "\n\n")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   270
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   271
          ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   272
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   273
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   274
  fun display_status filename status =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   275
      if notshowing "status" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   276
      else print ("SZS status " ^ Tptp.toStringStatus status ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   277
                  " for " ^ filename ^ "\n");
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   278
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   279
  fun display_problem filename cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   280
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   281
(*MetisDebug
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   282
        val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   283
            let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   284
              val problem =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   285
                  Tptp.mkProblem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   286
                    {comments = ["CNF clauses for " ^ filename],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   287
                     includes = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   288
                     names = Tptp.noClauseNames,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   289
                     roles = Tptp.noClauseRoles,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   290
                     problem = cls}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   291
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   292
              val mapping =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   293
                  Tptp.addVarSetMapping Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   294
                    (Tptp.freeVars problem)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   295
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   296
              val filename = "cnf_" ^ Int.toString (next_cnf ()) ^ ".tptp"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   297
            in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   298
              Tptp.write
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   299
                {problem = problem,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   300
                 mapping = mapping,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   301
                 filename = filename}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   302
            end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   303
*)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   304
        val () = display_clauses cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   305
        val () = display_size cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   306
        val () = display_category cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   307
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   308
        ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   309
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   310
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   311
  fun mkTptpFilename filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   312
      case !TPTP of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   313
        NONE => filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   314
      | SOME tptp =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   315
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   316
          val tptp = stripSuffix (equal #"/") tptp
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   317
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   318
          tptp ^ "/" ^ filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   319
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   320
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   321
  fun readIncludes mapping seen formulas includes =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   322
      case includes of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   323
        [] => formulas
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   324
      | inc :: includes =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   325
        if StringSet.member inc seen then
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   326
          readIncludes mapping seen formulas includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   327
        else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   328
          let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   329
            val seen = StringSet.add seen inc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   330
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   331
            val filename = mkTptpFilename inc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   332
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   333
            val Tptp.Problem {includes = i, formulas = f, ...} =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   334
                Tptp.read {filename = filename, mapping = mapping}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   335
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   336
            val formulas = f @ formulas
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   337
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   338
            val includes = List.revAppend (i,includes)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   339
          in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   340
            readIncludes mapping seen formulas includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   341
          end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   342
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   343
  fun read mapping filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   344
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   345
        val problem = Tptp.read {filename = filename, mapping = mapping}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   346
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   347
        val Tptp.Problem {comments,includes,formulas} = problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   348
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   349
        if null includes then problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   350
        else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   351
          let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   352
            val seen = StringSet.empty
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   353
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   354
            val includes = rev includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   355
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   356
            val formulas = readIncludes mapping seen formulas includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   357
          in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   358
            Tptp.Problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   359
              {comments = comments,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   360
               includes = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   361
               formulas = formulas}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   362
          end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   363
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   364
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   365
  val resolutionParameters =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   366
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   367
        val {active,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   368
             waiting} = Resolution.default
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   369
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   370
        val waiting =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   371
            let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   372
              val {symbolsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   373
                   variablesWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   374
                   literalsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   375
                   models} = waiting
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   376
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   377
              val models =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   378
                  case models of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   379
                    [{model = _,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   380
                      initialPerturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   381
                      maxChecks,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   382
                      perturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   383
                      weight}] =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   384
                    let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   385
                      val model = Tptp.defaultModel
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   386
                    in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   387
                      [{model = model,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   388
                        initialPerturbations = initialPerturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   389
                        maxChecks = maxChecks,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   390
                        perturbations = perturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   391
                        weight = weight}]
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   392
                    end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   393
                  | _ => raise Bug "resolutionParameters.waiting.models"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   394
            in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   395
              {symbolsWeight = symbolsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   396
               variablesWeight = variablesWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   397
               literalsWeight = literalsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   398
               models = models}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   399
            end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   400
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   401
        {active = active,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   402
         waiting = waiting}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   403
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   404
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   405
  fun refute {axioms,conjecture} =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   406
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   407
        val axioms = map Thm.axiom axioms
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   408
        and conjecture = map Thm.axiom conjecture
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   409
        val problem = {axioms = axioms, conjecture = conjecture}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   410
        val resolution = Resolution.new resolutionParameters problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   411
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   412
        Resolution.loop resolution
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   413
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   414
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   415
  fun refuteAll filename tptp probs acc =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   416
      case probs of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   417
        [] =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   418
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   419
          val status =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   420
              if !TEST then Tptp.UnknownStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   421
              else if Tptp.hasFofConjecture tptp then Tptp.TheoremStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   422
              else Tptp.UnsatisfiableStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   423
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   424
          val () = display_status filename status
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   425
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   426
          val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   427
              if !TEST then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   428
              else display_proof filename tptp (rev acc)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   429
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   430
          true
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   431
        end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   432
      | prob :: probs =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   433
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   434
          val {subgoal,problem,sources} = prob
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   435
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   436
          val () = display_problem filename problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   437
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   438
          if !TEST then refuteAll filename tptp probs acc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   439
          else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   440
            case refute problem of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   441
              Resolution.Contradiction th =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   442
              let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   443
                val subgoalProof =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   444
                    {subgoal = subgoal,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   445
                     sources = sources,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   446
                     refutation = th}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   447
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   448
                val acc = subgoalProof :: acc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   449
              in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   450
                refuteAll filename tptp probs acc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   451
              end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   452
            | Resolution.Satisfiable ths =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   453
              let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   454
                val status =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   455
                    if Tptp.hasFofConjecture tptp then
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   456
                      Tptp.CounterSatisfiableStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   457
                    else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   458
                      Tptp.SatisfiableStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   459
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   460
                val () = display_status filename status
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   461
                val () = display_saturation filename ths
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   462
              in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   463
                false
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   464
              end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   465
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   466
in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   467
  fun prove mapping filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   468
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   469
        val () = display_sep ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   470
        val () = display_name filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   471
        val tptp = read mapping filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   472
        val () = display_goal tptp
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   473
        val problems = Tptp.normalize tptp
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   474
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   475
        refuteAll filename tptp problems []
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   476
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   477
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   478
  fun proveAll mapping filenames =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   479
      List.all
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   480
        (if !QUIET then prove mapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   481
         else fn filename => prove mapping filename orelse true)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   482
        filenames;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   483
end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   484
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   485
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   486
(* Top level.                                                                *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   487
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   488
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   489
val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   490
let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   491
  val work = processOptions ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   492
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   493
  val () = if null work then usage "no input problem files" else ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   494
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   495
  val mapping = Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   496
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   497
  val success = proveAll mapping work
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   498
in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   499
  exit {message = NONE, usage = false, success = success}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   500
end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   501
handle Error s => die (PROGRAM^" failed:\n" ^ s)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   502
     | Bug s => die ("BUG found in "^PROGRAM^" program:\n" ^ s);