com.bigdata.rdf.rules
Class InferenceEngine

java.lang.Object
  extended by com.bigdata.rdf.rules.InferenceEngine

public class InferenceEngine
extends Object

Flyweight object encapsulates some configuration state and provides methods to compute or update the closure of the database. An instance of this is obtained from AbstractTripleStore.getInferenceEngine().

Version:
$Id: InferenceEngine.java 6031 2012-02-16 08:43:46Z mrpersonick $
Author:
Bryan Thompson
TODO:
Improve write efficiency for the proofs - they are slowing things way down. Perhaps turn off the range count metadata inside of the B+Tree for that index? Note that using magic sets or a backward chainer will let us avoid writing proofs altogether since we can prove whether or not a statement is still entailed without recourse to reading proofs chains., explore an option for "owl:sameAs" semantics using destructive merging (the terms are assigned the same term identifier, one of them is treated as a canonical, and there is no way to retract the sameAs assertion). If you take this approach then you must also re-write all existing assertions using the term whose term identifier is changed to be that of another term.

Nested Class Summary
static interface InferenceEngine.Options
          Options for the InferenceEngine.
 
Field Summary
 AbstractTripleStore database
          The database whose closure is being maintained.
protected static boolean DEBUG
          True iff the log level is DEBUG or less.
 DoNotAddFilter doNotAddFilter
          A filter for keeping certain entailments out of the database.
protected  boolean forwardChainOwlEquivalentClass
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_EQUIVALENT_CLASS.
protected  boolean forwardChainOwlEquivalentProperty
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_EQUIVALENT_PROPERTY.
protected  boolean forwardChainOwlHasValue
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_HAS_VALUE.
protected  boolean forwardChainOwlInverseOf
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_INVERSE_OF.
protected  boolean forwardChainOwlSameAsClosure
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_SAMEAS_CLOSURE.
protected  boolean forwardChainOwlSameAsProperties
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_SAMEAS_PROPERTIES.
protected  boolean forwardChainOwlSymmetricProperty
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_SYMMETRIC_PROPERTY.
protected  boolean forwardChainOwlTransitiveProperty
          Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_TRANSITIVE_PROPERTY.
protected  boolean forwardChainRdfTypeRdfsResource
          Set based on InferenceEngine.Options.FORWARD_CHAIN_RDF_TYPE_RDFS_RESOURCE.
protected static boolean INFO
          True iff the log level is INFO or less.
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
InferenceEngine(AbstractTripleStore database)
          Configure InferenceEngine using the properties used to configure the database.
 
Method Summary
 ClosureStats computeClosure(AbstractTripleStore focusStore)
          Compute the forward closure of a focusStore against the database using the algorithm selected by AbstractTripleStore.Options#CLOSURE_CLASS.
 ClosureStats computeClosure(AbstractTripleStore focusStore, boolean justify)
          This variant allows you to explicitly NOT generate Justifications for the computed entailments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

INFO

protected static final boolean INFO
True iff the log level is INFO or less.


DEBUG

protected static final boolean DEBUG
True iff the log level is DEBUG or less.


database

public final AbstractTripleStore database
The database whose closure is being maintained.


doNotAddFilter

public final DoNotAddFilter doNotAddFilter
A filter for keeping certain entailments out of the database. It is configured based on how the InferenceEngine is configured.

See Also:
DoNotAddFilter

forwardChainRdfTypeRdfsResource

protected final boolean forwardChainRdfTypeRdfsResource
Set based on InferenceEngine.Options.FORWARD_CHAIN_RDF_TYPE_RDFS_RESOURCE. When true the InferenceEngine is configured to forward chain and store entailments of the form (x rdf:type rdfs:Resource). When false, those entailments are computed at query time by #backchainIterator(long, long, long).


forwardChainOwlSameAsClosure

protected final boolean forwardChainOwlSameAsClosure
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_SAMEAS_CLOSURE. When true we will forward chain and store the reflexive and transitive closure of owl:sameAs using RuleOwlSameAs1 and RuleOwlSameAs2.

Note: When false, NO owl:sameAs processing will be performed since there is no privision for backward chaining the owl:sameAs closure.


forwardChainOwlSameAsProperties

protected final boolean forwardChainOwlSameAsProperties
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_SAMEAS_PROPERTIES. When true, we will forward chain RuleOwlSameAs2 and RuleOwlSameAs3 which replicate properties on individuals identified as the "same" by owl:sameAs. When false, we will compute those entailments at query time in #backchainIterator(long, long, long).


forwardChainOwlEquivalentProperty

protected final boolean forwardChainOwlEquivalentProperty
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_EQUIVALENT_PROPERTY. When true, we will forward chain and store those entailments. When false, those entailments will NOT be available.


forwardChainOwlEquivalentClass

protected final boolean forwardChainOwlEquivalentClass
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_EQUIVALENT_CLASS. When true, we will forward chain and store those entailments. When false, those entailments will NOT be available.


forwardChainOwlInverseOf

protected final boolean forwardChainOwlInverseOf
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_INVERSE_OF. When true, we will forward chain and store those entailments. When false, those entailments will NOT be available.


forwardChainOwlTransitiveProperty

protected final boolean forwardChainOwlTransitiveProperty
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_TRANSITIVE_PROPERTY. When true, we will forward chain and store those entailments. When false, those entailments will NOT be available.


forwardChainOwlHasValue

protected final boolean forwardChainOwlHasValue
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_HAS_VALUE. When true, we will forward chain and store those entailments. When false, those entailments will NOT be available.


forwardChainOwlSymmetricProperty

protected final boolean forwardChainOwlSymmetricProperty
Set based on InferenceEngine.Options.FORWARD_CHAIN_OWL_SYMMETRIC_PROPERTY. When true, we will forward chain and store those entailments. When false, those entailments will NOT be available.

Constructor Detail

InferenceEngine

public InferenceEngine(AbstractTripleStore database)
Configure InferenceEngine using the properties used to configure the database.

Parameters:
database - The database.
See Also:
AbstractTripleStore.getInferenceEngine()
Method Detail

computeClosure

public ClosureStats computeClosure(AbstractTripleStore focusStore)
Compute the forward closure of a focusStore against the database using the algorithm selected by AbstractTripleStore.Options#CLOSURE_CLASS.

Note: before calling this method with a non-null focusStore, the caller SHOULD examine the statements in the focusStore and then database. For each statement in the focusStore, if this statement exists explicitly in the database then remove it from the focusStore. If this statement exists implicitly in the database. Regardless of whether the statement was explicit or inferred in the database, remove it from the focusStore. This step prevents the needless (and expensive) reapplication of the rules to data already known to the database!

Note: If the focusStore is given, then the entailments will be asserted against the focusStore. Either this method or the caller MUST copy the focusStore onto the database using AbstractTripleStore.copyStatements(AbstractTripleStore, IElementFilter, boolean). If you are loading data from some kind of resource, then see DataLoader which already knows how to do this.

See TruthMaintenance.assertAll(TempTripleStore), which first handles statements already in the database, then calls this method, and finally copies the remaining explicit statements in the focusStore and the entailments into the database.

Parameters:
focusStore - The data set that will be closed against the database (optional). When null the store will be closed against itself.
Returns:
Statistics about the operation.

computeClosure

public ClosureStats computeClosure(AbstractTripleStore focusStore,
                                   boolean justify)
This variant allows you to explicitly NOT generate Justifications for the computed entailments. It is used by the TruthMaintenance class as part of the algorithm for truth maintenance when retracting statements from the database. It SHOULD NOT be used for any other purpose or you may risk failing to generate justifications.

Note: While this is synchronized, there is a stronger constraint on truth maintenance -- only one process can safely update the closure of the database at a time. Concurrent closure updates will result in an incoherent knowledge base (the closure will not be at fixed point but the underlying indices will be coherent). Closure operations MUST be serialized to avoid inconsistency in the knowledge base.

Parameters:
focusStore - The data set that will be closed against the database.
justify - Justifications will be generated iff this flag is true.
Returns:
Statistics about the operation.
See Also:
computeClosure(AbstractTripleStore)


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.