pub struct TruthValue {
pub strength: f64,
pub confidence: f64,
}Expand description
PLN indefinite truth value: (strength, confidence).
strength— probability estimate ∈ [0, 1]confidence— certainty in the strength estimate ∈ [0, 1] (0 = no information, 1 = complete certainty)
Fields§
§strength: f64Probability estimate.
confidence: f64Confidence in the strength estimate.
Implementations§
Source§impl TruthValue
impl TruthValue
Sourcepub fn new(strength: f64, confidence: f64) -> Self
pub fn new(strength: f64, confidence: f64) -> Self
Create a new truth value, clamping both components to [0, 1].
Sourcepub fn certain_true() -> Self
pub fn certain_true() -> Self
Return the true truth value (strength = 1, confidence = 1).
Sourcepub fn certain_false() -> Self
pub fn certain_false() -> Self
Return the false truth value (strength = 0, confidence = 1).
Sourcepub fn count(self) -> f64
pub fn count(self) -> f64
Effective sample count n = c / (1 − c).
Returns f64::INFINITY when confidence == 1.
Sourcepub fn conjunction(self, other: Self) -> Self
pub fn conjunction(self, other: Self) -> Self
PLN conjunction: A AND B.
Sourcepub fn disjunction(self, other: Self) -> Self
pub fn disjunction(self, other: Self) -> Self
PLN disjunction: A OR B.
Sourcepub fn revise(self, other: Self) -> Self
pub fn revise(self, other: Self) -> Self
PLN revision: merge two independent estimates of the same proposition.
Uses weighted average by effective sample count:
s_rev = (s1 * n1 + s2 * n2) / (n1 + n2)
c_rev = (n1 + n2) / (n1 + n2 + 1)Sourcepub fn deduction(ab: Self, bc: Self, b: Self, c: Self) -> Self
pub fn deduction(ab: Self, bc: Self, b: Self, c: Self) -> Self
PLN deduction: given A→B and B→C, infer A→C.
s_AC = s_AB * s_BC + (1 − s_AB) * (s_C − s_B * s_BC) / (1 − s_B)
c_AC = c_AB * c_BC * min(1, c_AB * c_BC)Sourcepub fn induction(ab: Self, ac: Self) -> Self
pub fn induction(ab: Self, ac: Self) -> Self
PLN induction: given A→B and A→C, infer B→C.
Simplified formula:
s_BC = s_AC / max(s_AB, 0.01), clamped [0, 1]
c_BC = c_AB * c_AC * min(1, c_AB * c_AC)Sourcepub fn abduction(ba: Self, ca: Self) -> Self
pub fn abduction(ba: Self, ca: Self) -> Self
PLN abduction: given B→A and C→A, infer B→C.
Dual of induction (swap roles of B and C):
s_BC = s_BA * s_CA / max(s_A, 0.01), clamped [0, 1] (simplified)
c_BC = c_BA * c_CA * min(1, c_BA * c_CA)Sourcepub fn modus_ponens(a: Self, ab: Self) -> Self
pub fn modus_ponens(a: Self, ab: Self) -> Self
PLN Modus Ponens: given A (premise) and A→B (implication), infer B.
s_B = s_A * s_AB + (1 − s_A) * (1 − s_AB) * 0.5 (mixture)
c_B = c_A * c_ABTrait Implementations§
Source§impl Clone for TruthValue
impl Clone for TruthValue
Source§fn clone(&self) -> TruthValue
fn clone(&self) -> TruthValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TruthValue
Source§impl Debug for TruthValue
impl Debug for TruthValue
Source§impl Default for TruthValue
impl Default for TruthValue
Source§impl Display for TruthValue
impl Display for TruthValue
Source§impl PartialEq for TruthValue
impl PartialEq for TruthValue
Source§fn eq(&self, other: &TruthValue) -> bool
fn eq(&self, other: &TruthValue) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TruthValue
Auto Trait Implementations§
impl Freeze for TruthValue
impl RefUnwindSafe for TruthValue
impl Send for TruthValue
impl Sync for TruthValue
impl Unpin for TruthValue
impl UnsafeUnpin for TruthValue
impl UnwindSafe for TruthValue
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more