#[repr(i8)]pub enum Trit {
False = -1,
Unknown = 0,
True = 1,
}Expand description
Balanced Ternary Primitive
Occupies 1 byte in memory (i8) but carries 1.58 bits of information (log2(3)). This is the fundamental unit of the Setun decision engine.
§Examples
use mindfry::setun::Trit;
// Consensus: Same-sign strengthens, opposite-sign cancels
assert_eq!(Trit::True * Trit::True, Trit::True);
assert_eq!(Trit::True * Trit::False, Trit::False);
assert_eq!(Trit::Unknown * Trit::True, Trit::Unknown);
// Inversion
assert_eq!(!Trit::True, Trit::False);
assert_eq!(!Trit::Unknown, Trit::Unknown);Variants§
False = -1
Inhibition / Rejection / Negative (-1) Biological analog: GABA neurotransmitter
Unknown = 0
Latent / Waiting / Neutral (0) Represents insufficient data or active indecision
True = 1
Excitation / Approval / Positive (+1) Biological analog: Glutamate neurotransmitter
Implementations§
Source§impl Trit
impl Trit
Sourcepub fn consensus(self, other: Trit) -> Trit
pub fn consensus(self, other: Trit) -> Trit
Consensus Logic (Multiplication)
Two parties in agreement strengthen each other (+ * + = +). Opposing parties cancel out (+ * - = -). Unknown absorbs everything (0 * x = 0).
This models synaptic reinforcement in biological networks.
Sourcepub const fn invert(self) -> Trit
pub const fn invert(self) -> Trit
Inversion (Negation)
True ↔ False, Unknown stays Unknown. Models inhibitory feedback loops.
Sourcepub const fn from_i8_saturating(val: i8) -> Trit
pub const fn from_i8_saturating(val: i8) -> Trit
Convert from i8 with saturation
Values > 0 become True, < 0 become False, == 0 becomes Unknown.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Trit
impl<'de> Deserialize<'de> for Trit
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Copy for Trit
impl Eq for Trit
impl StructuralPartialEq for Trit
Auto Trait Implementations§
impl Freeze for Trit
impl RefUnwindSafe for Trit
impl Send for Trit
impl Sync for Trit
impl Unpin for Trit
impl UnwindSafe for Trit
Blanket Implementations§
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
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