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
impl LogUpGadget
Trait Implementations§
Source§impl Clone for LogUpGadget
impl Clone for LogUpGadget
Source§fn clone(&self) -> LogUpGadget
fn clone(&self) -> LogUpGadget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogUpGadget
impl Debug for LogUpGadget
Source§impl Default for LogUpGadget
impl Default for LogUpGadget
Source§fn default() -> LogUpGadget
fn default() -> LogUpGadget
Source§impl LookupEvaluator for LogUpGadget
impl LookupEvaluator for LogUpGadget
Source§fn eval_local_lookup<AB>(&self, builder: &mut AB, context: &Lookup<AB::F>)where
AB: PermutationAirBuilder,
fn eval_local_lookup<AB>(&self, builder: &mut AB, context: &Lookup<AB::F>)where
AB: PermutationAirBuilder,
§Mathematical Details
The constraint enforces:
∑_i(multiplicities[i] / (α - combined_elements[i])) = 0where 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,
)where
AB: PermutationAirBuilder,
fn eval_global_update<AB>(
&self,
builder: &mut AB,
context: &Lookup<AB::F>,
expected_cumulated: AB::ExprEF,
)where
AB: PermutationAirBuilder,
§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
fn num_aux_cols(&self) -> usize
Source§fn num_challenges(&self) -> usize
fn num_challenges(&self) -> usize
Source§fn eval_lookups<AB>(&self, builder: &mut AB, contexts: &[Lookup<AB::F>])where
AB: PermutationAirBuilder,
fn eval_lookups<AB>(&self, builder: &mut AB, contexts: &[Lookup<AB::F>])where
AB: PermutationAirBuilder,
Source§impl LookupGadget for LogUpGadget
impl LookupGadget for LogUpGadget
Source§fn constraint_degree<F: Field>(&self, context: &Lookup<F>) -> usize
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>
fn verify_global_final_value<EF: Field>( &self, all_expected_cumulative: &[EF], ) -> Result<(), LookupError>
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>
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>
Auto Trait Implementations§
impl Freeze for LogUpGadget
impl RefUnwindSafe for LogUpGadget
impl Send for LogUpGadget
impl Sync for LogUpGadget
impl Unpin for LogUpGadget
impl UnsafeUnpin for LogUpGadget
impl UnwindSafe for LogUpGadget
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§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