| author | wenzelm | 
| Tue, 13 Oct 2020 16:33:43 +0200 | |
| changeset 72462 | 7c552a256ca5 | 
| parent 68848 | 8825efd1c2cf | 
| 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 = | 
| 68848 
8825efd1c2cf
updated URL to remote TPTP, following heads-up from Geoff Sutcliffe
 blanchet parents: 
61029diff
changeset | 15 | "http://www.tptp.org/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; | |
| 42970 | 28 | getopts("hws:t:c:q:",\%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");
 | |
| 42970 | 39 |   print("    -q<num>         quietness level (0 = most verbose, 3 = least verbose)\n");
 | 
| 38062 | 40 |   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 | 41 | exit(0); | 
| 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 42 | } | 
| 29590 | 43 | if (exists($Options{'h'})) {
 | 
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 44 | usage(); | 
| 29590 | 45 | } | 
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 46 | |
| 29590 | 47 | #----What systems flag | 
| 48 | if (exists($Options{'w'})) {
 | |
| 49 |     $URLParameters{"SubmitButton"} = "ListSystems";
 | |
| 50 |     delete($URLParameters{"ProblemSource"});
 | |
| 51 | } | |
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 52 | |
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 53 | #----X2TPTP | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 54 | if (exists($Options{'x'})) {
 | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 55 |     $URLParameters{"X2TPTP"} = "-S";
 | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 56 | } | 
| 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 57 | |
| 29590 | 58 | #----Selected system | 
| 59 | my $System; | |
| 60 | if (exists($Options{'s'})) {
 | |
| 61 |     $System = $Options{'s'};
 | |
| 62 | } else {
 | |
| 63 | # use Vampire as default | |
| 64 | $System = "Vampire---9.0"; | |
| 65 | } | |
| 66 | $URLParameters{"System___$System"} = $System;
 | |
| 67 | ||
| 68 | #----Time limit | |
| 69 | if (exists($Options{'t'})) {
 | |
| 70 |     $URLParameters{"TimeLimit___$System"} = $Options{'t'};
 | |
| 71 | } | |
| 72 | #----Custom command | |
| 73 | if (exists($Options{'c'})) {
 | |
| 74 |     $URLParameters{"Command___$System"} = $Options{'c'};
 | |
| 75 | } | |
| 42970 | 76 | #----Quietness | 
| 77 | if (exists($Options{'q'})) {
 | |
| 78 |     $URLParameters{"QuietFlag"} = "-q" . $Options{'q'};
 | |
| 79 | } | |
| 29590 | 80 | |
| 81 | #----Get single file name | |
| 82 | if (exists($URLParameters{"ProblemSource"})) {
 | |
| 83 |     if (scalar(@ARGV) >= 1) {
 | |
| 84 |         $URLParameters{"UPLOADProblem"} = [shift(@ARGV)];
 | |
| 85 |     } else {
 | |
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 86 |       print("Missing problem file\n");
 | 
| 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 87 | usage(); | 
| 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 88 | die; | 
| 29590 | 89 | } | 
| 90 | } | |
| 28573 | 91 | |
| 92 | # Query Server | |
| 93 | my $Agent = LWP::UserAgent->new; | |
| 39152 
f09b378cb252
make remote ATP invocation work for those people who need to go through a proxy;
 blanchet parents: 
38094diff
changeset | 94 | $Agent->env_proxy; | 
| 46241 
1a0b8f529b96
allow use of proxy for remote SMT solver invocations, just like in the "remote_atp" script
 blanchet parents: 
43528diff
changeset | 95 | $Agent->agent("Sledgehammer");
 | 
| 29590 | 96 | if (exists($Options{'t'})) {
 | 
| 97 | # give server more time to respond | |
| 43528 
35f74aafc878
give slightly more time to server to respond, to avoid leaving too much garbage on Geoff's servers
 blanchet parents: 
42970diff
changeset | 98 |   $Agent->timeout($Options{'t'} + 15);
 | 
| 29590 | 99 | } | 
| 28573 | 100 | my $Request = POST($SystemOnTPTPFormReplyURL, | 
| 101 | Content_Type => 'form-data',Content => \%URLParameters); | |
| 102 | my $Response = $Agent->request($Request); | |
| 29590 | 103 | |
| 104 | #catch errors / failure | |
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 105 | if(!$Response->is_success) {
 | 
| 38065 | 106 | my $message = $Response->message; | 
| 107 | $message =~ s/ \(Bad hostname ['"][^'"]*['"]\)//; | |
| 38094 | 108 | print "HTTP error: " . $message . "\n"; | 
| 30535 | 109 | exit(-1); | 
| 29590 | 110 | } elsif (exists($Options{'w'})) {
 | 
| 111 | print $Response->content; | |
| 112 | exit (0); | |
| 113 | } elsif ($Response->content =~ /WARNING: (\S*) does not exist/) {
 | |
| 38065 | 114 | print "The ATP \"$1\" is not available at SystemOnTPTP\n"; | 
| 29590 | 115 | 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 | 116 | } else {
 | 
| 31833 
9ab1326ed98d
use X2TPTP optionally and only for remote_spass;
 immler@in.tum.de parents: 
30979diff
changeset | 117 | print $Response->content; | 
| 30874 
34927a1e0ae8
reverted to explicitly check the presence of a refutation
 immler@in.tum.de parents: 
30535diff
changeset | 118 | exit(0); | 
| 28573 | 119 | } |