public class Justification extends Object implements Comparable<Justification>
A justification for a StatementEnum.Inferred
statement. The head is
the entailed statement. The tail of the justification is one or more triple
pattern(s). Consider rdf1
(?u ?a ?y) -> (?a rdf:type rdf:Property)
Then the triple pattern for the tail is:
(0 ?a 0)
where 0 reprents a IRawTripleStore#NULL
term identifier.
So a justification chain for rdf1
would be:
head := [?a rdf:type rdf:Property] tail := [0 ?a 0]
In fact, the total bindings for the rule are represented as a long[] with the head occupying the 1st N positions in that array and the bindings for the tail appearing thereafter in the declared order of the predicates in the tail.
When a StatementEnum.Explicit
statement is to be retracted from the
database we need to determined whether or not there exists a grounded
justification for that statement (same head). For each justification for that
statement we consider the tail. If there exists either an explicit statement
that satisifies the triple pattern for the tail or if there exists an
inference that satisifies the triple pattern for the tail and the inference
can be proven to be grounded by recursive examination of its justifications,
then the head is still valid and is converted from an explicit statement into
an inference.
This looks more or less like: Find all statements matching the pattern. If any are explicit, then that part of the tail is grounded. If none are explicit, then chase the justification recursively. Only retract a justification when it can no longer be grounded.
The concept of grounded vs ungrounded justifications is described in Inferencing and Truth Maintenance in RDF Schema : Exploring a naive practical approach by Jeen Broekstra and Arjohn Kampman.
Modifier and Type | Class and Description |
---|---|
static class |
Justification.VisitedSPOSet
A collection of
SPO objects (either fully bound or query
patterns) that have already been visited. |
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
True iff the
log level is DEBUG or less. |
static boolean |
INFO
True iff the
log level is INFO or less. |
protected static org.apache.log4j.Logger |
log |
IRule |
rule
From the ctor, but not persisted.
|
Constructor and Description |
---|
Justification(int N,
IV[] ids)
Used by the
JustificationTupleSerializer to materialize
justifications. |
Justification(ISolution solution)
Construct a justification directly an
ISolution . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Justification o)
Places the justifications into an ordering that clusters them based on
the entailment is being justified.
|
boolean |
equals(Justification o) |
SPO |
getHead()
Returns the head as an
SPO . |
static byte[] |
getKey(IKeyBuilder keyBuilder,
Justification jst)
Serialize a justification as an index key.
|
SPO[] |
getTail()
Returns the tail as an
SPO []. |
static boolean |
isGrounded(InferenceEngine inf,
TempTripleStore focusStore,
AbstractTripleStore db,
ISPO head,
boolean testHead,
boolean testFocusStore,
Justification.VisitedSPOSet visited) |
static boolean |
isGrounded(InferenceEngine inf,
TempTripleStore focusStore,
AbstractTripleStore db,
SPO head,
boolean testHead,
boolean testFocusStore)
Return true iff a grounded justification chain exists for the statement.
|
String |
toString() |
String |
toString(AbstractTripleStore db) |
protected static final transient org.apache.log4j.Logger log
public static final boolean INFO
log
level is INFO or less.public static final boolean DEBUG
log
level is DEBUG or less.public final transient IRule rule
public Justification(ISolution solution)
ISolution
.solution
- The solution.
FIXME If [rule == null] then this ctor will thrown an
AssertionError
. In the original rule execution layer the
bindings were are long[] and the were encoded by position. At the moment
the bindingSet is indexed by the IVariable
(essentially by the
variable name). This means that we MUST have the IRule
on hand in
order extract the bindings that we need.
Modify the new rule execution layer to assign variables an integer index in [0:nvars] for each rule and then we can do positional decoding of the binding set and loose the requirement for the rule when generating justifications.
This might not be that important for scale-out since the solutions are, I believe, processed solely in a local buffer for Insert and Delete and only serialized for Query.
public Justification(int N, IV[] ids)
JustificationTupleSerializer
to materialize
justifications.ids
- The bindings on the head and tail(s).public SPO getHead()
SPO
.
Note: The StatementEnum
associated with the head is actually
unknown, but it is marked as StatementEnum.Inferred
in the
returned object. In order to discover the StatementEnum
for the
head you MUST either already know it (this is not uncommon) or you MUST
read one of the statement indices.
public SPO[] getTail()
SPO
[].
Note: The StatementEnum
associated triple patterns in the tail is
actually unknown, but it is marked as StatementEnum.Inferred
in
the returned object. In fact, since the tail consists of triple patterns
and not necessarily fully bound triples, the concept of a
StatementEnum
is not even defined.
public static byte[] getKey(IKeyBuilder keyBuilder, Justification jst)
keyBuilder
- A key builder.public boolean equals(Justification o)
public int compareTo(Justification o)
compareTo
in interface Comparable<Justification>
public String toString(AbstractTripleStore db)
public static boolean isGrounded(InferenceEngine inf, TempTripleStore focusStore, AbstractTripleStore db, SPO head, boolean testHead, boolean testFocusStore)
focusStore
- The focusStore contains the set of statements that are being
retracted from the database. When looking for grounded
justifications we do NOT consider any statement that is found
in this store. This prevents statements that are being
retracted from providing either their own justification or the
justiciation of any other statement that is being retracted at
the same time.db
- The database from which the statements are to be retracted and
in which we will search for grounded justifications.head
- A triple pattern. When invoked on a statement during truth
maintenance this will be fully bound. However, during
recursive processing triple patterns may be encountered in the
tail of Justification
s that are not fully bound. In
such cases we test for any statement matching the triple
pattern that can be proven to be grounded.testHead
- When true
the head will be tested
against the database on entry before seeking a grounded
justification chain. When false
head will not
be tested directly but we will still seek a grounded
justification chain.testFocusStore
- visited
- A set of head (whether fully bound or query patterns) that
have already been considered. This parameter MUST be newly
allocated on each top-level call. It is used in order to avoid
infinite loops by rejecting for further consideration any head
which has already been visited.public static boolean isGrounded(InferenceEngine inf, TempTripleStore focusStore, AbstractTripleStore db, ISPO head, boolean testHead, boolean testFocusStore, Justification.VisitedSPOSet visited)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.