97 if (lookup_index == 0) {
101 switch (Settings_::LOOKUP_TYPES[lookup_index - 1]) {
124 if (table_index == 0) {
128 switch (Settings_::TABLE_TYPES[table_index - 1]) {
155 requires std::is_same_v<
decltype(S::NUM_LOOKUP_TERMS),
const size_t>;
156 requires std::is_same_v<
decltype(S::NUM_TABLE_TERMS),
const size_t>;
167 requires std::is_same_v<
decltype(S::LOOKUP_TUPLE_SIZE),
const size_t>;
170 requires std::is_same_v<
decltype(S::INVERSE_EXISTS_POLYNOMIAL_DEGREE),
const size_t>;
265 size_t accumulated_degree = 0;
267 size_t current_degree = 0;
268 switch (Settings::LOOKUP_TYPES[i]) {
273 current_degree = Settings::LOOKUP_TERM_DEGREES[i];
278 accumulated_degree += current_degree;
280 return accumulated_degree;
290 size_t accumulated_degree = 0;
292 size_t current_degree = 0;
293 switch (Settings::TABLE_TYPES[i]) {
298 current_degree = Settings::TABLE_TERM_DEGREES[i];
304 accumulated_degree += current_degree;
306 return accumulated_degree;
320 constexpr size_t ADDITIONAL_DEGREE = 3;
321 constexpr size_t TOTAL_TERM_PRODUCT_DEGREE =
324 size_t max_degree = 0;
326 size_t current_degree = 0;
327 switch (Settings::LOOKUP_TYPES[i]) {
332 current_degree = Settings::LOOKUP_TERM_DEGREES[i];
337 size_t adjusted_degree = TOTAL_TERM_PRODUCT_DEGREE - current_degree;
338 max_degree =
std::max(max_degree, adjusted_degree);
341 size_t current_degree = 0;
342 switch (Settings::TABLE_TYPES[i]) {
347 current_degree = Settings::TABLE_TERM_DEGREES[i];
353 size_t adjusted_degree = TOTAL_TERM_PRODUCT_DEGREE - current_degree;
354 max_degree =
std::max(max_degree, adjusted_degree);
356 return max_degree + ADDITIONAL_DEGREE;
367 Settings::INVERSE_EXISTS_POLYNOMIAL_DEGREE) +
390 return Settings::inverse_polynomial_is_computed_at_row(row);
416 template <
typename Accumulator,
typename AllEntities>
421 return Settings::template compute_inverse_exists<Accumulator>(in);
436 template <
typename Accumulator,
size_t index,
typename AllEntities>
441 using View =
typename Accumulator::View;
443 return Accumulator(View(
456 template <
typename Accumulator,
size_t lookup_index,
typename AllEntities>
461 using View =
typename Accumulator::View;
464 Settings::get_const_entities(in))));
476 template <
typename Accumulator,
size_t table_index,
typename AllEntities>
481 using View =
typename Accumulator::View;
484 Settings::get_const_entities(in))));
498 template <
typename Accumulator,
size_t lookup_index,
typename AllEntities,
typename Parameters>
501 using View =
typename Accumulator::View;
504 constexpr size_t start_polynomial_index =
506 const FF beta = params.beta;
507 const FF gamma = params.gamma;
509 if constexpr (Settings::LOOKUP_TYPES[lookup_index] ==
BASIC_LOOKUP) {
511 Accumulator result = Accumulator(0);
513 const auto all_polynomials = Settings::get_const_entities(in);
514 bb::constexpr_for<start_polynomial_index, start_polynomial_index + LOOKUP_TUPLE_SIZE, 1>(
515 [&]<
size_t i>() { result = (result * beta) + View(
std::get<i>(all_polynomials)); });
517 return result + gamma;
518 }
else if constexpr (Settings::LOOKUP_TYPES[lookup_index] ==
CUSTOMIZED_LOOKUP) {
519 return Settings::template compute_lookup_term<Accumulator, lookup_index>(in, params);
522 return Accumulator(0);
537 template <
typename Accumulator,
size_t table_index,
typename AllEntities,
typename Parameters>
540 using View =
typename Accumulator::View;
543 constexpr size_t start_polynomial_index =
545 const FF beta = params.beta;
546 const FF gamma = params.gamma;
548 if constexpr (Settings::TABLE_TYPES[table_index] ==
BASIC_TABLE) {
550 Accumulator result = Accumulator(0);
552 const auto all_polynomials = Settings::get_const_entities(in);
554 bb::constexpr_for<start_polynomial_index, start_polynomial_index + LOOKUP_TUPLE_SIZE, 1>(
555 [&]<
size_t i>() { result = (result * beta) + View(
std::get<i>(all_polynomials)); });
557 return result + gamma;
558 }
else if constexpr (Settings::TABLE_TYPES[table_index] ==
CUSTOMIZED_TABLE) {
559 return Settings::template compute_table_term<Accumulator, table_index>(in, params);
562 return Accumulator(0);
584 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
585 static void accumulate(ContainerOverSubrelations& accumulator,
586 const AllEntities& in,
587 const Parameters& params,
588 const FF& scaling_factor)
592 ContainerOverSubrelations,
595 false>(accumulator, in, params, scaling_factor);
599template <
typename Settings,
typename FF>
Generic implementation of a log-derivative based lookup relation.
static constexpr size_t compute_lookup_term_product_degree()
Compute the degree of the product of lookup terms.
static Accumulator compute_inverse_exists(const AllEntities &in)
Get selector/wire switching on (1) or off (0) inverse computation.
static constexpr size_t TABLE_TERM_ACCUMULATED_DEGREE
static constexpr std::array< bool, 2 > SUBRELATION_LINEARLY_INDEPENDENT
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters ¶ms, const FF &scaling_factor)
Compute generic log-derivative lookup subrelation accumulation.
static constexpr size_t compute_table_term_product_degree()
Compute the degree of the product of table terms.
static constexpr size_t LOOKUP_TUPLE_SIZE
static constexpr size_t FIRST_RELATION_PARTIAL_LENGTH
static bool operation_exists_at_row(const AllValues &row)
Check if we need to compute the inverse polynomial element value for this row.
static auto & get_inverse_polynomial(AllEntities &in)
Get the inverse permutation polynomial.
static Accumulator compute_lookup_term(const AllEntities &in, const Parameters ¶ms)
Compute the value of the lookup term at a given index.
static Accumulator compute_table_term(const AllEntities &in, const Parameters ¶ms)
Compute the value of a table term at a given index.
static constexpr size_t compute_second_subrelation_degree()
Compute the degree of the second subrelation.
static constexpr size_t NUM_LOOKUP_TERMS
static constexpr size_t NUM_TABLE_TERMS
static constexpr size_t SECOND_RELATION_PARTIAL_LENGTH
static constexpr size_t LENGTH
static constexpr size_t LOOKUP_TERM_ACCUMULATED_DEGREE
static Accumulator get_table_term_predicate(const AllEntities &in)
Extract predicate enabling looking up a given table term at this row.
static constexpr std::array< size_t, 2 > SUBRELATION_PARTIAL_LENGTHS
static Accumulator get_lookup_term_predicate(const AllEntities &in)
Extract predicate enabling looking up a given lookup term at this row.
static Accumulator lookup_read_counts(const AllEntities &in)
Get the number of times a particular table value has been looked up.
Polynomial structure required for the lookup argument.
static constexpr size_t NUM_LOOKUP_TERMS
static constexpr size_t compute_table_term_polynomial_offset(size_t table_index)
Compute where the polynomials defining a particular table term are located.
static constexpr size_t get_table_term_predicate_index(const size_t table_index)
static constexpr size_t compute_lookup_term_polynomial_offset(size_t lookup_index)
Compute where the polynomials defining a particular lookup term are located.
static constexpr size_t LOOKUP_TERM_START_POLYNOMIAL_INDEX
static constexpr size_t LOOKUP_TERM_PREDICATE_START_POLYNOMIAL_INDEX
static constexpr size_t get_inverse_polynomial_index()
static constexpr size_t get_read_count_polynomial_index(const size_t index)
static constexpr size_t INVERSE_POLYNOMIAL_INDEX
static constexpr size_t LOOKUP_READ_COUNT_START_POLYNOMIAL_INDEX
static constexpr size_t NUM_TABLE_TERMS
static constexpr size_t TABLE_TERM_PREDICATE_START_POLYNOMIAL_INDEX
static constexpr size_t get_lookup_term_predicate_index(const size_t lookup_index)
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
Concept defining the requirements for the Settings struct used to configure the GenericLookupRelation...
Entry point for Barretenberg command-line interface.
void _accumulate_logderivative_subrelation_contributions(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters ¶ms, const FF &scaling_factor)
Unified implementation of log-derivative subrelation accumulation.
void assert_failure(std::string const &err)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept