author | immler@in.tum.de |
Sat, 04 Apr 2009 20:22:39 +0200 | |
changeset 30874 | 34927a1e0ae8 |
parent 30535 | db8b10fd51a4 |
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 |
|
5 |
# |
|
6 |
||
7 |
use warnings; |
|
8 |
use strict; |
|
9 |
use Getopt::Std; |
|
10 |
use HTTP::Request::Common; |
|
29590 | 11 |
use LWP; |
28573 | 12 |
|
13 |
my $SystemOnTPTPFormReplyURL = "http://www.cs.miami.edu/~tptp/cgi-bin/SystemOnTPTPFormReply"; |
|
14 |
||
29590 | 15 |
# default parameters |
28573 | 16 |
my %URLParameters = ( |
17 |
"NoHTML" => 1, |
|
18 |
"QuietFlag" => "-q01", |
|
19 |
"X2TPTP" => "-S", |
|
20 |
"SubmitButton" => "RunSelectedSystems", |
|
21 |
"ProblemSource" => "UPLOAD", |
|
29590 | 22 |
); |
23 |
||
24 |
#----Get format and transform options if specified |
|
25 |
my %Options; |
|
26 |
getopts("hws:t:c:",\%Options); |
|
27 |
||
28 |
#----Usage |
|
30874
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
29 |
sub usage() { |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
30 |
print("Usage: remote [<options>] <File name>\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
31 |
print(" <options> are ...\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
32 |
print(" -h - print this help\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
33 |
print(" -w - list available ATP systems\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
34 |
print(" -s<system> - specified system to use\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
35 |
print(" -t<timelimit> - CPU time limit for system\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
36 |
print(" -c<command> - custom command for system\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
37 |
print(" <File name> - TPTP problem file\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
38 |
exit(0); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
39 |
} |
29590 | 40 |
if (exists($Options{'h'})) { |
30874
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
41 |
usage(); |
29590 | 42 |
} |
43 |
#----What systems flag |
|
44 |
if (exists($Options{'w'})) { |
|
45 |
$URLParameters{"SubmitButton"} = "ListSystems"; |
|
46 |
delete($URLParameters{"ProblemSource"}); |
|
47 |
} |
|
48 |
#----Selected system |
|
49 |
my $System; |
|
50 |
if (exists($Options{'s'})) { |
|
51 |
$System = $Options{'s'}; |
|
52 |
} else { |
|
53 |
# use Vampire as default |
|
54 |
$System = "Vampire---9.0"; |
|
55 |
} |
|
56 |
$URLParameters{"System___$System"} = $System; |
|
57 |
||
58 |
#----Time limit |
|
59 |
if (exists($Options{'t'})) { |
|
60 |
$URLParameters{"TimeLimit___$System"} = $Options{'t'}; |
|
61 |
} |
|
62 |
#----Custom command |
|
63 |
if (exists($Options{'c'})) { |
|
64 |
$URLParameters{"Command___$System"} = $Options{'c'}; |
|
65 |
} |
|
66 |
||
67 |
#----Get single file name |
|
68 |
if (exists($URLParameters{"ProblemSource"})) { |
|
69 |
if (scalar(@ARGV) >= 1) { |
|
70 |
$URLParameters{"UPLOADProblem"} = [shift(@ARGV)]; |
|
71 |
} else { |
|
30874
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
72 |
print("Missing problem file\n"); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
73 |
usage(); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
74 |
die; |
29590 | 75 |
} |
76 |
} |
|
28573 | 77 |
|
78 |
# Query Server |
|
79 |
my $Agent = LWP::UserAgent->new; |
|
29590 | 80 |
if (exists($Options{'t'})) { |
81 |
# give server more time to respond |
|
30534 | 82 |
$Agent->timeout($Options{'t'} + 10); |
29590 | 83 |
} |
28573 | 84 |
my $Request = POST($SystemOnTPTPFormReplyURL, |
85 |
Content_Type => 'form-data',Content => \%URLParameters); |
|
86 |
my $Response = $Agent->request($Request); |
|
29590 | 87 |
|
88 |
#catch errors / failure |
|
89 |
if(! $Response->is_success){ |
|
30535 | 90 |
print "HTTP-Error: " . $Response->message . "\n"; |
91 |
exit(-1); |
|
29590 | 92 |
} elsif (exists($Options{'w'})) { |
93 |
print $Response->content; |
|
94 |
exit (0); |
|
95 |
} elsif ($Response->content =~ /WARNING: (\S*) does not exist/) { |
|
96 |
print "Specified System $1 does not exist\n"; |
|
97 |
exit(-1); |
|
30874
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
98 |
} elsif ($Response->content =~ /%\s*Result\s*:\s*Unsatisfiable.*\n%\s*Output\s*:\s*(CNF)?Refutation.*\n%/) { |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
99 |
my @lines = split( /\n/, $Response->content); |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
100 |
my $extract = ""; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
101 |
foreach my $line (@lines){ |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
102 |
#ignore comments |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
103 |
if ($line !~ /^%/ && !($line eq "")) { |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
104 |
$extract .= "$line"; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
105 |
} |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
106 |
} |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
107 |
# insert newlines after ').' |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
108 |
$extract =~ s/\s//g; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
109 |
$extract =~ s/\)\.cnf/\)\.\ncnf/g; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
110 |
|
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
111 |
# orientation for res_reconstruct.ML |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
112 |
print "# SZS output start CNFRefutation.\n"; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
113 |
print "$extract\n"; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
114 |
print "# SZS output end CNFRefutation.\n"; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
115 |
exit(0); |
29590 | 116 |
} else { |
30874
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
117 |
print "Remote-script could not extract proof:\n".$Response->content; |
34927a1e0ae8
reverted to explicitly check the presence of a refutation
immler@in.tum.de
parents:
30535
diff
changeset
|
118 |
exit(-1); |
28573 | 119 |
} |
120 |