Skip to content

Commit 71f1ac8

Browse files
committed
PSOATransRun update
1 parent 5b314b8 commit 71f1ac8

32 files changed

+3341
-622
lines changed

PSOATransRun/test/README.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
The directory stores a test suite used for the automated testing of
2+
PSOA implementations, e.g. by our Java-based PSOATransRun
3+
@@@testing program@@@. Each test case is stored under one
4+
subdirectory, which we will call <testCaseName>. Under this
5+
subdirectory, there exists one main KB file <testCaseName>-KB.psoa,
6+
zero or more imported KB files, e.g. written as
7+
<testCaseName>-KB-importedI.psoa, I=1,2,... (the @@@testing
8+
program@@@ will ignore all files whose names contain anything
9+
between "KB" and ".psoa"), one or more query file
10+
<testCaseName>-queryJ.psoa, J=1,2,..., and one answer file
11+
<testCaseName>-answerJ.psoa for each query
12+
<testCaseName>-queryJ.psoa.
13+
14+
The following command is used to manually execute
15+
<testCaseName>-queryJ.psoa on <testCaseName>-KB.psoa
16+
(the answers will go to the standard output):
17+
java -jar PSOATransRunLocal.jar -i <testCaseName>-KB.psoa -q <testCaseName>-queryJ.psoa
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
tree grammar BodyExistentialRewriter;
2+
3+
options
4+
{
5+
output = AST;
6+
ASTLabelType = CommonTree;
7+
tokenVocab = PSOAPS;
8+
rewrite = true;
9+
k = 1;
10+
}
11+
12+
@header
13+
{
14+
package org.ruleml.psoa.normalizer;
15+
}
16+
17+
@members
18+
{
19+
private boolean _isQuery = false;
20+
}
21+
22+
document
23+
: ^(DOCUMENT base? prefix* importDecl* group?)
24+
;
25+
26+
base
27+
: ^(BASE IRI_REF)
28+
;
29+
30+
prefix
31+
: ^(PREFIX ID IRI_REF)
32+
;
33+
34+
importDecl
35+
: ^(IMPORT IRI_REF IRI_REF?)
36+
;
37+
38+
group
39+
: ^(GROUP group_element*)
40+
;
41+
42+
group_element
43+
: rule
44+
| group
45+
;
46+
47+
query
48+
: { _isQuery = true; } formula { _isQuery = false; }
49+
;
50+
51+
rule
52+
scope
53+
{
54+
CommonTree existVarsTree;
55+
}
56+
@init
57+
{
58+
$rule::existVarsTree = (CommonTree)adaptor.nil();
59+
}
60+
: ^(FORALL VAR_ID+ clause)
61+
-> ^(FORALL VAR_ID+ { $rule::existVarsTree } clause)
62+
| clause
63+
;
64+
65+
clause
66+
: ^(IMPLICATION head formula)
67+
| head
68+
;
69+
70+
head
71+
: atomic
72+
| ^(AND head+)
73+
| ^(EXISTS VAR_ID+ head)
74+
;
75+
76+
formula
77+
: ^(AND formula+)
78+
| ^(OR formula+)
79+
| FALSITY
80+
| ^(EXISTS
81+
(VAR_ID
82+
{
83+
if (!_isQuery)
84+
adaptor.addChild($rule::existVarsTree, $VAR_ID.tree);
85+
}
86+
)+
87+
formula)
88+
-> { _isQuery }? ^(EXISTS VAR_ID+ formula)
89+
-> formula
90+
| atomic
91+
| external
92+
;
93+
94+
atomic
95+
: atom
96+
| equal
97+
| subclass
98+
;
99+
100+
atom
101+
: psoa
102+
;
103+
104+
equal
105+
: ^(EQUAL term term)
106+
;
107+
108+
subclass
109+
: ^(SUBCLASS term term)
110+
;
111+
112+
term
113+
: constant
114+
| VAR_ID
115+
| psoa
116+
| external
117+
;
118+
119+
external
120+
: ^(EXTERNAL psoa)
121+
;
122+
123+
psoa
124+
: ^(PSOA term? ^(INSTANCE term) tuple* slot*)
125+
;
126+
127+
tuple
128+
: ^(TUPLE term+)
129+
;
130+
131+
slot
132+
: ^(SLOT term term)
133+
;
134+
135+
constant
136+
: ^(LITERAL IRI)
137+
| ^(SHORTCONST constshort)
138+
| TOP
139+
;
140+
141+
constshort
142+
: IRI
143+
| LITERAL
144+
| NUMBER
145+
| LOCAL
146+
;
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
tree grammar Concatenater;
2+
3+
options
4+
{
5+
output = AST;
6+
ASTLabelType = CommonTree;
7+
tokenVocab = PSOAPS;
8+
rewrite = false;
9+
k = 1;
10+
}
11+
12+
@header
13+
{
14+
package org.ruleml.psoa;
15+
}
16+
17+
@members
18+
{
19+
}
20+
21+
documents :
22+
scope
23+
{
24+
CommonTree docTree;
25+
}
26+
@init
27+
{
28+
$documents::docTree = (CommonTree)adaptor.create(DOCUMENT, "DOCUMENT");
29+
}
30+
document+ -> ^({ $documents::docTree } ^(GROUP document+))
31+
32+
document
33+
: ^(DOCUMENT base?
34+
(prefix { adaptor.addChild($documents::docTree, $prefix.tree); })*
35+
importDecl* group?)
36+
-> group
37+
;
38+
39+
base
40+
: ^(BASE IRI_REF)
41+
;
42+
43+
prefix
44+
: ^(PREFIX ID IRI_REF)
45+
;
46+
47+
importDecl
48+
: ^(IMPORT IRI_REF IRI_REF?)
49+
;
50+
51+
group
52+
: ^(GROUP group_element*) -> group_element*
53+
;
54+
55+
group_element
56+
: rule
57+
| group
58+
;
59+
60+
rule
61+
: ^(FORALL VAR_ID+ clause)
62+
| clause -> clause
63+
;
64+
65+
clause
66+
: ^(IMPLICATION head formula)
67+
| head
68+
;
69+
70+
head
71+
: atomic
72+
| ^(AND head+)
73+
| ^(EXISTS VAR_ID+ head)
74+
;
75+
76+
formula
77+
: ^(AND formula+)
78+
| ^(OR formula+)
79+
| ^(EXISTS VAR_ID+ formula)
80+
| FALSITY
81+
| atomic
82+
| external
83+
;
84+
85+
atomic
86+
: atom
87+
| equal
88+
| subclass
89+
;
90+
91+
atom
92+
: psoa
93+
;
94+
95+
equal
96+
: ^(EQUAL term term)
97+
;
98+
99+
subclass
100+
: ^(SUBCLASS term term)
101+
;
102+
103+
term
104+
: constant
105+
| VAR_ID
106+
| psoa
107+
| external
108+
;
109+
110+
external
111+
: ^(EXTERNAL psoa)
112+
;
113+
114+
psoa
115+
: ^(PSOA term? ^(INSTANCE term) tuple* slot*)
116+
;
117+
118+
tuple
119+
: ^(TUPLE term+)
120+
;
121+
122+
slot
123+
: ^(SLOT term term)
124+
;
125+
126+
constant
127+
: ^(LITERAL IRI)
128+
| ^(SHORTCONST constshort)
129+
| TOP
130+
;
131+
132+
constshort
133+
: IRI
134+
| LITERAL
135+
| NUMBER
136+
| LOCAL
137+
;

0 commit comments

Comments
 (0)