/** * {A} |- (--A) * /param v1 Truth value of the premise * /return Truth value of the conclusion */ public static TruthValue negation(TruthValue v1) { float f = 1 - v1.frequency; float c = v1.confidence; return(TruthValue.make(f, c)); }
public TruthValue projectionTruth(long targetTime, long currentTime) { TruthValue newTruth = null; if (!stamp.isEternal) { newTruth = TruthFunctions.eternalize(truth); if (targetTime != Stamp.ETERNAL) { long occurrenceTime = stamp.occurrenceTime; double factor = TruthFunctions.temporalProjection(occurrenceTime, targetTime, currentTime); float projectedConfidence = (float)(factor * truth.confidence); if (projectedConfidence > newTruth.confidence) { newTruth = TruthValue.make(truth.frequency, projectedConfidence); } } } if (newTruth == null) { newTruth = truth.clone(); } return(newTruth); }
/** * {M, <M ==> P>} |- P * /param v1 Truth value of the first premise * /param reliance Confidence of the second (analytical) premise * /return Truth value of the conclusion */ public static TruthValue deduction(TruthValue v1, float reliance) { float f1 = v1.frequency; float c1 = v1.confidence; float c = UtilityFunctions.and(f1, c1, reliance); return(TruthValue.make(f1, c, true)); }
/** * {(&&, <#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 */ public static TruthValue anonymousAnalogy(TruthValue v1, TruthValue v2) { float f1 = v1.frequency; float c1 = v1.confidence; TruthValue v0 = TruthValue.make(f1, UtilityFunctions.w2c(c1)); return(analogy(v2, v0)); }
/** * {<A ==> B>} |- <B ==> A> * /param v1 Truth value of the premise * /return Truth value of the conclusion */ public static TruthValue conversion(TruthValue v1) { float f1 = v1.frequency; float c1 = v1.confidence; float w = UtilityFunctions.and(f1, c1); float c = UtilityFunctions.w2c(w); return(TruthValue.make(1, c)); }
/** * {<S ==> M>, <M ==> P>} |- <S ==> P> * /param v1 Truth value of the first premise * /param v2 Truth value of the second premise * /return Truth value of the conclusion */ public static TruthValue deduction(TruthValue v1, TruthValue v2) { float f1 = v1.frequency; float f2 = v2.frequency; float c1 = v1.confidence; float c2 = v2.confidence; float f = UtilityFunctions.and(f1, f2); float c = UtilityFunctions.and(c1, c2, f); return(TruthValue.make(f, c)); }
/** * A function specially designed for desire value [To be refined] * /param v1 Truth value of the first premise * /param v2 Truth value of the second premise * /return Truth value of the conclusion */ public static TruthValue desireInd(TruthValue v1, TruthValue v2) { float f1 = v1.frequency; float f2 = v2.frequency; float c1 = v1.confidence; float c2 = v2.confidence; float w = UtilityFunctions.and(f2, c1, c2); float c = UtilityFunctions.w2c(w); return(TruthValue.make(f1, c)); }
/** * {<M ==> S>, <M ==> P>} |- <S <=> P> * /param v1 Truth value of the first premise * /param v2 Truth value of the second premise * /return Truth value of the conclusion */ public static TruthValue comparison(TruthValue v1, TruthValue v2) { float f1 = v1.frequency; float f2 = v2.frequency; float c1 = v1.confidence; float c2 = v2.confidence; float f0 = UtilityFunctions.or(f1, f2); float f = (f0 == 0) ? 0 : (UtilityFunctions.and(f1, f2) / f0); float w = UtilityFunctions.and(f0, c1, c2); float c = UtilityFunctions.w2c(w); return(TruthValue.make(f, c)); }
/** * {M, <P ==> M>} |- P * /param v1 Truth value of the first premise * /param reliance Confidence of the second (analytical) premise * /return Truth value of the conclusion */ public static TruthValue abduction(TruthValue v1, float reliance) { if (v1.analytic) { return(TruthValue.make(0.5f, 0f)); } float f1 = v1.frequency; float c1 = v1.confidence; float w = UtilityFunctions.and(c1, reliance); float c = UtilityFunctions.w2c(w); return(TruthValue.make(f1, c, true)); }
static void testNars() { CompoundAndTermContext compoundAndTermContext = new CompoundAndTermContext(); RuleDispatcher.compoundAndTermContext = compoundAndTermContext; // for debugging PrototypingInput prototypingInput = new PrototypingInput(compoundAndTermContext); Nar nar = Nar.make(compoundAndTermContext, new MetaNix.nars.config.RuntimeParameters()); CompoundIndex compoundIndex1 = prototypingInput.makeInheritance("a", "b"); ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters task1SentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); task1SentenceParameters.term = compoundAndTermContext.accessCompoundByIndex(compoundIndex1).thisTermReferer; task1SentenceParameters.truth = TruthValue.make(1.0f, 0.5f); task1SentenceParameters.stamp = Stamp.makeWithPresentTense(nar.memory); task1SentenceParameters.punctation = ClassicalSentence.EnumPunctation.JUDGMENT; ClassicalSentence task1Sentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(task1SentenceParameters); ClassicalTask.MakeParameters task1MakeParameters = new ClassicalTask.MakeParameters(); task1MakeParameters.sentence = task1Sentence; task1MakeParameters.budget = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f); nar.inputTask(ClassicalTask.make(task1MakeParameters)); CompoundIndex compoundIndex2 = prototypingInput.makeInheritance("b", "c"); ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters task2SentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); task2SentenceParameters.term = compoundAndTermContext.accessCompoundByIndex(compoundIndex2).thisTermReferer; task2SentenceParameters.truth = TruthValue.make(1.0f, 0.5f); task2SentenceParameters.stamp = Stamp.makeWithPresentTense(nar.memory); task2SentenceParameters.punctation = ClassicalSentence.EnumPunctation.JUDGMENT; ClassicalSentence task2Sentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(task2SentenceParameters); ClassicalTask.MakeParameters task2MakeParameters = new ClassicalTask.MakeParameters(); task2MakeParameters.sentence = task2Sentence; task2MakeParameters.budget = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f); nar.inputTask(ClassicalTask.make(task2MakeParameters)); for (;;) { nar.cycle(); } int here = 5; }
/** * {<M ==> S>, <P ==> 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 */ public static TruthValue exemplification(TruthValue v1, TruthValue v2) { if (v1.analytic || v2.analytic) { return(TruthValue.make(0.5f, 0f)); } float f1 = v1.frequency; float f2 = v2.frequency; float c1 = v1.confidence; float c2 = v2.confidence; float w = UtilityFunctions.and(f1, f2, c1, c2); float c = UtilityFunctions.w2c(w); return(TruthValue.make(1, c)); }
/* ----- double argument functions, called in MatchingRules ----- */ /** * {<S ==> P>, <S ==> P>} |- <S ==> P> * /param v1 Truth value of the first premise * /param v2 Truth value of the second premise * /return Truth value of the conclusion */ public static TruthValue revision(TruthValue v1, TruthValue v2) { return(revision(v1, v2, TruthValue.make(0, 0))); }