aboutsummaryrefslogtreecommitdiff
path: root/src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-05-19 19:06:04 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-05-19 19:06:04 +0100
commit7a68441a541b12b22587fb53072193e1130049ff (patch)
treee05f826da89e73a7f961c505359f4135cca646a8 /src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java
parent612729386b645b120f8397a007cd8421986af0ad (diff)
downloadACQuA-7a68441a541b12b22587fb53072193e1130049ff.tar.gz
ACQuA-7a68441a541b12b22587fb53072193e1130049ff.zip
Deleted unused classes.
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java')
-rw-r--r--src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java247
1 files changed, 123 insertions, 124 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java b/src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java
index 2143b03..d96c747 100644
--- a/src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java
+++ b/src/uk/ac/ox/cs/pagoda/tracking/TrackingRuleEncoderDisjVar1.java
@@ -17,95 +17,98 @@ import java.util.Set;
17 17
18public class TrackingRuleEncoderDisjVar1 extends TrackingRuleEncoderWithGap { 18public class TrackingRuleEncoderDisjVar1 extends TrackingRuleEncoderWithGap {
19 19
20 private Set<DLClause> disjunctiveRules = new HashSet<DLClause>();
21 private Variable X = Variable.create("X"), Y = Variable.create("Y");
22 private String bottomTrackingProgram = null;
23
20 public TrackingRuleEncoderDisjVar1(UpperDatalogProgram program, BasicQueryEngine store) { 24 public TrackingRuleEncoderDisjVar1(UpperDatalogProgram program, BasicQueryEngine store) {
21 super(program, store); 25 super(program, store);
22 } 26 }
23 27
24 private Set<DLClause> disjunctiveRules = new HashSet<DLClause>();
25
26 @Override 28 @Override
27 public boolean encodingRules() { 29 public boolean encodingRules() {
28 if (super.encodingRules()) { 30 if (super.encodingRules()) {
29 processDisjunctiveRules(); 31 processDisjunctiveRules();
30 return true; 32 return true;
31 } 33 }
32 return false; 34 return false;
33 } 35 }
34 36
35 @Override 37 @Override
36 protected void encodingRule(DLClause clause) { 38 protected void encodingRule(DLClause clause) {
37 if (currentQuery.isBottom()) { 39 if (currentQuery.isBottom()) {
38// super.encodingRule(clause); 40// super.encodingRule(clause);
39 encodingBottomQueryClause(clause); 41 encodingBottomQueryClause(clause);
40 return ; 42 return;
41 } 43 }
42 44
43 DLClause original = program.getCorrespondingClause(clause); 45 DLClause original = program.getCorrespondingClause(clause);
44 if (original.getHeadLength() <= 1) { 46 if (original.getHeadLength() <= 1) {
45 super.encodingRule(clause); 47 super.encodingRule(clause);
46 } 48 }
47 else { 49 else {
48 if (!DLClauseHelper.hasSubsetBodyAtoms(clause, original)) 50 if (!DLClauseHelper.hasSubsetBodyAtoms(clause, original))
49 super.encodingRule(clause); 51 super.encodingRule(clause);
50 addDisjunctiveRule(original); 52 addDisjunctiveRule(original);
51 } 53 }
52 54
53 } 55 }
54
55 56
56 private void processDisjunctiveRules() { 57 private void processDisjunctiveRules() {
57 for (DLClause clause: disjunctiveRules) 58 for (DLClause clause: disjunctiveRules)
58 encodingDisjunctiveRule(clause); 59 encodingDisjunctiveRule(clause);
59 } 60 }
60 61
61 private Atom getAuxiliaryAtom(Atom headAtom) { 62 private Atom getAuxiliaryAtom(Atom headAtom) {
62 DLPredicate p = headAtom.getDLPredicate(); 63 DLPredicate p = headAtom.getDLPredicate();
63 if (p instanceof AtLeast || p instanceof AtLeast) { 64 if (p instanceof AtLeast || p instanceof AtLeast) {
64 return Atom.create(generateAuxiliaryRule((AtLeast) p, true), headAtom.getArgument(0)); 65 return Atom.create(generateAuxiliaryRule((AtLeast) p, true), headAtom.getArgument(0));
65 } 66 }
66 if (p instanceof AtomicConcept) 67 if(p instanceof AtomicConcept)
67 return Atom.create(generateAuxiliaryRule((AtomicConcept) p), headAtom.getArgument(0)); 68 return Atom.create(generateAuxiliaryRule((AtomicConcept) p), headAtom.getArgument(0));
68 if (p instanceof AtomicRole) 69 if(p instanceof AtomicRole)
69 return Atom.create(generateAuxiliaryRule((AtomicRole) p), headAtom.getArgument(0), headAtom.getArgument(1)); 70 return Atom.create(generateAuxiliaryRule((AtomicRole) p), headAtom.getArgument(0), headAtom.getArgument(1));
70 if (p instanceof Equality || p instanceof AnnotatedEquality) 71 if(p instanceof Equality || p instanceof AnnotatedEquality)
71 return Atom.create(generateAuxiliaryRule(Equality.INSTANCE), headAtom.getArgument(0), headAtom.getArgument(1)); 72 return Atom.create(generateAuxiliaryRule(Equality.INSTANCE), headAtom.getArgument(0), headAtom.getArgument(1));
72 if (p instanceof Inequality) 73 if(p instanceof Inequality)
73 return Atom.create(generateAuxiliaryRule((Inequality) p), headAtom.getArgument(0), headAtom.getArgument(1)); 74 return Atom.create(generateAuxiliaryRule((Inequality) p), headAtom.getArgument(0), headAtom.getArgument(1));
74 75
75 return null; 76 return null;
76 } 77 }
77 78
78 private Atom getTrackingAtom(Atom headAtom) { 79 private Atom getTrackingAtom(Atom headAtom) {
79 DLPredicate p = headAtom.getDLPredicate(); 80 DLPredicate p = headAtom.getDLPredicate();
80 if (p instanceof AtLeast) { 81 if (p instanceof AtLeast) {
81 p = Normalisation.toAtLeastConcept((AtLeast) p); 82 p = Normalisation.toAtLeastConcept((AtLeast) p);
82 return Atom.create(getTrackingDLPredicate(AtomicConcept.create(Normalisation.getAuxiliaryConcept4Disjunct((AtLeastConcept) p))), headAtom.getArgument(0)); 83 return Atom.create(getTrackingDLPredicate(AtomicConcept.create(Normalisation.getAuxiliaryConcept4Disjunct((AtLeastConcept) p))), headAtom
84 .getArgument(0));
83 } 85 }
84 if (p instanceof AtomicConcept) 86 if(p instanceof AtomicConcept)
85 return Atom.create(getTrackingDLPredicate(p), headAtom.getArgument(0)); 87 return Atom.create(getTrackingDLPredicate(p), headAtom.getArgument(0));
86 if (p instanceof AtomicRole) 88 if(p instanceof AtomicRole)
87 return Atom.create(getTrackingDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1)); 89 return Atom.create(getTrackingDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1));
88 if (p instanceof Equality || p instanceof AnnotatedEquality) 90 if(p instanceof Equality || p instanceof AnnotatedEquality)
89 return Atom.create(getTrackingDLPredicate(Equality.INSTANCE), headAtom.getArgument(0), headAtom.getArgument(1)); 91 return Atom.create(getTrackingDLPredicate(Equality.INSTANCE), headAtom.getArgument(0), headAtom.getArgument(1));
90 if (p instanceof Inequality) 92 if(p instanceof Inequality)
91 return Atom.create(getTrackingDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1)); 93 return Atom.create(getTrackingDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1));
92 94
93 return null; 95 return null;
94 } 96 }
95 97
96 private Atom getGapAtom(Atom headAtom) { 98 private Atom getGapAtom(Atom headAtom) {
97 DLPredicate p = headAtom.getDLPredicate(); 99 DLPredicate p = headAtom.getDLPredicate();
98 if (p instanceof AtLeast) { 100 if (p instanceof AtLeast) {
99 p = Normalisation.toAtLeastConcept((AtLeast) p); 101 p = Normalisation.toAtLeastConcept((AtLeast) p);
100 return Atom.create(getGapDLPredicate(AtomicConcept.create(Normalisation.getAuxiliaryConcept4Disjunct((AtLeastConcept) p))), headAtom.getArgument(0)); 102 return Atom.create(getGapDLPredicate(AtomicConcept.create(Normalisation.getAuxiliaryConcept4Disjunct((AtLeastConcept) p))), headAtom
103 .getArgument(0));
101 } 104 }
102 if (p instanceof AtomicConcept) 105 if(p instanceof AtomicConcept)
103 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0)); 106 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0));
104 if (p instanceof AtomicRole) 107 if(p instanceof AtomicRole)
105 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1)); 108 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1));
106 if (p instanceof Equality || p instanceof AnnotatedEquality) 109 if(p instanceof Equality || p instanceof AnnotatedEquality)
107 return Atom.create(getGapDLPredicate(Equality.INSTANCE), headAtom.getArgument(0), headAtom.getArgument(1)); 110 return Atom.create(getGapDLPredicate(Equality.INSTANCE), headAtom.getArgument(0), headAtom.getArgument(1));
108 if (p instanceof Inequality) 111 if(p instanceof Inequality)
109 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1)); 112 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0), headAtom.getArgument(1));
110 if (p instanceof DatatypeRestriction) 113 if (p instanceof DatatypeRestriction)
111 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0)); 114 return Atom.create(getGapDLPredicate(p), headAtom.getArgument(0));
@@ -115,71 +118,71 @@ public class TrackingRuleEncoderDisjVar1 extends TrackingRuleEncoderWithGap {
115 118
116 private void encodingDisjunctiveRule(DLClause clause) { 119 private void encodingDisjunctiveRule(DLClause clause) {
117 int headLength = clause.getHeadLength(); 120 int headLength = clause.getHeadLength();
118 121
119 Atom[] auxAtoms = new Atom[headLength]; 122 Atom[] auxAtoms = new Atom[headLength];
120 for (int i = 0; i < headLength; ++i) 123 for (int i = 0; i < headLength; ++i)
121 auxAtoms[i] = getAuxiliaryAtom(clause.getHeadAtom(i)); 124 auxAtoms[i] = getAuxiliaryAtom(clause.getHeadAtom(i));
122 125
123 Atom[] trackingAtoms = new Atom[headLength]; 126 Atom[] trackingAtoms = new Atom[headLength];
124 for (int i = 0; i < headLength; ++i) 127 for (int i = 0; i < headLength; ++i)
125 trackingAtoms[i] = getTrackingAtom(clause.getHeadAtom(i)); 128 trackingAtoms[i] = getTrackingAtom(clause.getHeadAtom(i));
126 129
127 Atom[] gapAtoms = new Atom[headLength]; 130 Atom[] gapAtoms = new Atom[headLength];
128 for (int i = 0; i < headLength; ++i) 131 for (int i = 0; i < headLength; ++i)
129 gapAtoms[i] = getGapAtom(clause.getHeadAtom(i)); 132 gapAtoms[i] = getGapAtom(clause.getHeadAtom(i));
130 133
131 Atom[] bodyAtoms = clause.getBodyAtoms(); 134 Atom[] bodyAtoms = clause.getBodyAtoms();
132 135
133 LinkedList<Atom> newHeadAtoms = new LinkedList<Atom>(); 136 LinkedList<Atom> newHeadAtoms = new LinkedList<Atom>();
134 DLPredicate selected = AtomicConcept.create(getSelectedPredicate()); 137 DLPredicate selected = AtomicConcept.create(getSelectedPredicate());
135 newHeadAtoms.add(Atom.create(selected, getIndividual4GeneralRule(clause))); 138 newHeadAtoms.add(Atom.create(selected, getIndividual4GeneralRule(clause)));
136 139
137 for (Atom atom: bodyAtoms) { 140 for (Atom atom: bodyAtoms) {
138 Atom newAtom = Atom.create( 141 Atom newAtom = Atom.create(
139 getTrackingDLPredicate(atom.getDLPredicate()), 142 getTrackingDLPredicate(atom.getDLPredicate()),
140 DLClauseHelper.getArguments(atom)); 143 DLClauseHelper.getArguments(atom));
141 newHeadAtoms.add(newAtom); 144 newHeadAtoms.add(newAtom);
142 } 145 }
143 146
144 DLClause newClause; 147 DLClause newClause;
145 int index; 148 int index;
146 for (int j = 0; j < headLength; ++j) { 149 for (int j = 0; j < headLength; ++j) {
147 Atom[] newBodyAtoms = new Atom[headLength * 2 + bodyAtoms.length]; 150 Atom[] newBodyAtoms = new Atom[headLength * 2 + bodyAtoms.length];
148 index = 0; 151 index = 0;
149 for (int i = 0; i < headLength; ++i, ++index) 152 for (int i = 0; i < headLength; ++i, ++index)
150 newBodyAtoms[index] = gapAtoms[i]; 153 newBodyAtoms[index] = gapAtoms[i];
151 for (int i = 0; i < headLength; ++i, ++index) 154 for (int i = 0; i < headLength; ++i, ++index)
152 if (i != j) 155 if (i != j)
153 newBodyAtoms[index] = auxAtoms[i]; 156 newBodyAtoms[index] = auxAtoms[i];
154 else 157 else
155 newBodyAtoms[index] = trackingAtoms[i]; 158 newBodyAtoms[index] = trackingAtoms[i];
156 159
157 for (int i = 0; i < bodyAtoms.length; ++i, ++index) 160 for (int i = 0; i < bodyAtoms.length; ++i, ++index)
158 newBodyAtoms[index] = bodyAtoms[i]; 161 newBodyAtoms[index] = bodyAtoms[i];
159 162
160 for (Atom atom: newHeadAtoms) { 163 for (Atom atom: newHeadAtoms) {
161 newClause = DLClause.create(new Atom[] {atom}, newBodyAtoms); 164 newClause = DLClause.create(new Atom[]{atom}, newBodyAtoms);
162 addTrackingClause(newClause); 165 addTrackingClause(newClause);
163 } 166 }
164 } 167 }
165 } 168 }
166 169
167 private void addTrackingClause(DLClause clause) { 170 private void addTrackingClause(DLClause clause) {
168 trackingClauses.add(clause); 171 trackingClauses.add(clause);
169 } 172 }
170 173
171 private void addDisjunctiveRule(DLClause clause) { 174 private void addDisjunctiveRule(DLClause clause) {
172 disjunctiveRules.add(clause); 175 disjunctiveRules.add(clause);
173 } 176 }
174 177
175 private DLPredicate getAuxPredicate(DLPredicate p) { 178 private DLPredicate getAuxPredicate(DLPredicate p) {
176 if (p instanceof AtLeastConcept) { 179 if (p instanceof AtLeastConcept) {
177 StringBuilder builder = new StringBuilder( 180 StringBuilder builder = new StringBuilder(
178 Normalisation.getAuxiliaryConcept4Disjunct((AtLeastConcept) p)); 181 Normalisation.getAuxiliaryConcept4Disjunct((AtLeastConcept) p));
179 builder.append("_AUXa").append(currentQuery.getQueryID()); 182 builder.append("_AUXa").append(currentQuery.getQueryID());
180 return AtomicConcept.create(builder.toString()); 183 return AtomicConcept.create(builder.toString());
181 } 184 }
182 185
183 return getDLPredicate(p, "_AUXa" + currentQuery.getQueryID()); 186 return getDLPredicate(p, "_AUXa" + currentQuery.getQueryID());
184 } 187 }
185 188
@@ -188,120 +191,118 @@ public class TrackingRuleEncoderDisjVar1 extends TrackingRuleEncoderWithGap {
188 } 191 }
189 192
190 private DLPredicate generateAuxiliaryRule(AtLeast p1, boolean withAux) { 193 private DLPredicate generateAuxiliaryRule(AtLeast p1, boolean withAux) {
191 AtLeastConcept p = Normalisation.toAtLeastConcept(p1); 194 AtLeastConcept p = Normalisation.toAtLeastConcept(p1);
192 195
193 int num = p.getNumber(); 196 int num = p.getNumber();
194 Variable[] Ys = new Variable[num]; 197 Variable[] Ys = new Variable[num];
195 if (num > 1) 198 if (num > 1)
196 for (int i = 0; i < num; ++i) 199 for(int i = 0; i < num; ++i)
197 Ys[i] = Variable.create("Y" + (i + 1)); 200 Ys[i] = Variable.create("Y" + (i + 1));
198 else 201 else
199 Ys[0] = Y; 202 Ys[0] = Y;
200 203
201 Collection<Atom> expandedAtom = new LinkedList<Atom>(); 204 Collection<Atom> expandedAtom = new LinkedList<Atom>();
202 Collection<Atom> representativeAtom = new LinkedList<Atom>(); 205 Collection<Atom> representativeAtom = new LinkedList<Atom>();
203 if (p.getOnRole() instanceof AtomicRole) { 206 if (p.getOnRole() instanceof AtomicRole) {
204 AtomicRole r = (AtomicRole) p.getOnRole(); 207 AtomicRole r = (AtomicRole) p.getOnRole();
205 for (int i = 0; i < num; ++i) 208 for(int i = 0; i < num; ++i)
206 expandedAtom.add(Atom.create(r, X, Ys[i])); 209 expandedAtom.add(Atom.create(r, X, Ys[i]));
207 representativeAtom.add(Atom.create(r, X, Ys[0])); 210 representativeAtom.add(Atom.create(r, X, Ys[0]));
208 } 211 }
209 else { 212 else {
210 AtomicRole r = ((InverseRole) p.getOnRole()).getInverseOf(); 213 AtomicRole r = ((InverseRole) p.getOnRole()).getInverseOf();
211 for (int i = 0; i < num; ++i) 214 for(int i = 0; i < num; ++i)
212 expandedAtom.add(Atom.create(r, Ys[i], X)); 215 expandedAtom.add(Atom.create(r, Ys[i], X));
213 representativeAtom.add(Atom.create(r, Ys[0], X)); 216 representativeAtom.add(Atom.create(r, Ys[0], X));
214 } 217 }
215 218
216 if (num > 1) { 219 if (num > 1) {
217 representativeAtom.add(Atom.create(Inequality.INSTANCE, Ys[0], Ys[1])); 220 representativeAtom.add(Atom.create(Inequality.INSTANCE, Ys[0], Ys[1]));
218 } 221 }
219 for (int i = 0; i < num; ++i) 222 for (int i = 0; i < num; ++i)
220 for (int j = i + 1; j < num; ++j) 223 for (int j = i + 1; j < num; ++j)
221 expandedAtom.add(Atom.create(Inequality.INSTANCE, Ys[i], Ys[j])); 224 expandedAtom.add(Atom.create(Inequality.INSTANCE, Ys[i], Ys[j]));
222 225
223 if (!p.getToConcept().equals(AtomicConcept.THING)) { 226 if (!p.getToConcept().equals(AtomicConcept.THING)) {
224 AtomicConcept c; 227 AtomicConcept c;
225 if (p.getToConcept() instanceof AtomicConcept) 228 if(p.getToConcept() instanceof AtomicConcept)
226 c = (AtomicConcept) p.getToConcept(); 229 c = (AtomicConcept) p.getToConcept();
227 else { 230 else {
228 c = OverApproxExist.getNegationConcept(((AtomicNegationConcept) p.getToConcept()).getNegatedAtomicConcept()); 231 c = OverApproxExist.getNegationConcept(((AtomicNegationConcept) p.getToConcept()).getNegatedAtomicConcept());
229 } 232 }
230 for (int i = 0; i < num; ++i) 233 for (int i = 0; i < num; ++i)
231 expandedAtom.add(Atom.create(c, Ys[i])); 234 expandedAtom.add(Atom.create(c, Ys[i]));
232 representativeAtom.add(Atom.create(c, Ys[0])); 235 representativeAtom.add(Atom.create(c, Ys[0]));
233 } 236 }
234 237
235 AtomicConcept ac = AtomicConcept.create(Normalisation.getAuxiliaryConcept4Disjunct(p)); 238 AtomicConcept ac = AtomicConcept.create(Normalisation.getAuxiliaryConcept4Disjunct(p));
236 DLPredicate trackingPredicate = getTrackingDLPredicate(ac); 239 DLPredicate trackingPredicate = getTrackingDLPredicate(ac);
237 DLPredicate gapPredicate = getGapDLPredicate(ac); 240 DLPredicate gapPredicate = getGapDLPredicate(ac);
238 DLPredicate auxPredicate = withAux ? getAuxPredicate(p) : null; 241 DLPredicate auxPredicate = withAux ? getAuxPredicate(p) : null;
239 242
240 for (Atom atom: representativeAtom) { 243 for (Atom atom: representativeAtom) {
241 Atom[] bodyAtoms = new Atom[expandedAtom.size() + 1]; 244 Atom[] bodyAtoms = new Atom[expandedAtom.size() + 1];
242 if (atom.getArity() == 1) 245 if (atom.getArity() == 1)
243 bodyAtoms[0] = Atom.create(getTrackingDLPredicate(atom.getDLPredicate()), atom.getArgument(0)); 246 bodyAtoms[0] = Atom.create(getTrackingDLPredicate(atom.getDLPredicate()), atom.getArgument(0));
244 else 247 else
245 bodyAtoms[0] = Atom.create(getTrackingDLPredicate(atom.getDLPredicate()), atom.getArgument(0), atom.getArgument(1)); 248 bodyAtoms[0] = Atom.create(getTrackingDLPredicate(atom.getDLPredicate()), atom.getArgument(0), atom.getArgument(1));
246 int i = 0; 249 int i = 0;
247 for (Atom bodyAtom: expandedAtom) 250 for (Atom bodyAtom: expandedAtom)
248 bodyAtoms[++i] = bodyAtom; 251 bodyAtoms[++i] = bodyAtom;
249 addTrackingClause(DLClause.create(new Atom[] {Atom.create(trackingPredicate, X)}, bodyAtoms)); 252 addTrackingClause(DLClause.create(new Atom[] {Atom.create(trackingPredicate, X)}, bodyAtoms));
250 253
251 bodyAtoms = new Atom[expandedAtom.size() + 1]; 254 bodyAtoms = new Atom[expandedAtom.size() + 1];
252 if (atom.getArity() == 1) 255 if (atom.getArity() == 1)
253 bodyAtoms[0] = Atom.create(getGapDLPredicate(atom.getDLPredicate()), atom.getArgument(0)); 256 bodyAtoms[0] = Atom.create(getGapDLPredicate(atom.getDLPredicate()), atom.getArgument(0));
254 else 257 else
255 bodyAtoms[0] = Atom.create(getGapDLPredicate(atom.getDLPredicate()), atom.getArgument(0), atom.getArgument(1)); 258 bodyAtoms[0] = Atom.create(getGapDLPredicate(atom.getDLPredicate()), atom.getArgument(0), atom.getArgument(1));
256 i = 0; 259 i = 0;
257 for (Atom bodyAtom: expandedAtom) 260 for (Atom bodyAtom: expandedAtom)
258 bodyAtoms[++i] = bodyAtom; 261 bodyAtoms[++i] = bodyAtom;
259 addTrackingClause(DLClause.create(new Atom[] {Atom.create(gapPredicate, X)}, bodyAtoms)); 262 addTrackingClause(DLClause.create(new Atom[] {Atom.create(gapPredicate, X)}, bodyAtoms));
260 263
261 if (withAux) { 264 if (withAux) {
262 bodyAtoms = new Atom[expandedAtom.size() + 1]; 265 bodyAtoms = new Atom[expandedAtom.size() + 1];
263 bodyAtoms[0] = getAuxiliaryAtom(atom); 266 bodyAtoms[0] = getAuxiliaryAtom(atom);
264 i = 0; 267 i = 0;
265 for (Atom bodyAtom: expandedAtom) 268 for (Atom bodyAtom: expandedAtom)
266 bodyAtoms[++i] = bodyAtom; 269 bodyAtoms[++i] = bodyAtom;
267 addTrackingClause(DLClause.create(new Atom[] {Atom.create(auxPredicate, X)}, bodyAtoms)); 270 addTrackingClause(DLClause.create(new Atom[] {Atom.create(auxPredicate, X)}, bodyAtoms));
268 } 271 }
269 } 272 }
270 273
271 return withAux ? auxPredicate : trackingPredicate; 274 return withAux ? auxPredicate : trackingPredicate;
272 } 275 }
273 276
274 private DLPredicate generateAuxiliaryRule(AtomicRole p) { 277 private DLPredicate generateAuxiliaryRule(AtomicRole p) {
275 if (currentQuery.isBottom()) 278 if(currentQuery.isBottom())
276 return getTrackingDLPredicate(p); 279 return getTrackingDLPredicate(p);
277 280
278 DLPredicate ret = getAuxPredicate(p); 281 DLPredicate ret = getAuxPredicate(p);
279 Atom[] headAtom = new Atom[] {Atom.create(ret, X, Y)}; 282 Atom[] headAtom = new Atom[] {Atom.create(ret, X, Y)};
280 283
281 addTrackingClause( 284 addTrackingClause(
282 DLClause.create(headAtom, new Atom[] {Atom.create(getTrackingDLPredicate(p), X, Y)})); 285 DLClause.create(headAtom, new Atom[]{Atom.create(getTrackingDLPredicate(p), X, Y)}));
283 addTrackingClause( 286 addTrackingClause(
284 DLClause.create(headAtom, new Atom[] {Atom.create(getTrackingBottomDLPredicate(p), X, Y)})); 287 DLClause.create(headAtom, new Atom[]{Atom.create(getTrackingBottomDLPredicate(p), X, Y)}));
285 288
286 return ret; 289 return ret;
287 } 290 }
288
289 private Variable X = Variable.create("X"), Y = Variable.create("Y");
290 291
291 private DLPredicate generateAuxiliaryRule(AtomicConcept p) { 292 private DLPredicate generateAuxiliaryRule(AtomicConcept p) {
292 if (currentQuery.isBottom()) 293 if (currentQuery.isBottom())
293 return getTrackingDLPredicate(p); 294 return getTrackingDLPredicate(p);
294 295
295 DLPredicate ret = getAuxPredicate(p); 296 DLPredicate ret = getAuxPredicate(p);
296 Atom[] headAtom = new Atom[] {Atom.create(ret, X)}; 297 Atom[] headAtom = new Atom[]{Atom.create(ret, X)};
297 addTrackingClause( 298 addTrackingClause(
298 DLClause.create(headAtom, 299 DLClause.create(headAtom,
299 new Atom[] { Atom.create(getTrackingDLPredicate(p), X)})); 300 new Atom[]{Atom.create(getTrackingDLPredicate(p), X)}));
300 addTrackingClause( 301 addTrackingClause(
301 DLClause.create(headAtom, 302 DLClause.create(headAtom,
302 new Atom[] { Atom.create(getTrackingBottomDLPredicate(p), X)})); 303 new Atom[] { Atom.create(getTrackingBottomDLPredicate(p), X)}));
303 304
304 return ret; 305 return ret;
305 } 306 }
306 307
307 private DLPredicate generateAuxiliaryRule(Equality instance) { 308 private DLPredicate generateAuxiliaryRule(Equality instance) {
@@ -309,20 +310,18 @@ public class TrackingRuleEncoderDisjVar1 extends TrackingRuleEncoderWithGap {
309 } 310 }
310 311
311 private DLPredicate generateAuxiliaryRule(Inequality instance) { 312 private DLPredicate generateAuxiliaryRule(Inequality instance) {
312 return generateAuxiliaryRule(AtomicRole.create(Namespace.INEQUALITY)); 313 return generateAuxiliaryRule(AtomicRole.create(Namespace.INEQUALITY));
313 } 314 }
314 315
315 @Override 316 @Override
316 public String getTrackingProgram() { 317 public String getTrackingProgram() {
317 StringBuilder sb = getTrackingProgramBody(); 318 StringBuilder sb = getTrackingProgramBody();
318 if (currentQuery.isBottom()) 319 if (currentQuery.isBottom())
319 sb.append(getBottomTrackingProgram()); 320 sb.append(getBottomTrackingProgram());
320 sb.insert(0, MyPrefixes.PAGOdAPrefixes.prefixesText()); 321 sb.insert(0, MyPrefixes.PAGOdAPrefixes.prefixesText());
321 return sb.toString(); 322 return sb.toString();
322 } 323 }
323 324
324 private String bottomTrackingProgram = null;
325
326 private String getBottomTrackingProgram() { 325 private String getBottomTrackingProgram() {
327 if (bottomTrackingProgram != null) return bottomTrackingProgram.replace("_tn", getTrackingPredicate("")); 326 if (bottomTrackingProgram != null) return bottomTrackingProgram.replace("_tn", getTrackingPredicate(""));
328 327
@@ -350,7 +349,7 @@ public class TrackingRuleEncoderDisjVar1 extends TrackingRuleEncoderWithGap {
350// for (Atom tAtom: clause.getHeadAtoms()) { 349// for (Atom tAtom: clause.getHeadAtoms()) {
351// for (int i = 0; i < tAtom.getArity(); ++i) 350// for (int i = 0; i < tAtom.getArity(); ++i)
352// if ((t = tAtom.getArgument(i)) instanceof Individual) 351// if ((t = tAtom.getArgument(i)) instanceof Individual)
353// if (((Individual) t).getIRI().startsWith(OverApproxExist.skolemisedIndividualPrefix)) 352// if (((Individual) t).getIRI().startsWith(OverApproxExist.SKOLEMISED_INDIVIDUAL_PREFIX))
354// clause = program.getCorrespondingClause(clause); 353// clause = program.getCorrespondingClause(clause);
355// } 354// }
356 355