powdr-labs / powdr

A modular stack for zkVMs, with a focus on productivity, security and performance.
Apache License 2.0
338 stars 67 forks source link

Implement LogUp in PIL #1374

Open georgwiese opened 1 month ago

georgwiese commented 1 month ago

Similar to how we already implemented a permutation argument in PIL (see #1297 and #1306), we could implement a variant of LogUp (also see this summary).

As a first version, it could look like this:

So I think, the constraints would look something like this:

h' * (alpha - A) * (alpha - B) = h * (alpha - A) * (alpha - B) + (alpha - B) + m * (alpha - A);

# Actually, I don't think this constraint is needed for soundness, because of the wrapping
IS_FIRST' * h = 0;

(Note that because of wrapping $h_0 = h_4 = 0$, so row $1$ does not have to be handled separately.)

This leaves out two details, which should be handled analogously to the permutation argument:

Compared to the original LogUp, this implementation lacks some optimization applicable to multiple lookups, especially if they have the same left-hand side. But I think it would be a good first step and allow for some first benchmarks already.

onurinanc commented 3 days ago

@georgwiese I think the first constraint should be fixed from h' * (alpha - A) * (alpha - B) = h * (alpha - A) * (alpha - B) + (alpha - B) + m * (alpha - A);  to h' * (alpha - A) * (alpha - B) + m * (alpha - A) = h * (alpha - A) * (alpha - B) + (alpha - B);