src/HOL/Tools/ATP/scripts/remote_atp
author blanchet
Wed, 28 Jul 2010 23:05:35 +0200
changeset 38308 a7c9cc973ca1
parent 38307 685d1f0f75b3
child 38311 9069e1ad1527
permissions -rwxr-xr-x
fiddled with usage text
     1 #!/usr/bin/env perl
     2 #
     3 # Wrapper for custom remote provers on SystemOnTPTP
     4 # Author: Fabian Immler, TU Muenchen
     5 # Author: Jasmin Blanchette, TU Muenchen
     6 #
     7 
     8 use warnings;
     9 use strict;
    10 use Getopt::Std;
    11 use HTTP::Request::Common;
    12 use LWP;
    13 
    14 my $SystemOnTPTPFormReplyURL =
    15   "http://www.cs.miami.edu/~tptp/cgi-bin/SystemOnTPTPFormReply";
    16 
    17 # default parameters
    18 my %URLParameters = (
    19     "NoHTML" => 1,
    20     "QuietFlag" => "-q01",
    21     "SubmitButton" => "RunSelectedSystems",
    22     "ProblemSource" => "UPLOAD",
    23     "ForceSystem" => "-force",
    24     );
    25 
    26 #----Get format and transform options if specified
    27 my %Options;
    28 getopts("hws:t:c:",\%Options);
    29 
    30 #----Usage
    31 sub usage() {
    32   print("Usage: remote_atp [<options>] <file_name>\n");
    33   print("Options:\n");
    34   print("    -h              print this help\n");
    35   print("    -w              list available ATPs\n");
    36   print("    -s<system>      ATP to use\n");
    37   print("    -t<time_limit>  CPU time limit for ATP\n");
    38   print("    -c<command>     custom ATP invocation command\n");
    39   print("    <file_name>     TPTP problem file\n");
    40   exit(0);
    41 }
    42 if (exists($Options{'h'})) {
    43   usage();
    44 }
    45 
    46 #----What systems flag
    47 if (exists($Options{'w'})) {
    48     $URLParameters{"SubmitButton"} = "ListSystems";
    49     delete($URLParameters{"ProblemSource"});
    50 }
    51 
    52 #----X2TPTP
    53 if (exists($Options{'x'})) {
    54     $URLParameters{"X2TPTP"} = "-S";
    55 }
    56 
    57 #----Selected system
    58 my $System;
    59 if (exists($Options{'s'})) {
    60     $System = $Options{'s'};
    61 } else {
    62     # use Vampire as default
    63     $System = "Vampire---9.0";
    64 }
    65 $URLParameters{"System___$System"} = $System;
    66 
    67 #----Time limit
    68 if (exists($Options{'t'})) {
    69     $URLParameters{"TimeLimit___$System"} = $Options{'t'};
    70 }
    71 #----Custom command
    72 if (exists($Options{'c'})) {
    73     $URLParameters{"Command___$System"} = $Options{'c'};
    74 }
    75 
    76 #----Get single file name
    77 if (exists($URLParameters{"ProblemSource"})) {
    78     if (scalar(@ARGV) >= 1) {
    79         $URLParameters{"UPLOADProblem"} = [shift(@ARGV)];
    80     } else {
    81       print("Missing problem file\n");
    82       usage();
    83       die;
    84     }
    85 }
    86 
    87 # Query Server
    88 my $Agent = LWP::UserAgent->new;
    89 if (exists($Options{'t'})) {
    90   # give server more time to respond
    91   $Agent->timeout($Options{'t'} + 10);
    92 }
    93 my $Request = POST($SystemOnTPTPFormReplyURL,
    94 	Content_Type => 'form-data',Content => \%URLParameters);
    95 my $Response = $Agent->request($Request);
    96 
    97 #catch errors / failure
    98 if(!$Response->is_success) {
    99   print "HTTP-Error: " . $Response->message . "\n";
   100   exit(-1);
   101 } elsif (exists($Options{'w'})) {
   102   print $Response->content;
   103   exit (0);
   104 } elsif ($Response->content =~ /WARNING: (\S*) does not exist/) {
   105   print "Specified system $1 does not exist\n";
   106   exit(-1);
   107 } else {
   108   print $Response->content;
   109   exit(0);
   110 }