Skip to main content

LogicExpr

Enum LogicExpr 

Source
pub enum LogicExpr<'a> {
Show 38 variants Predicate { name: Symbol, args: &'a [Term<'a>], world: Option<Symbol>, }, Identity { left: &'a Term<'a>, right: &'a Term<'a>, }, Metaphor { tenor: &'a Term<'a>, vehicle: &'a Term<'a>, }, Quantifier { kind: QuantifierKind, variable: Symbol, body: &'a LogicExpr<'a>, island_id: u32, }, Categorical(Box<CategoricalData<'a>>), Relation(Box<RelationData<'a>>), Modal { vector: ModalVector, operand: &'a LogicExpr<'a>, }, Temporal { operator: TemporalOperator, body: &'a LogicExpr<'a>, }, TemporalBinary { operator: BinaryTemporalOp, left: &'a LogicExpr<'a>, right: &'a LogicExpr<'a>, }, Aspectual { operator: AspectOperator, body: &'a LogicExpr<'a>, }, Voice { operator: VoiceOperator, body: &'a LogicExpr<'a>, }, BinaryOp { left: &'a LogicExpr<'a>, op: TokenType, right: &'a LogicExpr<'a>, }, UnaryOp { op: TokenType, operand: &'a LogicExpr<'a>, }, Question { wh_variable: Symbol, body: &'a LogicExpr<'a>, }, YesNoQuestion { body: &'a LogicExpr<'a>, }, Atom(Symbol), Lambda { variable: Symbol, body: &'a LogicExpr<'a>, }, App { function: &'a LogicExpr<'a>, argument: &'a LogicExpr<'a>, }, Intensional { operator: Symbol, content: &'a LogicExpr<'a>, }, Event { predicate: &'a LogicExpr<'a>, adverbs: &'a [Symbol], }, NeoEvent(Box<NeoEventData<'a>>), Imperative { action: &'a LogicExpr<'a>, }, Exclamative { degree_var: Symbol, body: &'a LogicExpr<'a>, }, Optative { wish: &'a LogicExpr<'a>, }, Implicature { assertion: &'a LogicExpr<'a>, implicature: &'a LogicExpr<'a>, }, SpeechAct { performer: Symbol, act_type: Symbol, content: &'a LogicExpr<'a>, }, Counterfactual { antecedent: &'a LogicExpr<'a>, consequent: &'a LogicExpr<'a>, }, Causal { effect: &'a LogicExpr<'a>, cause: &'a LogicExpr<'a>, }, Concessive { main: &'a LogicExpr<'a>, concession: &'a LogicExpr<'a>, }, Comparative { adjective: Symbol, subject: &'a Term<'a>, object: &'a Term<'a>, difference: Option<&'a Term<'a>>, relation: ComparisonRelation, }, Superlative { adjective: Symbol, subject: &'a Term<'a>, domain: Symbol, }, Scopal { operator: Symbol, body: &'a LogicExpr<'a>, }, Control { verb: Symbol, subject: &'a Term<'a>, object: Option<&'a Term<'a>>, infinitive: &'a LogicExpr<'a>, }, Presupposition { assertion: &'a LogicExpr<'a>, presupposition: &'a LogicExpr<'a>, }, Focus { kind: FocusKind, focused: &'a Term<'a>, scope: &'a LogicExpr<'a>, }, TemporalAnchor { anchor: Symbol, body: &'a LogicExpr<'a>, }, Distributive { predicate: &'a LogicExpr<'a>, }, GroupQuantifier { group_var: Symbol, count: u32, member_var: Symbol, restriction: &'a LogicExpr<'a>, body: &'a LogicExpr<'a>, },
}
Expand description

First-order logic expression with modal, temporal, and event extensions.

This is the core AST type representing logical formulas. All nodes are arena-allocated with the 'a lifetime tracking the arena’s scope.

§Categories

Variants§

§

Predicate

Atomic predicate: P(t1, t2, ...) with optional world parameter.

Fields

§name: Symbol
§args: &'a [Term<'a>]
§world: Option<Symbol>

World argument for Kripke semantics. None = implicit actual world (w₀).

§

Identity

Identity statement: t1 = t2.

Fields

§left: &'a Term<'a>
§right: &'a Term<'a>
§

Metaphor

Metaphorical assertion: tenor “is” vehicle (non-literal identity).

Fields

§tenor: &'a Term<'a>
§vehicle: &'a Term<'a>
§

Quantifier

Quantified formula: ∀x.φ or ∃x.φ with scope island tracking.

Fields

§variable: Symbol
§body: &'a LogicExpr<'a>
§island_id: u32

Island ID prevents illicit scope interactions across syntactic boundaries.

§

Categorical(Box<CategoricalData<'a>>)

Aristotelian categorical proposition (boxed to keep enum small).

§

Relation(Box<RelationData<'a>>)

Simple S-V-O relation (boxed).

§

Modal

Modal operator: □φ (necessity) or ◇φ (possibility).

Fields

§operand: &'a LogicExpr<'a>
§

Temporal

Tense/temporal operator: PAST(φ), FUTURE(φ), ALWAYS(φ), EVENTUALLY(φ), NEXT(φ).

Fields

§body: &'a LogicExpr<'a>
§

TemporalBinary

Binary temporal operator: φ UNTIL ψ, φ RELEASE ψ, φ WEAKUNTIL ψ.

Fields

§left: &'a LogicExpr<'a>
§right: &'a LogicExpr<'a>
§

Aspectual

Aspect operator: PROG(φ), PERF(φ), HAB(φ), ITER(φ).

Fields

§body: &'a LogicExpr<'a>
§

Voice

Voice operator: PASSIVE(φ).

Fields

§operator: VoiceOperator
§body: &'a LogicExpr<'a>
§

BinaryOp

Binary connective: φ ∧ ψ, φ ∨ ψ, φ → ψ, φ ↔ ψ.

Fields

§left: &'a LogicExpr<'a>
§right: &'a LogicExpr<'a>
§

UnaryOp

Unary operator: ¬φ.

Fields

§operand: &'a LogicExpr<'a>
§

Question

Wh-question: λx.φ where x is the questioned variable.

Fields

§wh_variable: Symbol
§body: &'a LogicExpr<'a>
§

YesNoQuestion

Yes/no question: ?φ (is φ true?).

Fields

§body: &'a LogicExpr<'a>
§

Atom(Symbol)

Atomic symbol (variable or constant in lambda context).

§

Lambda

Lambda abstraction: λx.φ.

Fields

§variable: Symbol
§body: &'a LogicExpr<'a>
§

App

Function application: (φ)(ψ).

Fields

§function: &'a LogicExpr<'a>
§argument: &'a LogicExpr<'a>
§

Intensional

Intensional context: operator[content] for opaque verbs (believes, seeks).

Fields

§operator: Symbol
§content: &'a LogicExpr<'a>
§

Event

Legacy event semantics (Davidson-style with adverb list).

Fields

§predicate: &'a LogicExpr<'a>
§adverbs: &'a [Symbol]
§

NeoEvent(Box<NeoEventData<'a>>)

Neo-Davidsonian event with thematic roles (boxed).

§

Imperative

Imperative command: !φ.

Fields

§action: &'a LogicExpr<'a>
§

Exclamative

Exclamative: affective stance toward a surprisingly-high degree, with no subject-aux inversion (“How tall she is!”, “What a fool he is!”). Asserts ∃degree_var(body ∧ degree_var ≫ θ) and presupposes body.

Fields

§degree_var: Symbol
§body: &'a LogicExpr<'a>
§

Optative

Optative: a wish with no asserted truth (“May you prosper!”, “Long live the king!”, “If only it were Friday!”). → Wish(speaker, ⟨wish⟩); the complement is NOT entailed.

Fields

§wish: &'a LogicExpr<'a>
§

Implicature

Scalar implicature (§8.7): a weak scalar item asserts assertion and DEFEASIBLY implicates implicature (the negation of a stronger Horn alternative). “Some students passed.” → ∃… +> ¬∀…. Rendered assertion +> implicature; the implicature is cancellable and not part of truth conditions.

Fields

§assertion: &'a LogicExpr<'a>
§implicature: &'a LogicExpr<'a>
§

SpeechAct

Speech act: performative utterance with illocutionary force.

Fields

§performer: Symbol
§act_type: Symbol
§content: &'a LogicExpr<'a>
§

Counterfactual

Counterfactual conditional: “If P had been, Q would have been”.

Fields

§antecedent: &'a LogicExpr<'a>
§consequent: &'a LogicExpr<'a>
§

Causal

Causal relation: “effect because cause”.

Fields

§effect: &'a LogicExpr<'a>
§cause: &'a LogicExpr<'a>
§

Concessive

Concessive relation: “main, although concession” — the main clause holds DESPITE a defeated expectation from the concession (“Although she was tired, she finished.” → Finish(she) ∧ Concessive(Tired(she))).

Fields

§main: &'a LogicExpr<'a>
§concession: &'a LogicExpr<'a>
§

Comparative

Comparative / equative: “X is taller than Y” (>), “X is as tall as Y” (), “X is as tall as Y and no taller” (=). The relation selects the degree comparison; difference is the optional measure (“by 2 inches”).

Fields

§adjective: Symbol
§subject: &'a Term<'a>
§object: &'a Term<'a>
§difference: Option<&'a Term<'a>>
§

Superlative

Superlative: “X is the tallest among domain”.

Fields

§adjective: Symbol
§subject: &'a Term<'a>
§domain: Symbol
§

Scopal

Scopal adverb: “only”, “always”, etc. as operators.

Fields

§operator: Symbol
§body: &'a LogicExpr<'a>
§

Control

Control verb: “wants to VP”, “persuaded X to VP”.

Fields

§verb: Symbol
§subject: &'a Term<'a>
§object: Option<&'a Term<'a>>
§infinitive: &'a LogicExpr<'a>
§

Presupposition

Presupposition-assertion structure.

Fields

§assertion: &'a LogicExpr<'a>
§presupposition: &'a LogicExpr<'a>
§

Focus

Focus particle: “only X”, “even X” with alternative set.

Fields

§focused: &'a Term<'a>
§scope: &'a LogicExpr<'a>
§

TemporalAnchor

Temporal anchor: “yesterday(φ)”, “now(φ)”.

Fields

§anchor: Symbol
§body: &'a LogicExpr<'a>
§

Distributive

Distributive operator: *P distributes P over group members.

Fields

§predicate: &'a LogicExpr<'a>
§

GroupQuantifier

Group quantifier for collective cardinal readings. ∃g(Group(g) ∧ Count(g,n) ∧ ∀x(Member(x,g) → Restriction(x)) ∧ Body(g))

Fields

§group_var: Symbol
§count: u32
§member_var: Symbol
§restriction: &'a LogicExpr<'a>
§body: &'a LogicExpr<'a>

Implementations§

Source§

impl<'a> LogicExpr<'a>

Source

pub fn lambda( var: Symbol, body: &'a LogicExpr<'a>, arena: &'a Arena<LogicExpr<'a>>, ) -> &'a LogicExpr<'a>

Source

pub fn app( func: &'a LogicExpr<'a>, arg: &'a LogicExpr<'a>, arena: &'a Arena<LogicExpr<'a>>, ) -> &'a LogicExpr<'a>

Source§

impl<'a> LogicExpr<'a>

Source

pub fn transpile_discourse( &self, registry: &mut SymbolRegistry, interner: &Interner, format: OutputFormat, ) -> String

Transpile a discourse (multiple sentences) as numbered formulas. If the expression is a top-level conjunction of sentences, formats as:

1) formula1
2) formula2
3) formula3

If it’s a single sentence, just returns the formula without numbering.

Source

pub fn write_logic<W, F>( &self, w: &mut W, registry: &mut SymbolRegistry, interner: &Interner, fmt: &F, ) -> Result<(), Error>
where W: Write, F: LogicFormatter,

Source

pub fn transpile_with<F>( &self, registry: &mut SymbolRegistry, interner: &Interner, fmt: &F, ) -> String
where F: LogicFormatter,

Transpiles to a logic formula string using a custom formatter.

Source

pub fn transpile( &self, registry: &mut SymbolRegistry, interner: &Interner, format: OutputFormat, ) -> String

Transpiles to a logic formula string in the specified output format.

§Formats
Source

pub fn transpile_ctx<F>( &self, ctx: &mut TranspileContext<'_>, fmt: &F, ) -> String
where F: LogicFormatter,

Transpiles using a TranspileContext and custom formatter.

Source

pub fn transpile_ctx_unicode(&self, ctx: &mut TranspileContext<'_>) -> String

Transpiles to Unicode format using a TranspileContext.

Source

pub fn transpile_ctx_latex(&self, ctx: &mut TranspileContext<'_>) -> String

Transpiles to LaTeX format using a TranspileContext.

Trait Implementations§

Source§

impl<'a> Debug for LogicExpr<'a>

Source§

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

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

impl<'a> DisplayWith for LogicExpr<'a>

Source§

fn fmt_with( &self, interner: &Interner, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

fn with<'a>(&'a self, interner: &'a Interner) -> WithInterner<'a, Self>

Source§

impl<'a, 'b> Resolve<'a> for LogicExpr<'b>

Source§

type Output = ExprView<'a>

Source§

fn resolve(&self, interner: &'a Interner) -> ExprView<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for LogicExpr<'a>

§

impl<'a> RefUnwindSafe for LogicExpr<'a>

§

impl<'a> Send for LogicExpr<'a>

§

impl<'a> Sync for LogicExpr<'a>

§

impl<'a> Unpin for LogicExpr<'a>

§

impl<'a> UnsafeUnpin for LogicExpr<'a>

§

impl<'a> UnwindSafe for LogicExpr<'a>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,