Skip to content

Commit

Permalink
Restore equality detection of some unsupported constructors. Fixes #61
Browse files Browse the repository at this point in the history
Identical concepts built using the following constructors are detected

ObjectComplementOf
ObjectHasSelf
ObjectUnionOf
DataHasSelf

For example if an ontology contains axioms:

SubClassOf(:A ObjectComplementOf(:B))
SubClassOf(ObjectComplementOf(:B) :C)

Then SubClassOf(:A :C) will be derived by ELK
  • Loading branch information
ykazakov committed Mar 12, 2024
1 parent c848423 commit 639bb26
Show file tree
Hide file tree
Showing 48 changed files with 243 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ public Void visit(
}

@Override
public Void visit(SubClassInclusionComposedEntityMatch1 inferenceMatch1) {
public Void visit(SubClassInclusionComposedOfDecomposedMatch1 inferenceMatch1) {
SubClassInclusionDecomposedMatch1 premiseMatch2 = inferenceMatch1
.getPremiseMatch(conclusionFactory_);
inferences_.add(premiseMatch2, inferenceMatch1);
Expand All @@ -1816,7 +1816,7 @@ public Void visit(SubClassInclusionComposedEntityMatch1 inferenceMatch1) {
}

@Override
public Void visit(SubClassInclusionComposedEntityMatch2 inferenceMatch2) {
public Void visit(SubClassInclusionComposedOfDecomposedMatch2 inferenceMatch2) {
inferenceMatch2.getConclusionMatch(conclusionFactory_);

// no ELK inferences
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.semanticweb.elk.matching.conclusions.SubClassInclusionComposedMatch1;
import org.semanticweb.elk.matching.inferences.InferenceMatch;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedDefinedClass;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedEntity;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedOfDecomposed;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedInference;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectIntersectionOf;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectSomeValuesFrom;
Expand All @@ -50,8 +50,8 @@ public Void visit(SubClassInclusionComposedDefinedClass inference) {
}

@Override
public Void visit(SubClassInclusionComposedEntity inference) {
factory.getSubClassInclusionComposedEntityMatch1(inference, child);
public Void visit(SubClassInclusionComposedOfDecomposed inference) {
factory.getSubClassInclusionComposedOfDecomposedMatch1(inference, child);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.semanticweb.elk.matching.inferences.ForwardLinkOfObjectHasSelfMatch1;
import org.semanticweb.elk.matching.inferences.ForwardLinkOfObjectSomeValuesFromMatch1;
import org.semanticweb.elk.matching.inferences.InferenceMatch;
import org.semanticweb.elk.matching.inferences.SubClassInclusionComposedEntityMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionComposedOfDecomposedMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionDecomposedFirstConjunctMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionDecomposedSecondConjunctMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionExpandedDefinitionMatch2;
Expand Down Expand Up @@ -82,8 +82,8 @@ public Void visit(ForwardLinkOfObjectSomeValuesFromMatch1 inferenceMatch1) {
}

@Override
public Void visit(SubClassInclusionComposedEntityMatch1 inferenceMatch1) {
factory.getSubClassInclusionComposedEntityMatch2(inferenceMatch1,
public Void visit(SubClassInclusionComposedOfDecomposedMatch1 inferenceMatch1) {
factory.getSubClassInclusionComposedOfDecomposedMatch2(inferenceMatch1,
child);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.semanticweb.elk.matching.inferences.ForwardLinkOfObjectHasSelfMatch1;
import org.semanticweb.elk.matching.inferences.ForwardLinkOfObjectSomeValuesFromMatch1;
import org.semanticweb.elk.matching.inferences.InferenceMatch;
import org.semanticweb.elk.matching.inferences.SubClassInclusionComposedEntityMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionComposedOfDecomposedMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionDecomposedFirstConjunctMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionDecomposedSecondConjunctMatch1;
import org.semanticweb.elk.matching.inferences.SubClassInclusionExpandedDefinitionMatch2;
Expand Down Expand Up @@ -51,7 +51,7 @@ interface Visitor<O> extends BackwardLinkOfObjectHasSelfMatch1.Visitor<O>,
ClassInconsistencyOfObjectComplementOfMatch1.Visitor<O>,
ForwardLinkOfObjectHasSelfMatch1.Visitor<O>,
ForwardLinkOfObjectSomeValuesFromMatch1.Visitor<O>,
SubClassInclusionComposedEntityMatch1.Visitor<O>,
SubClassInclusionComposedOfDecomposedMatch1.Visitor<O>,
SubClassInclusionDecomposedFirstConjunctMatch1.Visitor<O>,
SubClassInclusionDecomposedSecondConjunctMatch1.Visitor<O>,
SubClassInclusionExpandedDefinitionMatch2.Visitor<O>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.semanticweb.elk.matching.conclusions;

import org.semanticweb.elk.matching.ElkMatchException;
import org.semanticweb.elk.matching.subsumers.IndexedClassEntityMatch;
import org.semanticweb.elk.matching.subsumers.IndexedClassMatch;
import org.semanticweb.elk.matching.subsumers.IndexedIndividualMatch;
import org.semanticweb.elk.matching.subsumers.IndexedObjectComplementOfMatch;
Expand Down Expand Up @@ -105,19 +104,6 @@ private <O> O failSubsumerMatch() {
throw new ElkMatchException(getSubsumer(), subsumerMatch_);
}

public IndexedClassEntityMatch getSubsumerIndexedClassEntityMatch() {
return subsumerMatch_
.accept(new FailingSubsumerMatcher<IndexedClassEntityMatch>() {

@Override
public IndexedClassEntityMatch defaultVisit(
IndexedClassEntityMatch match) {
return match;
}

});
}

public <O> O accept(final IndexedObjectUnionOfMatchVisitor<O> visitor) {

if (subsumerMatch_ instanceof SubsumerElkObjectMatch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ interface Factory extends BackwardLinkCompositionMatch1.Factory,
SubClassInclusionComposedEmptyObjectOneOfMatch2.Factory,
SubClassInclusionComposedEmptyObjectUnionOfMatch1.Factory,
SubClassInclusionComposedEmptyObjectUnionOfMatch2.Factory,
SubClassInclusionComposedEntityMatch1.Factory,
SubClassInclusionComposedEntityMatch2.Factory,
SubClassInclusionComposedOfDecomposedMatch1.Factory,
SubClassInclusionComposedOfDecomposedMatch2.Factory,
SubClassInclusionComposedObjectHasValueMatch1.Factory,
SubClassInclusionComposedObjectHasValueMatch2.Factory,
SubClassInclusionComposedObjectIntersectionOfMatch1.Factory,
Expand Down Expand Up @@ -268,8 +268,8 @@ interface Visitor<O> extends BackwardLinkCompositionMatch1.Visitor<O>,
SubClassInclusionComposedEmptyObjectOneOfMatch2.Visitor<O>,
SubClassInclusionComposedEmptyObjectUnionOfMatch1.Visitor<O>,
SubClassInclusionComposedEmptyObjectUnionOfMatch2.Visitor<O>,
SubClassInclusionComposedEntityMatch1.Visitor<O>,
SubClassInclusionComposedEntityMatch2.Visitor<O>,
SubClassInclusionComposedOfDecomposedMatch1.Visitor<O>,
SubClassInclusionComposedOfDecomposedMatch2.Visitor<O>,
SubClassInclusionComposedObjectHasValueMatch1.Visitor<O>,
SubClassInclusionComposedObjectHasValueMatch2.Visitor<O>,
SubClassInclusionComposedObjectIntersectionOfMatch1.Visitor<O>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import org.semanticweb.elk.reasoner.saturation.inferences.ForwardLinkOfObjectSomeValuesFrom;
import org.semanticweb.elk.reasoner.saturation.inferences.PropagationGenerated;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedDefinedClass;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedEntity;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedOfDecomposed;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectIntersectionOf;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectSomeValuesFrom;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectUnionOf;
Expand Down Expand Up @@ -758,18 +758,18 @@ public SubClassInclusionComposedEmptyObjectUnionOfMatch2 getSubClassInclusionCom
}

@Override
public SubClassInclusionComposedEntityMatch1 getSubClassInclusionComposedEntityMatch1(
SubClassInclusionComposedEntity parent,
public SubClassInclusionComposedOfDecomposedMatch1 getSubClassInclusionComposedOfDecomposedMatch1(
SubClassInclusionComposedOfDecomposed parent,
SubClassInclusionComposedMatch1 conclusionMatch) {
return new SubClassInclusionComposedEntityMatch1(parent,
return new SubClassInclusionComposedOfDecomposedMatch1(parent,
conclusionMatch);
}

@Override
public SubClassInclusionComposedEntityMatch2 getSubClassInclusionComposedEntityMatch2(
SubClassInclusionComposedEntityMatch1 parent,
public SubClassInclusionComposedOfDecomposedMatch2 getSubClassInclusionComposedOfDecomposedMatch2(
SubClassInclusionComposedOfDecomposedMatch1 parent,
SubClassInclusionDecomposedMatch2 premiseMatch) {
return new SubClassInclusionComposedEntityMatch2(parent, premiseMatch);
return new SubClassInclusionComposedOfDecomposedMatch2(parent, premiseMatch);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
import org.semanticweb.elk.reasoner.saturation.inferences.ForwardLinkOfObjectSomeValuesFrom;
import org.semanticweb.elk.reasoner.saturation.inferences.PropagationGenerated;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedDefinedClass;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedEntity;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedOfDecomposed;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectIntersectionOf;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectSomeValuesFrom;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedObjectUnionOf;
Expand Down Expand Up @@ -836,18 +836,18 @@ public SubClassInclusionComposedEmptyObjectUnionOfMatch2 getSubClassInclusionCom
}

@Override
public SubClassInclusionComposedEntityMatch1 getSubClassInclusionComposedEntityMatch1(
SubClassInclusionComposedEntity parent,
public SubClassInclusionComposedOfDecomposedMatch1 getSubClassInclusionComposedOfDecomposedMatch1(
SubClassInclusionComposedOfDecomposed parent,
SubClassInclusionComposedMatch1 conclusionMatch) {
return filter(mainFactory_.getSubClassInclusionComposedEntityMatch1(
return filter(mainFactory_.getSubClassInclusionComposedOfDecomposedMatch1(
parent, conclusionMatch));
}

@Override
public SubClassInclusionComposedEntityMatch2 getSubClassInclusionComposedEntityMatch2(
SubClassInclusionComposedEntityMatch1 parent,
public SubClassInclusionComposedOfDecomposedMatch2 getSubClassInclusionComposedOfDecomposedMatch2(
SubClassInclusionComposedOfDecomposedMatch1 parent,
SubClassInclusionDecomposedMatch2 premiseMatch) {
return filter(mainFactory_.getSubClassInclusionComposedEntityMatch2(
return filter(mainFactory_.getSubClassInclusionComposedOfDecomposedMatch2(
parent, premiseMatch));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ public String visit(
}

@Override
public String visit(SubClassInclusionComposedEntityMatch1 inferenceMatch1) {
public String visit(SubClassInclusionComposedOfDecomposedMatch1 inferenceMatch1) {
return inferenceMatch1.getParent() + " | ";
}

@Override
public String visit(SubClassInclusionComposedEntityMatch2 inferenceMatch2) {
public String visit(SubClassInclusionComposedOfDecomposedMatch2 inferenceMatch2) {
return inferenceMatch2.getParent() + " | ";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,31 @@
import org.semanticweb.elk.matching.conclusions.SubClassInclusionDecomposedMatch1;
import org.semanticweb.elk.matching.conclusions.SubClassInclusionDecomposedMatch1Watch;
import org.semanticweb.elk.matching.root.IndexedContextRootMatch;
import org.semanticweb.elk.matching.subsumers.IndexedClassEntityMatch;
import org.semanticweb.elk.matching.subsumers.SubsumerMatch;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedEntity;
import org.semanticweb.elk.reasoner.saturation.inferences.SubClassInclusionComposedOfDecomposed;

public class SubClassInclusionComposedEntityMatch1
extends AbstractInferenceMatch<SubClassInclusionComposedEntity>
public class SubClassInclusionComposedOfDecomposedMatch1
extends AbstractInferenceMatch<SubClassInclusionComposedOfDecomposed>
implements SubClassInclusionDecomposedMatch1Watch {

private final IndexedContextRootMatch originMatch_;

private final IndexedClassEntityMatch conclusionSubsumerMatch_;
private final SubsumerMatch conclusionSubsumerMatch_;

SubClassInclusionComposedEntityMatch1(
SubClassInclusionComposedEntity parent,
SubClassInclusionComposedOfDecomposedMatch1(
SubClassInclusionComposedOfDecomposed parent,
SubClassInclusionComposedMatch1 conclusionMatch) {
super(parent);
this.originMatch_ = conclusionMatch.getDestinationMatch();
this.conclusionSubsumerMatch_ = conclusionMatch
.getSubsumerIndexedClassEntityMatch();
this.conclusionSubsumerMatch_ = conclusionMatch.getSubsumerMatch();
checkEquals(conclusionMatch, getConclusionMatch(DEBUG_FACTORY));
}

public IndexedContextRootMatch getOriginMatch() {
return originMatch_;
}

public IndexedClassEntityMatch getConclusionSubsumerMatch() {
public SubsumerMatch getConclusionSubsumerMatch() {
return conclusionSubsumerMatch_;
}

Expand Down Expand Up @@ -91,7 +89,7 @@ public <O> O accept(
*/
public interface Visitor<O> {

O visit(SubClassInclusionComposedEntityMatch1 inferenceMatch1);
O visit(SubClassInclusionComposedOfDecomposedMatch1 inferenceMatch1);

}

Expand All @@ -103,8 +101,8 @@ public interface Visitor<O> {
*/
public interface Factory {

SubClassInclusionComposedEntityMatch1 getSubClassInclusionComposedEntityMatch1(
SubClassInclusionComposedEntity parent,
SubClassInclusionComposedOfDecomposedMatch1 getSubClassInclusionComposedOfDecomposedMatch1(
SubClassInclusionComposedOfDecomposed parent,
SubClassInclusionComposedMatch1 conclusionMatch);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import org.semanticweb.elk.matching.root.IndexedContextRootMatch;
import org.semanticweb.elk.matching.subsumers.SubsumerMatch;

public class SubClassInclusionComposedEntityMatch2
extends AbstractInferenceMatch<SubClassInclusionComposedEntityMatch1> {
public class SubClassInclusionComposedOfDecomposedMatch2
extends AbstractInferenceMatch<SubClassInclusionComposedOfDecomposedMatch1> {

private final IndexedContextRootMatch extendedOriginMatch_;

SubClassInclusionComposedEntityMatch2(
SubClassInclusionComposedEntityMatch1 parent,
SubClassInclusionComposedOfDecomposedMatch2(
SubClassInclusionComposedOfDecomposedMatch1 parent,
SubClassInclusionDecomposedMatch2 premiseMatch) {
super(parent);
SubsumerMatch subsumerMatch = premiseMatch.getSubsumerMatch();
Expand Down Expand Up @@ -81,7 +81,7 @@ public <O> O accept(InferenceMatch.Visitor<O> visitor) {
*/
public interface Visitor<O> {

O visit(SubClassInclusionComposedEntityMatch2 inferenceMatch2);
O visit(SubClassInclusionComposedOfDecomposedMatch2 inferenceMatch2);

}

Expand All @@ -93,8 +93,8 @@ public interface Visitor<O> {
*/
public interface Factory {

SubClassInclusionComposedEntityMatch2 getSubClassInclusionComposedEntityMatch2(
SubClassInclusionComposedEntityMatch1 parent,
SubClassInclusionComposedOfDecomposedMatch2 getSubClassInclusionComposedOfDecomposedMatch2(
SubClassInclusionComposedOfDecomposedMatch1 parent,
SubClassInclusionDecomposedMatch2 premiseMatch);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,7 @@ public void provabilityTest() throws Exception {
Reasoner reasoner = TestReasonerUtils.createTestReasoner(loader);

try {
// reasoner.getTaxonomy();
// ElkClass sub = elkFactory.getClass(new ElkFullIri("StiffNeck"));
// ElkClass sup = elkFactory
// .getClass(new ElkFullIri("PropertyOfPhenomenon"));
//
// getTestingVisitor(reasoner, ontology).subsumptionTest(sub, sup);

TracingTests tests = getProvabilityTests(reasoner);

tests.accept(getTestingVisitor(reasoner, ontology));
} finally {
reasoner.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public O visit(SubClassInclusionComposedDefinedClass inference) {
}

@Override
public O visit(SubClassInclusionComposedEntity inference) {
public O visit(SubClassInclusionComposedOfDecomposed inference) {
return conclusionVisitor_
.visit(inference.getConclusion(conclusionFactory_));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public Boolean visit(SubClassInclusionComposedDefinedClass inference) {
}

@Override
public Boolean visit(SubClassInclusionComposedEntity inference) {
public Boolean visit(SubClassInclusionComposedOfDecomposed inference) {
for (int i = 0; i < visitors_.length; i++) {
if (!visitors_[i].visit(inference))
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public O visit(SubClassInclusionComposedDefinedClass inference) {
}

@Override
public O visit(SubClassInclusionComposedEntity inference) {
public O visit(SubClassInclusionComposedOfDecomposed inference) {
return defaultVisit(inference);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public O visit(SubClassInclusionComposedDefinedClass inference) {
}

@Override
public O visit(SubClassInclusionComposedEntity inference) {
public O visit(SubClassInclusionComposedOfDecomposed inference) {
return defaultVisit(inference);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface SubClassInclusionComposedInference
*/
public static interface Visitor<O>
extends SubClassInclusionComposedDefinedClass.Visitor<O>,
SubClassInclusionComposedEntity.Visitor<O>,
SubClassInclusionComposedOfDecomposed.Visitor<O>,
SubClassInclusionComposedObjectIntersectionOf.Visitor<O>,
SubClassInclusionComposedObjectSomeValuesFrom.Visitor<O>,
SubClassInclusionComposedObjectUnionOf.Visitor<O>,
Expand Down
Loading

0 comments on commit 639bb26

Please sign in to comment.