Open TurtlePU opened 2 months ago
It seems, the first item can be solved by modifying the constraint
function instance for ArithmeticCircuit
.
Not the constraint
, but the newAssigned
function, I guess, as constraint
is not able to change any variable
But yeah, the first point is doable without running any specific optimization passes
As for the second item, we could do more if we make a reasonable assumption about the set of polynomial equations that are admissible constraints. Specifically, if we assume that any substitution of the form $x \rightarrow a_1 x_1 + a_2 x_2 + b$ does not make a valid constraint invalid, then we could eliminate all equations of the form $a_1 x_1 + a_2 x_2 + a_3 x_3 + b = 0$.
It holds true for Plonk and PlonkUp and, in general, is a pretty reasonable assumption, but it should be possible to turn it off if needed, I think. And, we should be careful with input variables.
For now, only "explicit constants" are optimized away -- that is, created with
fromConstant :: a -> var
inMonadCircuit
and withembed :: Symbolic c => f (BaseField c) -> c f
. More can be optimized:newAssigned
wherewitness
is evidently constant (e.g. the result offromConstant x * fromConstant y
) (#324)k
for which there is a constraintk - 1 == 0
) (#355)