| author | wenzelm | 
| Fri, 27 Aug 2010 17:23:57 +0200 | |
| changeset 38807 | 378ffc903bed | 
| parent 38094 | d01b8119b2e0 | 
| child 39152 | f09b378cb252 | 
| permissions | -rwxr-xr-x | 
| 28573 | 1 | #!/usr/bin/env perl | 
| 2 | # | |
| 3 | # Wrapper for custom remote provers on SystemOnTPTP | |
| 4 | # Author: Fabian Immler, TU Muenchen | |
| 38062 | 5 | # Author: Jasmin Blanchette, TU Muenchen | 
| 28573 | 6 | # | 
| 7 | ||
| 8 | use warnings; | |
| 9 | use strict; | |
| 10 | use Getopt::Std; | |
| 11 | use HTTP::Request::Common; | |
| 29590 | 12 | use LWP; | 
| 28573 | 13 | |
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 14 | my $SystemOnTPTPFormReplyURL = | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 15 | "http://www.cs.miami.edu/~tptp/cgi-bin/SystemOnTPTPFormReply"; | 
| 28573 | 16 | |
| 29590 | 17 | # default parameters | 
| 28573 | 18 | my %URLParameters = ( | 
| 19 | "NoHTML" => 1, | |
| 20 | "QuietFlag" => "-q01", | |
| 21 | "SubmitButton" => "RunSelectedSystems", | |
| 22 | "ProblemSource" => "UPLOAD", | |
| 32435 
711d680eab26
New option ForceSystem that makes sure we *really* get the system we ask for
 nipkow parents: 
32327diff
changeset | 23 | "ForceSystem" => "-force", | 
| 29590 | 24 | ); | 
| 25 | ||
| 26 | #----Get format and transform options if specified | |
| 27 | my %Options; | |
| 38042 
ef45bcccc9fd
remove needless "-x" option, now that (1) we can't handle remote SPASS anymore; and (2) we can a priori parse the SPASS syntax in "Sledgehammer_Proof_Reconstruct" anyway
 blanchet parents: 
38041diff
changeset | 28 | getopts("hws:t:c:",\%Options);
 | 
| 29590 | 29 | |
| 30 | #----Usage | |
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 31 | sub usage() {
 | 
| 38062 | 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");
 | |
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 40 | exit(0); | 
| 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 41 | } | 
| 29590 | 42 | if (exists($Options{'h'})) {
 | 
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 43 | usage(); | 
| 29590 | 44 | } | 
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 45 | |
| 29590 | 46 | #----What systems flag | 
| 47 | if (exists($Options{'w'})) {
 | |
| 48 |     $URLParameters{"SubmitButton"} = "ListSystems";
 | |
| 49 |     delete($URLParameters{"ProblemSource"});
 | |
| 50 | } | |
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 51 | |
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 52 | #----X2TPTP | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 53 | if (exists($Options{'x'})) {
 | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 54 |     $URLParameters{"X2TPTP"} = "-S";
 | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 55 | } | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 56 | |
| 29590 | 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 {
 | |
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 81 |       print("Missing problem file\n");
 | 
| 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 82 | usage(); | 
| 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 83 | die; | 
| 29590 | 84 | } | 
| 85 | } | |
| 28573 | 86 | |
| 87 | # Query Server | |
| 88 | my $Agent = LWP::UserAgent->new; | |
| 29590 | 89 | if (exists($Options{'t'})) {
 | 
| 90 | # give server more time to respond | |
| 30534 | 91 |   $Agent->timeout($Options{'t'} + 10);
 | 
| 29590 | 92 | } | 
| 28573 | 93 | my $Request = POST($SystemOnTPTPFormReplyURL, | 
| 94 | Content_Type => 'form-data',Content => \%URLParameters); | |
| 95 | my $Response = $Agent->request($Request); | |
| 29590 | 96 | |
| 97 | #catch errors / failure | |
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 98 | if(!$Response->is_success) {
 | 
| 38065 | 99 | my $message = $Response->message; | 
| 100 | $message =~ s/ \(Bad hostname ['"][^'"]*['"]\)//; | |
| 38094 | 101 | print "HTTP error: " . $message . "\n"; | 
| 30535 | 102 | exit(-1); | 
| 29590 | 103 | } elsif (exists($Options{'w'})) {
 | 
| 104 | print $Response->content; | |
| 105 | exit (0); | |
| 106 | } elsif ($Response->content =~ /WARNING: (\S*) does not exist/) {
 | |
| 38065 | 107 | print "The ATP \"$1\" is not available at SystemOnTPTP\n"; | 
| 29590 | 108 | exit(-1); | 
| 38042 
ef45bcccc9fd
remove needless "-x" option, now that (1) we can't handle remote SPASS anymore; and (2) we can a priori parse the SPASS syntax in "Sledgehammer_Proof_Reconstruct" anyway
 blanchet parents: 
38041diff
changeset | 109 | } else {
 | 
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 110 | print $Response->content; | 
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 111 | exit(0); | 
| 28573 | 112 | } |