LogicExpr

Enum LogicExpr 

Source
pub enum LogicExpr<'a> {
Show 33 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>, }, 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>, }, 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>, }, Comparative { adjective: Symbol, subject: &'a Term<'a>, object: &'a Term<'a>, difference: Option<&'a Term<'a>>, }, 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 operator: PAST(φ) or FUTURE(φ).

Fields

§body: &'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>
§

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>
§

Comparative

Comparative: “X is taller than Y (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: Write, F: LogicFormatter>( &self, w: &mut W, registry: &mut SymbolRegistry, interner: &Interner, fmt: &F, ) -> Result

Source

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

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: LogicFormatter>( &self, ctx: &mut TranspileContext<'_>, fmt: &F, ) -> String

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

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

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> 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
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, 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