pub trait ExprLowering {
type CellOutput;
Show 23 methods
// Required methods
fn lower_sum(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_product(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_neg(&self, expr: &Self::CellOutput) -> Result<Self::CellOutput>;
fn lower_constant(&self, f: Felt) -> Result<Self::CellOutput>;
fn lower_eq(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_lt(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_le(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_gt(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_ge(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_ne(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_and(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_or(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_not(&self, value: &Self::CellOutput) -> Result<Self::CellOutput>;
fn lower_true(&self) -> Result<Self::CellOutput>;
fn lower_false(&self) -> Result<Self::CellOutput>;
fn lower_det(&self, expr: &Self::CellOutput) -> Result<Self::CellOutput>;
fn lower_implies(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_iff(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>;
fn lower_function_input(&self, i: usize) -> Slot;
fn lower_function_output(&self, o: usize) -> Slot;
fn lower_funcio<IO>(&self, io: IO) -> Result<Self::CellOutput>
where IO: Into<Slot>;
// Provided methods
fn lower_function_inputs(
&self,
ins: impl IntoIterator<Item = usize>,
) -> Vec<Slot> { ... }
fn lower_function_outputs(
&self,
outs: impl IntoIterator<Item = usize>,
) -> Vec<Slot> { ... }
}Expand description
Defines the interface code generators expose for generating expressions in their corresponding IR.
Required Associated Types§
Sourcetype CellOutput
type CellOutput
The type representing a generated expression.
Required Methods§
Sourcefn lower_sum(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_sum( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits an expression representing addition.
Sourcefn lower_product(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_product( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits an expression representing multiplication.
Sourcefn lower_neg(&self, expr: &Self::CellOutput) -> Result<Self::CellOutput>
fn lower_neg(&self, expr: &Self::CellOutput) -> Result<Self::CellOutput>
Emits an expression representing negation.
Sourcefn lower_constant(&self, f: Felt) -> Result<Self::CellOutput>
fn lower_constant(&self, f: Felt) -> Result<Self::CellOutput>
Emits a constant value.
Sourcefn lower_eq(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_eq( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a boolean expression representing equality between the operands.
Sourcefn lower_lt(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_lt( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a boolean expression representing a less-than relation between the operands.
Sourcefn lower_le(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_le( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a boolean expression representing a less-than or equal relation between the operands.
Sourcefn lower_gt(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_gt( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a boolean expression representing a greater-than relation between the operands.
Sourcefn lower_ge(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_ge( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a boolean expression representing a greater-than or equal relation between the operands.
Sourcefn lower_ne(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_ne( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a boolean expression representing the negation of equality between the operands.
Sourcefn lower_and(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_and( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a logical AND between the two operands.
Sourcefn lower_or(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_or( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a logical OR between the two operands.
Sourcefn lower_not(&self, value: &Self::CellOutput) -> Result<Self::CellOutput>
fn lower_not(&self, value: &Self::CellOutput) -> Result<Self::CellOutput>
Emits a logical NOT between the two operands.
Sourcefn lower_true(&self) -> Result<Self::CellOutput>
fn lower_true(&self) -> Result<Self::CellOutput>
Emits a literal true value.
Sourcefn lower_false(&self) -> Result<Self::CellOutput>
fn lower_false(&self) -> Result<Self::CellOutput>
Emits a literal false value.
Sourcefn lower_det(&self, expr: &Self::CellOutput) -> Result<Self::CellOutput>
fn lower_det(&self, expr: &Self::CellOutput) -> Result<Self::CellOutput>
Emits an expression that hints that the given expression must be proven deterministic.
The concrete semantics of this expression are backend dependant but it must return an expression of boolean type.
Sourcefn lower_implies(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_implies( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a logical implication between the two operands.
Sourcefn lower_iff(
&self,
lhs: &Self::CellOutput,
rhs: &Self::CellOutput,
) -> Result<Self::CellOutput>
fn lower_iff( &self, lhs: &Self::CellOutput, rhs: &Self::CellOutput, ) -> Result<Self::CellOutput>
Emits a logical double-implication between the two operands.
Sourcefn lower_function_input(&self, i: usize) -> Slot
fn lower_function_input(&self, i: usize) -> Slot
Returns a Slot representing the i-th input.
Sourcefn lower_function_output(&self, o: usize) -> Slot
fn lower_function_output(&self, o: usize) -> Slot
Returns a Slot representing the o-th output.
Sourcefn lower_funcio<IO>(&self, io: IO) -> Result<Self::CellOutput>
fn lower_funcio<IO>(&self, io: IO) -> Result<Self::CellOutput>
Emits an expression representing the given IO.
Provided Methods§
Sourcefn lower_function_inputs(
&self,
ins: impl IntoIterator<Item = usize>,
) -> Vec<Slot>
fn lower_function_inputs( &self, ins: impl IntoIterator<Item = usize>, ) -> Vec<Slot>
Returns a list of Slot representing the input indices in the iterator.
Sourcefn lower_function_outputs(
&self,
outs: impl IntoIterator<Item = usize>,
) -> Vec<Slot>
fn lower_function_outputs( &self, outs: impl IntoIterator<Item = usize>, ) -> Vec<Slot>
Returns a list of Slot representing the output indices in the iterator.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.