Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
alu_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
6
7namespace bb::avm2 {
8
9template <typename FF_>
10template <typename ContainerOverSubrelations, typename AllEntities>
11void aluImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
12 const AllEntities& in,
13 [[maybe_unused]] const RelationParameters<FF_>&,
14 [[maybe_unused]] const FF_& scaling_factor)
15{
16 using C = ColumnAndShifts;
17
18 const auto constants_MEM_TAG_FF = FF(0);
19 const auto constants_MEM_TAG_U1 = FF(1);
20 const auto constants_MEM_TAG_U128 = FF(6);
21 const auto constants_AVM_EXEC_OP_ID_ALU_ADD = FF(1);
22 const auto constants_AVM_EXEC_OP_ID_ALU_SUB = FF(2);
23 const auto constants_AVM_EXEC_OP_ID_ALU_MUL = FF(4);
24 const auto constants_AVM_EXEC_OP_ID_ALU_DIV = FF(8);
25 const auto constants_AVM_EXEC_OP_ID_ALU_FDIV = FF(16);
26 const auto constants_AVM_EXEC_OP_ID_ALU_EQ = FF(32);
27 const auto constants_AVM_EXEC_OP_ID_ALU_LT = FF(64);
28 const auto constants_AVM_EXEC_OP_ID_ALU_LTE = FF(128);
29 const auto constants_AVM_EXEC_OP_ID_ALU_NOT = FF(256);
30 const auto constants_AVM_EXEC_OP_ID_ALU_SHL = FF(512);
31 const auto constants_AVM_EXEC_OP_ID_ALU_SHR = FF(1024);
32 const auto constants_AVM_EXEC_OP_ID_ALU_TRUNCATE = FF(2048);
33 const auto alu_IS_NOT_FF = (FF(1) - in.get(C::alu_sel_is_ff));
34 const auto alu_IS_NOT_U128 = (FF(1) - in.get(C::alu_sel_is_u128));
35 const auto alu_CHECK_TAG_FF = in.get(C::alu_sel_op_div) + in.get(C::alu_sel_op_fdiv) + in.get(C::alu_sel_op_lt) +
36 in.get(C::alu_sel_op_lte) + in.get(C::alu_sel_op_not) + in.get(C::alu_sel_shift_ops);
37 const auto alu_TAG_FF_DIFF = (in.get(C::alu_ia_tag) - constants_MEM_TAG_FF);
38 const auto alu_CHECK_TAG_U128 = in.get(C::alu_sel_op_mul) + in.get(C::alu_sel_op_div);
39 const auto alu_TAG_U128_DIFF = (in.get(C::alu_ia_tag) - constants_MEM_TAG_U128);
40 const auto alu_EXPECTED_C_TAG =
41 (in.get(C::alu_sel_op_add) + in.get(C::alu_sel_op_sub) + in.get(C::alu_sel_op_mul) + in.get(C::alu_sel_op_div) +
42 in.get(C::alu_sel_op_truncate) + in.get(C::alu_sel_shift_ops)) *
43 in.get(C::alu_ia_tag) +
44 (in.get(C::alu_sel_op_eq) + in.get(C::alu_sel_op_lt) + in.get(C::alu_sel_op_lte)) * constants_MEM_TAG_U1 +
45 in.get(C::alu_sel_op_fdiv) * constants_MEM_TAG_FF;
46 const auto alu_FF_TAG_ERR = (in.get(C::alu_sel_op_div) + in.get(C::alu_sel_op_not) + in.get(C::alu_sel_shift_ops)) *
47 in.get(C::alu_sel_is_ff) +
48 in.get(C::alu_sel_op_fdiv) * alu_IS_NOT_FF;
49 const auto alu_CHECK_AB_TAGS =
50 ((FF(1) - in.get(C::alu_sel_op_not) * in.get(C::alu_sel_is_ff)) - in.get(C::alu_sel_op_truncate));
51 const auto alu_AB_TAGS_EQ = (FF(1) - in.get(C::alu_sel_ab_tag_mismatch));
52 const auto alu_TWO_POW_64 = FF(uint256_t{ 0UL, 1UL, 0UL, 0UL });
53 const auto alu_DECOMPOSED_A =
54 (in.get(C::alu_sel_mul_u128) + in.get(C::alu_sel_shift_ops_no_overflow)) * in.get(C::alu_ia) +
55 (in.get(C::alu_sel_shift_ops) - in.get(C::alu_sel_shift_ops_no_overflow)) *
56 (in.get(C::alu_ib) - in.get(C::alu_max_bits)) +
57 in.get(C::alu_sel_is_u128) * in.get(C::alu_sel_op_div) * (FF(1) - in.get(C::alu_sel_tag_err)) *
58 in.get(C::alu_ic);
59 const auto alu_DECOMPOSED_B = in.get(C::alu_ib);
60 const auto alu_LIMB_SIZE = in.get(C::alu_sel_mul_div_u128) * alu_TWO_POW_64 +
61 in.get(C::alu_sel_shift_ops) * in.get(C::alu_two_pow_shift_lo_bits);
62 const auto alu_DIV_OPS = in.get(C::alu_sel_op_div) + in.get(C::alu_sel_op_fdiv);
63 const auto alu_DIV_OPS_NON_U128 =
64 (FF(1) - in.get(C::alu_sel_err)) * (in.get(C::alu_sel_op_fdiv) + in.get(C::alu_sel_op_div) * alu_IS_NOT_U128);
65 const auto alu_DIFF = (in.get(C::alu_ia) - in.get(C::alu_ib));
66 const auto alu_SHIFT_OVERFLOW = in.get(C::alu_sel_shift_ops) * (FF(1) - in.get(C::alu_sel_shift_ops_no_overflow));
67 const auto alu_SHIFT_HI_BITS =
68 (in.get(C::alu_max_bits) - in.get(C::alu_sel_shift_ops_no_overflow) * in.get(C::alu_shift_lo_bits));
69
70 {
71 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
72 auto tmp = static_cast<View>(in.get(C::alu_sel)) * (FF(1) - static_cast<View>(in.get(C::alu_sel)));
73 std::get<0>(evals) += (tmp * scaling_factor);
74 }
75 {
76 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
77 auto tmp = static_cast<View>(in.get(C::alu_cf)) * (FF(1) - static_cast<View>(in.get(C::alu_cf)));
78 std::get<1>(evals) += (tmp * scaling_factor);
79 }
80 {
81 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
82 auto tmp = static_cast<View>(in.get(C::alu_sel_is_ff)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_is_ff)));
83 std::get<2>(evals) += (tmp * scaling_factor);
84 }
85 {
86 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
87 auto tmp =
88 static_cast<View>(in.get(C::alu_sel_is_u128)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_is_u128)));
89 std::get<3>(evals) += (tmp * scaling_factor);
90 }
91 { // ERR_CHECK
92 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
93 auto tmp = (static_cast<View>(in.get(C::alu_sel_err)) -
94 ((static_cast<View>(in.get(C::alu_sel_tag_err)) + static_cast<View>(in.get(C::alu_sel_div_0_err))) -
95 static_cast<View>(in.get(C::alu_sel_tag_err)) * static_cast<View>(in.get(C::alu_sel_div_0_err))));
96 std::get<4>(evals) += (tmp * scaling_factor);
97 }
98 { // OP_ID_CHECK
99 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
100 auto tmp = (static_cast<View>(in.get(C::alu_op_id)) -
101 (static_cast<View>(in.get(C::alu_sel_op_add)) * CView(constants_AVM_EXEC_OP_ID_ALU_ADD) +
102 static_cast<View>(in.get(C::alu_sel_op_sub)) * CView(constants_AVM_EXEC_OP_ID_ALU_SUB) +
103 static_cast<View>(in.get(C::alu_sel_op_mul)) * CView(constants_AVM_EXEC_OP_ID_ALU_MUL) +
104 static_cast<View>(in.get(C::alu_sel_op_div)) * CView(constants_AVM_EXEC_OP_ID_ALU_DIV) +
105 static_cast<View>(in.get(C::alu_sel_op_fdiv)) * CView(constants_AVM_EXEC_OP_ID_ALU_FDIV) +
106 static_cast<View>(in.get(C::alu_sel_op_eq)) * CView(constants_AVM_EXEC_OP_ID_ALU_EQ) +
107 static_cast<View>(in.get(C::alu_sel_op_lt)) * CView(constants_AVM_EXEC_OP_ID_ALU_LT) +
108 static_cast<View>(in.get(C::alu_sel_op_lte)) * CView(constants_AVM_EXEC_OP_ID_ALU_LTE) +
109 static_cast<View>(in.get(C::alu_sel_op_not)) * CView(constants_AVM_EXEC_OP_ID_ALU_NOT) +
110 static_cast<View>(in.get(C::alu_sel_op_shl)) * CView(constants_AVM_EXEC_OP_ID_ALU_SHL) +
111 static_cast<View>(in.get(C::alu_sel_op_shr)) * CView(constants_AVM_EXEC_OP_ID_ALU_SHR) +
112 static_cast<View>(in.get(C::alu_sel_op_truncate)) * CView(constants_AVM_EXEC_OP_ID_ALU_TRUNCATE)));
113 std::get<5>(evals) += (tmp * scaling_factor);
114 }
115 { // TAG_IS_FF
116 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
117 auto tmp = CView(alu_CHECK_TAG_FF) *
118 ((CView(alu_TAG_FF_DIFF) * (static_cast<View>(in.get(C::alu_sel_is_ff)) *
119 (FF(1) - static_cast<View>(in.get(C::alu_tag_ff_diff_inv))) +
120 static_cast<View>(in.get(C::alu_tag_ff_diff_inv))) +
121 static_cast<View>(in.get(C::alu_sel_is_ff))) -
122 FF(1));
123 std::get<6>(evals) += (tmp * scaling_factor);
124 }
125 { // TAG_IS_U128
126 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
127 auto tmp = CView(alu_CHECK_TAG_U128) *
128 ((CView(alu_TAG_U128_DIFF) * (static_cast<View>(in.get(C::alu_sel_is_u128)) *
129 (FF(1) - static_cast<View>(in.get(C::alu_tag_u128_diff_inv))) +
130 static_cast<View>(in.get(C::alu_tag_u128_diff_inv))) +
131 static_cast<View>(in.get(C::alu_sel_is_u128))) -
132 FF(1));
133 std::get<7>(evals) += (tmp * scaling_factor);
134 }
135 { // C_TAG_CHECK
136 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
137 auto tmp = (FF(1) - static_cast<View>(in.get(C::alu_sel_err))) *
138 (CView(alu_EXPECTED_C_TAG) - static_cast<View>(in.get(C::alu_ic_tag)));
139 std::get<8>(evals) += (tmp * scaling_factor);
140 }
141 {
142 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
143 auto tmp =
144 static_cast<View>(in.get(C::alu_sel_tag_err)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err)));
145 std::get<9>(evals) += (tmp * scaling_factor);
146 }
147 {
148 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
149 auto tmp = static_cast<View>(in.get(C::alu_sel_ab_tag_mismatch)) *
150 (FF(1) - static_cast<View>(in.get(C::alu_sel_ab_tag_mismatch)));
151 std::get<10>(evals) += (tmp * scaling_factor);
152 }
153 { // TAG_ERR_CHECK
154 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
155 auto tmp = (static_cast<View>(in.get(C::alu_sel_tag_err)) -
156 ((static_cast<View>(in.get(C::alu_sel_ab_tag_mismatch)) + CView(alu_FF_TAG_ERR)) -
157 static_cast<View>(in.get(C::alu_sel_ab_tag_mismatch)) * CView(alu_FF_TAG_ERR)));
158 std::get<11>(evals) += (tmp * scaling_factor);
159 }
160 { // AB_TAGS_CHECK
161 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
162 auto tmp = CView(alu_CHECK_AB_TAGS) *
163 (((static_cast<View>(in.get(C::alu_ia_tag)) - static_cast<View>(in.get(C::alu_ib_tag))) *
164 (CView(alu_AB_TAGS_EQ) * (FF(1) - static_cast<View>(in.get(C::alu_ab_tags_diff_inv))) +
165 static_cast<View>(in.get(C::alu_ab_tags_diff_inv))) -
166 FF(1)) +
167 CView(alu_AB_TAGS_EQ));
168 std::get<12>(evals) += (tmp * scaling_factor);
169 }
170 {
171 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
172 auto tmp = (static_cast<View>(in.get(C::alu_sel_decompose_a)) -
173 (static_cast<View>(in.get(C::alu_sel_mul_div_u128)) +
174 static_cast<View>(in.get(C::alu_sel_shift_ops)) * CView(alu_IS_NOT_FF)));
175 std::get<13>(evals) += (tmp * scaling_factor);
176 }
177 { // A_DECOMPOSITION
178 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
179 auto tmp = static_cast<View>(in.get(C::alu_sel_decompose_a)) *
180 (CView(alu_DECOMPOSED_A) - (static_cast<View>(in.get(C::alu_a_lo)) +
181 CView(alu_LIMB_SIZE) * static_cast<View>(in.get(C::alu_a_hi))));
182 std::get<14>(evals) += (tmp * scaling_factor);
183 }
184 { // B_DECOMPOSITION
185 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
186 auto tmp = static_cast<View>(in.get(C::alu_sel_mul_div_u128)) *
187 (CView(alu_DECOMPOSED_B) - (static_cast<View>(in.get(C::alu_b_lo)) +
188 CView(alu_LIMB_SIZE) * static_cast<View>(in.get(C::alu_b_hi))));
189 std::get<15>(evals) += (tmp * scaling_factor);
190 }
191 {
192 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
193 auto tmp = static_cast<View>(in.get(C::alu_sel_mul_div_u128)) *
194 (FF(64) - static_cast<View>(in.get(C::alu_constant_64)));
195 std::get<16>(evals) += (tmp * scaling_factor);
196 }
197 { // A_LO_BITS
198 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
199 auto tmp = ((static_cast<View>(in.get(C::alu_a_lo_bits)) - static_cast<View>(in.get(C::alu_sel_mul_div_u128)) *
200 static_cast<View>(in.get(C::alu_constant_64))) -
201 static_cast<View>(in.get(C::alu_sel_shift_ops)) * static_cast<View>(in.get(C::alu_shift_lo_bits)));
202 std::get<17>(evals) += (tmp * scaling_factor);
203 }
204 { // A_HI_BITS
205 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
206 auto tmp = ((static_cast<View>(in.get(C::alu_a_hi_bits)) - static_cast<View>(in.get(C::alu_sel_mul_div_u128)) *
207 static_cast<View>(in.get(C::alu_constant_64))) -
208 static_cast<View>(in.get(C::alu_sel_shift_ops)) * CView(alu_SHIFT_HI_BITS));
209 std::get<18>(evals) += (tmp * scaling_factor);
210 }
211 {
212 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
213 auto tmp =
214 static_cast<View>(in.get(C::alu_sel_op_add)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_add)));
215 std::get<19>(evals) += (tmp * scaling_factor);
216 }
217 {
218 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
219 auto tmp =
220 static_cast<View>(in.get(C::alu_sel_op_sub)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_sub)));
221 std::get<20>(evals) += (tmp * scaling_factor);
222 }
223 { // ALU_ADD_SUB
224 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
225 auto tmp = (static_cast<View>(in.get(C::alu_sel_op_add)) + static_cast<View>(in.get(C::alu_sel_op_sub))) *
226 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
227 ((static_cast<View>(in.get(C::alu_ia)) - static_cast<View>(in.get(C::alu_ic))) +
228 (static_cast<View>(in.get(C::alu_sel_op_add)) - static_cast<View>(in.get(C::alu_sel_op_sub))) *
229 (static_cast<View>(in.get(C::alu_ib)) -
230 static_cast<View>(in.get(C::alu_cf)) * (static_cast<View>(in.get(C::alu_max_value)) + FF(1))));
231 std::get<21>(evals) += (tmp * scaling_factor);
232 }
233 {
234 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
235 auto tmp =
236 static_cast<View>(in.get(C::alu_sel_op_mul)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_mul)));
237 std::get<22>(evals) += (tmp * scaling_factor);
238 }
239 { // ALU_MUL_NON_U128
240 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
241 auto tmp = static_cast<View>(in.get(C::alu_sel_op_mul)) * CView(alu_IS_NOT_U128) *
242 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
243 ((static_cast<View>(in.get(C::alu_ia)) * static_cast<View>(in.get(C::alu_ib)) -
244 static_cast<View>(in.get(C::alu_ic))) -
245 (static_cast<View>(in.get(C::alu_max_value)) + FF(1)) * static_cast<View>(in.get(C::alu_c_hi)));
246 std::get<23>(evals) += (tmp * scaling_factor);
247 }
248 {
249 using View = typename std::tuple_element_t<24, ContainerOverSubrelations>::View;
250 auto tmp = (static_cast<View>(in.get(C::alu_sel_mul_u128)) -
251 static_cast<View>(in.get(C::alu_sel_is_u128)) * static_cast<View>(in.get(C::alu_sel_op_mul)));
252 std::get<24>(evals) += (tmp * scaling_factor);
253 }
254 { // ALU_MUL_U128
255 using View = typename std::tuple_element_t<25, ContainerOverSubrelations>::View;
256 auto tmp = static_cast<View>(in.get(C::alu_sel_mul_u128)) *
257 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
258 (((static_cast<View>(in.get(C::alu_ia)) * static_cast<View>(in.get(C::alu_b_lo)) +
259 static_cast<View>(in.get(C::alu_a_lo)) * static_cast<View>(in.get(C::alu_b_hi)) *
260 CView(alu_TWO_POW_64)) -
261 static_cast<View>(in.get(C::alu_ic))) -
262 (static_cast<View>(in.get(C::alu_max_value)) + FF(1)) *
263 (static_cast<View>(in.get(C::alu_cf)) * CView(alu_TWO_POW_64) +
264 static_cast<View>(in.get(C::alu_c_hi))));
265 std::get<25>(evals) += (tmp * scaling_factor);
266 }
267 {
268 using View = typename std::tuple_element_t<26, ContainerOverSubrelations>::View;
269 auto tmp =
270 static_cast<View>(in.get(C::alu_sel_op_div)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_div)));
271 std::get<26>(evals) += (tmp * scaling_factor);
272 }
273 {
274 using View = typename std::tuple_element_t<27, ContainerOverSubrelations>::View;
275 auto tmp =
276 (static_cast<View>(in.get(C::alu_sel_div_no_0_err)) -
277 static_cast<View>(in.get(C::alu_sel_op_div)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_div_0_err))));
278 std::get<27>(evals) += (tmp * scaling_factor);
279 }
280 {
281 using View = typename std::tuple_element_t<28, ContainerOverSubrelations>::View;
282 auto tmp = (static_cast<View>(in.get(C::alu_sel_mul_div_u128)) -
283 (static_cast<View>(in.get(C::alu_sel_mul_u128)) +
284 static_cast<View>(in.get(C::alu_sel_is_u128)) * static_cast<View>(in.get(C::alu_sel_op_div))));
285 std::get<28>(evals) += (tmp * scaling_factor);
286 }
287 { // ALU_DIV_U128_CHECK
288 using View = typename std::tuple_element_t<29, ContainerOverSubrelations>::View;
289 auto tmp = static_cast<View>(in.get(C::alu_sel_is_u128)) * static_cast<View>(in.get(C::alu_sel_op_div)) *
290 (FF(1) - static_cast<View>(in.get(C::alu_sel_err))) * static_cast<View>(in.get(C::alu_a_hi)) *
291 static_cast<View>(in.get(C::alu_b_hi));
292 std::get<29>(evals) += (tmp * scaling_factor);
293 }
294 { // ALU_DIV_U128
295 using View = typename std::tuple_element_t<30, ContainerOverSubrelations>::View;
296 auto tmp =
297 static_cast<View>(in.get(C::alu_sel_is_u128)) * static_cast<View>(in.get(C::alu_sel_op_div)) *
298 (FF(1) - static_cast<View>(in.get(C::alu_sel_err))) *
299 ((static_cast<View>(in.get(C::alu_ic)) * static_cast<View>(in.get(C::alu_b_lo)) +
300 static_cast<View>(in.get(C::alu_a_lo)) * static_cast<View>(in.get(C::alu_b_hi)) * CView(alu_TWO_POW_64)) -
301 (static_cast<View>(in.get(C::alu_ia)) - static_cast<View>(in.get(C::alu_helper1))));
302 std::get<30>(evals) += (tmp * scaling_factor);
303 }
304 {
305 using View = typename std::tuple_element_t<31, ContainerOverSubrelations>::View;
306 auto tmp =
307 static_cast<View>(in.get(C::alu_sel_op_fdiv)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_fdiv)));
308 std::get<31>(evals) += (tmp * scaling_factor);
309 }
310 {
311 using View = typename std::tuple_element_t<32, ContainerOverSubrelations>::View;
312 auto tmp =
313 static_cast<View>(in.get(C::alu_sel_div_0_err)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_div_0_err)));
314 std::get<32>(evals) += (tmp * scaling_factor);
315 }
316 { // DIV_0_ERR
317 using View = typename std::tuple_element_t<33, ContainerOverSubrelations>::View;
318 auto tmp =
319 (CView(alu_DIV_OPS) *
320 ((static_cast<View>(in.get(C::alu_ib)) * (static_cast<View>(in.get(C::alu_sel_div_0_err)) *
321 (FF(1) - static_cast<View>(in.get(C::alu_b_inv))) +
322 static_cast<View>(in.get(C::alu_b_inv))) +
323 static_cast<View>(in.get(C::alu_sel_div_0_err))) -
324 FF(1)) +
325 static_cast<View>(in.get(C::alu_sel_div_0_err)) *
326 (static_cast<View>(in.get(C::alu_sel_div_0_err)) - CView(alu_DIV_OPS)));
327 std::get<33>(evals) += (tmp * scaling_factor);
328 }
329 { // ALU_FDIV_DIV_NON_U128
330 using View = typename std::tuple_element_t<34, ContainerOverSubrelations>::View;
331 auto tmp = CView(alu_DIV_OPS_NON_U128) *
332 (static_cast<View>(in.get(C::alu_ib)) * static_cast<View>(in.get(C::alu_ic)) -
333 (static_cast<View>(in.get(C::alu_ia)) -
334 static_cast<View>(in.get(C::alu_sel_op_div)) * static_cast<View>(in.get(C::alu_helper1))));
335 std::get<34>(evals) += (tmp * scaling_factor);
336 }
337 {
338 using View = typename std::tuple_element_t<35, ContainerOverSubrelations>::View;
339 auto tmp = static_cast<View>(in.get(C::alu_sel_op_eq)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_eq)));
340 std::get<35>(evals) += (tmp * scaling_factor);
341 }
342 { // EQ_OP_MAIN
343 using View = typename std::tuple_element_t<36, ContainerOverSubrelations>::View;
344 auto tmp =
345 static_cast<View>(in.get(C::alu_sel_op_eq)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
346 ((CView(alu_DIFF) *
347 (static_cast<View>(in.get(C::alu_ic)) * (FF(1) - static_cast<View>(in.get(C::alu_ab_diff_inv))) +
348 static_cast<View>(in.get(C::alu_ab_diff_inv))) -
349 FF(1)) +
350 static_cast<View>(in.get(C::alu_ic)));
351 std::get<36>(evals) += (tmp * scaling_factor);
352 }
353 {
354 using View = typename std::tuple_element_t<37, ContainerOverSubrelations>::View;
355 auto tmp = static_cast<View>(in.get(C::alu_sel_op_lt)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_lt)));
356 std::get<37>(evals) += (tmp * scaling_factor);
357 }
358 {
359 using View = typename std::tuple_element_t<38, ContainerOverSubrelations>::View;
360 auto tmp =
361 static_cast<View>(in.get(C::alu_sel_op_lte)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_lte)));
362 std::get<38>(evals) += (tmp * scaling_factor);
363 }
364 {
365 using View = typename std::tuple_element_t<39, ContainerOverSubrelations>::View;
366 auto tmp = (static_cast<View>(in.get(C::alu_sel_lt_ops)) -
367 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
368 (static_cast<View>(in.get(C::alu_sel_op_lt)) + static_cast<View>(in.get(C::alu_sel_op_lte))));
369 std::get<39>(evals) += (tmp * scaling_factor);
370 }
371 {
372 using View = typename std::tuple_element_t<40, ContainerOverSubrelations>::View;
373 auto tmp = (static_cast<View>(in.get(C::alu_sel_ff_lt_ops)) -
374 static_cast<View>(in.get(C::alu_sel_is_ff)) * static_cast<View>(in.get(C::alu_sel_lt_ops)));
375 std::get<40>(evals) += (tmp * scaling_factor);
376 }
377 {
378 using View = typename std::tuple_element_t<41, ContainerOverSubrelations>::View;
379 auto tmp = (static_cast<View>(in.get(C::alu_sel_int_lt_ops)) -
380 CView(alu_IS_NOT_FF) * static_cast<View>(in.get(C::alu_sel_lt_ops)));
381 std::get<41>(evals) += (tmp * scaling_factor);
382 }
383 { // LT_SWAP_INPUTS_A
384 using View = typename std::tuple_element_t<42, ContainerOverSubrelations>::View;
385 auto tmp = (static_cast<View>(in.get(C::alu_sel_op_lt)) *
386 (static_cast<View>(in.get(C::alu_lt_ops_input_a)) - static_cast<View>(in.get(C::alu_ib))) +
387 static_cast<View>(in.get(C::alu_sel_op_lte)) *
388 (static_cast<View>(in.get(C::alu_lt_ops_input_a)) - static_cast<View>(in.get(C::alu_ia))));
389 std::get<42>(evals) += (tmp * scaling_factor);
390 }
391 { // LT_SWAP_INPUTS_B
392 using View = typename std::tuple_element_t<43, ContainerOverSubrelations>::View;
393 auto tmp = (static_cast<View>(in.get(C::alu_sel_op_lt)) *
394 (static_cast<View>(in.get(C::alu_lt_ops_input_b)) - static_cast<View>(in.get(C::alu_ia))) +
395 static_cast<View>(in.get(C::alu_sel_op_lte)) *
396 (static_cast<View>(in.get(C::alu_lt_ops_input_b)) - static_cast<View>(in.get(C::alu_ib))));
397 std::get<43>(evals) += (tmp * scaling_factor);
398 }
399 { // LTE_NEGATE_RESULT_C
400 using View = typename std::tuple_element_t<44, ContainerOverSubrelations>::View;
401 auto tmp =
402 (static_cast<View>(in.get(C::alu_sel_op_lt)) *
403 (static_cast<View>(in.get(C::alu_lt_ops_result_c)) - static_cast<View>(in.get(C::alu_ic))) +
404 static_cast<View>(in.get(C::alu_sel_op_lte)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
405 ((FF(1) - static_cast<View>(in.get(C::alu_lt_ops_result_c))) - static_cast<View>(in.get(C::alu_ic))));
406 std::get<44>(evals) += (tmp * scaling_factor);
407 }
408 {
409 using View = typename std::tuple_element_t<45, ContainerOverSubrelations>::View;
410 auto tmp =
411 static_cast<View>(in.get(C::alu_sel_op_not)) * (FF(1) - static_cast<View>(in.get(C::alu_sel_op_not)));
412 std::get<45>(evals) += (tmp * scaling_factor);
413 }
414 { // NOT_OP_MAIN
415 using View = typename std::tuple_element_t<46, ContainerOverSubrelations>::View;
416 auto tmp = static_cast<View>(in.get(C::alu_sel_op_not)) *
417 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
418 ((static_cast<View>(in.get(C::alu_ia)) + static_cast<View>(in.get(C::alu_ib))) -
419 static_cast<View>(in.get(C::alu_max_value)));
420 std::get<46>(evals) += (tmp * scaling_factor);
421 }
422 { // SHL_TWO_POW_SHIFT
423 using View = typename std::tuple_element_t<47, ContainerOverSubrelations>::View;
424 auto tmp =
425 static_cast<View>(in.get(C::alu_sel_op_shl)) * static_cast<View>(in.get(C::alu_sel_shift_ops_no_overflow)) *
426 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
427 ((static_cast<View>(in.get(C::alu_max_value)) + FF(1)) -
428 static_cast<View>(in.get(C::alu_two_pow_shift_lo_bits)) * static_cast<View>(in.get(C::alu_helper1)));
429 std::get<47>(evals) += (tmp * scaling_factor);
430 }
431 { // ALU_SHL
432 using View = typename std::tuple_element_t<48, ContainerOverSubrelations>::View;
433 auto tmp = static_cast<View>(in.get(C::alu_sel_op_shl)) *
434 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
435 (static_cast<View>(in.get(C::alu_ic)) - static_cast<View>(in.get(C::alu_sel_shift_ops_no_overflow)) *
436 static_cast<View>(in.get(C::alu_a_lo)) *
437 static_cast<View>(in.get(C::alu_helper1)));
438 std::get<48>(evals) += (tmp * scaling_factor);
439 }
440 { // ALU_SHR
441 using View = typename std::tuple_element_t<49, ContainerOverSubrelations>::View;
442 auto tmp = static_cast<View>(in.get(C::alu_sel_op_shr)) *
443 (FF(1) - static_cast<View>(in.get(C::alu_sel_tag_err))) *
444 (static_cast<View>(in.get(C::alu_ic)) - static_cast<View>(in.get(C::alu_sel_shift_ops_no_overflow)) *
445 static_cast<View>(in.get(C::alu_a_hi)));
446 std::get<49>(evals) += (tmp * scaling_factor);
447 }
448 {
449 using View = typename std::tuple_element_t<50, ContainerOverSubrelations>::View;
450 auto tmp = (static_cast<View>(in.get(C::alu_sel_shift_ops)) -
451 (static_cast<View>(in.get(C::alu_sel_op_shl)) + static_cast<View>(in.get(C::alu_sel_op_shr))));
452 std::get<50>(evals) += (tmp * scaling_factor);
453 }
454 {
455 using View = typename std::tuple_element_t<51, ContainerOverSubrelations>::View;
456 auto tmp = static_cast<View>(in.get(C::alu_sel_shift_ops_no_overflow)) *
457 (FF(1) - static_cast<View>(in.get(C::alu_sel_shift_ops)));
458 std::get<51>(evals) += (tmp * scaling_factor);
459 }
460 { // SHIFTS_LO_BITS
461 using View = typename std::tuple_element_t<52, ContainerOverSubrelations>::View;
462 auto tmp = ((static_cast<View>(in.get(C::alu_shift_lo_bits)) -
463 static_cast<View>(in.get(C::alu_sel_shift_ops_no_overflow)) *
464 (static_cast<View>(in.get(C::alu_sel_op_shl)) *
465 (static_cast<View>(in.get(C::alu_max_bits)) - static_cast<View>(in.get(C::alu_ib))) +
466 static_cast<View>(in.get(C::alu_sel_op_shr)) * static_cast<View>(in.get(C::alu_ib)))) -
467 CView(alu_SHIFT_OVERFLOW) * static_cast<View>(in.get(C::alu_max_bits)));
468 std::get<52>(evals) += (tmp * scaling_factor);
469 }
470 {
471 using View = typename std::tuple_element_t<53, ContainerOverSubrelations>::View;
472 auto tmp = static_cast<View>(in.get(C::alu_sel_op_truncate)) *
473 (FF(1) - static_cast<View>(in.get(C::alu_sel_op_truncate)));
474 std::get<53>(evals) += (tmp * scaling_factor);
475 }
476 {
477 using View = typename std::tuple_element_t<54, ContainerOverSubrelations>::View;
478 auto tmp = static_cast<View>(in.get(C::alu_sel_trunc_trivial)) *
479 (FF(1) - static_cast<View>(in.get(C::alu_sel_trunc_trivial)));
480 std::get<54>(evals) += (tmp * scaling_factor);
481 }
482 {
483 using View = typename std::tuple_element_t<55, ContainerOverSubrelations>::View;
484 auto tmp = static_cast<View>(in.get(C::alu_sel_trunc_gte_128)) *
485 (FF(1) - static_cast<View>(in.get(C::alu_sel_trunc_gte_128)));
486 std::get<55>(evals) += (tmp * scaling_factor);
487 }
488 {
489 using View = typename std::tuple_element_t<56, ContainerOverSubrelations>::View;
490 auto tmp = static_cast<View>(in.get(C::alu_sel_trunc_lt_128)) *
491 (FF(1) - static_cast<View>(in.get(C::alu_sel_trunc_lt_128)));
492 std::get<56>(evals) += (tmp * scaling_factor);
493 }
494 { // SEL_TRUNC_NON_TRIVIAL
495 using View = typename std::tuple_element_t<57, ContainerOverSubrelations>::View;
496 auto tmp = (static_cast<View>(in.get(C::alu_sel_trunc_non_trivial)) -
497 (static_cast<View>(in.get(C::alu_sel_trunc_gte_128)) +
498 static_cast<View>(in.get(C::alu_sel_trunc_lt_128))));
499 std::get<57>(evals) += (tmp * scaling_factor);
500 }
501 { // SEL_TRUNCATE
502 using View = typename std::tuple_element_t<58, ContainerOverSubrelations>::View;
503 auto tmp = (static_cast<View>(in.get(C::alu_sel_op_truncate)) -
504 (static_cast<View>(in.get(C::alu_sel_trunc_non_trivial)) +
505 static_cast<View>(in.get(C::alu_sel_trunc_trivial))));
506 std::get<58>(evals) += (tmp * scaling_factor);
507 }
508 { // TRUNC_TRIVIAL_CASE
509 using View = typename std::tuple_element_t<59, ContainerOverSubrelations>::View;
510 auto tmp = static_cast<View>(in.get(C::alu_sel_trunc_trivial)) *
511 (static_cast<View>(in.get(C::alu_ia)) - static_cast<View>(in.get(C::alu_ic)));
512 std::get<59>(evals) += (tmp * scaling_factor);
513 }
514 { // SMALL_TRUNC_VAL_IS_LO
515 using View = typename std::tuple_element_t<60, ContainerOverSubrelations>::View;
516 auto tmp = static_cast<View>(in.get(C::alu_sel_trunc_lt_128)) *
517 (static_cast<View>(in.get(C::alu_a_lo)) - static_cast<View>(in.get(C::alu_ia)));
518 std::get<60>(evals) += (tmp * scaling_factor);
519 }
520 { // TRUNC_LO_128_DECOMPOSITION
521 using View = typename std::tuple_element_t<61, ContainerOverSubrelations>::View;
522 auto tmp = static_cast<View>(in.get(C::alu_sel_trunc_non_trivial)) *
523 ((static_cast<View>(in.get(C::alu_ic)) +
524 static_cast<View>(in.get(C::alu_mid)) * (static_cast<View>(in.get(C::alu_max_value)) + FF(1))) -
525 static_cast<View>(in.get(C::alu_a_lo)));
526 std::get<61>(evals) += (tmp * scaling_factor);
527 }
528 { // TRUNC_MID_BITS
529 using View = typename std::tuple_element_t<62, ContainerOverSubrelations>::View;
530 auto tmp =
531 (static_cast<View>(in.get(C::alu_mid_bits)) - static_cast<View>(in.get(C::alu_sel_trunc_non_trivial)) *
532 (FF(128) - static_cast<View>(in.get(C::alu_max_bits))));
533 std::get<62>(evals) += (tmp * scaling_factor);
534 }
535}
536
537} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
Definition alu_impl.hpp:11
ColumnAndShifts
Definition columns.hpp:34
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define CView(v)
Container for parameters used by the grand product (permutation, lookup) Honk relations.