12#include "barretenberg/common/constexpr_utils.hpp"
13#include "barretenberg/polynomials/polynomial.hpp"
14#include "barretenberg/polynomials/univariate.hpp"
15#include "barretenberg/relations/relation_types.hpp"
17namespace proof_system::honk::sumcheck {
23 INVERSE_POLYNOMIAL_INDEX,
24 ENABLE_INVERSE_CORRECTNESS_CHECK_POLYNOMIAL_INDEX,
25 FIRST_PERMUTATION_SET_ENABLE_POLYNOMIAL_INDEX,
27 SECOND_PERMUTATION_SET_ENABLE_POLYNOMIAL_INDEX,
30 PERMUTATION_SETS_START_POLYNOMIAL_INDEX,
39 static constexpr size_t READ_TERMS = 1;
40 static constexpr size_t WRITE_TERMS = 1;
42 static constexpr size_t LENGTH = READ_TERMS + WRITE_TERMS + 3;
44 static constexpr std::array<size_t, 2> SUBRELATION_PARTIAL_LENGTHS{
67 return Settings::inverse_polynomial_is_computed_at_row(row);
78 return std::get<INVERSE_POLYNOMIAL_INDEX>(Settings::get_nonconst_entities(in));
85 template <
typename Accumulator,
typename AllEntities>
88 using View =
typename Accumulator::View;
92 View(std::get<ENABLE_INVERSE_CORRECTNESS_CHECK_POLYNOMIAL_INDEX>(Settings::get_const_entities(in))));
100 template <
typename Accumulator,
size_t read_index,
typename AllEntities>
104 static_assert(read_index < WRITE_TERMS);
105 using View =
typename Accumulator::View;
110 View(std::get<FIRST_PERMUTATION_SET_ENABLE_POLYNOMIAL_INDEX>(Settings::get_const_entities(in))));
118 template <
typename Accumulator,
size_t write_index,
typename AllEntities>
121 static_assert(write_index < WRITE_TERMS);
122 using View =
typename Accumulator::View;
127 View(std::get<SECOND_PERMUTATION_SET_ENABLE_POLYNOMIAL_INDEX>(Settings::get_const_entities(in))));
140 template <
typename Accumulator,
size_t read_index,
typename AllEntities,
typename Parameters>
143 using View =
typename Accumulator::View;
145 static_assert(read_index < READ_TERMS);
148 const auto all_polynomials = Settings::get_const_entities(in);
150 auto result = Accumulator(0);
154 PERMUTATION_SETS_START_POLYNOMIAL_INDEX + Settings::COLUMNS_PER_SET,
156 [&]<
size_t i>() { result = result * params.beta + View(std::get<i>(all_polynomials)); });
158 const auto& gamma = params.gamma;
159 return result + gamma;
172 template <
typename Accumulator,
size_t write_index,
typename AllEntities,
typename Parameters>
175 using View =
typename Accumulator::View;
177 static_assert(write_index < WRITE_TERMS);
180 const auto& used_entities = Settings::get_const_entities(in);
182 auto result = Accumulator(0);
185 PERMUTATION_SETS_START_POLYNOMIAL_INDEX + 2 * Settings::COLUMNS_PER_SET,
187 [&]<
size_t i>() { result = result * params.beta + View(std::get<i>(used_entities)); });
189 const auto& gamma = params.gamma;
190 return result + gamma;
200 template <
typename ContainerOverSubrelations,
typename AllEntities,
typename Parameters>
201 static void accumulate(ContainerOverSubrelations& accumulator,
202 const AllEntities& in,
203 const Parameters& params,
204 const FF& scaling_factor);
207template <
typename Settings,
typename FF>
The templates defined herein facilitate sharing the relation arithmetic between the prover and the ve...
Definition: relation_types.hpp:121
Definition: generic_permutation_relation.hpp:34
static Accumulator compute_read_term(const AllEntities &in, const Parameters ¶ms)
Compute the value of a single item in the set.
Definition: generic_permutation_relation.hpp:141
static auto & get_inverse_polynomial(AllEntities &in)
Get the inverse permutation polynomial (needed to compute its value)
Definition: generic_permutation_relation.hpp:74
static constexpr std::array< bool, 2 > SUBRELATION_LINEARLY_INDEPENDENT
We apply the power polynomial only to the first subrelation.
Definition: generic_permutation_relation.hpp:56
static Accumulator compute_read_term_predicate(const AllEntities &in)
Compute if the value from the first set exists in this row.
Definition: generic_permutation_relation.hpp:101
static Accumulator compute_write_term(const AllEntities &in, const Parameters ¶ms)
Compute the value of a single item in the set.
Definition: generic_permutation_relation.hpp:173
static void accumulate(ContainerOverSubrelations &accumulator, const AllEntities &in, const Parameters ¶ms, const FF &scaling_factor)
Expression for generic log-derivative-based set permutation.
Definition: generic_permutation_relation.cpp:18
static Accumulator compute_inverse_exists(const AllEntities &in)
Get selector/wire switching on(1) or off(0) inverse computation.
Definition: generic_permutation_relation.hpp:86
static bool operation_exists_at_row(const AllValues &row)
Check if we need to compute the inverse polynomial element value for this row.
Definition: generic_permutation_relation.hpp:64
static Accumulator compute_write_term_predicate(const AllEntities &in)
Compute if the value from the second set exists in this row.
Definition: generic_permutation_relation.hpp:119
GenericPermutationSettingIndices
Specifies positions of elements in the tuple of entities received from methods in the Settings class.
Definition: generic_permutation_relation.hpp:22
constexpr void constexpr_for(F &&f)
Implements a loop using a compile-time iterator. Requires c++20. Implementation (and description) fro...
Definition: constexpr_utils.hpp:65