openvm_circuit_primitives::is_less_than

Struct IsLtSubAir

Source
pub struct IsLtSubAir {
    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 the boolean equal to 1 iff x < y, assuming the two numbers both have a max number of bits, given by max_bits. The SubAir compares the numbers by decomposing y - x - 1 + 2^max_bits 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))

N.B.: AssertLtSubAir could be implemented by directly passing through to IsLtSubAir with out = AB::Expr::ONE. The only additional constraint in this air is assert_bool(io.out). However since both Airs are fundamental and the constraints are simple, we opt to keep the two versions separate.

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 decompose and range check y - x - 1 + 2^max_bits is non-negative. This requires 2^{max_bits+1} < |F|. When F::bits() = 31, this implies max_bits <= 29.

§decomp_limbs: usize

decomp_limbs = max_bits.div_ceil(bus.range_max_bits).

Implementations§

Source§

impl IsLtSubAir

Source

pub fn new(bus: VariableRangeCheckerBus, max_bits: usize) -> Self

Source

pub fn range_max_bits(&self) -> usize

Source

pub fn when_transition(self) -> IsLtWhenTransitionAir

Source

pub fn eval_range_checks<AB: InteractionBuilder>( &self, builder: &mut AB, lower_decomp: &[AB::Var], count: impl Into<AB::Expr>, )

Trait Implementations§

Source§

impl Clone for IsLtSubAir

Source§

fn clone(&self) -> IsLtSubAir

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IsLtSubAir

Source§

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

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

impl<AB: InteractionBuilder> SubAir<AB> for IsLtSubAir

Source§

type AirContext<'a> = (IsLessThanIo<<AB as AirBuilder>::Expr>, &'a [<AB as AirBuilder>::Var]) where AB::Expr: 'a, AB::Var: 'a, AB: 'a

Type to define the context, typically in terms of AB::Expr that are needed to define the SubAir’s constraints.
Source§

fn eval<'a>( &'a self, builder: &'a mut AB, (io, lower_decomp): (IsLessThanIo<AB::Expr>, &'a [AB::Var]), )
where AB::Var: 'a, AB::Expr: 'a,

Source§

impl<F: Field> TraceSubRowGenerator<F> for IsLtSubAir

Source§

type TraceContext<'a> = (&'a VariableRangeCheckerChip, u32, u32)

(range_checker, x, y)

Source§

type ColsMut<'a> = (&'a mut [F], &'a mut F)

(lower_decomp, out)

Source§

fn generate_subrow<'a>( &'a self, (range_checker, x, y): (&'a VariableRangeCheckerChip, u32, u32), (lower_decomp, out): (&'a mut [F], &'a mut F), )

Only use this when count != 0.

Source§

impl Copy for IsLtSubAir

Auto Trait Implementations§

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more