| author | wenzelm |
| Thu, 27 Jun 2024 22:39:20 +0200 | |
| changeset 80430 | 89cd8fedefa7 |
| parent 79510 | d8330439823a |
| 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 |
|
| 75393 | 12 |
object SystemOnTPTP {
|
| 73420 | 13 |
/* requests */ |
14 |
||
|
79510
d8330439823a
clarified signature: explicit type isabelle.Url to avoid oddities of java.net.URL (e.g. its "equals" method);
wenzelm
parents:
78592
diff
changeset
|
15 |
def get_url(options: Options): Url = Url(options.string("SystemOnTPTP"))
|
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
16 |
|
| 73422 | 17 |
def post_request( |
|
79510
d8330439823a
clarified signature: explicit type isabelle.Url to avoid oddities of java.net.URL (e.g. its "equals" method);
wenzelm
parents:
78592
diff
changeset
|
18 |
url: Url, |
| 73422 | 19 |
parameters: List[(String, Any)], |
| 75393 | 20 |
timeout: Time = HTTP.Client.default_timeout |
21 |
): HTTP.Content = {
|
|
| 73423 | 22 |
try {
|
| 73441 | 23 |
HTTP.Client.post(url, |
24 |
("NoHTML" -> 1) :: parameters,
|
|
25 |
timeout = timeout, |
|
26 |
user_agent = "Sledgehammer") |
|
| 73423 | 27 |
} |
28 |
catch { case ERROR(msg) => cat_error("Failed to access SystemOnTPTP server", msg) }
|
|
| 73420 | 29 |
} |
30 |
||
31 |
||
32 |
/* list systems */ |
|
33 |
||
|
79510
d8330439823a
clarified signature: explicit type isabelle.Url to avoid oddities of java.net.URL (e.g. its "equals" method);
wenzelm
parents:
78592
diff
changeset
|
34 |
def list_systems(url: Url): HTTP.Content = |
| 73441 | 35 |
post_request(url, |
36 |
List("SubmitButton" -> "ListSystems",
|
|
37 |
"ListStatus" -> "READY", |
|
38 |
"QuietFlag" -> "-q0")) |
|
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
39 |
|
| 75393 | 40 |
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
|
41 |
val here = Scala_Project.here |
| 73440 | 42 |
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
|
43 |
} |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
44 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
45 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
46 |
/* run system */ |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
47 |
|
|
79510
d8330439823a
clarified signature: explicit type isabelle.Url to avoid oddities of java.net.URL (e.g. its "equals" method);
wenzelm
parents:
78592
diff
changeset
|
48 |
def run_system(url: Url, |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
49 |
system: String, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
50 |
problem: String, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
51 |
extra: String = "", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
52 |
quiet: String = "01", |
| 75393 | 53 |
timeout: Time = Time.seconds(60) |
54 |
): HTTP.Content = {
|
|
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
55 |
val paramaters = |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
56 |
List( |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
57 |
"SubmitButton" -> "RunSelectedSystems", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
58 |
"ProblemSource" -> "FORMULAE", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
59 |
"FORMULAEProblem" -> problem, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
60 |
"ForceSystem" -> "-force", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
61 |
"System___" + system -> system, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
62 |
"TimeLimit___" + system -> timeout.seconds.ceil.toLong, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
63 |
"Command___" + system -> extra, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
64 |
"QuietFlag" -> ("-q" + quiet))
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
65 |
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
|
66 |
} |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
67 |
|
| 75393 | 68 |
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
|
69 |
val here = Scala_Project.here |
| 75393 | 70 |
def apply(args: List[String]): List[String] = {
|
| 78592 | 71 |
val List(url, system, problem_path, extra, Value.Int(timeout)) = args : @unchecked |
|
73434
00b77365552e
clarified signature: refer to file name instead of file content;
wenzelm
parents:
73431
diff
changeset
|
72 |
val problem = File.read(Path.explode(problem_path)) |
| 73441 | 73 |
|
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
74 |
val res = run_system(Url(url), system, problem, extra = extra, timeout = Time.ms(timeout)) |
| 73440 | 75 |
val text = res.text |
76 |
val timing = res.elapsed_time.ms |
|
77 |
||
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
78 |
val bad_prover = "WARNING: " + system + " does not exist" |
| 73440 | 79 |
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
|
80 |
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
|
81 |
} |
|
73568
bdba138d462d
clarified signature: more structured arguments, notably for remote provers;
wenzelm
parents:
73565
diff
changeset
|
82 |
else List(text, timing.toString) |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
83 |
} |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
84 |
} |
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
85 |
} |