pub enum Formula {
}Expand description
A linear logic formula.
Linear logic has a rich set of connectives split into multiplicative and additive families, plus exponentials for controlled structural rules.
Variants§
Atom(String)
Atomic proposition
NegAtom(String)
Negated atomic proposition (A⊥)
Tensor(Box<Formula>, Box<Formula>)
Tensor product (A ⊗ B) - “both A and B independently”
Par(Box<Formula>, Box<Formula>)
Par (A ⅋ B) - “A or B, opponent chooses”
One
Multiplicative unit (1)
Bottom
Multiplicative false (⊥)
With(Box<Formula>, Box<Formula>)
With (A & B) - “both available, you choose one”
Plus(Box<Formula>, Box<Formula>)
Plus (A ⊕ B) - “one of them, I choose which”
Top
Additive truth (⊤)
Zero
Additive false (0)
OfCourse(Box<Formula>)
Of course (!A) - “unlimited supply of A, can copy/discard”
WhyNot(Box<Formula>)
Why not (?A) - “demand for A”
Lolli(Box<Formula>, Box<Formula>)
Linear implication (A ⊸ B) - sugar for A⊥ ⅋ B
Implementations§
Source§impl Formula
impl Formula
Sourcepub fn negate(&self) -> Formula
pub fn negate(&self) -> Formula
Compute the linear negation of a formula.
Linear negation is involutive: (A⊥)⊥ = A
De Morgan dualities:
- (A ⊗ B)⊥ = A⊥ ⅋ B⊥
- (A ⅋ B)⊥ = A⊥ ⊗ B⊥
- (A & B)⊥ = A⊥ ⊕ B⊥
- (A ⊕ B)⊥ = A⊥ & B⊥
- 1⊥ = ⊥
- ⊥⊥ = 1
- (!A)⊥ = ?(A⊥)
- (?A)⊥ = !(A⊥)
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if this formula is positive (async/eager).
Positive formulas: ⊗, 1, ⊕, 0, !, atoms
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if this formula is negative (sync/lazy).
Negative formulas: ⅋, ⊥, &, ⊤, ?, negated atoms
Sourcepub fn pretty_ascii(&self) -> String
pub fn pretty_ascii(&self) -> String
Pretty print the formula with ASCII symbols.
Sourcepub fn pretty_latex(&self) -> String
pub fn pretty_latex(&self) -> String
Pretty print the formula for LaTeX.