aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRncLsn <rnc.lsn@gmail.com>2015-08-03 17:07:39 +0100
committerRncLsn <rnc.lsn@gmail.com>2015-08-03 17:07:39 +0100
commit0c39145b3b76b3db73db0a38d5324caa7ff3c434 (patch)
tree388c97e1460d4180e74b531e048a60fc62963c5a
parent02cf14060d3b9e722480e07ebfd32538bbb8e73b (diff)
downloadACQuA-0c39145b3b76b3db73db0a38d5324caa7ff3c434.tar.gz
ACQuA-0c39145b3b76b3db73db0a38d5324caa7ff3c434.zip
The LimitedSkolemisation now employs a fixed-depth term instead of a constant. Performed some testing before merging with master.
-rw-r--r--src/resources/pagoda.properties2
-rw-r--r--src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java1
-rw-r--r--src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java28
-rw-r--r--src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java28
-rw-r--r--test/resources/BugTests.xml2
-rw-r--r--test/resources/MainTests.xml4
-rw-r--r--test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java3
-rw-r--r--test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java2
8 files changed, 43 insertions, 27 deletions
diff --git a/src/resources/pagoda.properties b/src/resources/pagoda.properties
index 07a0eac..e6aa503 100644
--- a/src/resources/pagoda.properties
+++ b/src/resources/pagoda.properties
@@ -1,9 +1,9 @@
1debug=true 1debug=true
2useAlwaysSimpleUpperBound=false 2useAlwaysSimpleUpperBound=false
3skolemUpperBound=DISABLED 3skolemUpperBound=DISABLED
4skolemDepth=1
5#skolemUpperBound=BEFORE_SUMMARISATION 4#skolemUpperBound=BEFORE_SUMMARISATION
6#skolemUpperBound=AFTER_SUMMARISATION 5#skolemUpperBound=AFTER_SUMMARISATION
6skolemDepth=1
7toCallHermit=true 7toCallHermit=true
8 8
9statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file 9statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file
diff --git a/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java b/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java
index 320af09..0f215ad 100644
--- a/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java
+++ b/src/uk/ac/ox/cs/pagoda/endomorph/DependencyGraph.java
@@ -241,7 +241,6 @@ public class DependencyGraph {
241 ++homomorphismCheckCounter; 241 ++homomorphismCheckCounter;
242 homomorphismChecker.setMapping(u, v); 242 homomorphismChecker.setMapping(u, v);
243 243
244 // TODO recently added, test it
245 if(!homomorphismChecker.isMappingTo(u, v)) 244 if(!homomorphismChecker.isMappingTo(u, v))
246 return false; 245 return false;
247 246
diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java
index 2c8e23d..7d29c74 100644
--- a/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java
+++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/LimitedSkolemisationApproximator.java
@@ -2,7 +2,6 @@ package uk.ac.ox.cs.pagoda.rules.approximators;
2 2
3import org.semanticweb.HermiT.model.*; 3import org.semanticweb.HermiT.model.*;
4import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; 4import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram;
5import uk.ac.ox.cs.pagoda.rules.ExistConstantApproximator;
6import uk.ac.ox.cs.pagoda.util.tuples.Tuple; 5import uk.ac.ox.cs.pagoda.util.tuples.Tuple;
7import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder; 6import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder;
8 7
@@ -23,16 +22,10 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima
23 private static final Atom[] EMPTY_BODY = new Atom[0]; 22 private static final Atom[] EMPTY_BODY = new Atom[0];
24 private static final Variable X = Variable.create("X"); 23 private static final Variable X = Variable.create("X");
25 private final int maxTermDepth; 24 private final int maxTermDepth;
26 private final TupleDependentApproximator alternativeApproximator;
27 private final SkolemTermsManager skolemTermsManager; 25 private final SkolemTermsManager skolemTermsManager;
28 26
29 public LimitedSkolemisationApproximator(int maxTermDepth) { 27 public LimitedSkolemisationApproximator(int maxTermDepth) {
30 this(maxTermDepth, new ExistConstantApproximator());
31 }
32
33 public LimitedSkolemisationApproximator(int maxTermDepth, TupleDependentApproximator alternativeApproximator) {
34 this.maxTermDepth = maxTermDepth; 28 this.maxTermDepth = maxTermDepth;
35 this.alternativeApproximator = alternativeApproximator;
36 this.skolemTermsManager = SkolemTermsManager.getInstance(); 29 this.skolemTermsManager = SkolemTermsManager.getInstance();
37 } 30 }
38 31
@@ -64,10 +57,8 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima
64 private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) { 57 private Collection<DLClause> overApprox(DLClause clause, DLClause originalClause, Collection<Tuple<Individual>> violationTuples) {
65 ArrayList<DLClause> result = new ArrayList<>(); 58 ArrayList<DLClause> result = new ArrayList<>();
66 for(Tuple<Individual> violationTuple : violationTuples) { 59 for(Tuple<Individual> violationTuple : violationTuples) {
67 if(getMaxDepth(violationTuple) < maxTermDepth) 60 result.addAll(getGroundSkolemisation(clause,
68 result.addAll(getGroundSkolemisation(clause, originalClause, violationTuple)); 61 originalClause, violationTuple, getMaxDepth(violationTuple) >= maxTermDepth));
69 else
70 result.addAll(alternativeApproximator.convert(clause, originalClause, null));
71 } 62 }
72 63
73 return result; 64 return result;
@@ -75,7 +66,8 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima
75 66
76 private Collection<DLClause> getGroundSkolemisation(DLClause clause, 67 private Collection<DLClause> getGroundSkolemisation(DLClause clause,
77 DLClause originalClause, 68 DLClause originalClause,
78 Tuple<Individual> violationTuple) { 69 Tuple<Individual> violationTuple,
70 boolean useClauseUniqueIndividual) {
79 71
80 String[] commonVars = MultiStageUpperProgram.getCommonVars(clause); 72 String[] commonVars = MultiStageUpperProgram.getCommonVars(clause);
81 73
@@ -100,7 +92,6 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima
100 AtomicConcept atomicConcept; 92 AtomicConcept atomicConcept;
101 93
102 if(concept instanceof AtomicNegationConcept) { 94 if(concept instanceof AtomicNegationConcept) {
103 // TODO CHECK: is this already in MultiStageUpperProgram?
104 Atom atom1 = 95 Atom atom1 =
105 Atom.create(atomicConcept = ((AtomicNegationConcept) concept).getNegatedAtomicConcept(), X); 96 Atom.create(atomicConcept = ((AtomicNegationConcept) concept).getNegatedAtomicConcept(), X);
106 Atom atom2 = Atom.create(atomicConcept = OverApproxExist.getNegationConcept(atomicConcept), X); 97 Atom atom2 = Atom.create(atomicConcept = OverApproxExist.getNegationConcept(atomicConcept), X);
@@ -116,9 +107,14 @@ public class LimitedSkolemisationApproximator implements TupleDependentApproxima
116 Individual[] individuals = new Individual[card]; 107 Individual[] individuals = new Individual[card];
117 SkolemTermsManager termsManager = SkolemTermsManager.getInstance(); 108 SkolemTermsManager termsManager = SkolemTermsManager.getInstance();
118 for(int i = 0; i < card; ++i) 109 for(int i = 0; i < card; ++i)
119 individuals[i] = termsManager.getFreshIndividual(originalClause, 110 if(useClauseUniqueIndividual)
120 offset + i, 111 individuals[i] = termsManager.getFreshIndividual(originalClause,
121 commonIndividuals); 112 offset + i,
113 maxTermDepth + 1);
114 else
115 individuals[i] = termsManager.getFreshIndividual(originalClause,
116 offset + i,
117 commonIndividuals);
122 118
123 for(int i = 0; i < card; ++i) { 119 for(int i = 0; i < card; ++i) {
124 if(atomicConcept != null) 120 if(atomicConcept != null)
diff --git a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java
index a78aabe..ed93d0e 100644
--- a/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java
+++ b/src/uk/ac/ox/cs/pagoda/rules/approximators/SkolemTermsManager.java
@@ -13,6 +13,7 @@ import java.util.Map;
13public class SkolemTermsManager { 13public class SkolemTermsManager {
14 14
15 public static final String SKOLEMISED_INDIVIDUAL_PREFIX = Namespace.PAGODA_ANONY + "individual"; 15 public static final String SKOLEMISED_INDIVIDUAL_PREFIX = Namespace.PAGODA_ANONY + "individual";
16 public static final String RULE_UNIQUE_SKOLEMISED_INDIVIDUAL_PREFIX = SKOLEMISED_INDIVIDUAL_PREFIX + "_unique";
16 17
17 private static SkolemTermsManager skolemTermsManager; 18 private static SkolemTermsManager skolemTermsManager;
18 19
@@ -54,10 +55,29 @@ public class SkolemTermsManager {
54 + "_" + mapDependencyToId(dependency); 55 + "_" + mapDependencyToId(dependency);
55 Individual newIndividual = Individual.create(SKOLEMISED_INDIVIDUAL_PREFIX + termId); 56 Individual newIndividual = Individual.create(SKOLEMISED_INDIVIDUAL_PREFIX + termId);
56 57
57 int depth = 0; 58 if(!individualToDepth_map.containsKey(newIndividual)) {
58 for(Individual individual : dependency) 59 int depth = 0;
59 depth = Integer.max(depth, getDepthOf(individual)); 60 for (Individual individual : dependency)
60 individualToDepth_map.put(newIndividual, depth + 1); 61 depth = Integer.max(depth, getDepthOf(individual));
62 individualToDepth_map.put(newIndividual, depth + 1);
63 }
64
65 return newIndividual;
66 }
67
68 /***
69 * Create a term of a given depth, unique for the clause and the depth.
70 *
71 * @param originalClause
72 * @param offset
73 * @param depth
74 * @return
75 */
76 public Individual getFreshIndividual(DLClause originalClause, int offset, int depth) {
77 String termId = Integer.toString(mapClauseToId(originalClause) + offset) + "_depth_" + depth;
78 Individual newIndividual = Individual.create(RULE_UNIQUE_SKOLEMISED_INDIVIDUAL_PREFIX + termId);
79
80 individualToDepth_map.putIfAbsent(newIndividual, depth);
61 81
62 return newIndividual; 82 return newIndividual;
63 } 83 }
diff --git a/test/resources/BugTests.xml b/test/resources/BugTests.xml
index 1413b5b..4844fbe 100644
--- a/test/resources/BugTests.xml
+++ b/test/resources/BugTests.xml
@@ -6,7 +6,7 @@
6 <test name="BugTest"> 6 <test name="BugTest">
7 <classes> 7 <classes>
8 <class name="uk.ac.ox.cs.pagoda.global_tests.BugTests"/> 8 <class name="uk.ac.ox.cs.pagoda.global_tests.BugTests"/>
9 <!--<class name="uk.ac.ox.cs.pagoda.endomorph.DependencyGraphTest"/>--> 9 <class name="uk.ac.ox.cs.pagoda.endomorph.DependencyGraphTest"/>
10 </classes> 10 </classes>
11 </test> 11 </test>
12 12
diff --git a/test/resources/MainTests.xml b/test/resources/MainTests.xml
index 255b68e..43300a1 100644
--- a/test/resources/MainTests.xml
+++ b/test/resources/MainTests.xml
@@ -7,9 +7,9 @@
7 <run> 7 <run>
8 <!--<include name="correctness"/>--> 8 <!--<include name="correctness"/>-->
9 <!--<include name="light"/>--> 9 <!--<include name="light"/>-->
10 <!--<include name="justExecute"/>--> 10 <include name="justExecute"/>
11 <!--&lt;!&ndash;<include name="heavy"/>&ndash;&gt;--> 11 <!--&lt;!&ndash;<include name="heavy"/>&ndash;&gt;-->
12 <include name="nonOriginal"/> 12 <!--<include name="nonOriginal"/>-->
13 </run> 13 </run>
14 </groups> 14 </groups>
15 <classes> 15 <classes>
diff --git a/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java b/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java
index eec1e8f..a4579a3 100644
--- a/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java
+++ b/test/uk/ac/ox/cs/pagoda/endomorph/DependencyGraphTest.java
@@ -2,6 +2,7 @@ package uk.ac.ox.cs.pagoda.endomorph;
2 2
3import org.semanticweb.owlapi.apibinding.OWLManager; 3import org.semanticweb.owlapi.apibinding.OWLManager;
4import org.semanticweb.owlapi.model.*; 4import org.semanticweb.owlapi.model.*;
5import org.testng.Assert;
5import org.testng.annotations.Test; 6import org.testng.annotations.Test;
6import uk.ac.ox.cs.JRDFox.model.GroundTerm; 7import uk.ac.ox.cs.JRDFox.model.GroundTerm;
7import uk.ac.ox.cs.JRDFox.model.Individual; 8import uk.ac.ox.cs.JRDFox.model.Individual;
@@ -54,6 +55,6 @@ public class DependencyGraphTest {
54 55
55 dependencyGraph.build(tuples); 56 dependencyGraph.build(tuples);
56 57
57 System.out.println(dependencyGraph.getTopologicalOrder()); 58 Assert.assertTrue(dependencyGraph.getTopologicalOrder().size() >= 2);
58 } 59 }
59} 60}
diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java
index a7a562d..42f0ac1 100644
--- a/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java
+++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestPagodaFLY.java
@@ -62,7 +62,7 @@ public class TestPagodaFLY {
62// .answer(Paths.get("/home/alessandro/Desktop/answers.json")) 62// .answer(Paths.get("/home/alessandro/Desktop/answers.json"))
63 .classify(false) 63 .classify(false)
64 .hermit(true) 64 .hermit(true)
65 .skolem(PagodaProperties.SkolemUpperBoundOptions.AFTER_SUMMARISATION) 65 .skolem(PagodaProperties.SkolemUpperBoundOptions.BEFORE_SUMMARISATION)
66 .build() 66 .build()
67 .run(); 67 .run();
68 } 68 }