use of nars.entity.TruthValue 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);
}
use of nars.entity.TruthValue in project opennars by opennars.
the class TruthFunctions method anonymousAnalogy.
/**
* {(&&, <#x() ==> M>, <#x() ==> P>), S ==> M} |- <S ==> P>
* @param v1 Truth value of the first premise
* @param v2 Truth value of the second premise
* @return Truth value of the conclusion
*/
static final TruthValue anonymousAnalogy(final TruthValue v1, final TruthValue v2) {
final float f1 = v1.getFrequency();
final float c1 = v1.getConfidence();
final TruthValue v0 = new TruthValue(f1, w2c(c1));
return analogy(v2, v0);
}
use of nars.entity.TruthValue in project opennars by opennars.
the class Anticipate method deriveDidntHappen.
protected void deriveDidntHappen(Term aTerm, long expectedOccurenceTime) {
TruthValue truth = expiredTruth;
BudgetValue budget = expiredBudget;
Stamp stamp = new Stamp(nal.memory);
// stamp.setOccurrenceTime(nal.memory.time());
// it did not happen, so the time of when it did not
stamp.setOccurrenceTime(expectedOccurenceTime);
// happen is exactly the time it was expected
Sentence S = new Sentence(aTerm, Symbols.JUDGMENT_MARK, truth, stamp);
Task task = new Task(S, budget, true);
nal.derivedTask(task, false, true, false);
task.setElemOfSequenceBuffer(true);
nal.memory.emit(DISAPPOINT.class, task);
}
use of nars.entity.TruthValue in project opennars by opennars.
the class Feel method feeling.
/**
* To get the current value of an internal sensor
*
* @param value The value to be checked, in [0, 1]
* @param memory The memory in which the operation is executed
* @return Immediate results as Tasks
*/
protected ArrayList<Task> feeling(float value, Memory memory) {
Stamp stamp = new Stamp(memory, Tense.Present);
TruthValue truth = new TruthValue(value, Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Term predicate = new SetInt(feelingTerm);
Term content = Inheritance.make(selfSubject, predicate);
Sentence sentence = new Sentence(content, Symbols.JUDGMENT_MARK, truth, stamp);
float quality = BudgetFunctions.truthToQuality(truth);
BudgetValue budget = new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY, Parameters.DEFAULT_JUDGMENT_DURABILITY, quality);
return Lists.newArrayList(new Task(sentence, budget, true));
}
Aggregations