|
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
|
|
|
5 |
environment variable TPTP_PROBLEMS_PATH, which should point to the
|
|
|
6 |
TPTP-vX.Y.Z/Problems directory.
|
|
|
7 |
*)
|
|
|
8 |
|
|
|
9 |
theory TPTP_Parser_Test
|
|
47518
|
10 |
imports TPTP_Test TPTP_Parser_Example
|
|
46844
|
11 |
begin
|
|
|
12 |
|
|
47528
|
13 |
section "Problem-name parsing tests"
|
|
|
14 |
ML {*
|
|
|
15 |
local
|
|
|
16 |
open TPTP_Syntax;
|
|
|
17 |
open TPTP_Problem_Name;
|
|
|
18 |
|
|
|
19 |
val name_tests =
|
|
|
20 |
[("HWV041_4.p",
|
|
|
21 |
Standard {suffix = Problem ((4, NONE), "p"), prob_form = TFF, prob_domain = "HWV", prob_number = 41}),
|
|
|
22 |
("LCL617^1.p",
|
|
|
23 |
Standard {suffix = Problem ((1, NONE), "p"), prob_form = THF, prob_domain = "LCL", prob_number = 617}),
|
|
|
24 |
("LCL831-1.p",
|
|
|
25 |
Standard {suffix = Problem ((1, NONE), "p"), prob_form = CNF, prob_domain = "LCL", prob_number = 831}),
|
|
|
26 |
("HWV045=1.p",
|
|
|
27 |
Standard {suffix = Problem ((1, NONE), "p"), prob_form = TFF_with_arithmetic, prob_domain = "HWV", prob_number = 45}),
|
|
|
28 |
("LCL655+1.010.p",
|
|
|
29 |
Standard {suffix = Problem ((1, SOME 10), "p"), prob_form = FOF, prob_domain = "LCL", prob_number = 655}),
|
|
|
30 |
("OTH123.p",
|
|
|
31 |
Nonstandard "OTH123.p"),
|
|
|
32 |
("other",
|
|
|
33 |
Nonstandard "other"),
|
|
|
34 |
("AAA000£0.axiom",
|
|
|
35 |
Nonstandard "AAA000£0.axiom"),
|
|
|
36 |
("AAA000£0.p",
|
|
|
37 |
Nonstandard "AAA000£0.p"),
|
|
|
38 |
("AAA000.0.p",
|
|
|
39 |
Nonstandard "AAA000.0.p"),
|
|
|
40 |
("AAA000£0.what",
|
|
|
41 |
Nonstandard "AAA000£0.what"),
|
|
|
42 |
("",
|
|
|
43 |
Nonstandard "")];
|
|
|
44 |
in
|
|
|
45 |
val _ = map (fn (str, res) =>
|
|
|
46 |
@{assert}(TPTP_Problem_Name.parse_problem_name str = res)) name_tests
|
|
|
47 |
end
|
|
|
48 |
*}
|
|
|
49 |
|
|
|
50 |
|
|
46844
|
51 |
section "Parser tests"
|
|
|
52 |
|
|
|
53 |
ML {*
|
|
|
54 |
TPTP_Parser.parse_expression "" "fof(dt_k4_waybel34, axiom, ~ v3).";
|
|
|
55 |
TPTP_Parser.parse_expression "" "thf(dt_k4_waybel34, axiom, ~ ($true | $false)).";
|
|
|
56 |
TPTP_Parser.parse_expression ""
|
|
|
57 |
"thf(dt_k4_waybel34, axiom, ~ (! [X : $o, Y : ($o > $o)] : ( (X | (Y = Y))))).";
|
|
|
58 |
TPTP_Parser.parse_expression "" "tff(dt_k4_waybel34, axiom, ~ ($true)).";
|
|
|
59 |
payloads_of it;
|
|
|
60 |
*}
|
|
|
61 |
ML {*
|
|
|
62 |
TPTP_Parser.parse_expression "" "thf(bla, type, x : $o).";
|
|
|
63 |
TPTP_Parser.parse_expression ""
|
|
|
64 |
"fof(dt_k4_waybel34, axiom, ~ v3_struct_0(k4_waybel34(A))).";
|
|
|
65 |
TPTP_Parser.parse_expression ""
|
|
|
66 |
"fof(dt_k4_waybel34, axiom, (! [A] : (v1_xboole_0(A) => ( ~ v3_struct_0(k4_waybel34(A)))))).";
|
|
|
67 |
*}
|
|
|
68 |
ML {*
|
|
|
69 |
TPTP_Parser.parse_expression ""
|
|
|
70 |
("fof(dt_k4_waybel34,axiom,(" ^
|
|
|
71 |
"! [A] :" ^
|
|
|
72 |
"( ~ v1_xboole_0(A)" ^
|
|
|
73 |
"=> ( ~ v3_struct_0(k4_waybel34(A))" ^
|
|
|
74 |
"& v2_altcat_1(k4_waybel34(A))" ^
|
|
|
75 |
"& v6_altcat_1(k4_waybel34(A))" ^
|
|
|
76 |
"& v11_altcat_1(k4_waybel34(A))" ^
|
|
|
77 |
"& v12_altcat_1(k4_waybel34(A))" ^
|
|
|
78 |
"& v2_yellow21(k4_waybel34(A))" ^
|
|
|
79 |
"& l2_altcat_1(k4_waybel34(A)) ) ) )).")
|
|
|
80 |
*}
|
|
|
81 |
|
|
|
82 |
ML {*
|
|
|
83 |
open TPTP_Syntax;
|
|
|
84 |
@{assert}
|
|
|
85 |
((TPTP_Parser.parse_expression ""
|
|
|
86 |
"thf(x,axiom,^ [X] : ^ [Y] : f @ g)."
|
|
|
87 |
|> payloads_of |> hd)
|
|
|
88 |
=
|
|
|
89 |
Fmla (Interpreted_ExtraLogic Apply,
|
|
|
90 |
[Quant (Lambda, [("X", NONE)],
|
|
|
91 |
Quant (Lambda, [("Y", NONE)],
|
|
|
92 |
Atom (THF_Atom_term (Term_Func (Uninterpreted "f", []))))),
|
|
|
93 |
Atom (THF_Atom_term (Term_Func (Uninterpreted "g", [])))])
|
|
|
94 |
)
|
|
|
95 |
*}
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
text "Parse a specific problem."
|
|
|
99 |
ML {*
|
|
|
100 |
map TPTP_Parser.parse_file
|
|
|
101 |
["$TPTP_PROBLEMS_PATH/FLD/FLD051-1.p",
|
|
|
102 |
"$TPTP_PROBLEMS_PATH/FLD/FLD005-3.p",
|
|
|
103 |
"$TPTP_PROBLEMS_PATH/SWV/SWV567-1.015.p",
|
|
|
104 |
"$TPTP_PROBLEMS_PATH/SWV/SWV546-1.010.p"]
|
|
|
105 |
*}
|
|
|
106 |
ML {*
|
|
|
107 |
parser_test @{context} (situate "DAT/DAT001=1.p");
|
|
|
108 |
parser_test @{context} (situate "ALG/ALG001^5.p");
|
|
|
109 |
parser_test @{context} (situate "NUM/NUM021^1.p");
|
|
|
110 |
parser_test @{context} (situate "SYN/SYN000^1.p")
|
|
|
111 |
*}
|
|
|
112 |
|
|
|
113 |
text "Run the parser over all problems."
|
|
|
114 |
ML {*
|
|
47518
|
115 |
if test_all @{context} then
|
|
|
116 |
(report @{context} "Testing parser";
|
|
|
117 |
S timed_test parser_test @{context})
|
|
|
118 |
else ()
|
|
46844
|
119 |
*}
|
|
|
120 |
|
|
|
121 |
end |