TLExpr

Enum TLExpr 

Source
pub enum TLExpr {
Show 52 variants Pred { name: String, args: Vec<Term>, }, And(Box<TLExpr>, Box<TLExpr>), Or(Box<TLExpr>, Box<TLExpr>), Not(Box<TLExpr>), Exists { var: String, domain: String, body: Box<TLExpr>, }, ForAll { var: String, domain: String, body: Box<TLExpr>, }, Imply(Box<TLExpr>, Box<TLExpr>), Score(Box<TLExpr>), Add(Box<TLExpr>, Box<TLExpr>), Sub(Box<TLExpr>, Box<TLExpr>), Mul(Box<TLExpr>, Box<TLExpr>), Div(Box<TLExpr>, Box<TLExpr>), Pow(Box<TLExpr>, Box<TLExpr>), Mod(Box<TLExpr>, Box<TLExpr>), Min(Box<TLExpr>, Box<TLExpr>), Max(Box<TLExpr>, Box<TLExpr>), Abs(Box<TLExpr>), Floor(Box<TLExpr>), Ceil(Box<TLExpr>), Round(Box<TLExpr>), Sqrt(Box<TLExpr>), Exp(Box<TLExpr>), Log(Box<TLExpr>), Sin(Box<TLExpr>), Cos(Box<TLExpr>), Tan(Box<TLExpr>), Eq(Box<TLExpr>, Box<TLExpr>), Lt(Box<TLExpr>, Box<TLExpr>), Gt(Box<TLExpr>, Box<TLExpr>), Lte(Box<TLExpr>, Box<TLExpr>), Gte(Box<TLExpr>, Box<TLExpr>), IfThenElse { condition: Box<TLExpr>, then_branch: Box<TLExpr>, else_branch: Box<TLExpr>, }, Constant(f64), Aggregate { op: AggregateOp, var: String, domain: String, body: Box<TLExpr>, group_by: Option<Vec<String>>, }, Let { var: String, value: Box<TLExpr>, body: Box<TLExpr>, }, Box(Box<TLExpr>), Diamond(Box<TLExpr>), Next(Box<TLExpr>), Eventually(Box<TLExpr>), Always(Box<TLExpr>), Until { before: Box<TLExpr>, after: Box<TLExpr>, }, TNorm { kind: TNormKind, left: Box<TLExpr>, right: Box<TLExpr>, }, TCoNorm { kind: TCoNormKind, left: Box<TLExpr>, right: Box<TLExpr>, }, FuzzyNot { kind: FuzzyNegationKind, expr: Box<TLExpr>, }, FuzzyImplication { kind: FuzzyImplicationKind, premise: Box<TLExpr>, conclusion: Box<TLExpr>, }, SoftExists { var: String, domain: String, body: Box<TLExpr>, temperature: f64, }, SoftForAll { var: String, domain: String, body: Box<TLExpr>, temperature: f64, }, WeightedRule { weight: f64, rule: Box<TLExpr>, }, ProbabilisticChoice { alternatives: Vec<(f64, TLExpr)>, }, Release { released: Box<TLExpr>, releaser: Box<TLExpr>, }, WeakUntil { before: Box<TLExpr>, after: Box<TLExpr>, }, StrongRelease { released: Box<TLExpr>, releaser: Box<TLExpr>, },
}

Variants§

§

Pred

Fields

§name: String
§args: Vec<Term>
§

And(Box<TLExpr>, Box<TLExpr>)

§

Or(Box<TLExpr>, Box<TLExpr>)

§

Not(Box<TLExpr>)

§

Exists

Fields

§domain: String
§body: Box<TLExpr>
§

ForAll

Fields

§domain: String
§body: Box<TLExpr>
§

Imply(Box<TLExpr>, Box<TLExpr>)

§

Score(Box<TLExpr>)

§

Add(Box<TLExpr>, Box<TLExpr>)

§

Sub(Box<TLExpr>, Box<TLExpr>)

§

Mul(Box<TLExpr>, Box<TLExpr>)

§

Div(Box<TLExpr>, Box<TLExpr>)

§

Pow(Box<TLExpr>, Box<TLExpr>)

§

Mod(Box<TLExpr>, Box<TLExpr>)

§

Min(Box<TLExpr>, Box<TLExpr>)

§

Max(Box<TLExpr>, Box<TLExpr>)

§

Abs(Box<TLExpr>)

§

Floor(Box<TLExpr>)

§

Ceil(Box<TLExpr>)

§

Round(Box<TLExpr>)

§

Sqrt(Box<TLExpr>)

§

Exp(Box<TLExpr>)

§

Log(Box<TLExpr>)

§

Sin(Box<TLExpr>)

§

Cos(Box<TLExpr>)

§

Tan(Box<TLExpr>)

§

Eq(Box<TLExpr>, Box<TLExpr>)

§

Lt(Box<TLExpr>, Box<TLExpr>)

§

Gt(Box<TLExpr>, Box<TLExpr>)

§

Lte(Box<TLExpr>, Box<TLExpr>)

§

Gte(Box<TLExpr>, Box<TLExpr>)

§

IfThenElse

Fields

§condition: Box<TLExpr>
§then_branch: Box<TLExpr>
§else_branch: Box<TLExpr>
§

Constant(f64)

§

Aggregate

Fields

§domain: String
§body: Box<TLExpr>
§group_by: Option<Vec<String>>

Optional group-by variables

§

Let

Fields

§value: Box<TLExpr>
§body: Box<TLExpr>
§

Box(Box<TLExpr>)

Necessity operator (□, “box”): something is necessarily true In all possible worlds or states, the expression holds

§

Diamond(Box<TLExpr>)

Possibility operator (◇, “diamond”): something is possibly true In at least one possible world or state, the expression holds Related to Box by: ◇P = ¬□¬P

§

Next(Box<TLExpr>)

Next operator (X): true in the next state

§

Eventually(Box<TLExpr>)

Eventually operator (F): true in some future state

§

Always(Box<TLExpr>)

Always/Globally operator (G): true in all future states

§

Until

Until operator (U): first expression holds until second becomes true

Fields

§before: Box<TLExpr>
§after: Box<TLExpr>
§

TNorm

T-norm (fuzzy AND) with specified semantics

Fields

§left: Box<TLExpr>
§right: Box<TLExpr>
§

TCoNorm

T-conorm (fuzzy OR) with specified semantics

Fields

§left: Box<TLExpr>
§right: Box<TLExpr>
§

FuzzyNot

Fuzzy negation with specified semantics

Fields

§expr: Box<TLExpr>
§

FuzzyImplication

Fuzzy implication operator

Fields

§premise: Box<TLExpr>
§conclusion: Box<TLExpr>
§

SoftExists

Soft existential quantifier with temperature parameter Temperature controls how “soft” the quantifier is:

  • Low temperature (→0): approaches hard max (standard exists)
  • High temperature: smoother aggregation (log-sum-exp)

Fields

§domain: String
§body: Box<TLExpr>
§temperature: f64

Temperature parameter (default: 1.0)

§

SoftForAll

Soft universal quantifier with temperature parameter Temperature controls how “soft” the quantifier is:

  • Low temperature (→0): approaches hard min (standard forall)
  • High temperature: smoother aggregation

Fields

§domain: String
§body: Box<TLExpr>
§temperature: f64

Temperature parameter (default: 1.0)

§

WeightedRule

Weighted rule with confidence/probability Used in probabilistic logic programming

Fields

§weight: f64
§rule: Box<TLExpr>
§

ProbabilisticChoice

Probabilistic choice between alternatives with given probabilities Probabilities should sum to 1.0

Fields

§alternatives: Vec<(f64, TLExpr)>
§

Release

Release operator (R): dual of Until P R Q means Q holds until and including when P becomes true

Fields

§released: Box<TLExpr>
§releaser: Box<TLExpr>
§

WeakUntil

Weak Until (W): P W Q means P holds until Q, but Q may never hold

Fields

§before: Box<TLExpr>
§after: Box<TLExpr>
§

StrongRelease

Strong Release (M): dual of weak until

Fields

§released: Box<TLExpr>
§releaser: Box<TLExpr>

Implementations§

Source§

impl TLExpr

Source

pub fn free_vars(&self) -> HashSet<String>

Collect all free variables in this expression

Source

pub fn all_predicates(&self) -> HashMap<String, usize>

Collect all predicates and their arities

Source§

impl TLExpr

Source

pub fn validate_domains(&self, registry: &DomainRegistry) -> Result<(), IrError>

Validate all domain references in this expression.

Checks that:

  • All quantifier domains exist in the registry
  • Variables used consistently across different quantifiers
Source

pub fn referenced_domains(&self) -> Vec<String>

Extract all domains referenced in this expression.

Source§

impl TLExpr

Source

pub fn validate_arity(&self) -> Result<(), String>

Validate that all predicates with the same name have consistent arity

Source§

impl TLExpr

Source

pub fn pred(name: impl Into<String>, args: Vec<Term>) -> Self

Source

pub fn and(left: TLExpr, right: TLExpr) -> Self

Source

pub fn or(left: TLExpr, right: TLExpr) -> Self

Source

pub fn negate(expr: TLExpr) -> Self

Source

pub fn exists( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn forall( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn imply(premise: TLExpr, conclusion: TLExpr) -> Self

Source

pub fn score(expr: TLExpr) -> Self

Source

pub fn add(left: TLExpr, right: TLExpr) -> Self

Source

pub fn sub(left: TLExpr, right: TLExpr) -> Self

Source

pub fn mul(left: TLExpr, right: TLExpr) -> Self

Source

pub fn div(left: TLExpr, right: TLExpr) -> Self

Source

pub fn pow(left: TLExpr, right: TLExpr) -> Self

Source

pub fn modulo(left: TLExpr, right: TLExpr) -> Self

Source

pub fn min(left: TLExpr, right: TLExpr) -> Self

Source

pub fn max(left: TLExpr, right: TLExpr) -> Self

Source

pub fn abs(expr: TLExpr) -> Self

Source

pub fn floor(expr: TLExpr) -> Self

Source

pub fn ceil(expr: TLExpr) -> Self

Source

pub fn round(expr: TLExpr) -> Self

Source

pub fn sqrt(expr: TLExpr) -> Self

Source

pub fn exp(expr: TLExpr) -> Self

Source

pub fn log(expr: TLExpr) -> Self

Source

pub fn sin(expr: TLExpr) -> Self

Source

pub fn cos(expr: TLExpr) -> Self

Source

pub fn tan(expr: TLExpr) -> Self

Source

pub fn eq(left: TLExpr, right: TLExpr) -> Self

Source

pub fn lt(left: TLExpr, right: TLExpr) -> Self

Source

pub fn gt(left: TLExpr, right: TLExpr) -> Self

Source

pub fn lte(left: TLExpr, right: TLExpr) -> Self

Source

pub fn gte(left: TLExpr, right: TLExpr) -> Self

Source

pub fn if_then_else( condition: TLExpr, then_branch: TLExpr, else_branch: TLExpr, ) -> Self

Source

pub fn constant(value: f64) -> Self

Source

pub fn aggregate( op: AggregateOp, var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn aggregate_with_group_by( op: AggregateOp, var: impl Into<String>, domain: impl Into<String>, body: TLExpr, group_by: Vec<String>, ) -> Self

Source

pub fn count( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn sum( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn average( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn max_agg( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn min_agg( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn product( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, ) -> Self

Source

pub fn let_binding(var: impl Into<String>, value: TLExpr, body: TLExpr) -> Self

Source

pub fn modal_box(expr: TLExpr) -> Self

Create a Box (necessity) operator.

□P: “P is necessarily true” - holds in all possible worlds/states

Source

pub fn modal_diamond(expr: TLExpr) -> Self

Create a Diamond (possibility) operator.

◇P: “P is possibly true” - holds in at least one possible world/state

Source

pub fn next(expr: TLExpr) -> Self

Create a Next operator.

XP: “P is true in the next state”

Source

pub fn eventually(expr: TLExpr) -> Self

Create an Eventually operator.

FP: “P will eventually be true” - true in some future state

Source

pub fn always(expr: TLExpr) -> Self

Create an Always operator.

GP: “P is always true” - true in all future states

Source

pub fn until(before: TLExpr, after: TLExpr) -> Self

Create an Until operator.

P U Q: “P holds until Q becomes true”

Source

pub fn tnorm(kind: TNormKind, left: TLExpr, right: TLExpr) -> Self

Create a T-norm (fuzzy AND) operation with specified semantics.

Source

pub fn fuzzy_and(left: TLExpr, right: TLExpr) -> Self

Create a minimum T-norm (standard fuzzy AND).

Source

pub fn probabilistic_and(left: TLExpr, right: TLExpr) -> Self

Create a product T-norm (probabilistic AND).

Source

pub fn tconorm(kind: TCoNormKind, left: TLExpr, right: TLExpr) -> Self

Create a T-conorm (fuzzy OR) operation with specified semantics.

Source

pub fn fuzzy_or(left: TLExpr, right: TLExpr) -> Self

Create a maximum T-conorm (standard fuzzy OR).

Source

pub fn probabilistic_or(left: TLExpr, right: TLExpr) -> Self

Create a probabilistic sum T-conorm.

Source

pub fn fuzzy_not(kind: FuzzyNegationKind, expr: TLExpr) -> Self

Create a fuzzy negation with specified semantics.

Source

pub fn standard_fuzzy_not(expr: TLExpr) -> Self

Create a standard fuzzy negation (1 - x).

Source

pub fn fuzzy_imply( kind: FuzzyImplicationKind, premise: TLExpr, conclusion: TLExpr, ) -> Self

Create a fuzzy implication with specified semantics.

Source

pub fn soft_exists( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, temperature: f64, ) -> Self

Create a soft existential quantifier with temperature parameter.

§Arguments
  • var - Variable name
  • domain - Domain name
  • body - Expression body
  • temperature - Temperature parameter (default 1.0). Lower = harder max.
Source

pub fn soft_forall( var: impl Into<String>, domain: impl Into<String>, body: TLExpr, temperature: f64, ) -> Self

Create a soft universal quantifier with temperature parameter.

§Arguments
  • var - Variable name
  • domain - Domain name
  • body - Expression body
  • temperature - Temperature parameter (default 1.0). Lower = harder min.
Source

pub fn weighted_rule(weight: f64, rule: TLExpr) -> Self

Create a weighted rule with confidence/probability.

§Arguments
  • weight - Weight/confidence (typically in [0,1] for probabilities)
  • rule - The rule expression
Source

pub fn probabilistic_choice(alternatives: Vec<(f64, TLExpr)>) -> Self

Create a probabilistic choice between alternatives.

§Arguments
  • alternatives - Vector of (probability, expression) pairs. Should sum to 1.0.
Source

pub fn release(released: TLExpr, releaser: TLExpr) -> Self

Create a Release operator (R).

P R Q: “Q holds until and including when P becomes true”

Source

pub fn weak_until(before: TLExpr, after: TLExpr) -> Self

Create a Weak Until operator (W).

P W Q: “P holds until Q, but Q may never hold”

Source

pub fn strong_release(released: TLExpr, releaser: TLExpr) -> Self

Create a Strong Release operator (M).

P M Q: Dual of weak until

Trait Implementations§

Source§

impl Clone for TLExpr

Source§

fn clone(&self) -> TLExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TLExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TLExpr

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for TLExpr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TLExpr

Source§

fn eq(&self, other: &TLExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TLExpr

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TLExpr

Auto Trait Implementations§

§

impl Freeze for TLExpr

§

impl RefUnwindSafe for TLExpr

§

impl Send for TLExpr

§

impl Sync for TLExpr

§

impl Unpin for TLExpr

§

impl UnwindSafe for TLExpr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,