src/Tools/Metis/src/metis.sml
author wenzelm
Sat, 09 Jul 2011 21:53:27 +0200
changeset 43721 fad8634cee62
parent 43269 3535f16d9714
child 45778 df6e210fb44c
permissions -rw-r--r--
echo prover input via raw_messages, for improved protocol tracing;
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                                                  *)
39502
cffceed8e7fa fix license
blanchet
parents: 39501
diff changeset
     3
(* Copyright (c) 2001 Joe Hurd, distributed under the BSD License            *)
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     4
(* ========================================================================= *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     5
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     6
open Useful;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     7
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     8
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
     9
(* The program name and 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
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    12
val PROGRAM = "metis";
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    13
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
    14
val VERSION = "2.3";
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    15
43269
3535f16d9714 new Metis version
blanchet
parents: 42102
diff changeset
    16
val versionString = PROGRAM^" "^VERSION^" (release 20110531)"^"\n";
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    17
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    18
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    19
(* Program options.                                                          *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    20
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    21
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    22
val ITEMS = ["name","goal","clauses","size","category","proof","saturation"];
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    23
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    24
val TIMEOUT : int option ref = ref NONE;
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    25
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    26
val TPTP : string option ref = ref NONE;
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    27
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    28
val QUIET = ref false;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    29
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    30
val TEST = ref false;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    31
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    32
val extended_items = "all" :: ITEMS;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    33
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    34
val show_items = List.map (fn s => (s, ref false)) ITEMS;
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    35
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    36
fun show_ref s =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    37
    case List.find (equal s o fst) show_items of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    38
      NONE => raise Bug ("item " ^ s ^ " not found")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    39
    | SOME (_,r) => r;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    40
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    41
fun show_set b = app (fn (_,r) => r := b) show_items;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    42
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    43
fun showing s = not (!QUIET) andalso (s = "status" orelse !(show_ref s));
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    44
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    45
fun notshowing s = not (showing s);
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    46
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    47
fun showing_any () = List.exists showing 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 notshowing_any () = not (showing_any ());
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    50
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    51
fun show "all" = show_set true
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    52
  | show s = case show_ref s of r => r := true;
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 hide "all" = show_set false
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    55
  | hide s = case show_ref s of r => r := false;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    56
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    57
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    58
(* Process command line arguments and environment variables.                 *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    59
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    60
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    61
local
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    62
  open Useful Options;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    63
in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    64
  val specialOptions =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    65
    [{switches = ["--show"], arguments = ["ITEM"],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    66
      description = "show ITEM (see below for list)",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    67
      processor =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    68
        beginOpt (enumOpt extended_items endOpt) (fn _ => fn s => show s)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    69
     {switches = ["--hide"], arguments = ["ITEM"],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    70
      description = "hide ITEM (see below for list)",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    71
      processor =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    72
        beginOpt (enumOpt extended_items endOpt) (fn _ => fn s => hide s)},
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    73
     {switches = ["--time-limit"], arguments = ["N"],
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    74
      description = "give up after N seconds",
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    75
      processor =
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    76
        beginOpt (optionOpt ("-", intOpt (SOME 0, NONE)) endOpt)
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
    77
          (fn _ => fn n => TIMEOUT := n)},
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    78
     {switches = ["--tptp"], arguments = ["DIR"],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    79
      description = "specify the TPTP installation directory",
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 (stringOpt endOpt) (fn _ => fn s => TPTP := SOME s)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    82
     {switches = ["-q","--quiet"], arguments = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    83
      description = "Run quietly; indicate provability with return value",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    84
      processor = beginOpt endOpt (fn _ => QUIET := true)},
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    85
     {switches = ["--test"], arguments = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    86
      description = "Skip the proof search for the input problems",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    87
      processor = beginOpt endOpt (fn _ => TEST := true)}];
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    88
end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    89
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    90
val programOptions =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    91
    {name = PROGRAM,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    92
     version = versionString,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    93
     header = "usage: "^PROGRAM^" [option ...] problem.tptp ...\n" ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    94
              "Proves the input TPTP problem files.\n",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    95
     footer = "Possible ITEMs are {" ^ join "," extended_items ^ "}.\n" ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    96
              "Problems can be read from standard input using the " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    97
              "special - filename.\n",
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    98
     options = specialOptions @ Options.basicOptions};
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
    99
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   100
fun exit x : unit = Options.exit programOptions x;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   101
fun succeed () = Options.succeed programOptions;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   102
fun fail mesg = Options.fail programOptions mesg;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   103
fun usage mesg = Options.usage programOptions mesg;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   104
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   105
fun processOptions () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   106
    let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   107
      val args = CommandLine.arguments ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   108
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   109
      val (_,work) = Options.processOptions programOptions args
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   110
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   111
      val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   112
          case !TPTP of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   113
            SOME _ => ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   114
          | NONE => TPTP := OS.Process.getEnv "TPTP"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   115
    in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   116
      work
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   117
    end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   118
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   119
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   120
(* The core application.                                                     *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   121
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   122
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   123
fun newLimit () =
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   124
    case !TIMEOUT of
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   125
      NONE => K true
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   126
    | SOME lim =>
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   127
      let
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   128
        val timer = Timer.startRealTimer ()
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   129
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   130
        val lim = Time.fromReal (Real.fromInt lim)
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   131
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   132
        fun check () =
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   133
            let
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   134
              val time = Timer.checkRealTimer timer
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   135
            in
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   136
              Time.<= (time,lim)
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   137
            end
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   138
      in
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   139
        check
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   140
      end;
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   141
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   142
(*MetisDebug
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   143
val next_cnf =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   144
    let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   145
      val cnf_counter = ref 0
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   146
    in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   147
      fn () =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   148
         let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   149
           val ref cnf_count = cnf_counter
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   150
           val () = cnf_counter := cnf_count + 1
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   151
         in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   152
           cnf_count
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   153
         end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   154
    end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   155
*)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   156
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   157
local
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   158
  fun display_sep () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   159
      if notshowing_any () then ()
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   160
      else TextIO.print (nChars #"-" (!Print.lineLength) ^ "\n");
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   161
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   162
  fun display_name filename =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   163
      if notshowing "name" then ()
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   164
      else TextIO.print ("Problem: " ^ filename ^ "\n\n");
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   165
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   166
  fun display_goal tptp =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   167
      if notshowing "goal" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   168
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   169
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   170
          val goal = Tptp.goal tptp
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   171
        in
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   172
          TextIO.print ("Goal:\n" ^ Formula.toString goal ^ "\n\n")
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   173
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   174
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   175
  fun display_clauses cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   176
      if notshowing "clauses" then ()
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   177
      else TextIO.print ("Clauses:\n" ^ Problem.toString cls ^ "\n\n");
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   178
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   179
  fun display_size cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   180
      if notshowing "size" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   181
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   182
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   183
          fun plural 1 s = "1 " ^ s
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   184
            | plural n s = Int.toString n ^ " " ^ s ^ "s"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   185
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   186
          val {clauses,literals,symbols,typedSymbols} = Problem.size cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   187
        in
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   188
          TextIO.print
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   189
            ("Size: " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   190
             plural clauses "clause" ^ ", " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   191
             plural literals "literal" ^ ", " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   192
             plural symbols "symbol" ^ ", " ^
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   193
             plural typedSymbols "typed symbol" ^ ".\n\n")
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   194
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   195
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   196
  fun display_category cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   197
      if notshowing "category" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   198
      else
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 cat = Problem.categorize cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   201
        in
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   202
          TextIO.print ("Category: " ^ Problem.categoryToString cat ^ ".\n\n")
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   203
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   204
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   205
  local
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   206
    fun display_proof_start filename =
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   207
        TextIO.print ("\nSZS output start CNFRefutation for " ^ filename ^ "\n");
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   208
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   209
    fun display_proof_body problem proofs =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   210
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   211
          val comments = []
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   212
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   213
          val includes = []
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 formulas =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   216
              Tptp.fromProof
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   217
                {problem = problem,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   218
                 proofs = proofs}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   219
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   220
          val proof =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   221
              Tptp.Problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   222
                {comments = comments,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   223
                 includes = includes,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   224
                 formulas = formulas}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   225
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   226
          val mapping = Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   227
          val mapping = Tptp.addVarSetMapping mapping (Tptp.freeVars proof)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   228
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   229
          val filename = "-"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   230
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   231
          Tptp.write
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   232
            {problem = proof,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   233
             mapping = mapping,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   234
             filename = filename}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   235
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   236
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   237
    fun display_proof_end filename =
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   238
        TextIO.print ("SZS output end CNFRefutation for " ^ filename ^ "\n\n");
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   239
  in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   240
    fun display_proof filename problem proofs =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   241
        if notshowing "proof" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   242
        else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   243
          let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   244
            val () = display_proof_start filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   245
            val () = display_proof_body problem proofs
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   246
            val () = display_proof_end filename
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   247
          in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   248
            ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   249
          end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   250
  end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   251
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   252
  fun display_saturation filename ths =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   253
      if notshowing "saturation" then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   254
      else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   255
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   256
(*MetisDebug
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   257
          val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   258
              let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   259
                val problem =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   260
                    Tptp.mkProblem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   261
                      {comments = ["Saturation clause set for " ^ filename],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   262
                       includes = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   263
                       names = Tptp.noClauseNames,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   264
                       roles = Tptp.noClauseRoles,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   265
                       problem = {axioms = [],
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   266
                                  conjecture = List.map Thm.clause ths}}
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   267
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   268
                val mapping =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   269
                    Tptp.addVarSetMapping Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   270
                      (Tptp.freeVars problem)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   271
              in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   272
                Tptp.write
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   273
                  {problem = problem,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   274
                   mapping = mapping,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   275
                   filename = "saturation.tptp"}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   276
              end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   277
*)
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   278
          val () =
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   279
              TextIO.print
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   280
                ("\nSZS output start Saturation for " ^ filename ^ "\n")
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   281
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   282
          val () = app (fn th => TextIO.print (Thm.toString th ^ "\n")) ths
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   283
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   284
          val () =
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   285
              TextIO.print
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   286
                ("SZS output end Saturation for " ^ filename ^ "\n\n")
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   287
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   288
          ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   289
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   290
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   291
  fun display_status filename status =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   292
      if notshowing "status" then ()
39443
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   293
      else
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   294
        TextIO.print ("SZS status " ^ Tptp.toStringStatus status ^
e330437cd22a copied the unmodified official Metis 2.3 (15 Sept. 2010) sources into Isabelle
blanchet
parents: 39353
diff changeset
   295
                      " for " ^ filename ^ "\n");
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   296
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   297
  fun display_problem filename cls =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   298
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   299
(*MetisDebug
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   300
        val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   301
            let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   302
              val problem =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   303
                  Tptp.mkProblem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   304
                    {comments = ["CNF clauses for " ^ filename],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   305
                     includes = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   306
                     names = Tptp.noClauseNames,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   307
                     roles = Tptp.noClauseRoles,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   308
                     problem = cls}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   309
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   310
              val mapping =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   311
                  Tptp.addVarSetMapping Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   312
                    (Tptp.freeVars problem)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   313
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   314
              val filename = "cnf_" ^ Int.toString (next_cnf ()) ^ ".tptp"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   315
            in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   316
              Tptp.write
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   317
                {problem = problem,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   318
                 mapping = mapping,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   319
                 filename = filename}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   320
            end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   321
*)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   322
        val () = display_clauses cls
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   323
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   324
        val () = display_size cls
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   325
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   326
        val () = display_category cls
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   327
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   328
        ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   329
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   330
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   331
  fun mkTptpFilename filename =
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   332
      if isPrefix "/" filename then filename
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   333
      else
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   334
        case !TPTP of
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   335
          NONE => filename
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   336
        | SOME tptp =>
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   337
          let
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   338
            val tptp = stripSuffix (equal #"/") tptp
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   339
          in
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   340
            tptp ^ "/" ^ filename
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   341
          end;
39348
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 readIncludes mapping seen formulas includes =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   344
      case includes of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   345
        [] => formulas
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   346
      | inc :: includes =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   347
        if StringSet.member inc seen then
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   348
          readIncludes mapping seen formulas includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   349
        else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   350
          let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   351
            val seen = StringSet.add seen inc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   352
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   353
            val filename = mkTptpFilename inc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   354
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   355
            val Tptp.Problem {includes = i, formulas = f, ...} =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   356
                Tptp.read {filename = filename, mapping = mapping}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   357
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   358
            val formulas = f @ formulas
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   359
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   360
            val includes = List.revAppend (i,includes)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   361
          in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   362
            readIncludes mapping seen formulas includes
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
  fun read mapping filename =
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 problem = Tptp.read {filename = filename, mapping = mapping}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   368
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   369
        val Tptp.Problem {comments,includes,formulas} = problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   370
      in
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   371
        if List.null includes then problem
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   372
        else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   373
          let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   374
            val seen = StringSet.empty
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   375
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   376
            val includes = rev includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   377
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   378
            val formulas = readIncludes mapping seen formulas includes
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   379
          in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   380
            Tptp.Problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   381
              {comments = comments,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   382
               includes = [],
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   383
               formulas = formulas}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   384
          end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   385
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   386
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   387
  val resolutionParameters =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   388
      let
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   389
        val {active,waiting} = Resolution.default
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   390
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   391
        val waiting =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   392
            let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   393
              val {symbolsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   394
                   variablesWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   395
                   literalsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   396
                   models} = waiting
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   397
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   398
              val models =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   399
                  case models of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   400
                    [{model = _,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   401
                      initialPerturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   402
                      maxChecks,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   403
                      perturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   404
                      weight}] =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   405
                    let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   406
                      val model = Tptp.defaultModel
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   407
                    in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   408
                      [{model = model,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   409
                        initialPerturbations = initialPerturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   410
                        maxChecks = maxChecks,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   411
                        perturbations = perturbations,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   412
                        weight = weight}]
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
                  | _ => raise Bug "resolutionParameters.waiting.models"
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   415
            in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   416
              {symbolsWeight = symbolsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   417
               variablesWeight = variablesWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   418
               literalsWeight = literalsWeight,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   419
               models = models}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   420
            end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   421
      in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   422
        {active = active,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   423
         waiting = waiting}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   424
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   425
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   426
  fun resolutionLoop limit res =
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   427
      case Resolution.iterate res of
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   428
        Resolution.Decided dec => SOME dec
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   429
      | Resolution.Undecided res =>
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   430
        if limit () then resolutionLoop limit res else NONE;
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   431
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   432
  fun refute limit {axioms,conjecture} =
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   433
      let
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   434
        val axioms = List.map Thm.axiom axioms
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   435
        and conjecture = List.map Thm.axiom conjecture
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   436
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   437
        val problem = {axioms = axioms, conjecture = conjecture}
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   438
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   439
        val res = Resolution.new resolutionParameters problem
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   440
      in
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   441
        resolutionLoop limit res
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   442
      end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   443
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   444
  fun refuteAll limit filename tptp probs acc =
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   445
      case probs of
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   446
        [] =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   447
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   448
          val status =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   449
              if !TEST then Tptp.UnknownStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   450
              else if Tptp.hasFofConjecture tptp then Tptp.TheoremStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   451
              else Tptp.UnsatisfiableStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   452
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   453
          val () = display_status filename status
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   454
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   455
          val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   456
              if !TEST then ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   457
              else display_proof filename tptp (rev acc)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   458
        in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   459
          true
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   460
        end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   461
      | prob :: probs =>
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   462
        let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   463
          val {subgoal,problem,sources} = prob
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   464
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   465
          val () = display_problem filename problem
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   466
        in
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   467
          if !TEST then refuteAll limit filename tptp probs acc
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   468
          else
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   469
            case refute limit problem of
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   470
              SOME (Resolution.Contradiction th) =>
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   471
              let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   472
                val subgoalProof =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   473
                    {subgoal = subgoal,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   474
                     sources = sources,
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   475
                     refutation = th}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   476
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   477
                val acc = subgoalProof :: acc
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   478
              in
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   479
                refuteAll limit filename tptp probs acc
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   480
              end
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   481
            | SOME (Resolution.Satisfiable ths) =>
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   482
              let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   483
                val status =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   484
                    if Tptp.hasFofConjecture tptp then
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   485
                      Tptp.CounterSatisfiableStatus
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   486
                    else
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   487
                      Tptp.SatisfiableStatus
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 () = display_status filename status
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   490
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   491
                val () = display_saturation filename ths
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   492
              in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   493
                false
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   494
              end
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   495
            | NONE =>
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   496
              let
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   497
                val status = Tptp.UnknownStatus
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   498
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   499
                val () = display_status filename status
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   500
              in
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   501
                false
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   502
              end
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   503
        end;
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   504
in
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   505
  fun prove limit mapping filename =
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   506
      let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   507
        val () = display_sep ()
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   508
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   509
        val () = display_name filename
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   510
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   511
        val tptp = read mapping filename
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   512
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   513
        val () = display_goal tptp
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   514
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   515
        val problems = Tptp.normalize tptp
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   516
      in
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   517
        refuteAll limit filename tptp problems []
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   518
      end;
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   519
end;
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   520
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   521
fun proveAll limit mapping filenames =
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   522
    List.all
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   523
      (if !QUIET then prove limit mapping
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   524
       else fn filename => prove limit mapping filename orelse true)
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   525
      filenames;
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   526
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   527
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   528
(* Top level.                                                                *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   529
(* ------------------------------------------------------------------------- *)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   530
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   531
val () =
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   532
let
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   533
  val work = processOptions ()
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   534
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   535
  val () = if List.null work then usage "no input problem files" else ()
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   536
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   537
  val limit = newLimit ()
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   538
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   539
  val mapping = Tptp.defaultMapping
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   540
42102
fcfd07f122d4 new version of Metis 2.3 (29 Dec. 2010)
blanchet
parents: 39502
diff changeset
   541
  val success = proveAll limit mapping work
39348
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   542
in
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   543
  exit {message = NONE, usage = false, success = success}
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   544
end
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   545
handle Error s => die (PROGRAM^" failed:\n" ^ s)
6f9c9899f99f new version of the Metis files
blanchet
parents:
diff changeset
   546
     | Bug s => die ("BUG found in "^PROGRAM^" program:\n" ^ s);