use of nars.language.CompoundTerm in project opennars by opennars.
the class SyllogisticRules method elimiVarDep.
/**
* {(&&, <#x() --> S>, <#x() --> P>>, <M --> P>} |- <M --> S>
*
* @param compound The compound term to be decomposed
* @param component The part of the compound to be removed
* @param compoundTask Whether the compound comes from the task
* @param nal Reference to the memory
*/
static void elimiVarDep(CompoundTerm compound, Term component, boolean compoundTask, DerivationContext nal) {
Term comp = null;
for (Term t : compound) {
Term[] unify = new Term[] { t, component };
if (Variables.unify(Symbols.VAR_DEPENDENT, unify)) {
comp = t;
break;
}
if (Variables.unify(Symbols.VAR_QUERY, unify)) {
comp = t;
break;
}
}
if (comp == null) {
return;
}
Term content = reduceComponents(compound, comp, nal.mem());
if ((content == null) || ((content instanceof Statement) && ((Statement) content).invalid())) {
return;
}
Task task = nal.getCurrentTask();
Sentence sentence = task.sentence;
Sentence belief = nal.getCurrentBelief();
TruthValue v1 = sentence.truth;
TruthValue v2 = belief.truth;
TruthValue truth = null;
BudgetValue budget;
if (sentence.isQuestion() || sentence.isQuest()) {
budget = (compoundTask ? BudgetFunctions.backward(v2, nal) : BudgetFunctions.backwardWeak(v2, nal));
} else {
if (sentence.isGoal()) {
// to check
truth = (compoundTask ? TruthFunctions.desireDed(v1, v2) : TruthFunctions.desireInd(v1, v2));
} else {
truth = (compoundTask ? TruthFunctions.anonymousAnalogy(v1, v2) : TruthFunctions.anonymousAnalogy(v2, v1));
}
budget = BudgetFunctions.compoundForward(truth, content, nal);
}
nal.doublePremiseTask(content, truth, budget, false, false);
}
Aggregations