Search in sources :

Example 61 with TruthValue

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);
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Statement(nars.language.Statement) TruthValue(nars.entity.TruthValue) CompoundTerm(nars.language.CompoundTerm) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Example 62 with TruthValue

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);
}
Also used : TruthValue(nars.entity.TruthValue)

Example 63 with TruthValue

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);
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Sentence(nars.entity.Sentence)

Example 64 with TruthValue

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));
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) SetInt(nars.language.SetInt) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Aggregations

TruthValue (nars.entity.TruthValue)64 BudgetValue (nars.entity.BudgetValue)52 Term (nars.language.Term)46 Sentence (nars.entity.Sentence)39 CompoundTerm (nars.language.CompoundTerm)36 Task (nars.entity.Task)34 Statement (nars.language.Statement)20 Stamp (nars.entity.Stamp)18 Conjunction (nars.language.Conjunction)18 Inheritance (nars.language.Inheritance)12 Interval (nars.language.Interval)10 Implication (nars.language.Implication)9 Product (nars.language.Product)7 Variable (nars.language.Variable)7 Concept (nars.entity.Concept)5 SetExt (nars.language.SetExt)5 SetInt (nars.language.SetInt)5 Operation (nars.operator.Operation)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4