Package org.mindswap.pellet.utils

Examples of org.mindswap.pellet.utils.Bool


    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

    }

    c = ATermUtils.normalize( c );

    if( isClassified() && !doExplanation() ) {
      Bool equivToBottom = builder.getTaxonomy().isEquivalent( ATermUtils.BOTTOM, c );
      if( equivToBottom.isKnown() )
        return equivToBottom.isFalse();
    }

    return abox.isSatisfiable( c );
  }
View Full Code Here

    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 );
View Full Code Here

    // normalize concepts
    c1 = ATermUtils.normalize( c1 );
    c2 = ATermUtils.normalize( c2 );

    if( isClassified() && !doExplanation() ) {
      Bool isSubNode = builder.getTaxonomy().isSubNodeOf( c1, c2 );
      if( isSubNode.isKnown() )
        return isSubNode.isTrue();
    }

    return abox.isSubClassOf( c1, c2 );
  }
View Full Code Here

    // normalize concepts
    c1 = ATermUtils.normalize( c1 );
    c2 = ATermUtils.normalize( c2 );

    if( !doExplanation() ) {
      Bool isEquivalent = Bool.UNKNOWN;
      if( isClassified() )
        isEquivalent = builder.getTaxonomy().isEquivalent( c1, c2 );

      if( isEquivalent.isUnknown() )
        isEquivalent = abox.isKnownSubClassOf( c1, c2 ).and(
            abox.isKnownSubClassOf( c2, c1 ) );

      if( isEquivalent.isKnown() )
        return isEquivalent.isTrue();
    }

    ATermAppl notC2 = ATermUtils.negate( c2 );
    ATermAppl notC1 = ATermUtils.negate( c1 );
    ATermAppl c1NotC2 = ATermUtils.makeAnd( c1, notC2 );
View Full Code Here

   
    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 );       
      }
View Full Code Here

          subs = taxonomy.getFlattenedSubs( c, false );
      }

      List<ATermAppl> unknowns = new ArrayList<ATermAppl>();
      for( ATermAppl x : individuals ) {
        Bool isType = abox.isKnownType( x, c, subs );
        if( isType.isTrue() )
          knowns.add( x );
        else if( isType.isUnknown() )
          unknowns.add( x );
      }

      if( !unknowns.isEmpty() ) {
        if( PelletOptions.INSTANCE_RETRIEVAL == InstanceRetrievalMethod.TRACING_BASED
View Full Code Here

    final KnowledgeBase kb = query.getKB();
    kb.ensureConsistency();

    // unless proven otherwise all (ground) triples are satisfied
    Bool allTriplesSatisfied = Bool.TRUE;

    for( final QueryAtom atom : query.getAtoms() ) {
      // by default we don't know if triple is satisfied
      Bool tripleSatisfied = Bool.UNKNOWN;
      // we can only check ground triples
      if( atom.isGround() ) {
        final List<ATermAppl> arguments = atom.getArguments();

        switch ( atom.getPredicate() ) {
        case Type:
          tripleSatisfied = kb.isKnownType( arguments.get( 0 ), arguments.get( 1 ) );
          break;
        case Annotation:
        case PropertyValue:
          tripleSatisfied = kb.hasKnownPropertyValue( arguments.get( 0 ), arguments
              .get( 1 ), arguments.get( 2 ) );
          break;
        default:
          tripleSatisfied = Bool.UNKNOWN;
        }
      }

      // if we cannot decide the truth value of this triple (without a
      // consistency
      // check) then over all truth value cannot be true. However, we will
      // continue
      // to see if there is a triple that is obviously false
      if( tripleSatisfied.isUnknown() )
        allTriplesSatisfied = Bool.UNKNOWN;
      else if( tripleSatisfied.isFalse() ) {
        // if one triple is false then the whole query, which is the
        // conjunction of
        // all triples, is false. We can stop now.
        allTriplesSatisfied = Bool.FALSE;
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.