pub(crate) struct CSatTransformer {
width: usize,
solvable_witness: HashSet<Witness>,
}
Expand description
A transformer which processes any Expression
s to break them up such that they
fit within the backend’s width.
This transformer is only used when targeting the Bounded
configuration.
This is done by creating intermediate variables to hold partial calculations and then combining them to calculate the original expression.
Pre-Condition:
- General Optimizer must run before this pass
Fields§
§width: usize
§solvable_witness: HashSet<Witness>
Track the witness that can be solved
Implementations§
Source§impl CSatTransformer
impl CSatTransformer
Sourcepub(crate) fn new(width: usize) -> CSatTransformer
pub(crate) fn new(width: usize) -> CSatTransformer
Create an optimizer with a given width.
Panics if width
is less than MIN_EXPRESSION_WIDTH
.
Sourcefn try_solve<F>(&mut self, opcode: &Expression<F>)
fn try_solve<F>(&mut self, opcode: &Expression<F>)
Check if the equation ‘expression=0’ can be solved, and if yes, add the solved witness to set of solvable witness
Sourcepub(crate) fn mark_solvable(&mut self, witness: Witness)
pub(crate) fn mark_solvable(&mut self, witness: Witness)
Adds the witness to set of solvable witness
Sourcepub(crate) fn transform<F: AcirField>(
&mut self,
opcode: Expression<F>,
intermediate_variables: &mut IndexMap<Expression<F>, (F, Witness)>,
num_witness: &mut u32,
) -> Expression<F>
pub(crate) fn transform<F: AcirField>( &mut self, opcode: Expression<F>, intermediate_variables: &mut IndexMap<Expression<F>, (F, Witness)>, num_witness: &mut u32, ) -> Expression<F>
Transform the input arithmetic expression into a new one having the correct ‘width’ by creating intermediate variables as needed. Having the correct width means:
- it has at most one multiplicative term
- it uses at most ‘width-1’ witness linear combination terms, to account for the new intermediate variable
fn full_opcode_scan_optimization<F: AcirField>( &mut self, opcode: Expression<F>, intermediate_variables: &mut IndexMap<Expression<F>, (F, Witness)>, num_witness: &mut u32, ) -> Expression<F>
Sourcefn normalize<F: AcirField>(expr: Expression<F>) -> (F, Expression<F>)
fn normalize<F: AcirField>(expr: Expression<F>) -> (F, Expression<F>)
Normalize an expression by dividing it by its first coefficient The first coefficient here means coefficient of the first linear term, or of the first quadratic term if no linear terms exist. The function panic if the input expression is constant
Sourcefn get_or_create_intermediate_vars<F: AcirField>(
intermediate_variables: &mut IndexMap<Expression<F>, (F, Witness)>,
expr: Expression<F>,
num_witness: &mut u32,
) -> (F, Witness)
fn get_or_create_intermediate_vars<F: AcirField>( intermediate_variables: &mut IndexMap<Expression<F>, (F, Witness)>, expr: Expression<F>, num_witness: &mut u32, ) -> (F, Witness)
Get or generate a scaled intermediate witness which is equal to the provided expression The sets of previously generated witness and their (normalized) expression is cached in the intermediate_variables map If there is no cache hit, we generate a new witness (and add the expression to the cache) else, we return the cached witness along with the scaling factor so it is equal to the provided expression
fn partial_opcode_scan_optimization<F: AcirField>( &mut self, opcode: Expression<F>, intermediate_variables: &mut IndexMap<Expression<F>, (F, Witness)>, num_witness: &mut u32, ) -> Expression<F>
Auto Trait Implementations§
impl Freeze for CSatTransformer
impl RefUnwindSafe for CSatTransformer
impl Send for CSatTransformer
impl Sync for CSatTransformer
impl Unpin for CSatTransformer
impl UnwindSafe for CSatTransformer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more