public void add( T obj, Bool isKnown ) { if( isKnown.isTrue() ) { knowns.add( obj ); } else if( isKnown.isUnknown() ) { unknowns.add( obj ); } }
public String toString() { return isTrue() ? "true" : isFalse() ? "false" : "unknown"; } }
public void add( T obj, Bool isKnown ) { if( isKnown.isTrue() ) { knowns.add( obj ); } else if( isKnown.isUnknown() ) { unknowns.add( obj ); } }
public String toString() { return isTrue() ? "true" : isFalse() ? "false" : "unknown"; } }
public void update( T obj, Bool isCandidate ) { if( isCandidate.isTrue() ) { // do nothing } else if( isCandidate.isFalse() ) { remove( obj ); } else { if( knowns.contains( obj ) ) { knowns.remove( obj ); unknowns.add( obj ); } } }
public void update( T obj, Bool isCandidate ) { if( isCandidate.isTrue() ) { // do nothing } else if( isCandidate.isFalse() ) { remove( obj ); } else { if( knowns.contains( obj ) ) { knowns.remove( obj ); unknowns.add( obj ); } } }
public void visit(OWLEquivalentClassesAxiom axiom) { isEntailed = true; Iterator<OWLClassExpression> i = axiom.getClassExpressions().iterator(); if( i.hasNext() ) { OWLClassExpression first = i.next(); while( i.hasNext() && isEntailed ) { OWLClassExpression next = i.next(); if( !reasoner.isClassified() || first.isAnonymous() || next.isAnonymous() ) isEntailed = reasoner.getReasoner().isEntailed( OWL.equivalentClasses( first, next ) ); else isEntailed = reasoner.getTaxonomy().isEquivalent( (OWLClass) first, (OWLClass) next ).isTrue(); } } }
@Override public boolean contains(KnowledgeBase kb, GraphLoader loader, Node s, Node p, Node o) { ATermAppl prop = loader.node2term( p ); if( !kb.isProperty( prop ) ) return false; for( ATermAppl ind : kb.getIndividuals() ) { if( kb.hasKnownPropertyValue( ind, prop, null ).isTrue() ) { return true; } } return false; }
/** * Returns true if there is at least one named individual that belongs to * the given class * * @param c * @return */ public boolean hasInstance(ATerm d) { if( !isClass( d ) ) { handleUndefinedEntity( d + " is not a class!" ); return false; } ensureConsistency(); ATermAppl c = ATermUtils.normalize( (ATermAppl) d ); List<ATermAppl> unknowns = new ArrayList<ATermAppl>(); Iterator<Individual> i = new IndividualIterator( abox ); while( i.hasNext() ) { ATermAppl x = i.next().getName(); Bool knownType = abox.isKnownType( x, c ); if( knownType.isTrue() ) return true; else if( knownType.isUnknown() ) unknowns.add( x ); } boolean hasInstance = !unknowns.isEmpty() && abox.isType( unknowns, c ); return hasInstance; }
@Override protected void addUses(ATermAppl c, ATermAppl d) { if( definitionOrderTaxonomy.isEquivalent( c, d ).isTrue() ) return; TaxonomyNode<ATermAppl> cNode = definitionOrderTaxonomy.getNode( c ); TaxonomyNode<ATermAppl> dNode = definitionOrderTaxonomy.getNode( d ); if( cNode == null ) throw new InternalReasonerException( c + " is not in the definition order" ); else if( cNode.equals( definitionOrderTaxonomy.getTop() ) ) definitionOrderTaxonomy.merge( cNode, dNode ); else { definitionOrderTaxonomy.addSuper( c, d ); definitionOrderTaxonomy.removeCycles( cNode ); } }
@Override protected void addUses(ATermAppl c, ATermAppl d) { if( definitionOrderTaxonomy.isEquivalent( c, d ).isTrue() ) return; TaxonomyNode<ATermAppl> cNode = definitionOrderTaxonomy.getNode( c ); TaxonomyNode<ATermAppl> dNode = definitionOrderTaxonomy.getNode( d ); if( cNode == null ) throw new InternalReasonerException( c + " is not in the definition order" ); else if( cNode.equals( definitionOrderTaxonomy.getTop() ) ) definitionOrderTaxonomy.merge( cNode, dNode ); else { definitionOrderTaxonomy.addSuper( c, d ); definitionOrderTaxonomy.removeCycles( cNode ); } }
public Set<ATermAppl> getDifferents(ATermAppl name) { ensureConsistency(); Individual ind = abox.getIndividual( name ); if( ind == null ) { handleUndefinedEntity( name + " is not an individual!" ); return Collections.emptySet(); } boolean isIndependent = true; if( ind.isMerged() ) { isIndependent = ind.getMergeDependency( true ).isIndependent(); ind = ind.getSame(); } ATermAppl c = ATermUtils.makeNot( ATermUtils.makeValue( name ) ); Set<ATermAppl> differents = new HashSet<ATermAppl>(); for( ATermAppl x : individuals ) { Bool isType = abox.isKnownType( x, c ); if( isIndependent && isType.isKnown() ) { if( isType.isTrue() ) differents.add( x ); } else if( isType( x, c ) ) { differents.add( x ); } } return differents; }
public Set<ATermAppl> getDifferents(ATermAppl name) { ensureConsistency(); Individual ind = abox.getIndividual( name ); if( ind == null ) { handleUndefinedEntity( name + " is not an individual!" ); return Collections.emptySet(); } boolean isIndependent = true; if( ind.isMerged() ) { isIndependent = ind.getMergeDependency( true ).isIndependent(); ind = ind.getSame(); } ATermAppl c = ATermUtils.makeNot( ATermUtils.makeValue( name ) ); Set<ATermAppl> differents = new HashSet<ATermAppl>(); for( ATermAppl x : individuals ) { Bool isType = abox.isKnownType( x, c ); if( isIndependent && isType.isKnown() ) { if( isType.isTrue() ) differents.add( x ); } else if( isType( x, c ) ) { differents.add( x ); } } return differents; }
public boolean isSubClassOf(ATermAppl c1, ATermAppl c2) { if( !doExplanation ) { Bool isKnownSubClass = isKnownSubClassOf( c1, c2 ); if( isKnownSubClass.isKnown() ) { return isKnownSubClass.isTrue(); } } if( log.isLoggable( Level.FINE ) ) { long count = kb.timers.getTimer( "subClassSat" ) == null ? 0 : kb.timers.getTimer( "subClassSat" ).getCount(); log.fine( count + ") Checking subclass [" + ATermUtils.toString( c1 ) + " " + ATermUtils.toString( c2 ) + "]" ); } ATermAppl notC2 = ATermUtils.negate( c2 ); ATermAppl c = ATermUtils.makeAnd( c1, notC2 ); Timer t = kb.timers.startTimer( "subClassSat" ); boolean sub = !isSatisfiable( c, false ); t.stop(); if( log.isLoggable( Level.FINE ) ) { log.fine( " Result: " + sub + " (" + t.getLast() + "ms)" ); } return sub; }
public boolean isSubClassOf(ATermAppl c1, ATermAppl c2) { if( !doExplanation ) { Bool isKnownSubClass = isKnownSubClassOf( c1, c2 ); if( isKnownSubClass.isKnown() ) { return isKnownSubClass.isTrue(); } } if( log.isLoggable( Level.FINE ) ) { long count = kb.timers.getTimer( "subClassSat" ) == null ? 0 : kb.timers.getTimer( "subClassSat" ).getCount(); log.fine( count + ") Checking subclass [" + ATermUtils.toString( c1 ) + " " + ATermUtils.toString( c2 ) + "]" ); } ATermAppl notC2 = ATermUtils.negate( c2 ); ATermAppl c = ATermUtils.makeAnd( c1, notC2 ); Timer t = kb.timers.startTimer( "subClassSat" ); boolean sub = !isSatisfiable( c, false ); t.stop(); if( log.isLoggable( Level.FINE ) ) { log.fine( " Result: " + sub + " (" + t.getLast() + "ms)" ); } return sub; }
public void visit(OWLSubClassOfAxiom axiom) { OWLClassExpression subClass = axiom.getSubClass(); OWLClassExpression superClass = axiom.getSuperClass(); if( !reasoner.isClassified() || subClass.isAnonymous() || superClass.isAnonymous() ) isEntailed = reasoner.getReasoner().isEntailed( axiom ); else isEntailed = reasoner.getTaxonomy().isSubNodeOf( (OWLClass) subClass, (OWLClass) superClass ).isTrue(); }
public Bool isKnownType(ATermAppl x, ATermAppl c, Collection<ATermAppl> subs) { assert isComplete() : "Initial consistency check has not been performed!"; Individual pNode = getIndividual( x ); boolean isIndependent = true; if( pNode.isMerged() ) { isIndependent = pNode.getMergeDependency( true ).isIndependent(); pNode = pNode.getSame(); } Bool isType = isKnownType( pNode, c, subs ); if( isIndependent ) { return isType; } else if( isType.isTrue() ) { return Bool.UNKNOWN; } else { return isType; } }
public Bool isKnownType(ATermAppl x, ATermAppl c, Collection<ATermAppl> subs) { assert isComplete() : "Initial consistency check has not been performed!"; Individual pNode = getIndividual( x ); boolean isIndependent = true; if( pNode.isMerged() ) { isIndependent = pNode.getMergeDependency( true ).isIndependent(); pNode = pNode.getSame(); } Bool isType = isKnownType( pNode, c, subs ); if( isIndependent ) { return isType; } else if( isType.isTrue() ) { return Bool.UNKNOWN; } else { return isType; } }
public boolean hasPropertyValue(ATermAppl s, ATermAppl p, ATermAppl o) { Bool hasObviousValue = hasObviousPropertyValue( s, p, o ); if( hasObviousValue.isKnown() ) { if( hasObviousValue.isFalse() || !doExplanation() ) { return hasObviousValue.isTrue(); } } ATermAppl c = null; if( o == null ) { if( kb.isDatatypeProperty( p ) ) { c = ATermUtils.makeMin( p, 1, ATermUtils.TOP_LIT ); } else { c = ATermUtils.makeMin( p, 1, ATermUtils.TOP ); } } else { c = ATermUtils.makeHasValue( p, o ); } boolean isType = isType( s, c ); return isType; }
public boolean hasPropertyValue(ATermAppl s, ATermAppl p, ATermAppl o) { Bool hasObviousValue = hasObviousPropertyValue( s, p, o ); if( hasObviousValue.isKnown() ) { if( hasObviousValue.isFalse() || !doExplanation() ) { return hasObviousValue.isTrue(); } } ATermAppl c = null; if( o == null ) { if( kb.isDatatypeProperty( p ) ) { c = ATermUtils.makeMin( p, 1, ATermUtils.TOP_LIT ); } else { c = ATermUtils.makeMin( p, 1, ATermUtils.TOP ); } } else { c = ATermUtils.makeHasValue( p, o ); } boolean isType = isType( s, c ); return isType; }