111 static constexpr std::array<bool, 3>
116 template <
typename AllEntities>
inline static bool skip(
const AllEntities& in)
119 return in.q_lookup.is_zero() && in.lookup_read_counts.is_zero();
136 return (row.q_lookup == 1) || (row.lookup_read_tags == 1);
157 template <
typename Accumulator,
typename AllEntities>
160 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
162 const auto row_has_write = CoefficientAccumulator(in.lookup_read_tags);
163 const auto row_has_read = CoefficientAccumulator(in.q_lookup);
171 return Accumulator(-(row_has_write * row_has_read) + row_has_write + row_has_read);
191 template <
typename Accumulator,
typename AllEntities,
typename Parameters>
194 using ParameterCoefficientAccumulator =
typename Parameters::DataType::CoefficientAccumulator;
195 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
197 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
198 const auto beta = ParameterCoefficientAccumulator(params.beta);
199 const auto beta_sqr = ParameterCoefficientAccumulator(params.beta_sqr);
200 const auto beta_cube = ParameterCoefficientAccumulator(params.beta_cube);
202 auto table_1 = CoefficientAccumulator(in.table_1);
203 auto table_2 = CoefficientAccumulator(in.table_2);
204 auto table_3 = CoefficientAccumulator(in.table_3);
205 auto table_4 = CoefficientAccumulator(in.table_4);
208 auto result = (table_2 * beta) + (table_3 * beta_sqr) + (table_4 * beta_cube);
211 return Accumulator(result);
214 template <
typename Accumulator,
typename AllEntities,
typename Parameters>
217 using ParameterCoefficientAccumulator =
typename Parameters::DataType::CoefficientAccumulator;
218 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
220 const auto gamma = ParameterCoefficientAccumulator(params.gamma);
221 const auto beta = ParameterCoefficientAccumulator(params.beta);
222 const auto beta_sqr = ParameterCoefficientAccumulator(params.beta_sqr);
223 const auto beta_cube = ParameterCoefficientAccumulator(params.beta_cube);
225 auto w_1 = CoefficientAccumulator(in.w_l);
226 auto w_2 = CoefficientAccumulator(in.w_r);
227 auto w_3 = CoefficientAccumulator(in.w_o);
229 auto w_1_shift = CoefficientAccumulator(in.w_l_shift);
230 auto w_2_shift = CoefficientAccumulator(in.w_r_shift);
231 auto w_3_shift = CoefficientAccumulator(in.w_o_shift);
233 auto table_index = CoefficientAccumulator(in.q_o);
234 auto negative_column_1_step_size = CoefficientAccumulator(in.q_r);
235 auto negative_column_2_step_size = CoefficientAccumulator(in.q_m);
236 auto negative_column_3_step_size = CoefficientAccumulator(in.q_c);
242 auto derived_table_entry_1 = (negative_column_1_step_size * w_1_shift) + (w_1 + gamma);
244 auto derived_table_entry_2 = (negative_column_2_step_size * w_2_shift) + w_2;
246 auto derived_table_entry_3 = (negative_column_3_step_size * w_3_shift) + w_3;
248 auto table_index_entry = table_index * beta_cube;
253 auto result = Accumulator(derived_table_entry_2) * beta + Accumulator(derived_table_entry_3) * beta_sqr;
254 result += Accumulator(derived_table_entry_1 + table_index_entry);
269 template <
typename Polynomials>
271 auto& relation_parameters,
272 const size_t circuit_size)
277 size_t min_iterations_per_thread = 1 << 6;
281 for (
size_t i : chunk.
range(circuit_size)) {
283 if (polynomials.q_lookup.get(i) == 1 || polynomials.lookup_read_tags.get(i) == 1) {
285 auto row = polynomials.get_row(i);
286 auto value = compute_lookup_term<FF>(row, relation_parameters) *
287 compute_table_term<FF>(row, relation_parameters);
288 inverse_polynomial.at(i) =
value;
306 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
307 static void accumulate(ContainerOverSubrelations& accumulator,
308 const AllEntities& in,
309 const Parameters& params,
310 const FF& scaling_factor)
317 using ShortView =
typename ShortAccumulator::View;
320 using CoefficientAccumulator =
typename Accumulator::CoefficientAccumulator;
325 const auto inverses_m = CoefficientAccumulator(in.lookup_inverses);
326 const Accumulator inverses(inverses_m);
327 const auto read_counts_m = CoefficientAccumulator(in.lookup_read_counts);
328 const auto read_selector_m = CoefficientAccumulator(in.q_lookup);
330 const auto inverse_exists = compute_inverse_exists<Accumulator>(in);
331 const auto lookup_term = compute_lookup_term<Accumulator>(in, params);
332 const auto table_term = compute_table_term<Accumulator>(in, params);
337 const Accumulator logderiv_first_term = (lookup_term * table_term * inverses - inverse_exists) * scaling_factor;
338 std::get<0>(accumulator) += ShortView(logderiv_first_term);
343 Accumulator tmp = Accumulator(read_selector_m) * table_term;
344 tmp -= (Accumulator(read_counts_m) * lookup_term);
349 const auto read_tag_m = CoefficientAccumulator(in.lookup_read_tags);
350 const auto read_tag = BooleanCheckerAccumulator(read_tag_m);
352 std::get<2>(accumulator) += (read_tag * read_tag - read_tag) * scaling_factor;
#define BB_BENCH_NAME(name)
Log-derivative lookup argument relation for establishing lookup reads from tables with 3 or fewer col...
static constexpr std::array< size_t, 3 > SUBRELATION_PARTIAL_LENGTHS
static bool operation_exists_at_row(const AllValues &row)
Does the provided row contain data relevant to table lookups.
static constexpr size_t TABLE_TERMS
static void compute_logderivative_inverse(Polynomials &polynomials, auto &relation_parameters, const size_t circuit_size)
Construct the polynomial whose components are the inverse of the product of the read and write terms...
static constexpr size_t LOOKUP_SUBRELATION_LENGTH
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters ¶ms, const FF &scaling_factor)
Accumulate the subrelation contributions for reads from a lookup table.
static Accumulator compute_inverse_exists(const AllEntities &in)
Compute the Accumulator whose values indicate whether the inverse is computed or not.
static constexpr size_t INVERSE_SUBRELATION_LENGTH
static Accumulator compute_table_term(const AllEntities &in, const Parameters ¶ms)
Compute the table term.
static constexpr std::array< bool, 3 > SUBRELATION_LINEARLY_INDEPENDENT
static bool skip(const AllEntities &in)
static Accumulator compute_lookup_term(const AllEntities &in, const Parameters ¶ms)
static auto & get_inverse_polynomial(AllEntities &in)
static constexpr size_t BOOLEAN_CHECK_SUBRELATION_LENGTH
A wrapper for Relations to expose methods used by the Sumcheck prover or verifier to add the contribu...
Entry point for Barretenberg command-line interface.
size_t calculate_num_threads(size_t num_iterations, size_t min_iterations_per_thread)
calculates number of threads to create based on minimum iterations per thread
void parallel_for(size_t num_iterations, const std::function< void(size_t)> &func)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
auto range(size_t size, size_t offset=0) const
static void batch_invert(C &coeffs) noexcept
Batch invert a collection of field elements using Montgomery's trick.