Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Bool


  protected ATermAppl createRestriction(Node node) throws UnsupportedFeatureException {
    Node restrictionType = null;
    Node p = null;
    Node filler = null;
    Node qualification = null;
    Bool isObjectRestriction = Bool.UNKNOWN;

    ClosableIterator<Triple> i = graph.find( node, null, null );
    while( i.hasNext() ) {
      monitor.incrementProgress();
View Full Code Here


   * Bool.FALSE if the individual definetely does NOT have the property value
   * and Bool.UNKNOWN if it cannot be determined for sure, i.e. consistency check is
   * required
   */
  public Bool hasDataPropertyValue( Role r, Object value ) {
      Bool hasValue = Bool.FALSE;
     
    EdgeList edges = outEdges.getEdges( r );
    for(int i = 0; i < edges.size(); i++) {
        Edge edge = edges.edgeAt( i );
        DependencySet ds = edge.getDepends();
View Full Code Here

          return Bool.UNKNOWN;
        }

        EdgeList edges = ind.getRNeighborEdges( role );

        Bool ot = Bool.FALSE;

        for( int e = 0; e < edges.size(); e++ ) {
          Edge edge = edges.edgeAt( e );

          if( !edge.getDepends().isIndependent() ) {
            ot = Bool.UNKNOWN;
            continue;
          }

          Individual y = (Individual) edge.getNeighbor( ind );

          // TODO all this stuff in one method - this is only for
          // handling AND
          // clauses - they are implemented in abox.isKnownType
          ot = ot.or( abox.isKnownType( y, d, SetUtils.<ATermAppl>emptySet() ) );// y.hasObviousType(d));

          if( ot.isTrue() ) {
            return ot;
          }
        }
        return ot;
      }
View Full Code Here

  private void expand(Individual x) {
    checkTimer();

    if( !abox.doExplanation() && PelletOptions.USE_ADVANCED_CACHING ) {
      Timer t = abox.getKB().timers.startTimer( "cache" );
      Bool cachedSat = isCachedSat( x );
      t.stop();
      if( cachedSat.isKnown() ) {
        if( cachedSat.isTrue() ) {
          if( log.isLoggable( Level.FINE ) )
            log.fine( "Stop cached " + x );
          mayNeedExpanding.remove( 0 );
        }
        else {
View Full Code Here

    if( x.isRoot() )
      return Bool.UNKNOWN;

    ATermAppl c = createConcept( x );
   
    Bool sat = isCachedSat( c );

    if( sat.isUnknown() ) {
      if( log.isLoggable( Level.FINEST ) )
        log.finest( "??? Cache miss for " + c );
      cachedNodes.put( x, c );
    }
    else if( !cacheSafety.isSafe( c, x ) ) {
View Full Code Here

   
    return sat;
  }
 
  private Bool isCachedSat(ATermAppl c) {
    Bool sat = abox.getCachedSat(c);

    // return if we have the cached result or the class is not an intersection
    if (sat.isKnown() || !ATermUtils.isAnd(c))
      return sat;

    sat = null;

    // try to find the satisfiability of an intersection by inspecting the elements inside the conjunction
    ATermList list = (ATermList) c.getArgument(0);
    CachedNode cached1 = null;
    CachedNode cached2 = null;
    for (; !list.isEmpty(); list = list.getNext()) {
      ATermAppl d = (ATermAppl) list.getFirst();
      CachedNode node = abox.getCached(d);

      if (node == null || !node.isComplete()) {
        // we don't have complete sat info about an element so give up
        sat = Bool.UNKNOWN;
        break;
      }
      else if (node.isBottom()) {
        // an element is unsat so the intersection is unsat
        sat = Bool.FALSE;
        break;
      }
      else if (node.isTop()) {
        // do nothing, intersection with TOP is redundant
      }
      else {
        if (cached1 == null)
          cached1 = node;
        else if (cached2 == null)
          cached2 = node;
        else {
          // if there are more than two nodes we cannot do mergability check so give up
          sat = Bool.UNKNOWN;
          break;
        }
      }
    }

    // we can do mergability check
    if (sat == null) {
      if (cached2 == null) {
        // only one element in the intersection that is not TOP so the intersection is
        // satisfiable
        sat = Bool.TRUE;
      }
      else {
        // there are two classes in the intersection, so check if the cahed models can
        // be merged without a clash
        sat = abox.getCache().isMergable(abox.getKB(), cached1, cached2);
      }
    }

    if (sat.isKnown()) {
      abox.getCache().putSat(c, sat.isTrue());
    }

    return sat; 
  }
View Full Code Here

    this.maxSize = maxSize;
  }
 

  private Bool checkTrivialClash(CachedNode node1, CachedNode node2) {
    Bool result = null;

    if( node1.isBottom() || node2.isBottom() ) {
      result = Bool.TRUE;
    }
    else if( node1.isTop() || node2.isTop() ) {
View Full Code Here

    return result;
  }

  public Bool isMergable(KnowledgeBase kb, CachedNode root1, CachedNode root2) {
    Bool result = checkTrivialClash( root1, root2 );
    if( result != null )
      return result.not();

    CachedNode roots[] = new CachedNode[] { root1, root2 };
    boolean isIndependent = root1.isIndependent() && root2.isIndependent();
   
    int root = roots[0].getDepends().size() < roots[1].getDepends().size()
      ? 0
      : 1;
    int otherRoot = 1 - root;
    for( Entry<ATermAppl, DependencySet> entry : roots[root].getDepends().entrySet() ) {
      ATermAppl c = entry.getKey();
      ATermAppl notC = ATermUtils.negate( c );

      DependencySet ds2 = roots[otherRoot].getDepends().get( notC );
      if( ds2 != null ) {
        DependencySet ds1 = entry.getValue();
        boolean allIndependent = isIndependent && ds1.isIndependent() && ds2.isIndependent();
        if( allIndependent ) {
          if( log.isLoggable( Level.FINE ) )
            log.fine( roots[root] + " has " + c + " " + roots[otherRoot]
                + " has negation " + ds1.max() + " " + ds2.max() );
          return Bool.FALSE;
        }
        else {
          if( log.isLoggable( Level.FINE ) )
            log.fine( roots[root] + " has " + c + " " + roots[otherRoot]
                + " has negation " + ds1.max() + " " + ds2.max() );
          result = Bool.UNKNOWN;
        }
      }
    }

    // if there is a suspicion there is no way to fix it later so return now
    if( result != null )
      return result;

    for( root = 0; root < 2; root++ ) {
      otherRoot = 1 - root;

      for( ATermAppl c : roots[root].getDepends().keySet() ) {
        if( ATermUtils.isPrimitive( c ) ) {
          result = checkBinaryClash( kb, c, roots[root], roots[otherRoot] );
        }
        else if( ATermUtils.isAllValues( c ) ) {
          result = checkAllValuesClash( kb, c, roots[root], roots[otherRoot] );
        }
        else if( ATermUtils.isNot( c ) ) {
          ATermAppl arg = (ATermAppl) c.getArgument( 0 );
          if( ATermUtils.isMin( arg ) ) {       
            result = checkMaxClash( kb, c, roots[root], roots[otherRoot] );
          }
          else if( ATermUtils.isSelf( arg ) ) {
            result = checkSelfClash( kb, arg, roots[root], roots[otherRoot] );
          }
        }

        if( result != null )
          return result;
      }
    }
   
    boolean bothNamedIndividuals = (root1 instanceof Individual && root2 instanceof Individual);

    if( kb.getExpressivity().hasFunctionality() || kb.getExpressivity().hasFunctionalityD() ) {
      root = (roots[0].getOutEdges().size() + roots[0].getInEdges().size()) < (roots[1]
          .getOutEdges().size() + roots[1].getInEdges().size())
        ? 0
        : 1;
      otherRoot = 1 - root;

      if( bothNamedIndividuals )
        result = checkFunctionalityClashWithDifferents( (Individual) roots[root],
            (Individual) roots[otherRoot] );
      else
        result = checkFunctionalityClash( roots[root], roots[otherRoot] );
      if( result != null )
        return result;
    }

    if( bothNamedIndividuals ) {
      Individual ind1 = (Individual) root1;
      Individual ind2 = (Individual) root2;
      DependencySet ds = ind1.getDifferenceDependency( ind2 );
      if( ds != null ) {
        return ds.isIndependent()
          ? Bool.FALSE
          : Bool.UNKNOWN;
      }
     
      for (Edge edge : ind1.getOutEdges()) {
        if (edge.getRole().isIrreflexive() && edge.getTo().equals(ind2)) {
          return edge.getDepends().isIndependent()
            ? Bool.FALSE
            : Bool.UNKNOWN;
        }
      }
     
      for (Edge edge : ind1.getInEdges()) {
        if (edge.getRole().isIrreflexive() && edge.getFrom().equals(ind2)) {
          return edge.getDepends().isIndependent()
            ? Bool.FALSE
            : Bool.UNKNOWN;
        }
      }
    }
   
    if( kb.getExpressivity().hasDisjointRoles() ) {
      Bool clash = checkDisjointPropertyClash( root1, root2 );
      if (clash != null ) {
        if( log.isLoggable( Level.FINE ) )
          log.fine( "Cannot determine if two named individuals can be merged or not: " + roots[0] + "  + roots[1]" );
        return Bool.UNKNOWN;   
      }
View Full Code Here

    return null;
  }
 
  private Bool checkFunctionalityClashWithDifferents(Individual root, Individual otherRoot) {
    Bool result = null;
    for( Edge edge : root.getOutEdges() ) {
      Role role = edge.getRole();

      if( !role.isFunctional() )
        continue;
View Full Code Here

    return null;
  }

  public Bool checkNominalEdges(KnowledgeBase kb, CachedNode pNode, CachedNode cNode) {
    Bool result = Bool.UNKNOWN;

    if( pNode.isComplete() && cNode.isComplete() && cNode.isIndependent() ) {
      result = checkNominalEdges( kb, pNode, cNode, false );
      if( result.isUnknown() )
        result = checkNominalEdges( kb, pNode, cNode, true );
    }

    return result;
  }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.utils.Bool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.