Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FRI folded layers domain #368

Closed
wants to merge 1 commit into from

Conversation

plafer
Copy link
Contributor

@plafer plafer commented Feb 15, 2025

Fixes the (implied) FRI layer domains.

For example, let

  • domain_size = 16,
  • folding_factor = 2,
  • $\omega$ be the generator of group size 16,
  • $h$ be the domain offset,

then the FRI domains are

  • $[h, h\omega, h \omega^2, h\omega^3, \dots, h\omega^{15}]$,
  • $[h^2, h^2\omega^2, h^2 \omega^4, h^2\omega^6, h^2\omega^8, h^2\omega^{10}, h^2\omega^{12}, h^2\omega^{14}]$,
  • $[h^4, h^4\omega^4, h^4 \omega^8, h^4\omega^{12}]$,
  • $[h^8, h^8\omega^8]$.

Noticeably, the domain offset is also squared - which the previous implementation did not do. The Miden VM's recursive verifier will probably need to be updated accordingly as well.

cc @Al-Kindi-0

@plafer plafer force-pushed the plafer-fix-fri-domains branch from 18fa38a to 7ac4ae9 Compare February 15, 2025 16:17
@Al-Kindi-0
Copy link
Contributor

Al-Kindi-0 commented Feb 15, 2025

Unless there is a strong reason for this, I would keep it as is. I agree that it is probably more natural to define the folded domains using a "pure" square map in the case of folding factor 2, but the current implementation is equally valid and can be expressed using the same framework.

Noticeably, the domain offset is also squared - which the previous implementation did not do. The Miden VM's recursive verifier will probably need to be updated accordingly as well.

This is one of the reasons why I would like to keep it as is :). However, we can comeback to this once we have some spare capacity to update things on the VM side.

@plafer
Copy link
Contributor Author

plafer commented Feb 16, 2025

but the current implementation is equally valid and can be expressed using the same framework.

I can't find the right way to explain what's going on though. For example, for a folding factor of 2, we have

$$ f^{(d-1)}(x) = \frac{1}{2} (f^{(d)}(x^{1/2}) + f^{(d)}(-x^{1/2})) + \frac{\alpha}{2 x^{1/2}} (f^{(d)}(x^{1/2}) - f^{(d)}(-x^{1/2})) $$

If the domain of $f^{(d-1)}$ is $[h, h\omega^{2}, h\omega^{4}, \dots, h\omega^{14}]$ (as currently implemented), then e.g. $f^{(d)}(x^{1/2})$ over this domain is $[f^{(d)}(h^{1/2}), f^{(d)}(h^{1/2} \omega), f^{(d)}(h^{1/2} \omega^2), \dots]$, which are not evaluations committed to in the first layer.

What am I missing?

@Al-Kindi-0
Copy link
Contributor

Al-Kindi-0 commented Feb 17, 2025

I think you can just define the projection map to be, instead of a pure square, $\pi_d\left(\{h\cdot \omega^i, h\cdot\omega^{i + \frac{N}{2}}\} \right) = h \cdot \omega^{2i}$.
We can now define the evaluations of the folded polynomial at the points of the next domain to be
$$P^{d + 1}\left( h \cdot \omega^{2i} \right) := \frac{1}{2} \cdot \left(P^d\left(h\cdot\omega^i\right) + P^d\left(-h\cdot\omega^i\right)\right) + \alpha \cdot \frac{P^d\left(h\cdot\omega^i\right) - P^d\left(-h\cdot\omega^i\right)}{h\cdot\omega^i - (-h\cdot\omega^i)}$$
where we used $\omega^{i + \frac{N}{2}} = -\omega^i$.

In more details, take the polynomial in the $0$-th layer hence dropping some of the super-indices, and let's look at its evaluations over the domain $L^0 := \{h \cdot \omega^i, 0 \leq n \}$, where $\rho := \frac{k}{n}$. Let $g = \omega^j$ for some $j$ in $0..(n-1)$.

$$\begin{aligned} P\left(h\cdot g\right) &= \sum_{i = 0}^{k - 1} a_i \cdot (h\cdot g)^i \\\ &= \sum_{i = 0}^{\frac{k}{2} - 1} a_{2i} \cdot (h\cdot g)^{2i} + \sum_{i = 0}^{\frac{k}{2} - 1} a_{2i + 1} \cdot (h\cdot g)^{2i + 1} \\\ &= \sum_{i = 0}^{\frac{k}{2} - 1} a_{2i} \cdot h^i \cdot (h\cdot g^2)^{i} + h\cdot g \cdot \sum_{i = 0}^{\frac{k}{2} - 1} a_{2i + 1} \cdot h^i \cdot (h\cdot g^2)^{i} \\\ &= P_e\left(h \cdot g^2\right) + h \cdot g \cdot P_o\left(h \cdot g^2\right) \end{aligned}$$

where $$P_e\left(X\right) := \sum_{i = 0}^{\frac{k}{2} - 1} a_{2i} \cdot h^i \cdot X$$

and $$P_o\left(X\right) := \sum_{i = 0}^{\frac{k}{2} - 1} a_{2i + 1} \cdot h^i \cdot X$$

So we have in some sense a scaled even-odd decomposition of the original polynomial, but the crucial point here is that the degree bounds on both polynomials is half that of the one on the original polynomial, and moreover we have a relation linking the original evaluations to the evaluations of the two decomposition polynomials in the spirit of butterflys in FFTs.

Now we can build the folded code-word as $$P_{\alpha}\left(h\cdot g^2\right) = P_e\left(h \cdot g^2\right) + \alpha \cdot P_o\left(h \cdot g^2\right)$$. Note that $$P_{\alpha}\left(h\cdot g^2\right) = P_e\left(h \cdot g^2\right) + h \cdot \alpha \cdot P_o\left(h \cdot g^2\right)$$ would work too but we would get a different final expression.

Now using the relation $P\left(h\cdot g\right) = P_e\left(h \cdot g^2\right) + h \cdot g \cdot P_o\left(h \cdot g^2\right)$ we get that
$$P_e\left(h \cdot g^2\right) = \frac{1}{2} \cdot \left(P\left(h\cdot g\right) + P\left(-h\cdot g\right)\right)$$
and
$$P_o\left(h \cdot g^2\right) = \frac{1}{2\cdot h \cdot g} \cdot \left(P\left(h\cdot g\right) - P\left(-h\cdot g\right)\right)$$

Putting everything together we get $$P_{\alpha}\left(h\cdot g^2\right) = \frac{1}{2} \cdot \left(P\left(h\cdot g\right) + P\left(-h\cdot g\right)\right) + \frac{\alpha}{2\cdot h \cdot g} \cdot \left(P\left(h\cdot g\right) - P\left(-h\cdot g\right)\right)$$

@plafer
Copy link
Contributor Author

plafer commented Feb 20, 2025

Awesome, thank you for the detailed explanation, that clears things up!

@plafer plafer closed this Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants