Class ABoxImpl

  • All Implemented Interfaces:
    ABox, openllet.shared.tools.Logging

    public class ABoxImpl
    extends java.lang.Object
    implements ABox

    Copyright: Copyright (c) 2008

    Company: Clark & Parsia, LLC.

    Author:
    Evren Sirin
    • Constructor Detail

      • ABoxImpl

        public ABoxImpl​(KnowledgeBase kb,
                        boolean copyCache)
      • ABoxImpl

        public ABoxImpl​(KnowledgeBase kb,
                        ABoxImpl abox,
                        openllet.aterm.ATermAppl extraIndividual,
                        boolean copyIndividuals)
    • Method Detail

      • getLogger

        public java.util.logging.Logger getLogger()
        Specified by:
        getLogger in interface openllet.shared.tools.Logging
      • getNodeList

        public java.util.List<openllet.aterm.ATermAppl> getNodeList()
        Specified by:
        getNodeList in interface ABox
      • setSourceABox

        public void setSourceABox​(ABox sourceABox)
        Specified by:
        setSourceABox in interface ABox
      • isRulesNotApplied

        public boolean isRulesNotApplied()
        Specified by:
        isRulesNotApplied in interface ABox
      • setRulesNotApplied

        public void setRulesNotApplied​(boolean rulesNotApplied)
        Specified by:
        setRulesNotApplied in interface ABox
      • copy

        public ABoxImpl copy()
        Specified by:
        copy in interface ABox
        Returns:
        a copy of this ABox with all the nodes and edges.
      • copy

        public ABoxImpl copy​(KnowledgeBase kb)
        Specified by:
        copy in interface ABox
        Parameters:
        kb - from witch the ABox is extracted
        Returns:
        a copy of this ABox with all the nodes and edges and the given KB.
      • copy

        public ABoxImpl copy​(openllet.aterm.ATermAppl extraIndividual,
                             boolean copyIndividuals)
        Description copied from interface: ABox
        Create a copy of this ABox with one more additional individual. This is NOT equivalent to create a copy and then add the individual. The order of individuals in the ABox is important to figure out which individuals exist in the original ontology and which ones are created by the tableau algorithm. This function creates a new ABox such that the individual is supposed to exist in the original ontology. This is very important when satisfiability of a concept starts with a pesudo model rather than the initial ABox.
        Specified by:
        copy in interface ABox
        Parameters:
        extraIndividual - Extra _individual to be added to the copy ABox
        copyIndividuals - are the new individual that are supposed to exist in the original ontology.
        Returns:
        a copy of this ABox
      • copyOnWrite

        public void copyOnWrite()
        Specified by:
        copyOnWrite in interface ABox
      • clearCaches

        public void clearCaches​(boolean clearSatCache)
        Clear the pseudo model created for the ABox and concept satisfiability.
        Specified by:
        clearCaches in interface ABox
        Parameters:
        clearSatCache - If true clear concept satisfiability _cache, if false only clear pseudo model.
      • getCachedSat

        public Bool getCachedSat​(openllet.aterm.ATermAppl c)
        Specified by:
        getCachedSat in interface ABox
      • getCached

        public CachedNode getCached​(openllet.aterm.ATermAppl c)
        Specified by:
        getCached in interface ABox
      • isKnownSubClassOf

        public Bool isKnownSubClassOf​(openllet.aterm.ATermAppl c1,
                                      openllet.aterm.ATermAppl c2)
        Specified by:
        isKnownSubClassOf in interface ABox
      • isSubClassOf

        public boolean isSubClassOf​(openllet.aterm.ATermAppl c1,
                                    openllet.aterm.ATermAppl c2)
        Specified by:
        isSubClassOf in interface ABox
      • isSatisfiable

        public boolean isSatisfiable​(openllet.aterm.ATermAppl c)
        Specified by:
        isSatisfiable in interface ABox
      • isSatisfiable

        public boolean isSatisfiable​(openllet.aterm.ATermAppl cParam,
                                     boolean cacheModel)
        Specified by:
        isSatisfiable in interface ABox
      • getObviousInstances

        public CandidateSet<openllet.aterm.ATermAppl> getObviousInstances​(openllet.aterm.ATermAppl c)
        Specified by:
        getObviousInstances in interface ABox
      • getObviousInstances

        public CandidateSet<openllet.aterm.ATermAppl> getObviousInstances​(openllet.aterm.ATermAppl cParam,
                                                                          java.util.Collection<openllet.aterm.ATermAppl> individuals)
        Specified by:
        getObviousInstances in interface ABox
      • getObviousTypes

        public void getObviousTypes​(openllet.aterm.ATermAppl x,
                                    java.util.List<openllet.aterm.ATermAppl> types,
                                    java.util.List<openllet.aterm.ATermAppl> nonTypes)
        Specified by:
        getObviousTypes in interface ABox
      • getObviousSubjects

        public CandidateSet<openllet.aterm.ATermAppl> getObviousSubjects​(openllet.aterm.ATermAppl p,
                                                                         openllet.aterm.ATermAppl o)
        Specified by:
        getObviousSubjects in interface ABox
      • getSubjects

        public void getSubjects​(openllet.aterm.ATermAppl p,
                                openllet.aterm.ATermAppl o,
                                CandidateSet<openllet.aterm.ATermAppl> candidates)
        Specified by:
        getSubjects in interface ABox
      • getObviousSubjects

        public void getObviousSubjects​(openllet.aterm.ATermAppl p,
                                       openllet.aterm.ATermAppl o,
                                       CandidateSet<openllet.aterm.ATermAppl> candidates)
        Specified by:
        getObviousSubjects in interface ABox
      • getObviousObjects

        public void getObviousObjects​(openllet.aterm.ATermAppl pParam,
                                      CandidateSet<openllet.aterm.ATermAppl> candidates)
        Specified by:
        getObviousObjects in interface ABox
      • isKnownType

        public Bool isKnownType​(openllet.aterm.ATermAppl x,
                                openllet.aterm.ATermAppl c)
        Specified by:
        isKnownType in interface ABox
      • isKnownType

        public Bool isKnownType​(openllet.aterm.ATermAppl x,
                                openllet.aterm.ATermAppl c,
                                java.util.Collection<openllet.aterm.ATermAppl> subs)
        Specified by:
        isKnownType in interface ABox
      • isKnownType

        public Bool isKnownType​(Individual pNode,
                                openllet.aterm.ATermAppl concept,
                                java.util.Collection<openllet.aterm.ATermAppl> subs)
        Specified by:
        isKnownType in interface ABox
      • isSameAs

        public boolean isSameAs​(openllet.aterm.ATermAppl ind1,
                                openllet.aterm.ATermAppl ind2)
        Specified by:
        isSameAs in interface ABox
      • isType

        public boolean isType​(openllet.aterm.ATermAppl x,
                              openllet.aterm.ATermAppl cParam)
        Specified by:
        isType in interface ABox
        Parameters:
        x - is an individual
        cParam - is a class
        Returns:
        true if individual x belongs to type c. This is a logical consequence of the KB if in all possible models x belongs to C. This is checked by trying to construct a model where x belongs to not(c).
      • existType

        public boolean existType​(java.util.List<openllet.aterm.ATermAppl> inds,
                                 openllet.aterm.ATermAppl cParam)
        Specified by:
        existType in interface ABox
        Returns:
        true if any of the individuals in the given list belongs to type c.
      • hasObviousPropertyValue

        public Bool hasObviousPropertyValue​(openllet.aterm.ATermAppl s,
                                            openllet.aterm.ATermAppl p,
                                            openllet.aterm.ATermAppl o)
        Specified by:
        hasObviousPropertyValue in interface ABox
      • hasObviousDataPropertyValue

        public Bool hasObviousDataPropertyValue​(openllet.aterm.ATermAppl s,
                                                openllet.aterm.ATermAppl p,
                                                java.lang.Object value)
        Specified by:
        hasObviousDataPropertyValue in interface ABox
      • hasObviousObjectPropertyValue

        public Bool hasObviousObjectPropertyValue​(openllet.aterm.ATermAppl s,
                                                  openllet.aterm.ATermAppl p,
                                                  openllet.aterm.ATermAppl o)
        Specified by:
        hasObviousObjectPropertyValue in interface ABox
      • hasPropertyValue

        public boolean hasPropertyValue​(openllet.aterm.ATermAppl s,
                                        openllet.aterm.ATermAppl p,
                                        openllet.aterm.ATermAppl o)
        Specified by:
        hasPropertyValue in interface ABox
      • getDataPropertyValues

        public java.util.List<openllet.aterm.ATermAppl> getDataPropertyValues​(openllet.aterm.ATermAppl s,
                                                                              Role role,
                                                                              openllet.aterm.ATermAppl datatype)
        Specified by:
        getDataPropertyValues in interface ABox
      • getDataPropertyValues

        public java.util.List<openllet.aterm.ATermAppl> getDataPropertyValues​(openllet.aterm.ATermAppl s,
                                                                              Role role,
                                                                              openllet.aterm.ATermAppl datatype,
                                                                              boolean onlyObvious)
        Specified by:
        getDataPropertyValues in interface ABox
      • getObviousDataPropertyValues

        public java.util.List<openllet.aterm.ATermAppl> getObviousDataPropertyValues​(openllet.aterm.ATermAppl s,
                                                                                     Role prop,
                                                                                     openllet.aterm.ATermAppl datatype)
        Specified by:
        getObviousDataPropertyValues in interface ABox
      • getObjectPropertyValues

        public void getObjectPropertyValues​(openllet.aterm.ATermAppl s,
                                            Role role,
                                            java.util.Set<openllet.aterm.ATermAppl> knowns,
                                            java.util.Set<openllet.aterm.ATermAppl> unknowns,
                                            boolean getSames)
        Specified by:
        getObjectPropertyValues in interface ABox
      • getSimpleObjectPropertyValues

        public void getSimpleObjectPropertyValues​(Individual subj,
                                                  Role role,
                                                  java.util.Set<openllet.aterm.ATermAppl> knowns,
                                                  java.util.Set<openllet.aterm.ATermAppl> unknowns,
                                                  boolean getSames)
        Specified by:
        getSimpleObjectPropertyValues in interface ABox
      • getTransitivePropertyValues

        public void getTransitivePropertyValues​(Individual subj,
                                                Role prop,
                                                java.util.Set<openllet.aterm.ATermAppl> knowns,
                                                java.util.Set<openllet.aterm.ATermAppl> unknowns,
                                                boolean getSames,
                                                java.util.Map<Individual,​java.util.Set<Role>> visited,
                                                boolean isIndependent)
        Specified by:
        getTransitivePropertyValues in interface ABox
      • getSames

        public void getSames​(Individual ind,
                             java.util.Set<openllet.aterm.ATermAppl> knowns,
                             java.util.Set<openllet.aterm.ATermAppl> unknowns)
        Specified by:
        getSames in interface ABox
      • isConsistent

        public boolean isConsistent()
        Specified by:
        isConsistent in interface ABox
        Returns:
        true if this ABox is consistent. Consistent ABox means after applying all the tableau completion rules at least one _branch with no clashes was found
      • isIncConsistent

        public boolean isIncConsistent()
        Check the consistency of this ABox using the incremental consistency checking approach
        Specified by:
        isIncConsistent in interface ABox
        Returns:
        true if this ABox is consistent, using the incremental consistency checking approach
      • getInEdges

        public EdgeList getInEdges​(openllet.aterm.ATerm x)
        Specified by:
        getInEdges in interface ABox
      • getOutEdges

        public EdgeList getOutEdges​(openllet.aterm.ATerm x)
        Specified by:
        getOutEdges in interface ABox
      • getLiteral

        public Literal getLiteral​(openllet.aterm.ATerm x)
        Specified by:
        getLiteral in interface ABox
      • getNode

        public Node getNode​(openllet.aterm.ATerm x)
        Specified by:
        getNode in interface ABox
      • addType

        public void addType​(openllet.aterm.ATermAppl x,
                            openllet.aterm.ATermAppl c)
        Specified by:
        addType in interface ABox
      • addType

        public void addType​(openllet.aterm.ATermAppl x,
                            openllet.aterm.ATermAppl cParam,
                            DependencySet dsParam)
        Specified by:
        addType in interface ABox
      • addEdge

        public Edge addEdge​(openllet.aterm.ATermAppl p,
                            openllet.aterm.ATermAppl s,
                            openllet.aterm.ATermAppl o,
                            DependencySet dsParam)
        Specified by:
        addEdge in interface ABox
      • removeNode

        public boolean removeNode​(openllet.aterm.ATermAppl x)
        Remove the given node from the node map which maps names to nodes. Does not remove the node from the node list or other nodes' edge lists.
        Specified by:
        removeNode in interface ABox
        Parameters:
        x - is a node.
        Returns:
        true if something have been remove. false if there was nothing to remove.
      • removeType

        public void removeType​(openllet.aterm.ATermAppl x,
                               openllet.aterm.ATermAppl c)
        Specified by:
        removeType in interface ABox
      • addLiteral

        public Literal addLiteral​(DependencySet ds)
        Description copied from interface: ABox
        Add a new literal to the ABox. This function is used only when the literal value does not have a known value, e.g. applyMinRule would create such a literal.
        Specified by:
        addLiteral in interface ABox
        Returns:
        the literal added.
      • addLiteral

        public Literal addLiteral​(openllet.aterm.ATermAppl dataValue)
        Add a new literal to the ABox. Literal will be assigned a fresh unique name.
        Specified by:
        addLiteral in interface ABox
        Parameters:
        dataValue - A literal ATerm which should be constructed with one of ATermUtils.makeXXXLiteral functions
        Returns:
        Literal object that has been created
      • addSame

        public void addSame​(openllet.aterm.ATermAppl x,
                            openllet.aterm.ATermAppl y)
        Specified by:
        addSame in interface ABox
      • addDifferent

        public void addDifferent​(openllet.aterm.ATermAppl x,
                                 openllet.aterm.ATermAppl y)
        Specified by:
        addDifferent in interface ABox
      • addAllDifferent

        public void addAllDifferent​(openllet.aterm.ATermList list)
        Description copied from interface: ABox
        Say that all the term of the list are different from each-other.
        Specified by:
        addAllDifferent in interface ABox
        Parameters:
        list - of different element.
      • isNode

        public boolean isNode​(openllet.aterm.ATerm x)
        Specified by:
        isNode in interface ABox
      • createUniqueName

        public final openllet.aterm.ATermAppl createUniqueName​(boolean isNominal)
        Specified by:
        createUniqueName in interface ABox
      • getNodes

        public final java.util.Map<openllet.aterm.ATermAppl,​Node> getNodes()
        Specified by:
        getNodes in interface ABox
      • getNodeNames

        public final java.util.List<openllet.aterm.ATermAppl> getNodeNames()
        Specified by:
        getNodeNames in interface ABox
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isComplete

        public boolean isComplete()
        Specified by:
        isComplete in interface ABox
        Returns:
        Returns the isComplete.
      • setComplete

        public void setComplete​(boolean isComplete)
        Specified by:
        setComplete in interface ABox
        Parameters:
        isComplete - The isComplete to set.
      • isClosed

        public boolean isClosed()
        Specified by:
        isClosed in interface ABox
        Returns:
        true if Abox is closed.
      • setClash

        public void setClash​(Clash clash)
        Specified by:
        setClash in interface ABox
      • getRole

        public Role getRole​(openllet.aterm.ATerm r)
        Convenience function to get the named role.
        Specified by:
        getRole in interface ABox
        Parameters:
        r - is the name of the role
        Returns:
        the named role.
      • getRBox

        public RBox getRBox()
        Return the RBox
        Specified by:
        getRBox in interface ABox
        Returns:
        the RBox
      • getTBox

        public TBox getTBox()
        Return the TBox
        Specified by:
        getTBox in interface ABox
        Returns:
        the TBox
      • getBranchIndex

        public int getBranchIndex()
        Return the _current branch number. Branches are created when a non-deterministic rule, e.g. disjunction or max rule, is being applied.
        Specified by:
        getBranchIndex in interface ABox
        Returns:
        Returns the branch.
      • setBranchIndex

        public void setBranchIndex​(int branch)
        Description copied from interface: ABox
        Set the _branch number (should only be called when backjumping is in progress)
        Specified by:
        setBranchIndex in interface ABox
      • incrementBranch

        public void incrementBranch()
        Description copied from interface: ABox
        Increment the branch number (should only be called when a non-deterministic rule, e.g. disjunction or max rule, is being applied)
        Specified by:
        incrementBranch in interface ABox
      • isInitialized

        public boolean isInitialized()
        Check if the ABox is ready to be completed.
        Specified by:
        isInitialized in interface ABox
        Returns:
        Returns the initialized.
      • setInitialized

        public void setInitialized​(boolean initialized)
        Specified by:
        setInitialized in interface ABox
      • doExplanation

        public final boolean doExplanation()
        Checks if the clashExplanation is turned on.
        Specified by:
        doExplanation in interface ABox
        Returns:
        Returns the doExplanation.
      • setDoExplanation

        public void setDoExplanation​(boolean doExplanation)
        Description copied from interface: ABox
        Enable/disable clashExplanation generation
        Specified by:
        setDoExplanation in interface ABox
        Parameters:
        doExplanation - The doExplanation to set.
      • getExplanation

        public java.lang.String getExplanation()
        Specified by:
        getExplanation in interface ABox
      • getExplanationSet

        public java.util.Set<openllet.aterm.ATermAppl> getExplanationSet()
        Specified by:
        getExplanationSet in interface ABox
      • getBranches

        public java.util.List<Branch> getBranches()
        Returns the branches.
        Specified by:
        getBranches in interface ABox
        Returns:
        the branches.
      • validate

        public void validate()
        Validate all the edges in the ABox nodes. Used to find bugs in the copy and detach/attach functions.
        Specified by:
        validate in interface ABox
      • validateTypes

        public void validateTypes​(Individual node,
                                  java.util.List<openllet.aterm.ATermAppl> negatedTypes)
        Specified by:
        validateTypes in interface ABox
      • printTree

        public void printTree​(java.io.PrintStream stream)
        Print the ABox as a completion tree (child nodes are indented).
        Specified by:
        printTree in interface ABox
        Parameters:
        stream - is where to print
      • setKeepLastCompletion

        public void setKeepLastCompletion​(boolean keepLastCompletion)
        Specified by:
        setKeepLastCompletion in interface ABox
      • size

        public int size()
        Specified by:
        size in interface ABox
        Returns:
        the number of nodes in the ABox. This number includes both the individuals and the literals.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface ABox
        Returns:
        true if there are no individuals in the ABox.
      • setSyntacticUpdate

        public void setSyntacticUpdate​(boolean val)
        Description copied from interface: ABox
        Set whether changes to the update should be treated as syntactic updates, i.e., if the changes are made on explicit source axioms. This is used for the completion queue for incremental consistency checking purposes.
        Specified by:
        setSyntacticUpdate in interface ABox
        Parameters:
        val - The value
      • isSyntacticUpdate

        public boolean isSyntacticUpdate()
        Description copied from interface: ABox
        Set whether changes to the update should be treated as syntactic updates, i.e., if the changes are made on explicit source axioms. This is used for the completion _queue for incremental consistency checking purposes.
        Specified by:
        isSyntacticUpdate in interface ABox
        Returns:
        the value
      • reset

        public void reset()
        Reset the ABox to contain only asserted information. Any ABox assertion added by tableau rules will be removed.
        Specified by:
        reset in interface ABox
      • resetQueue

        public void resetQueue()
        Specified by:
        resetQueue in interface ABox
      • setAnonCount

        public int setAnonCount​(int anonCount)
        Specified by:
        setAnonCount in interface ABox
        Parameters:
        anonCount - the anonCount to set
        Returns:
        the count set.
      • getAnonCount

        public int getAnonCount()
        Specified by:
        getAnonCount in interface ABox
        Returns:
        the anonCount
      • getDisjBranchStats

        public java.util.Map<openllet.aterm.ATermAppl,​int[]> getDisjBranchStats()
        Specified by:
        getDisjBranchStats in interface ABox
        Returns:
        the disjBranchStats
      • setChanged

        public void setChanged​(boolean changed)
        Specified by:
        setChanged in interface ABox
        Parameters:
        changed - the changed to set
      • isChanged

        public boolean isChanged()
        Specified by:
        isChanged in interface ABox
        Returns:
        the changed
      • getToBeMerged

        public java.util.List<NodeMerge> getToBeMerged()
        Specified by:
        getToBeMerged in interface ABox
        Returns:
        the toBeMerged