diff options
| author | RncLsn <rnc.lsn@gmail.com> | 2015-08-03 17:07:39 +0100 |
|---|---|---|
| committer | RncLsn <rnc.lsn@gmail.com> | 2015-08-03 17:07:39 +0100 |
| commit | 0c39145b3b76b3db73db0a38d5324caa7ff3c434 (patch) | |
| tree | 388c97e1460d4180e74b531e048a60fc62963c5a /src | |
| parent | 02cf14060d3b9e722480e07ebfd32538bbb8e73b (diff) | |
| download | ACQuA-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.
Diffstat (limited to 'src')
4 files changed, 37 insertions, 22 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 @@ | |||
| 1 | debug=true | 1 | debug=true |
| 2 | useAlwaysSimpleUpperBound=false | 2 | useAlwaysSimpleUpperBound=false |
| 3 | skolemUpperBound=DISABLED | 3 | skolemUpperBound=DISABLED |
| 4 | skolemDepth=1 | ||
| 5 | #skolemUpperBound=BEFORE_SUMMARISATION | 4 | #skolemUpperBound=BEFORE_SUMMARISATION |
| 6 | #skolemUpperBound=AFTER_SUMMARISATION | 5 | #skolemUpperBound=AFTER_SUMMARISATION |
| 6 | skolemDepth=1 | ||
| 7 | toCallHermit=true | 7 | toCallHermit=true |
| 8 | 8 | ||
| 9 | statisticsDir=/home/alessandro/Dropbox/Oxford/PAGOdA/statistics \ No newline at end of file | 9 | statisticsDir=/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 | ||
| 3 | import org.semanticweb.HermiT.model.*; | 3 | import org.semanticweb.HermiT.model.*; |
| 4 | import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; | 4 | import uk.ac.ox.cs.pagoda.multistage.MultiStageUpperProgram; |
| 5 | import uk.ac.ox.cs.pagoda.rules.ExistConstantApproximator; | ||
| 6 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; | 5 | import uk.ac.ox.cs.pagoda.util.tuples.Tuple; |
| 7 | import uk.ac.ox.cs.pagoda.util.tuples.TupleBuilder; | 6 | import 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; | |||
| 13 | public class SkolemTermsManager { | 13 | public 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 | } |
