Skip to main content

LogUpGadget

Struct LogUpGadget 

Source
pub struct LogUpGadget;
Expand description

Core LogUp gadget implementing lookup arguments via logarithmic derivatives.

The LogUp gadget transforms the multiplicative lookup constraint:

∏(α - a_i)^(m_i) = ∏(α - b_j)^(m'_j)

Into an equivalent additive constraint using logarithmic differentiation:

∑(m_i/(α - a_i)) = ∑(m'_j/(α - b_j))

This is implemented using a running sum auxiliary column s that accumulates:

s[i+1] = s[i] + ∑(m_a/(α - a)) - ∑(m_b/(α - b))

Note that we do not differentiate between a and b in the implementation: we simply have a list of elements with possibly negative multiplicities.

Constraints are defined as:

  • Initial Constraint: s[0] = 0
  • Transition Constraint: s[i+1] = s[i] + contribution[i]
  • Final Constraint: s[n-1] + contribution[n-1] = 0

Implementations§

Source§

impl LogUpGadget

Source

pub const fn new() -> Self

Creates a new LogUp gadget instance.

Trait Implementations§

Source§

impl Clone for LogUpGadget

Source§

fn clone(&self) -> LogUpGadget

Returns a duplicate 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 LogUpGadget

Source§

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

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

impl Default for LogUpGadget

Source§

fn default() -> LogUpGadget

Returns the “default value” for a type. Read more
Source§

impl LookupEvaluator for LogUpGadget

Source§

fn eval_local_lookup<AB>(&self, builder: &mut AB, context: &Lookup<AB::F>)

§Mathematical Details

The constraint enforces:

∑_i(multiplicities[i] / (α - combined_elements[i])) = 0

where multiplicities can be negative, and combined_elements[i] = ∑elements[i][n-j] * β^j.

This is implemented using a running sum column that should sum to zero.

Source§

fn eval_global_update<AB>( &self, builder: &mut AB, context: &Lookup<AB::F>, expected_cumulated: AB::ExprEF, )

§Mathematical Details

The constraint enforces:

∑_i(multiplicities[i] / (α - combined_elements[i])) = `expected_cumulated`

where multiplicities can be negative, and combined_elements[i] = ∑elements[i][n-j] * β^j.

expected_cumulated is provided by the prover, and the sum of all expected_cumulated for this global interaction should be 0. The latter is checked as the final step, after all AIRS have been verified.

This is implemented using a running sum column that should sum to expected_cumulated.

Source§

fn num_aux_cols(&self) -> usize

Returns the number of auxiliary columns needed by this lookup protocol. Read more
Source§

fn num_challenges(&self) -> usize

Returns the number of challenges for each lookup argument. Read more
Source§

fn eval_lookups<AB>(&self, builder: &mut AB, contexts: &[Lookup<AB::F>])

Evaluates the lookup constraints for all provided contexts. Read more
Source§

impl LookupGadget for LogUpGadget

Source§

fn constraint_degree<F: Field>(&self, context: &Lookup<F>) -> usize

We need to compute the degree of the transition constraint, as it is the constraint with highest degree: (s[n + 1] - s[n]) * common_denominator - numerator = 0

But in common_denominator, each combined element e_i = ∑e_{i, j} β^j contributes (α - e_i). So we need to sum the degree of all combined elements to find the degree of the common denominator.

numerator = ∑(m_i * ∏_{j≠i}(α - e_j)), where the e_j are the combined elements. So we have to compute the max of all m_i * ∏_{j≠i}(α - e_j).

The constraint degree is then: 1 + max(deg(numerator), deg(common_denominator))

Source§

fn verify_global_final_value<EF: Field>( &self, all_expected_cumulative: &[EF], ) -> Result<(), LookupError>

Evaluates the final cumulated value over all AIRs involved in the interaction, and checks that it is equal to the expected final value. Read more
Source§

fn generate_permutation<SC: StarkGenericConfig>( &self, main: &RowMajorMatrix<Val<SC>>, preprocessed: &Option<RowMajorMatrix<Val<SC>>>, public_values: &[Val<SC>], lookups: &[Lookup<Val<SC>>], lookup_data: &mut [LookupData<SC::Challenge>], permutation_challenges: &[SC::Challenge], ) -> RowMajorMatrix<SC::Challenge>

Generates the permutation matrix for the lookup argument.

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, 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> 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> 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<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