Admin/E/eproof
author wenzelm
Thu, 07 Jul 2011 23:55:15 +0200
changeset 44572 91c4d7397f0e
parent 32675 5fe601aff9be
permissions -rwxr-xr-x
simplified make_option/dest_option;
added make_variant/dest_variant -- usual representation of datatypes;
     1 #!/usr/bin/perl -w
     2 #
     3 # eproof - run E and translate its output into TSTP format
     4 #
     5 # Author: Sascha Boehme, TU Muenchen
     6 #
     7 # This script is a port of a Bash script with the same name coming with
     8 # E 1.0-004 (written by Stephan Schulz).
     9 #
    10 
    11 
    12 use File::Basename qw/ dirname /;
    13 use File::Temp qw/ tempfile /;
    14 use English;
    15 
    16 
    17 # E executables
    18 
    19 my $edir = dirname($0);
    20 my $eprover = "$edir/eprover";
    21 my $epclextract = "$edir/epclextract";
    22 
    23 
    24 # build E command from given commandline arguments
    25 
    26 my $format = "";
    27 my $timelimit = 2000000000;   # effectively unlimited
    28 
    29 my $eprover_cmd = "'$eprover'";
    30 foreach (@ARGV) {
    31   if (m/--cpu-limit=([0-9]+)/) {
    32     $timelimit = $1;
    33   }
    34 
    35   if (m/--tstp-out/) {
    36     $format = $_;
    37   }
    38   else {
    39     $eprover_cmd = "$eprover_cmd '$_'";
    40   }
    41 }
    42 $eprover_cmd = "$eprover_cmd -l4 -R -o- --pcl-terms-compressed --pcl-compact";
    43 
    44 
    45 # run E, redirecting output into a temporary file
    46 
    47 my ($fh, $filename) = tempfile(UNLINK => 1);
    48 my $r = system "$eprover_cmd > '$filename'";
    49 exit ($r >> 8) if $r != 0;
    50 
    51 
    52 # analyze E output
    53 
    54 my @lines = <$fh>;
    55 my $content = join "", @lines[-60 .. -1];
    56   # Note: Like the original eproof, we only look at the last 60 lines.
    57 
    58 if ($content =~ m/Total time\s*:\s*([0-9]+\.[0-9]+)/) {
    59   $timelimit = int($timelimit - $1 - 1);
    60 
    61   if ($content =~ m/No proof found!/) {
    62     print "# Problem is satisfiable (or invalid), " .
    63       "generating saturation derivation\n";
    64   }
    65   elsif ($content =~ m/Proof found!/) {
    66     print "# Problem is unsatisfiable (or provable), " .
    67       "constructing proof object\n";
    68   }
    69   elsif ($content =~ m/Watchlist is empty!/) {
    70     print "# All watchlist clauses generated, constructing derivation\n";
    71   }
    72   else {
    73     print "# Cannot determine problem status\n";
    74     exit $r;
    75   }
    76 }
    77 else {
    78   print "# Cannot determine problem status within resource limit\n";
    79   exit $r;
    80 }
    81 
    82 
    83 # translate E output
    84 
    85 foreach (@lines) {
    86   print if (m/# SZS status/ or m/"# Failure"/);
    87 }
    88 $r = system ("exec bash -c \"ulimit -S -t $timelimit; " .
    89   "'$epclextract' $format -f --competition-framing '$filename'\"");
    90   # Note: Setting the user time is not supported on Cygwin, i.e., ulimit fails
    91   # and prints and error message. How could we then limit the execution time?
    92 exit ($r >> 8);
    93