| author | haftmann |
| Thu, 24 Mar 2022 16:34:37 +0000 | |
| changeset 75319 | c7ff16398535 |
| parent 73568 | bdba138d462d |
| child 75393 | 87ebf5a50283 |
| permissions | -rw-r--r-- |
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
1 |
/* Title: HOL/Tools/ATP/system_on_tptp.scala |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
3 |
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
4 |
Support for remote ATPs via SystemOnTPTP. |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
5 |
*/ |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
6 |
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
7 |
package isabelle.atp |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
8 |
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
9 |
import isabelle._ |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
10 |
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
11 |
import java.net.URL |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
12 |
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
13 |
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
14 |
object SystemOnTPTP |
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
15 |
{
|
| 73420 | 16 |
/* requests */ |
17 |
||
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
18 |
def get_url(options: Options): URL = Url(options.string("SystemOnTPTP"))
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
19 |
|
| 73422 | 20 |
def post_request( |
21 |
url: URL, |
|
22 |
parameters: List[(String, Any)], |
|
23 |
timeout: Time = HTTP.Client.default_timeout): HTTP.Content = |
|
| 73420 | 24 |
{
|
| 73423 | 25 |
try {
|
| 73441 | 26 |
HTTP.Client.post(url, |
27 |
("NoHTML" -> 1) :: parameters,
|
|
28 |
timeout = timeout, |
|
29 |
user_agent = "Sledgehammer") |
|
| 73423 | 30 |
} |
31 |
catch { case ERROR(msg) => cat_error("Failed to access SystemOnTPTP server", msg) }
|
|
| 73420 | 32 |
} |
33 |
||
34 |
||
35 |
/* list systems */ |
|
36 |
||
| 73430 | 37 |
def list_systems(url: URL): HTTP.Content = |
| 73441 | 38 |
post_request(url, |
39 |
List("SubmitButton" -> "ListSystems",
|
|
40 |
"ListStatus" -> "READY", |
|
41 |
"QuietFlag" -> "-q0")) |
|
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
42 |
|
| 73565 | 43 |
object List_Systems extends Scala.Fun_String("SystemOnTPTP.list_systems", thread = true)
|
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
44 |
{
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
45 |
val here = Scala_Project.here |
| 73440 | 46 |
def apply(url: String): String = list_systems(Url(url)).text |
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
47 |
} |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
48 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
49 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
50 |
/* run system */ |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
51 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
52 |
def run_system(url: URL, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
53 |
system: String, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
54 |
problem: String, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
55 |
extra: String = "", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
56 |
quiet: String = "01", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
57 |
timeout: Time = Time.seconds(60)): HTTP.Content = |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
58 |
{
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
59 |
val paramaters = |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
60 |
List( |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
61 |
"SubmitButton" -> "RunSelectedSystems", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
62 |
"ProblemSource" -> "FORMULAE", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
63 |
"FORMULAEProblem" -> problem, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
64 |
"ForceSystem" -> "-force", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
65 |
"System___" + system -> system, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
66 |
"TimeLimit___" + system -> timeout.seconds.ceil.toLong, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
67 |
"Command___" + system -> extra, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
68 |
"QuietFlag" -> ("-q" + quiet))
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
69 |
post_request(url, paramaters, timeout = timeout + Time.seconds(15)) |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
70 |
} |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
71 |
|
|
73568
bdba138d462d
clarified signature: more structured arguments, notably for remote provers;
wenzelm
parents:
73565
diff
changeset
|
72 |
object Run_System extends Scala.Fun_Strings("SystemOnTPTP.run_system", thread = true)
|
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
73 |
{
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
74 |
val here = Scala_Project.here |
|
73568
bdba138d462d
clarified signature: more structured arguments, notably for remote provers;
wenzelm
parents:
73565
diff
changeset
|
75 |
def apply(args: List[String]): List[String] = |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
76 |
{
|
|
73568
bdba138d462d
clarified signature: more structured arguments, notably for remote provers;
wenzelm
parents:
73565
diff
changeset
|
77 |
val List(url, system, problem_path, extra, Value.Int(timeout)) = args |
|
73434
00b77365552e
clarified signature: refer to file name instead of file content;
wenzelm
parents:
73431
diff
changeset
|
78 |
val problem = File.read(Path.explode(problem_path)) |
| 73441 | 79 |
|
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
80 |
val res = run_system(Url(url), system, problem, extra = extra, timeout = Time.ms(timeout)) |
| 73440 | 81 |
val text = res.text |
82 |
val timing = res.elapsed_time.ms |
|
83 |
||
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
84 |
val bad_prover = "WARNING: " + system + " does not exist" |
| 73440 | 85 |
if (split_lines(text).exists(_.startsWith(bad_prover))) {
|
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
86 |
error("The ATP " + quote(system) + " is not available at SystemOnTPTP")
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
87 |
} |
|
73568
bdba138d462d
clarified signature: more structured arguments, notably for remote provers;
wenzelm
parents:
73565
diff
changeset
|
88 |
else List(text, timing.toString) |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
89 |
} |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
90 |
} |
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
91 |
} |