[Pellet-users] query bug?

Antonio Sanchez Ruiz-Granados antonio.sanchez at fdi.ucm.es
Thu May 29 12:47:07 UTC 2008


Hi,

I am working with Pellet 1.5.2 and I am using intensely the incremental 
reasoning feature of this reasoner. I also use SPARQL queries to 
retrieve ABox instances. After making some ABox changes, one of the 
SPARQL queries wasn't working as I expected. The query has the form

ASK { dom:i1 rdf:type dom:C1. dom:i1 rdf:type dom:C2. prob:i2 rdf:type 
dom:C3. }

where {dom:i1, dom:i2} are two instances of my ontology and {dom:C1, 
dom:C2, dom:C3} are concepts.

I started to debug the Pellet java code and I traced it to the method 
execBoolean of the class 
org.mindswap.pellet.query.impl.NoDistVarsQueryExec. I paste the code 
below. Reading this code if any of the query triples is UNKNOWN and the 
query cannot be directly asserted as false, it reaches the point below 
the comment "// do the unavoidable consistency check" where only the 
type of the first constant is checked. My problem was that my query 
should be false because the second instance, but the method only checks 
the first one (so it returns true even when it shouldn't). I have 
changed that part so now it checks all the constants in the query and it 
seems to work right, but I don't know if this is really a bug or I am 
misunderstanding something.

Thanks in advance,
Antonio Sánchez.


    public boolean execBoolean( Query query ) {               
        boolean querySatisfied;
       
        kb = query.getKB();
       
        if( query.getConstants().isEmpty() ) {
            throw new UnsupportedFeatureException(
                "Executing queries with no constants is not implemented 
yet!" );
        }

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

        List patterns = query.getQueryPatterns();
        for(int i = 0; i < patterns.size(); i++) {
            QueryPattern triple = (QueryPattern) patterns.get(i);

            // by default we don't know if triple is satisfied
            Bool tripleSatisfied = Bool.UNKNOWN;
            // we can only check ground triples
            if( triple.isGround() ) {
                tripleSatisfied = triple.isTypePattern()
                    ? kb.isKnownType( triple.getSubject(), 
triple.getObject() )       
                    : kb.hasKnownPropertyValue( triple.getSubject(), 
triple.getPredicate(), triple.getObject());
            }
           
            // 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;
               
                if( log.isTraceEnabled() )
                    log.trace( "Failed triple: " + triple );
               
                break;
            }                   
        }
       
        // if we reached a verdict, return it
        if( allTriplesSatisfied.isKnown() )
            querySatisfied = allTriplesSatisfied.isTrue();
        else {
            // do the unavoidable consistency check
            ATermAppl testInd = (ATermAppl) 
query.getConstants().iterator().next();
            ATermAppl testClass = query.rollUpTo( testInd );
       
            if( log.isTraceEnabled() )
                log.trace( "Boolean query: " + testInd + " -> " + 
testClass );
               
            querySatisfied = kb.isType( testInd, testClass );
        }      

        return querySatisfied;           
    }

-- 
__________________________________________

Antonio A. Sanchez Ruiz-Granados
Dpto. de Ingeniería del Software e Inteligencia Artificial
Facultad de Informática
Universidad Complutense de Madrid
e-mail: antonio.sanchez at fdi.ucm.es
web: http://gaia.fdi.ucm.es/people/antonio/

___________________________________________




More information about the Pellet-users mailing list