This note picks up where the previous one on multiset checks left off. The main motivation for this note is to support a variation on multiset checks where we can encode how many times we expect an element to show up in the set (i.e. the multiplicity) without having that element showing up that many times. Specifically, the multiset check with multiplicities equation is
For example, if
This is especially useful for range checks, which the Miden VM docs have a good introduction about.
Adding multiplicities creates challenges when implementing the new equation in STARKs, as it makes the running product column discussed in the previous note no longer viable. Specifically, the transition constraint for the running product column
The right-hand side equation is not a polynomial, since both
The core idea of LogUp is relatively simple. It involves applying the logarithm to both sides of the multiset check with multiplicities equation, followed by a derivative.
Note that the logarithm and the derivative are concepts defined over the real numbers. The paper goes into the formalism of how to formally think about these operations over finite fields, which we will take for granted in this note.
Start with the multiset check with multiplicities equation,
apply the logarithm to both sides (and a few logarithm rules),
and then apply the derivative to both sides (where
And that's it! The final form of the LogUp equation is
LogUp in STARKs is going to look very similar to standard multiset checks: we will implement a running sum auxiliary column instead of a running product. Let's see how that would work. But first, we need to rearrange the LogUp equation slightly by subtracting the right-hand side on both sides:
Our running sum column
Row | |
---|---|
1 | 0 |
2 | |
3 | |
4 | |
In the boundary constraints, we make sure that the first and last row of
Then, the transition constraint needs to ensure that every row
However, the current form is not a valid polynomial expression. We need to rearrange the equation so that we remove the division operations for equivalent multiplications:
This equation is a little difficult to parse, but it is simply the result of multiplying out all the denominators on both sides. For example, if
Ultimately, the running sum column implementing LogUp achieved what the running product column could not: a polynomial transition constraint.
LogUp is a good choice for use cases that can't do without representing multiplicities. However, as we'll see, we pay with a higher transition constraint degree. Specifically, the transition constraint degree is the maximum of
The biggest difference with the running product column transition constraint degree (other than the fact that we now have multiplicities) is that now the degree of the
Hence, the rule of thumb is that between a standard multiset check and LogUp, prefer to use a standard multiset check when possible to lower the transition constraint degree.