inference = new InferenceEnvironment(null);
continuation = ConsList.empty();
}
public RelationshipDelta getInferredDelta(RelationshipPredicate rel, Substitution sub) {
RelationshipDelta delta;
if (variant != Variant.PRAGMATIC_VARIANT)
return null;
//check to see if we've looked for this relationship before with our existing continuation...
if (alreadyLookingForRel(rel, sub))
return null;
continuation = ConsList.cons(new Pair<RelationshipPredicate, Substitution>(rel, sub), continuation);
for (InferredRel inf : inference) {
//first, find out what substitutions are needed to make rel. There might
//be more than one if more than one effect could be the one to use.
List<Substitution> subs = inf.canProduce(rel, sub);
for (Substitution partSub : subs) {
//bind up the rest of the variables that we need
List<Substitution> finalSubs = this.allValidSubs(partSub, inf.getFreeVars());
//and then only look at definite ones (we want true/falses, not unknowns!)
for (Substitution finalSub : finalSubs) {
ThreeValue val = inf.getPredicate().getTruth(this, finalSub);
if (val != ThreeValue.TRUE)
continue;
//ok, see if this conflicts with what we have
delta = new RelationshipDelta();
for (Effect effect : inf.getEffects())
delta.override(effect.makeEffects(this, finalSub));
//if it doesn't conflict AND it makes some change, return it!
if (delta.isStrictlyMorePrecise(context)) {
continuation = continuation.tl();
return delta;
}
}
}