org.semanticweb.elk.reasoner.saturation
Class ContextImpl

java.lang.Object
  extended by org.semanticweb.elk.reasoner.saturation.ContextImpl
All Implemented Interfaces:
Context

public class ContextImpl
extends Object
implements Context

Context implementation that is used for EL reasoning. It provides data structures for storing and retrieving various types of derived expressions, including computed subsumptions between class expressions.

Author:
Markus Kroetzsch, Frantisek Simancik, "Yevgeny Kazakov"

Field Summary
protected  boolean isInconsistent
          true if owl:Nothing is stored in subsumers_
protected  boolean isSaturated
          true if all derived Subsumer of root_ have been computed.
 
Constructor Summary
ContextImpl(IndexedClassExpression root)
          Construct a new Context for the given root IndexedClassExpression.
 
Method Summary
 boolean addBackwardLink(BackwardLink link)
          Adds the given BackwardLink to this Context.
 boolean addDisjointnessAxiom(IndexedDisjointnessAxiom disjointnessAxiom)
          Adds one instance of IndexedDisjointnessAxiom to this Context.
 boolean addSubsumer(IndexedClassExpression expression)
          Adds the given IndexedClassExpression to the subsumers of the root IndexedClassExpression of this Context.
 boolean addToDo(Conclusion conclusion)
          Adds the given Conclusion to be processed within this Context.
 boolean containsBackwardLink(BackwardLink link)
           
 boolean containsDisjointnessAxiom(IndexedDisjointnessAxiom axiom)
           
 boolean containsSubsumer(IndexedClassExpression expression)
          Tests whether the given IndexedClassExpression is a subsumer of the root IndexedClassExpression of this Context.
 AbstractChain<ModifiableLinkRule<BackwardLink>> getBackwardLinkRuleChain()
           
 ModifiableLinkRule<BackwardLink> getBackwardLinkRuleHead()
           
 Multimap<IndexedPropertyChain,Context> getBackwardLinksByObjectProperty()
           
 IndexedClassExpression getRoot()
           
 Set<IndexedClassExpression> getSubsumers()
           
 boolean inconsistencyDisjointnessAxiom(IndexedDisjointnessAxiom axiom)
           
 boolean isEmpty()
           
 boolean isInconsistent()
           
 boolean isSaturated()
           
 boolean removeBackwardLink(BackwardLink link)
           
 boolean removeDisjointnessAxiom(IndexedDisjointnessAxiom axiom)
          Removes one instance of the given IndexedDisjointnessAxiom from this Context.
 void removeLinks()
          removes links to the next and previous contexts, effectively removing this Context from the chain of contexts
 boolean removeSubsumer(IndexedClassExpression expression)
          Removes the given IndexedClassExpression from the subsumers of the root IndexedClassExpression of this Context.
 boolean setInconsistent(boolean inconsistent)
          Sets the inconsistency of this Context to the given value.
 boolean setSaturated(boolean saturated)
          Marks this Context as saturated.
 Conclusion takeToDo()
          Removes and returns one of the unprocessed Conclusions of this context.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isSaturated

protected volatile boolean isSaturated
true if all derived Subsumer of root_ have been computed.


isInconsistent

protected volatile boolean isInconsistent
true if owl:Nothing is stored in subsumers_

Constructor Detail

ContextImpl

public ContextImpl(IndexedClassExpression root)
Construct a new Context for the given root IndexedClassExpression. Initially, the context is not active.

Parameters:
root -
Method Detail

getRoot

public IndexedClassExpression getRoot()
Specified by:
getRoot in interface Context
Returns:
the IndexedClassExpression for which this Context is assigned. This may never been null.

removeLinks

public void removeLinks()
Description copied from interface: Context
removes links to the next and previous contexts, effectively removing this Context from the chain of contexts

Specified by:
removeLinks in interface Context

getSubsumers

public Set<IndexedClassExpression> getSubsumers()
Specified by:
getSubsumers in interface Context
Returns:
the object representing all derived (implied) IndexedClassExpressions that subsume the root IndexedClassExpression

addSubsumer

public boolean addSubsumer(IndexedClassExpression expression)
Description copied from interface: Context
Adds the given IndexedClassExpression to the subsumers of the root IndexedClassExpression of this Context.

Specified by:
addSubsumer in interface Context
Parameters:
expression - the IndexedClassExpression to be added as a susbumer of the root IndexedClassExpression of this Context.
Returns:
true if the set of subsumers of this Context has changed as the result of calling this method, i.e., the input IndexedClassExpression was not a subsumer before. This method is not thread safe.

containsSubsumer

public boolean containsSubsumer(IndexedClassExpression expression)
Description copied from interface: Context
Tests whether the given IndexedClassExpression is a subsumer of the root IndexedClassExpression of this Context.

Specified by:
containsSubsumer in interface Context
Parameters:
expression - the IndexedClassExpression to be tested for this Context
Returns:
true if the given IndexedClassExpression is a subsumer of the root in this Context. This method is not thread safe.

removeSubsumer

public boolean removeSubsumer(IndexedClassExpression expression)
Description copied from interface: Context
Removes the given IndexedClassExpression from the subsumers of the root IndexedClassExpression of this Context.

Specified by:
removeSubsumer in interface Context
Parameters:
expression - the IndexedClassExpression to be removed from the subsumers of the root in this Context
Returns:
true if the set of subsumers of this Context has changed as the result of calling this method, i.e., the input IndexedClassExpression was a subsumer before. This method is not thread safe.

isInconsistent

public boolean isInconsistent()
Specified by:
isInconsistent in interface Context
Returns:
true if a contradiction has not been derived for the root IndexedClassExpression

setInconsistent

public boolean setInconsistent(boolean inconsistent)
Description copied from interface: Context
Sets the inconsistency of this Context to the given value.

Specified by:
setInconsistent in interface Context
Returns:
the previous inconsistency value

getBackwardLinksByObjectProperty

public Multimap<IndexedPropertyChain,Context> getBackwardLinksByObjectProperty()
Specified by:
getBackwardLinksByObjectProperty in interface Context
Returns:
the Contexts from which there exists an (implied) "existential relation" with this Context indexed by the IndexedPropertyChain of this relation. For example, if the input ontology contains an axiom SubClassOf(:A ObjectSomeValuesFrom(:r :B) then an existential link between the context with root :A and the context with root :B with property :r will be created. For technical reasons, this link is stored in the context for :B, as a "backward link" <:r, :A> indexed by :r in the Multimap returned by this method. The returned Multimap is not thread safe and should be accessed from at most one thread at a time. This is never null.

containsBackwardLink

public boolean containsBackwardLink(BackwardLink link)
Specified by:
containsBackwardLink in interface Context

addDisjointnessAxiom

public boolean addDisjointnessAxiom(IndexedDisjointnessAxiom disjointnessAxiom)
Description copied from interface: Context
Adds one instance of IndexedDisjointnessAxiom to this Context.

Specified by:
addDisjointnessAxiom in interface Context
Parameters:
disjointnessAxiom - the IndexedDisjointnessAxiom to be added to this Context
Returns:
true if adding the axiom changes the state of this Context, i.e., some rules need to be applied

removeDisjointnessAxiom

public boolean removeDisjointnessAxiom(IndexedDisjointnessAxiom axiom)
Description copied from interface: Context
Removes one instance of the given IndexedDisjointnessAxiom from this Context.

Specified by:
removeDisjointnessAxiom in interface Context
Parameters:
axiom - the IndexedDisjointnessAxiom to be removed from this Context
Returns:
true if the state of this Context has changed as the result of calling this method, i.e., the context has contained this IndexedDisjointnessAxiom

containsDisjointnessAxiom

public boolean containsDisjointnessAxiom(IndexedDisjointnessAxiom axiom)
Specified by:
containsDisjointnessAxiom in interface Context
Parameters:
axiom - the IndexedDisjointnessAxiom to be checked for occurrences in this Context
Returns:
true if the given IndexedDisjointnessAxiom occurs in this Context

inconsistencyDisjointnessAxiom

public boolean inconsistencyDisjointnessAxiom(IndexedDisjointnessAxiom axiom)
Specified by:
inconsistencyDisjointnessAxiom in interface Context
Parameters:
axiom - the IndexedDisjointnessAxiom to be checked for causing inconsistency in this Context
Returns:
true if the given IndexedDisjointnessAxiom causes inconsistency of this Context

setSaturated

public boolean setSaturated(boolean saturated)
Description copied from interface: Context
Marks this Context as saturated. This means that all all Conclusions for this Context are already computed.

Specified by:
setSaturated in interface Context
Returns:
the previous value of the saturation state for this Context

isSaturated

public boolean isSaturated()
Specified by:
isSaturated in interface Context
Returns:
true if all Conclusions for this Context, as determined by the function Conclusion.getSourceContext(Context), are already computed.

addBackwardLink

public boolean addBackwardLink(BackwardLink link)
Description copied from interface: Context
Adds the given BackwardLink to this Context.

Specified by:
addBackwardLink in interface Context
Parameters:
link - the BackwardLink being added to this Context
Returns:
true if this Context has changed as the result this method, i.e., the given BackwardLink has not been added before to this Context. This method is not thread safe.

removeBackwardLink

public boolean removeBackwardLink(BackwardLink link)
Specified by:
removeBackwardLink in interface Context

getBackwardLinkRuleChain

public AbstractChain<ModifiableLinkRule<BackwardLink>> getBackwardLinkRuleChain()
Specified by:
getBackwardLinkRuleChain in interface Context
Returns:
the Chain view of all backward link rules assigned to this Context; this is always not null. This method can be used for convenient search and modification (addition and deletion) of the rules using the methods of the Chain interface without without worrying about null values.

getBackwardLinkRuleHead

public ModifiableLinkRule<BackwardLink> getBackwardLinkRuleHead()
Specified by:
getBackwardLinkRuleHead in interface Context
Returns:
the first backward link rule assigned to this Context, or null if there no such rules; all other rules can be obtained by traversing over Link.next(); this method should be used to access the rules without modifying them.

addToDo

public boolean addToDo(Conclusion conclusion)
Description copied from interface: Context
Adds the given Conclusion to be processed within this Context. The method returns true when this is the first unprocessed conclusion added to the context after it is being created or cleared (that is, Context.takeToDo() has returned null). If several threads call this method at the same time for the same Context then at most one of these method returns true, unless Context.takeToDo() is called as well.

Specified by:
addToDo in interface Context
Parameters:
conclusion - the Conclusion added to be processed within this Context
Returns:
true when the added conclusion is the first unprocessed conclusion for this context
See Also:
Context.takeToDo()

takeToDo

public Conclusion takeToDo()
Description copied from interface: Context
Removes and returns one of the unprocessed Conclusions of this context. This method is thread safe and can be used concurrently with the method Context.addToDo(Conclusion).

Specified by:
takeToDo in interface Context
Returns:
some unprocessed Conclusion of this context, if there is one, or null if there is no such Conclusion
See Also:
Context.addToDo(Conclusion)

toString

public String toString()
Overrides:
toString in class Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Context
Returns:
true if the context is empty


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.