author | haftmann |
Tue, 21 Apr 2020 07:28:17 +0000 | |
changeset 71788 | ca3ac5238c41 |
parent 69366 | b6dacf6eabe3 |
permissions | -rw-r--r-- |
46844 | 1 |
(* Title: HOL/TPTP/TPTP_Parser_Test.thy |
2 |
Author: Nik Sultana, Cambridge University Computer Laboratory |
|
3 |
||
4 |
Some tests for the TPTP interface. Some of the tests rely on the Isabelle |
|
47558
55b42f9af99d
phase out "$TPTP_PROBLEMS_PATH"; prefer "$TPTP" for consistency with CASC setup
blanchet
parents:
47528
diff
changeset
|
5 |
environment variable $TPTP, which should point to the TPTP-vX.Y.Z directory. |
46844 | 6 |
*) |
7 |
||
8 |
theory TPTP_Parser_Test |
|
47518 | 9 |
imports TPTP_Test TPTP_Parser_Example |
46844 | 10 |
begin |
11 |
||
47528 | 12 |
section "Problem-name parsing tests" |
63167 | 13 |
ML \<open> |
47528 | 14 |
local |
15 |
open TPTP_Syntax; |
|
16 |
open TPTP_Problem_Name; |
|
17 |
||
18 |
val name_tests = |
|
19 |
[("HWV041_4.p", |
|
20 |
Standard {suffix = Problem ((4, NONE), "p"), prob_form = TFF, prob_domain = "HWV", prob_number = 41}), |
|
21 |
("LCL617^1.p", |
|
22 |
Standard {suffix = Problem ((1, NONE), "p"), prob_form = THF, prob_domain = "LCL", prob_number = 617}), |
|
23 |
("LCL831-1.p", |
|
24 |
Standard {suffix = Problem ((1, NONE), "p"), prob_form = CNF, prob_domain = "LCL", prob_number = 831}), |
|
25 |
("HWV045=1.p", |
|
26 |
Standard {suffix = Problem ((1, NONE), "p"), prob_form = TFF_with_arithmetic, prob_domain = "HWV", prob_number = 45}), |
|
27 |
("LCL655+1.010.p", |
|
28 |
Standard {suffix = Problem ((1, SOME 10), "p"), prob_form = FOF, prob_domain = "LCL", prob_number = 655}), |
|
29 |
("OTH123.p", |
|
30 |
Nonstandard "OTH123.p"), |
|
31 |
("other", |
|
32 |
Nonstandard "other"), |
|
68672 | 33 |
("AAA000\194\1630.axiom", |
34 |
Nonstandard "AAA000\194\1630.axiom"), |
|
35 |
("AAA000\194\1630.p", |
|
36 |
Nonstandard "AAA000\194\1630.p"), |
|
47528 | 37 |
("AAA000.0.p", |
38 |
Nonstandard "AAA000.0.p"), |
|
68672 | 39 |
("AAA000\194\1630.what", |
40 |
Nonstandard "AAA000\194\1630.what"), |
|
47528 | 41 |
("", |
42 |
Nonstandard "")]; |
|
43 |
in |
|
44 |
val _ = map (fn (str, res) => |
|
45 |
@{assert}(TPTP_Problem_Name.parse_problem_name str = res)) name_tests |
|
46 |
end |
|
47687 | 47 |
|
48 |
(*test against all TPTP problems*) |
|
49 |
fun problem_names () = |
|
69366 | 50 |
map (Path.file_name #> |
47687 | 51 |
TPTP_Problem_Name.parse_problem_name #> |
52 |
TPTP_Problem_Name.mangle_problem_name) |
|
55595
2e2e9bc7c4c6
made list of test files a parameter to timed_test in TPTP_Test.thy, and updated dependent definitions;
sultana
parents:
47687
diff
changeset
|
53 |
(TPTP_Syntax.get_file_list tptp_probs_dir) |
63167 | 54 |
\<close> |
47528 | 55 |
|
56 |
||
46844 | 57 |
section "Parser tests" |
58 |
||
63167 | 59 |
ML \<open> |
46844 | 60 |
TPTP_Parser.parse_expression "" "fof(dt_k4_waybel34, axiom, ~ v3)."; |
61 |
TPTP_Parser.parse_expression "" "thf(dt_k4_waybel34, axiom, ~ ($true | $false))."; |
|
62 |
TPTP_Parser.parse_expression "" |
|
63 |
"thf(dt_k4_waybel34, axiom, ~ (! [X : $o, Y : ($o > $o)] : ( (X | (Y = Y)))))."; |
|
64 |
TPTP_Parser.parse_expression "" "tff(dt_k4_waybel34, axiom, ~ ($true))."; |
|
65 |
payloads_of it; |
|
63167 | 66 |
\<close> |
67 |
ML \<open> |
|
46844 | 68 |
TPTP_Parser.parse_expression "" "thf(bla, type, x : $o)."; |
69 |
TPTP_Parser.parse_expression "" |
|
70 |
"fof(dt_k4_waybel34, axiom, ~ v3_struct_0(k4_waybel34(A)))."; |
|
71 |
TPTP_Parser.parse_expression "" |
|
72 |
"fof(dt_k4_waybel34, axiom, (! [A] : (v1_xboole_0(A) => ( ~ v3_struct_0(k4_waybel34(A))))))."; |
|
63167 | 73 |
\<close> |
74 |
ML \<open> |
|
46844 | 75 |
TPTP_Parser.parse_expression "" |
76 |
("fof(dt_k4_waybel34,axiom,(" ^ |
|
77 |
"! [A] :" ^ |
|
78 |
"( ~ v1_xboole_0(A)" ^ |
|
79 |
"=> ( ~ v3_struct_0(k4_waybel34(A))" ^ |
|
80 |
"& v2_altcat_1(k4_waybel34(A))" ^ |
|
81 |
"& v6_altcat_1(k4_waybel34(A))" ^ |
|
82 |
"& v11_altcat_1(k4_waybel34(A))" ^ |
|
83 |
"& v12_altcat_1(k4_waybel34(A))" ^ |
|
84 |
"& v2_yellow21(k4_waybel34(A))" ^ |
|
85 |
"& l2_altcat_1(k4_waybel34(A)) ) ) )).") |
|
63167 | 86 |
\<close> |
46844 | 87 |
|
63167 | 88 |
ML \<open> |
46844 | 89 |
open TPTP_Syntax; |
90 |
@{assert} |
|
91 |
((TPTP_Parser.parse_expression "" |
|
92 |
"thf(x,axiom,^ [X] : ^ [Y] : f @ g)." |
|
93 |
|> payloads_of |> hd) |
|
94 |
= |
|
95 |
Fmla (Interpreted_ExtraLogic Apply, |
|
96 |
[Quant (Lambda, [("X", NONE)], |
|
97 |
Quant (Lambda, [("Y", NONE)], |
|
98 |
Atom (THF_Atom_term (Term_Func (Uninterpreted "f", []))))), |
|
99 |
Atom (THF_Atom_term (Term_Func (Uninterpreted "g", [])))]) |
|
100 |
) |
|
63167 | 101 |
\<close> |
46844 | 102 |
|
103 |
||
104 |
text "Parse a specific problem." |
|
63167 | 105 |
ML \<open> |
46844 | 106 |
map TPTP_Parser.parse_file |
47558
55b42f9af99d
phase out "$TPTP_PROBLEMS_PATH"; prefer "$TPTP" for consistency with CASC setup
blanchet
parents:
47528
diff
changeset
|
107 |
["$TPTP/Problems/FLD/FLD051-1.p", |
55b42f9af99d
phase out "$TPTP_PROBLEMS_PATH"; prefer "$TPTP" for consistency with CASC setup
blanchet
parents:
47528
diff
changeset
|
108 |
"$TPTP/Problems/FLD/FLD005-3.p", |
55b42f9af99d
phase out "$TPTP_PROBLEMS_PATH"; prefer "$TPTP" for consistency with CASC setup
blanchet
parents:
47528
diff
changeset
|
109 |
"$TPTP/Problems/SWV/SWV567-1.015.p", |
55b42f9af99d
phase out "$TPTP_PROBLEMS_PATH"; prefer "$TPTP" for consistency with CASC setup
blanchet
parents:
47528
diff
changeset
|
110 |
"$TPTP/Problems/SWV/SWV546-1.010.p"] |
63167 | 111 |
\<close> |
112 |
ML \<open> |
|
46844 | 113 |
parser_test @{context} (situate "DAT/DAT001=1.p"); |
114 |
parser_test @{context} (situate "ALG/ALG001^5.p"); |
|
115 |
parser_test @{context} (situate "NUM/NUM021^1.p"); |
|
116 |
parser_test @{context} (situate "SYN/SYN000^1.p") |
|
63167 | 117 |
\<close> |
46844 | 118 |
|
119 |
text "Run the parser over all problems." |
|
63167 | 120 |
ML \<open> |
47518 | 121 |
if test_all @{context} then |
122 |
(report @{context} "Testing parser"; |
|
55595
2e2e9bc7c4c6
made list of test files a parameter to timed_test in TPTP_Test.thy, and updated dependent definitions;
sultana
parents:
47687
diff
changeset
|
123 |
S timed_test parser_test @{context} (TPTP_Syntax.get_file_list tptp_probs_dir)) |
47518 | 124 |
else () |
63167 | 125 |
\<close> |
46844 | 126 |
|
62390 | 127 |
end |