[][src]Enum poi::Expr

pub enum Expr {
    Sym(Symbol),
    Ret(Value),
    Op(OpBox<Expr>, Box<Expr>),
    Tup(Vec<Expr>),
    List(Vec<Expr>),
}

Function expression.

Variants

Sym(Symbol)

A symbol that is used together with symbolic knowledge.

Ret(Value)

Some function that returns a value, ignoring the argument.

This can also be used to store values, since zero arguments is a value.

Op(OpBox<Expr>, Box<Expr>)

A binary operation on functions.

Tup(Vec<Expr>)

A tuple for more than one argument.

List(Vec<Expr>)

A list.

Implementations

impl Expr[src]

pub fn display(
    &self,
    w: &mut Formatter<'_>,
    parens: bool,
    rule: bool
) -> Result<(), Error>
[src]

Used to display format with additional options.

pub fn needs_parens(&self, parent_op: &Symbol, left: bool) -> bool[src]

Returns true if the expression needs parentheses, given parent operation and side.

impl Expr[src]

pub fn arity(&self) -> Option<usize>[src]

Returns the arity of an expression.

Unfinished: This function requires analysis and unit testing.

impl Expr[src]

pub fn equivalences(&self, knowledge: &[Knowledge]) -> Vec<(Expr, usize)>[src]

Returns available equivalences of the expression, using a knowledge base.

pub fn contains_nan(&self) -> bool[src]

Returns true if expressions contains NaN (not a number).

pub fn eval(&self, knowledge: &[Knowledge]) -> Result<Expr, Error>[src]

Evaluate an expression using a knowledge base.

This combines reductions and inlining of all symbols.

pub fn reduce_all(&self, knowledge: &[Knowledge]) -> Expr[src]

Reduces an expression using a knowledge base, until it can not be reduces further.

pub fn reduce_eval_all(&self, knowledge: &[Knowledge], eval: bool) -> Expr[src]

Reduces an expression using a knowledge base, until it can not be reduces further.

pub fn reduce(&self, knowledge: &[Knowledge]) -> Result<(Expr, usize), Error>[src]

Reduces expression one step using a knowledge base.

pub fn reduce_eval(
    &self,
    knowledge: &[Knowledge],
    eval: bool
) -> Result<(Expr, usize), Error>
[src]

Reduces expression one step using a knowledge base.

When eval is set to true, the EqvEval variants are reduced.

pub fn inline_all(&self, knowledge: &[Knowledge]) -> Result<Expr, Error>[src]

Inlines all symbols using a knowledge base.

Ignores missing definitions in domain constraints.

pub fn inline(
    &self,
    sym: &Symbol,
    knowledge: &[Knowledge]
) -> Result<Expr, Error>
[src]

Inline a symbol using a knowledge base.

pub fn has_constraint(&self, arity_args: usize) -> bool[src]

Returns true if a function has any constraints, false if there are none constraints.

This is used in the following rules in the standard library, using no_constr:

  • ∀(f:!{}) => \true
  • f:!{}([x..]) => f{(: vec)}(x)
  • f:!{}(a)(a) <=> f{eq}(a)(a)

For example, to detect whether it is safe to insert a new constraint. This check is important because a constraint refers to one or more arguments. By introducing a new constraint that refers incorrectly to its argument, it leads to unsoundness.

A function has none constraints if it is applied enough times to cover existing constraints. This means the total arity of constraints is less or equal than the total arity of arguments.

To avoid unsoundness under uncertain edge cases, this function should return true. This is because the no_constr check fails to pattern match, which is safe, since inactive rules do not introduce unsoundness.

Unfinished: This function requires analysis and unit testing.

pub fn has_type_judgement(&self) -> bool[src]

Returns true if expression has type judgement.

Trait Implementations

impl Add<Expr> for Expr[src]

type Output = Expr

The resulting type after applying the + operator.

impl Clone for Expr[src]

impl Debug for Expr[src]

impl Display for Expr[src]

impl Into<Expr> for bool[src]

impl Into<Expr> for f64[src]

impl<T, U> Into<Expr> for (T, U) where
    T: Into<Expr>,
    U: Into<Expr>, 
[src]

impl<T0, T1, T2> Into<Expr> for (T0, T1, T2) where
    T0: Into<Expr>,
    T1: Into<Expr>,
    T2: Into<Expr>, 
[src]

impl Into<Expr> for Symbol[src]

impl Into<Expr> for &'static str[src]

impl Mul<Expr> for Expr[src]

type Output = Expr

The resulting type after applying the * operator.

impl PartialEq<Expr> for Expr[src]

impl PartialOrd<Expr> for Expr[src]

impl StructuralPartialEq for Expr[src]

impl Sub<Expr> for Expr[src]

type Output = Expr

The resulting type after applying the - operator.

Auto Trait Implementations

impl RefUnwindSafe for Expr

impl Send for Expr

impl Sync for Expr

impl Unpin for Expr

impl UnwindSafe for Expr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.