pub struct AssertLtSubAir {
pub bus: VariableRangeCheckerBus,
pub max_bits: usize,
pub decomp_limbs: usize,
}
Expand description
This is intended for use as a SubAir, not as a standalone Air.
This SubAir constrains that x < y
when count != 0
, assuming
the two numbers both have a max number of bits, given by max_bits
.
The SubAir decomposes y - x - 1
into limbs of
size bus.range_max_bits
, and interacts with a
VariableRangeCheckerBus
to range check the decompositions.
The SubAir will own auxilliary columns to store the decomposed limbs.
The number of limbs is max_bits.div_ceil(bus.range_max_bits)
.
The expected max constraint degree of eval
is
deg(count) + max(1, deg(x), deg(y))
Fields§
§bus: VariableRangeCheckerBus
The bus for sends to range chip
max_bits: usize
The maximum number of bits for the numbers to compare Soundness requirement: max_bits <= 29 max_bits > 29 doesn’t work: the approach is to check that y-x-1 is non-negative. For a field with prime modular, this is equivalent to checking that y-x-1 is in the range [0, 2^max_bits - 1]. However, for max_bits > 29, if y is small enough and x is large enough, then y-x-1 is negative but can still be in the range due to the field size not being big enough.
decomp_limbs: usize
decomp_limbs = max_bits.div_ceil(bus.range_max_bits)
is the
number of limbs that y - x - 1
will be decomposed into.
Implementations§
Source§impl AssertLtSubAir
impl AssertLtSubAir
pub fn new(bus: VariableRangeCheckerBus, max_bits: usize) -> Self
pub fn when_transition(self) -> AssertLtWhenTransitionAir
pub fn range_max_bits(&self) -> usize
Trait Implementations§
Source§impl Clone for AssertLtSubAir
impl Clone for AssertLtSubAir
Source§fn clone(&self) -> AssertLtSubAir
fn clone(&self) -> AssertLtSubAir
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AssertLtSubAir
impl Debug for AssertLtSubAir
Source§impl<AB: InteractionBuilder> SubAir<AB> for AssertLtSubAir
impl<AB: InteractionBuilder> SubAir<AB> for AssertLtSubAir
Source§type AirContext<'a> = (AssertLessThanIo<<AB as AirBuilder>::Expr>, &'a [<AB as AirBuilder>::Var])
where
AB::Expr: 'a,
AB::Var: 'a,
AB: 'a
type AirContext<'a> = (AssertLessThanIo<<AB as AirBuilder>::Expr>, &'a [<AB as AirBuilder>::Var]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a
AB::Expr
that are needed
to define the SubAir’s constraints.fn eval<'a>( &'a self, builder: &'a mut AB, (io, lower_decomp): (AssertLessThanIo<AB::Expr>, &'a [AB::Var]), )
Source§impl<F: Field> TraceSubRowGenerator<F> for AssertLtSubAir
impl<F: Field> TraceSubRowGenerator<F> for AssertLtSubAir
Source§type TraceContext<'a> = (&'a VariableRangeCheckerChip, u32, u32)
type TraceContext<'a> = (&'a VariableRangeCheckerChip, u32, u32)
(range_checker, x, y)
Source§fn generate_subrow<'a>(
&'a self,
(range_checker, x, y): (&'a VariableRangeCheckerChip, u32, u32),
lower_decomp: &'a mut [F],
)
fn generate_subrow<'a>( &'a self, (range_checker, x, y): (&'a VariableRangeCheckerChip, u32, u32), lower_decomp: &'a mut [F], )
Should only be used when io.count != 0
.
impl Copy for AssertLtSubAir
Auto Trait Implementations§
impl Freeze for AssertLtSubAir
impl RefUnwindSafe for AssertLtSubAir
impl Send for AssertLtSubAir
impl Sync for AssertLtSubAir
impl Unpin for AssertLtSubAir
impl UnwindSafe for AssertLtSubAir
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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