src/HOL/Tools/res_atp_provers.ML
author webertj
Wed, 30 Aug 2006 16:27:53 +0200
changeset 20440 e6fe74eebda3
parent 19723 7602f74c914b
child 22373 c6002b06e63e
permissions -rw-r--r--
faster clause representation (again): full CNF formula as a hypothesis, instead of separate clauses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     1
(*  ID:         $Id$
17907
c20e4bddcb11 *** empty log message ***
mengj
parents: 17905
diff changeset
     2
    Author:     Jia Meng, NICTA
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     3
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     4
Functions used for ATP Oracle.
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     5
*)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     6
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     7
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     8
structure ResAtpProvers =
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
     9
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    10
struct
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    11
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    12
fun if_proof_vampire instr = (TextIO.inputLine instr = "Refutation found. Thanks to Tanya!\n");
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    13
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    14
fun if_proof_E instr =
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    15
  let val thisLine = TextIO.inputLine instr
19479
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    16
  in thisLine <> "" andalso 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    17
     (thisLine = "# Proof found!\n" orelse if_proof_E instr) 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    18
  end;
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    19
19723
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    20
fun if_proof_spass instr = 
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    21
    let val thisLine = TextIO.inputLine instr
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    22
    in thisLine <> "" andalso 
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    23
       (thisLine = "SPASS beiseite: Proof found.\n" orelse if_proof_spass instr) 
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    24
    end;
19129
b66dff8ab7e9 eprover removes tmp files too.
mengj
parents: 18726
diff changeset
    25
18726
02b310b1fa10 added some debugging code.
mengj
parents: 18272
diff changeset
    26
local 
02b310b1fa10 added some debugging code.
mengj
parents: 18272
diff changeset
    27
19195
e0b483dea2c0 Moved the settings for ATP time limit to res_atp.ML
mengj
parents: 19129
diff changeset
    28
fun location s = warning ("ATP input at: " ^ s);
18726
02b310b1fa10 added some debugging code.
mengj
parents: 18272
diff changeset
    29
02b310b1fa10 added some debugging code.
mengj
parents: 18272
diff changeset
    30
in 
02b310b1fa10 added some debugging code.
mengj
parents: 18272
diff changeset
    31
19195
e0b483dea2c0 Moved the settings for ATP time limit to res_atp.ML
mengj
parents: 19129
diff changeset
    32
fun call_vampire (file:string, time: int) = 
e0b483dea2c0 Moved the settings for ATP time limit to res_atp.ML
mengj
parents: 19129
diff changeset
    33
  let val _ = location file
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    34
      val runtime = "-t " ^ (string_of_int time)
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    35
      val vampire = ResAtp.helper_path "VAMPIRE_HOME" "vampire"
19479
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    36
      val ch:(TextIO.instream,TextIO.outstream) Unix.proc = 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    37
          Unix.execute(vampire, [runtime,file])
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    38
      val (instr,outstr) = Unix.streamsOf ch
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    39
  in if_proof_vampire instr
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    40
  end;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    41
19195
e0b483dea2c0 Moved the settings for ATP time limit to res_atp.ML
mengj
parents: 19129
diff changeset
    42
fun call_eprover (file:string, time:int) =
e0b483dea2c0 Moved the settings for ATP time limit to res_atp.ML
mengj
parents: 19129
diff changeset
    43
  let val _ = location file
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    44
      val eprover = ResAtp.helper_path "E_HOME" "/PROVER/eprover"
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    45
      val runtime = "--cpu-limit=" ^ (string_of_int time)
19479
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    46
      val ch:(TextIO.instream,TextIO.outstream) Unix.proc = 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    47
          Unix.execute(eprover, [runtime,"--tptp-format","-tAuto","-xAuto",file])
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    48
      val (instr,outstr) = Unix.streamsOf ch
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    49
  in if_proof_E instr
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    50
  end; 
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    51
19723
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    52
fun call_spass (file:string, time:int) =
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    53
    let val _ = location file
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    54
	val runtime = "-TimeLimit=" ^ (string_of_int time)
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    55
	val spass = ResAtp.helper_path "SPASS_HOME" "SPASS"
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    56
	val ch:(TextIO.instream,TextIO.outstream) Unix.proc =
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    57
	    Unix.execute(spass, [runtime,"-Splits=0", "-FullRed=0", "-SOS=1",file])
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    58
	val (instr,outstr) = Unix.streamsOf ch
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    59
    in if_proof_spass instr
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    60
    end;
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    61
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    62
18726
02b310b1fa10 added some debugging code.
mengj
parents: 18272
diff changeset
    63
end
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    64
19479
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    65
fun vampire_o _ (file,time) = 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    66
  if call_vampire (file,time) 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    67
  then (warning file; ResAtp.cond_rm_tmp file; HOLogic.mk_Trueprop HOLogic.false_const)  
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    68
  else (ResAtp.cond_rm_tmp file; raise Fail ("vampire oracle failed"));
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    69
19479
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    70
fun eprover_o _ (file,time) = 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    71
  if call_eprover (file,time) 
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    72
  then (warning file; ResAtp.cond_rm_tmp file; HOLogic.mk_Trueprop HOLogic.false_const)
caaf68a64ac4 cosmetic changes
paulson
parents: 19195
diff changeset
    73
  else (ResAtp.cond_rm_tmp file; raise Fail ("eprover oracle failed"));
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    74
19723
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    75
fun spass_o _ (file,time) =
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    76
    if call_spass (file,time)
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    77
    then (warning file; ResAtp.cond_rm_tmp file; HOLogic.mk_Trueprop HOLogic.false_const)
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    78
    else (ResAtp.cond_rm_tmp file; raise Fail ("SPASS oracle failed"));
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    79
7602f74c914b A new "spass" method.
mengj
parents: 19479
diff changeset
    80
17905
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    81
end;
1574533861b1 Added files in order to use external ATPs as oracles and invoke these ATPs by calling Isabelle methods (currently "vampire" and "eprover").
mengj
parents:
diff changeset
    82