| author | wenzelm |
| Mon, 15 Mar 2021 11:43:56 +0100 | |
| changeset 73440 | 3696bb4085ed |
| parent 73434 | 00b77365552e |
| child 73441 | f2167948157e |
| 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 |
{
|
25 |
val parameters0 = |
|
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
26 |
List("NoHTML" -> 1, "QuietFlag" -> "-q0")
|
| 73420 | 27 |
.filterNot(p0 => parameters.exists(p => p0._1 == p._1)) |
| 73423 | 28 |
try {
|
29 |
HTTP.Client.post(url, parameters0 ::: parameters, |
|
30 |
timeout = timeout, user_agent = "Sledgehammer") |
|
31 |
} |
|
32 |
catch { case ERROR(msg) => cat_error("Failed to access SystemOnTPTP server", msg) }
|
|
| 73420 | 33 |
} |
34 |
||
35 |
||
36 |
/* list systems */ |
|
37 |
||
| 73430 | 38 |
def list_systems(url: URL): HTTP.Content = |
39 |
post_request(url, List("SubmitButton" -> "ListSystems", "ListStatus" -> "READY"))
|
|
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
40 |
|
|
73419
22f3f2117ed7
clarified signature: function_thread is determined in Isabelle/Scala, not Isabelle/ML;
wenzelm
parents:
73418
diff
changeset
|
41 |
object List_Systems extends Scala.Fun("SystemOnTPTP.list_systems", thread = true)
|
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
42 |
{
|
|
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
43 |
val here = Scala_Project.here |
| 73440 | 44 |
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
|
45 |
} |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
46 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
47 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
48 |
/* run system */ |
|
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 |
def run_system(url: URL, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
51 |
system: String, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
52 |
problem: String, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
53 |
extra: String = "", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
54 |
quiet: String = "01", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
55 |
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
|
56 |
{
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
57 |
val paramaters = |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
58 |
List( |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
59 |
"SubmitButton" -> "RunSelectedSystems", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
60 |
"ProblemSource" -> "FORMULAE", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
61 |
"FORMULAEProblem" -> problem, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
62 |
"ForceSystem" -> "-force", |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
63 |
"System___" + system -> system, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
64 |
"TimeLimit___" + system -> timeout.seconds.ceil.toLong, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
65 |
"Command___" + system -> extra, |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
66 |
"QuietFlag" -> ("-q" + quiet))
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
67 |
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
|
68 |
} |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
69 |
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
70 |
object Run_System extends Scala.Fun("SystemOnTPTP.run_system", thread = true)
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
71 |
{
|
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
72 |
val here = Scala_Project.here |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
73 |
def apply(arg: String): String = |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
74 |
{
|
|
73434
00b77365552e
clarified signature: refer to file name instead of file content;
wenzelm
parents:
73431
diff
changeset
|
75 |
val List(url, system, problem_path, extra, Value.Int(timeout)) = Library.split_strings0(arg) |
|
00b77365552e
clarified signature: refer to file name instead of file content;
wenzelm
parents:
73431
diff
changeset
|
76 |
val problem = File.read(Path.explode(problem_path)) |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
77 |
val res = run_system(Url(url), system, problem, extra = extra, timeout = Time.ms(timeout)) |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
78 |
|
| 73440 | 79 |
val text = res.text |
80 |
val timing = res.elapsed_time.ms |
|
81 |
||
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
82 |
val bad_prover = "WARNING: " + system + " does not exist" |
| 73440 | 83 |
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
|
84 |
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
|
85 |
} |
| 73440 | 86 |
else Library.cat_strings0(List(text, timing.toString)) |
|
73431
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
87 |
} |
|
f27d7b12e8a4
support for SystemOnTPTP.run_system, with strict error following scripts/remote_atp;
wenzelm
parents:
73430
diff
changeset
|
88 |
} |
|
73418
7d7d959547a1
support for SystemOnTPTP in Isabelle/ML and Isabelle/Scala (without perl);
wenzelm
parents:
diff
changeset
|
89 |
} |