org.semanticweb.owlapi.model.OWLObjectComplementOf Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLObjectComplementOf. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NormalizedOWLQLTbox.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
public Set<OWLClass> getUnsatisfiableNamedClasses() {
	if (unsatisfiableClasses == null) {
		unsatisfiableClasses = new HashSet<OWLClass>();
		// unsatisfiabe named classes C are in the negative closure in the form
		// subclass( C, not(C)) 
		for (OWLSubClassOfAxiom ax: getNegativeInclInNegClosure()) {
			OWLClassExpression sub = ax.getSubClass();
			OWLClassExpression sup = ax.getSuperClass();
			if (!sub.isAnonymous()
			&& sup.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF)
			&& ((OWLObjectComplementOf) sup).getOperand().equals(sub)) {
				unsatisfiableClasses.add(sub.asOWLClass());
			}
		}
	}
	return Collections.unmodifiableSet(unsatisfiableClasses);
	//return new HashSet<OWLClass>();
}
 
Example #2
Source File: TBoxUnFoldingTool.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public OWLObjectComplementOf visit(OWLObjectComplementOf ce) {
	if (LOG.isDebugEnabled()) {
		LOG.debug("Unfolding complement_of: "+ce);
	}
	
	OWLClassExpression operand = ce.getOperand();
	if (operand != null) {
		OWLClassExpression unfold = operand.accept(this);
		if (unfold != null) {
			return factory.getOWLObjectComplementOf(unfold);
		}
	}
	return null;
}
 
Example #3
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public Void visit(OWLObjectComplementOf desc) {
  long subject =
      getOrCreateNode(getIri(desc), OwlLabels.OWL_COMPLEMENT_OF, OwlLabels.OWL_ANONYMOUS);
  long operand = getOrCreateNode(getIri(desc.getOperand()));
  getOrCreateRelationship(subject, operand, OwlRelationships.OPERAND);
  return null;
}
 
Example #4
Source File: AbstractElkObjectConverter.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public OWLObjectComplementOf visit(ElkObjectComplementOf expression) {
	return owlFactory_.getOWLObjectComplementOf(
			convert(expression.getClassExpression()));
}
 
Example #5
Source File: OwlClassExpressionConverterVisitor.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public ElkObjectComplementOf visit(
		OWLObjectComplementOf owlObjectComplementOf) {
	return CONVERTER.convert(owlObjectComplementOf);
}
 
Example #6
Source File: OwlConverter.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-method")
public ElkObjectComplementOf convert(
		OWLObjectComplementOf owlObjectComplementOf) {
	return new ElkObjectComplementOfWrap<OWLObjectComplementOf>(
			owlObjectComplementOf);
}
 
Example #7
Source File: ManchesterOWLSyntaxObjectHTMLRenderer.java    From robot with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Given an OWLClassExpression, determine the particular type of OWLClassExpression that it is,
 * and then call the appropriate visit() function for it.
 */
public void visit(OWLClassExpression ce) throws ClassNotFoundException {
  if (ce instanceof OWLClass) {
    visit((OWLClass) ce);
  } else if (ce instanceof OWLObjectSomeValuesFrom) {
    visit((OWLObjectSomeValuesFrom) ce);
  } else if (ce instanceof OWLObjectAllValuesFrom) {
    visit((OWLObjectAllValuesFrom) ce);
  } else if (ce instanceof OWLObjectMinCardinality) {
    visit((OWLObjectMinCardinality) ce);
  } else if (ce instanceof OWLObjectMaxCardinality) {
    visit((OWLObjectMaxCardinality) ce);
  } else if (ce instanceof OWLObjectExactCardinality) {
    visit((OWLObjectExactCardinality) ce);
  } else if (ce instanceof OWLObjectHasValue) {
    visit((OWLObjectHasValue) ce);
  } else if (ce instanceof OWLObjectHasSelf) {
    visit((OWLObjectHasSelf) ce);
  } else if (ce instanceof OWLDataSomeValuesFrom) {
    visit((OWLDataSomeValuesFrom) ce);
  } else if (ce instanceof OWLDataAllValuesFrom) {
    visit((OWLDataAllValuesFrom) ce);
  } else if (ce instanceof OWLDataMinCardinality) {
    visit((OWLDataMinCardinality) ce);
  } else if (ce instanceof OWLDataMaxCardinality) {
    visit((OWLDataMaxCardinality) ce);
  } else if (ce instanceof OWLDataExactCardinality) {
    visit((OWLDataExactCardinality) ce);
  } else if (ce instanceof OWLDataHasValue) {
    visit((OWLDataHasValue) ce);
  } else if (ce instanceof OWLObjectIntersectionOf) {
    visit((OWLObjectIntersectionOf) ce);
  } else if (ce instanceof OWLObjectUnionOf) {
    visit((OWLObjectUnionOf) ce);
  } else if (ce instanceof OWLObjectComplementOf) {
    visit((OWLObjectComplementOf) ce);
  } else if (ce instanceof OWLObjectOneOf) {
    visit((OWLObjectOneOf) ce);
  } else {
    logger.error(
        "Could not visit class expression: {} of type: {}",
        ce.toString(),
        ce.getClass().toString());
  }
}
 
Example #8
Source File: CardinalityContraintsTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public HandlerResult visit(OWLObjectComplementOf ce) {
	return ce.getOperand().accept(this);
}
 
Example #9
Source File: NormalizedOWLQLTbox.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isSubClass(OWLClassExpression sub, OWLClassExpression sup) {
	// if sup is equivalent to Top return true
	if (sup.isOWLThing()) {
		return true;
	}
	if (sup.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF)
	&& 
	(
		((OWLObjectComplementOf) sup).getOperand().isOWLNothing()
		|| getUnsatisfiableNamedClasses().contains(((OWLObjectComplementOf) sup).getOperand()) 
	)  ) {
		return true;
	}
	//
	
	// if sub is equivalent to Bottom return true
	if (sub.isOWLNothing() || getUnsatisfiableNamedClasses().contains(sub)) {
		return true;
	}
	if (sub.getClassExpressionType().equals(ClassExpressionType.OBJECT_COMPLEMENT_OF)
	&& ((OWLObjectComplementOf) sub).getOperand().isOWLThing()) {
		return true;
	}
	if ( (sub.getClassExpressionType().equals(ClassExpressionType.OBJECT_SOME_VALUES_FROM)
	|| sub.getClassExpressionType().equals(ClassExpressionType.DATA_SOME_VALUES_FROM))
		&&
	(((OWLQuantifiedRestriction) sub).getProperty().isOWLBottomObjectProperty()
		||((OWLQuantifiedRestriction) sub).getProperty().isOWLBottomDataProperty()
		|| getUnsatisfiableProperties().contains(((OWLQuantifiedRestriction) sub).getProperty()))) {
		return true;
	}
	//

	// check that tbox union {subclass(NC, sub), sublcass(NC, not(sup)), NC(Nind)}
	// is inconsistent. NC: new concept, Nind: new individual
	
	List<OWLAxiom> newAxioms = new LinkedList<OWLAxiom>();
	NormalizedOWLQLTbox ret = this;//copy();
	OWLClass newConcept = ret.getNormalizer().createNewNamedClass();
	newAxioms.add(fac.getOWLSubClassOfAxiom(newConcept, sub.getNNF()));
	newAxioms.add(fac.getOWLSubClassOfAxiom(newConcept, sup.getComplementNNF()));
	List<OWLAxiom> newNonOWLQLAxioms = new LinkedList<OWLAxiom>();
	
	Set<OWLAxiom> normalizedAxioms = ret.getNormalizer().toQLNormalForm(newAxioms, newNonOWLQLAxioms);
	if (!newNonOWLQLAxioms.isEmpty()) {
		throw new RuntimeException("Both concepts  must be OWL QL valid concepts");
	}
	List<OWLSubClassOfAxiom> deltaNegIncAx = new LinkedList<OWLSubClassOfAxiom>();
	List<OWLDisjointObjectPropertiesAxiom> deltaNegObjSubPropAx = new LinkedList<OWLDisjointObjectPropertiesAxiom>();
	List<OWLDisjointDataPropertiesAxiom> deltaNegDataSubPropAx = new LinkedList<OWLDisjointDataPropertiesAxiom>();
	List<OWLSubClassOfAxiom> deltaPosIncAx = new LinkedList<OWLSubClassOfAxiom>();
	List<OWLSubPropertyAxiom> deltaPosSubPropAx = new LinkedList<OWLSubPropertyAxiom>();
	organizeTboxAxioms(normalizedAxioms, deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx,deltaPosIncAx, deltaPosSubPropAx,
			new HashSet<OWLObjectProperty>(), new HashSet<OWLObjectProperty>(),
			new HashMap<String, Set<OWLSubClassOfAxiom>>(), new HashMap<String, Set<OWLSubPropertyAxiom>>());
	// inconsistent iff subclass(NC, not(NC)) is in the negative closure 
	OWLAxiom inconsistencyWitness = fac.getOWLSubClassOfAxiom(newConcept, newConcept.getComplementNNF());
	Set<OWLAxiom> newNegClos = ret.computeNegativeInclusionClosure(deltaNegIncAx, deltaNegObjSubPropAx, deltaNegDataSubPropAx, 
			deltaPosIncAx, deltaPosSubPropAx, inconsistencyWitness);
	//assert newNegClos == null || !newNegClos.contains(inconsistencyWitness) : newNegClos;
	// 
	
	return newNegClos == null;
	
}