Skip to main content

AirExpr

Enum AirExpr 

Source
pub enum AirExpr<F: Field> {
    Constant(F),
    Ref(ColumnRef),
    Neg(Box<AirExpr<F>>),
    Sum(Box<AirExpr<F>>, Box<AirExpr<F>>),
    Product(Box<AirExpr<F>>, Box<AirExpr<F>>),
}
Expand description

A symbolic polynomial expression over row-relative column references.

Used to define AIR transition constraints: expressions that must equal zero for every consecutive row pair (row[i], row[i+1]).

§Examples

use field_cat::F101;
use machine_cat::{AirExpr, Column};

// Constraint: next_a - current_b = 0
let current_b = AirExpr::<F101>::current(Column::new(1));
let next_a = AirExpr::<F101>::next(Column::new(0));
let constraint = next_a - current_b;

Variants§

§

Constant(F)

A field constant.

§

Ref(ColumnRef)

A row-relative column reference.

§

Neg(Box<AirExpr<F>>)

Negation.

§

Sum(Box<AirExpr<F>>, Box<AirExpr<F>>)

Sum of two expressions.

§

Product(Box<AirExpr<F>>, Box<AirExpr<F>>)

Product of two expressions.

Implementations§

Source§

impl<F: Field> AirExpr<F>

Source

pub fn constant(c: F) -> Self

A constant expression.

Source

pub fn current(col: Column) -> Self

Reference a column in the current row.

Source

pub fn next(col: Column) -> Self

Reference a column in the next row.

Source

pub fn evaluate<A: Fn(ColumnRef) -> Result<F, Error>>( &self, assignment: &A, ) -> Result<F, Error>

Evaluate this expression given a row-pair assignment.

The assignment maps each ColumnRef to a field value for a specific (row[i], row[i+1]) pair.

§Errors

Returns an error if the assignment fails for any referenced column (e.g., column out of bounds).

Trait Implementations§

Source§

impl<F: Field> Add for AirExpr<F>

Source§

type Output = AirExpr<F>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl<F: Clone + Field> Clone for AirExpr<F>

Source§

fn clone(&self) -> AirExpr<F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + Field> Debug for AirExpr<F>

Source§

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

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

impl<F: Field> Mul for AirExpr<F>

Source§

type Output = AirExpr<F>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl<F: Field> Neg for AirExpr<F>

Source§

type Output = AirExpr<F>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<F: Field> Sub for AirExpr<F>

Source§

type Output = AirExpr<F>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<F> Freeze for AirExpr<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for AirExpr<F>
where F: RefUnwindSafe,

§

impl<F> Send for AirExpr<F>
where F: Send,

§

impl<F> Sync for AirExpr<F>
where F: Sync,

§

impl<F> Unpin for AirExpr<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for AirExpr<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for AirExpr<F>
where F: UnwindSafe,

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> Same for T

Source§

type Output = T

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