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