Skip to content

Commit f06b836

Browse files
authored
feat(bivariate): Lee-O'Sullivan interpolation for GS decoder (#250)
* Add Lee-O'Sullivan interpolation * Performance improvement for Lee-O'Sullivan interpolation * Interpolation bench groups cleanup * More accurate reference for Lee-O'Sullivan algorithm
1 parent 23bd660 commit f06b836

45 files changed

Lines changed: 9794 additions & 77 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CompPoly.lean

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CompPoly.Bivariate.Basic
22
import CompPoly.Bivariate.CMvEquiv
3+
import CompPoly.Bivariate.CoeffRows
34
import CompPoly.Bivariate.Deriv
45
import CompPoly.Bivariate.Factor
56
import CompPoly.Bivariate.FactorMonic
@@ -15,6 +16,19 @@ import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Basic
1516
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Correctness
1617
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Dense.Algorithm
1718
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Dense.Correctness
19+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan
20+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Algorithm
21+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Basic
22+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness
23+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Basis
24+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Combinations
25+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Common
26+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Completeness
27+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Divisibility
28+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Normalization
29+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Rows
30+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Selection
31+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness.Soundness
1832
import CompPoly.Bivariate.GuruswamiSudan.Polynomial
1933
import CompPoly.Bivariate.GuruswamiSudan.PolynomialCorrectness
2034
import CompPoly.Bivariate.GuruswamiSudan.Root.Alekhnovich.Algorithm
@@ -99,6 +113,23 @@ import CompPoly.LinearAlgebra.Dense.RowOps
99113
import CompPoly.LinearAlgebra.Dense.RowOpsCorrectness
100114
import CompPoly.LinearAlgebra.Dense.RrefSemantics
101115
import CompPoly.LinearAlgebra.Dense.RrefShape
116+
import CompPoly.LinearAlgebra.PolynomialMatrix
117+
import CompPoly.LinearAlgebra.PolynomialMatrix.Basic
118+
import CompPoly.LinearAlgebra.PolynomialMatrix.Degree
119+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohann
120+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness
121+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Combinations
122+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Conflict
123+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Fast
124+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Leading
125+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.MatrixRows
126+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Measure
127+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Minimal
128+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Reduction
129+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.RowOps
130+
import CompPoly.LinearAlgebra.PolynomialMatrix.RowSpan
131+
import CompPoly.LinearAlgebra.PolynomialMatrix.Shifted
132+
import CompPoly.LinearAlgebra.PolynomialMatrix.ShiftedReduction
102133
import CompPoly.Multilinear.Basic
103134
import CompPoly.Multilinear.Equiv
104135
import CompPoly.Multilinear.ManyEval
@@ -136,11 +167,13 @@ import CompPoly.Univariate.BatchEval.Correctness
136167
import CompPoly.Univariate.BatchEval.Naive
137168
import CompPoly.Univariate.BatchEval.SubproductTree
138169
import CompPoly.Univariate.CMvEquiv
170+
import CompPoly.Univariate.CoefficientInterpolation
139171
import CompPoly.Univariate.Context
140172
import CompPoly.Univariate.Deriv
141173
import CompPoly.Univariate.DivisionCorrectness
142174
import CompPoly.Univariate.EuclideanAlgorithm
143175
import CompPoly.Univariate.Lagrange
176+
import CompPoly.Univariate.LagrangeArray
144177
import CompPoly.Univariate.Linear
145178
import CompPoly.Univariate.ManyEval
146179
import CompPoly.Univariate.ManyEval.Basic
@@ -194,3 +227,4 @@ import CompPoly.Univariate.ToPoly.Core
194227
import CompPoly.Univariate.ToPoly.Degree
195228
import CompPoly.Univariate.ToPoly.Equiv
196229
import CompPoly.Univariate.ToPoly.Impl
230+
import CompPoly.Univariate.Vanishing

CompPoly/Bivariate/CoeffRows.lean

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
/-
2+
Copyright (c) 2026 CompPoly Contributors. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Valerii Huhnin
5+
-/
6+
7+
import CompPoly.Bivariate.Basic
8+
import CompPoly.LinearAlgebra.PolynomialMatrix.Shifted
9+
10+
/-!
11+
# Coefficient Rows for Bivariate Polynomials
12+
13+
Conversions between finite `Y`-coefficient rows and `CBivariate`.
14+
-/
15+
16+
namespace CompPoly
17+
18+
namespace CBivariate
19+
20+
variable {F : Type*}
21+
22+
/-- Interpret a polynomial row `[q_0, ..., q_l]` as `∑ q_j(X) Y^j`. -/
23+
def ofCoeffRow [Zero F] [BEq F] [LawfulBEq F]
24+
(row : PolynomialRow F) : CBivariate F :=
25+
CPolynomial.ofArray row
26+
27+
/-- Truncate a bivariate polynomial to its first `width` `Y`-coefficient rows. -/
28+
def toCoeffRow [Zero F] (width : Nat) (Q : CBivariate F) :
29+
PolynomialRow F :=
30+
(List.range width).map (fun j ↦ CPolynomial.coeff Q j) |>.toArray
31+
32+
/-- Truncated coefficient rows have the requested width. -/
33+
theorem toCoeffRow_size [Zero F] (width : Nat) (Q : CBivariate F) :
34+
(toCoeffRow width Q).size = width := by
35+
simp [toCoeffRow]
36+
37+
/-- Lee-style shift array for `(1, w)` weighted degree. -/
38+
def weightedDegreeShift (w width : Nat) : Array Nat :=
39+
(List.range width).map (fun j ↦ j * w) |>.toArray
40+
41+
/-- Coefficient-row conversion preserves finite `Y` coefficients below row width. -/
42+
theorem coeff_ofCoeffRow_of_lt [Zero F] [BEq F] [LawfulBEq F]
43+
(row : PolynomialRow F) {i j : Nat} (hj : j < row.size) :
44+
CBivariate.coeff (ofCoeffRow row) i j = CPolynomial.coeff (row.getD j 0) i := by
45+
have _ := hj
46+
rw [ofCoeffRow, CBivariate.coeff]
47+
unfold CPolynomial.ofArray CPolynomial.coeff
48+
rw [CPolynomial.Raw.Trim.coeff_eq_coeff]
49+
50+
/-- Coefficients past the row width vanish after row-to-bivariate conversion. -/
51+
theorem coeff_ofCoeffRow_of_size_le [Zero F] [BEq F] [LawfulBEq F]
52+
(row : PolynomialRow F) {i j : Nat} (hj : row.size ≤ j) :
53+
CBivariate.coeff (ofCoeffRow row) i j = 0 := by
54+
rw [ofCoeffRow, CBivariate.coeff]
55+
unfold CPolynomial.ofArray CPolynomial.coeff
56+
rw [CPolynomial.Raw.Trim.coeff_eq_coeff]
57+
change CPolynomial.coeff (CPolynomial.Raw.coeff row j) i = 0
58+
simpa [CPolynomial.Raw.coeff, hj] using CPolynomial.coeff_zero (R := F) i
59+
60+
/-- Row shifted degree for the Lee shift matches weighted degree of the bivariate view. -/
61+
theorem rowShiftedDegree?_eq_natWeightedDegree_ofCoeffRow
62+
[Field F] [BEq F] [LawfulBEq F]
63+
(row : PolynomialRow F) (w d : Nat)
64+
(hdeg :
65+
PolynomialMatrix.rowShiftedDegree? row (weightedDegreeShift w row.size) = some d) :
66+
CBivariate.natWeightedDegree (ofCoeffRow row) 1 w = d := by
67+
have hshift :
68+
∀ j, j < row.size → (weightedDegreeShift w row.size).getD j 0 = j * w := by
69+
intro j hj
70+
simp [weightedDegreeShift, Array.getD_eq_getD_getElem?, hj]
71+
apply le_antisymm
72+
· rw [CBivariate.natWeightedDegree_le_iff]
73+
intro j hj
74+
have hcoeff_ne :
75+
CPolynomial.coeff (ofCoeffRow row) j ≠ 0 := by
76+
exact (CPolynomial.mem_support_iff (ofCoeffRow row) j).mp hj
77+
have hjlt : j < row.size := by
78+
by_contra hnot
79+
have hge : row.size ≤ j := Nat.le_of_not_gt hnot
80+
have hcoeff_zero : CPolynomial.coeff (ofCoeffRow row) j = 0 := by
81+
rw [CPolynomial.eq_zero_iff_coeff_zero]
82+
intro i
83+
exact coeff_ofCoeffRow_of_size_le row (i := i) hge
84+
exact hcoeff_ne hcoeff_zero
85+
have houter :
86+
CPolynomial.coeff (ofCoeffRow row) j = row.getD j 0 := by
87+
rw [ofCoeffRow]
88+
unfold CPolynomial.ofArray CPolynomial.coeff
89+
rw [CPolynomial.Raw.Trim.coeff_eq_coeff]
90+
have hrow_ne : row.getD j 00 := by
91+
intro hzero
92+
exact hcoeff_ne (by simp [houter, hzero])
93+
have hentry :
94+
PolynomialMatrix.shiftedEntryDegree? row (weightedDegreeShift w row.size) j =
95+
some ((row.getD j 0).natDegree +
96+
(weightedDegreeShift w row.size).getD j 0) := by
97+
simp [PolynomialMatrix.shiftedEntryDegree?, PolynomialMatrix.rowGet]
98+
simpa [PolynomialMatrix.rowGet] using hrow_ne
99+
have hle :=
100+
PolynomialMatrix.shiftedEntryDegree?_le_of_rowShiftedDegree?_eq_some
101+
hdeg hjlt hentry
102+
simpa [houter, hshift j hjlt, Nat.mul_comm] using hle
103+
· obtain ⟨j, hj, hentry⟩ :=
104+
PolynomialMatrix.exists_shiftedEntryDegree?_eq_of_rowShiftedDegree?_eq_some hdeg
105+
have houter :
106+
CPolynomial.coeff (ofCoeffRow row) j = row.getD j 0 := by
107+
rw [ofCoeffRow]
108+
unfold CPolynomial.ofArray CPolynomial.coeff
109+
rw [CPolynomial.Raw.Trim.coeff_eq_coeff]
110+
have hrow_ne : row.getD j 00 := by
111+
intro hzero
112+
have hnone :
113+
PolynomialMatrix.shiftedEntryDegree? row (weightedDegreeShift w row.size) j =
114+
none := by
115+
simp [PolynomialMatrix.shiftedEntryDegree?, PolynomialMatrix.rowGet, hzero]
116+
rw [hentry] at hnone
117+
contradiction
118+
have hsupport : j ∈ CPolynomial.support (ofCoeffRow row) := by
119+
rw [CPolynomial.mem_support_iff]
120+
simpa [houter] using hrow_ne
121+
have hd :
122+
d = (row.getD j 0).natDegree +
123+
(weightedDegreeShift w row.size).getD j 0 := by
124+
have hsimp :
125+
row[j]?.getD 00
126+
d = (row[j]?.getD 0).natDegree +
127+
(weightedDegreeShift w row.size)[j]?.getD 0 := by
128+
simpa [PolynomialMatrix.shiftedEntryDegree?, PolynomialMatrix.rowGet] using hentry.symm
129+
simpa [Array.getD_eq_getD_getElem?] using hsimp.2
130+
calc
131+
d = (row.getD j 0).natDegree +
132+
(weightedDegreeShift w row.size).getD j 0 := hd
133+
_ = 1 * (CPolynomial.coeff (ofCoeffRow row) j).natDegree + w * j := by
134+
simp [houter, hshift j hj, Nat.mul_comm]
135+
_ ≤ (CPolynomial.support (ofCoeffRow row)).sup
136+
(fun j ↦ 1 * (CPolynomial.coeff (ofCoeffRow row) j).natDegree + w * j) := by
137+
exact Finset.le_sup
138+
(s := CPolynomial.support (ofCoeffRow row))
139+
(f := fun j ↦ 1 * (CPolynomial.coeff (ofCoeffRow row) j).natDegree + w * j)
140+
hsupport
141+
_ = CBivariate.natWeightedDegree (ofCoeffRow row) 1 w := by
142+
rfl
143+
144+
/-- Weighted-degree bounded rows convert to weighted-degree bounded bivariate polynomials. -/
145+
theorem natWeightedDegree_ofCoeffRow_le_of_rowShiftedDegree?_le
146+
[Field F] [BEq F] [LawfulBEq F]
147+
(row : PolynomialRow F) (w bound d : Nat)
148+
(hdeg :
149+
PolynomialMatrix.rowShiftedDegree? row (weightedDegreeShift w row.size) = some d)
150+
(hle : d ≤ bound) :
151+
CBivariate.natWeightedDegree (ofCoeffRow row) 1 w ≤ bound := by
152+
rw [rowShiftedDegree?_eq_natWeightedDegree_ofCoeffRow row w d hdeg]
153+
exact hle
154+
155+
end CBivariate
156+
157+
end CompPoly

CompPoly/Bivariate/GuruswamiSudan.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Basic
1515
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Correctness
1616
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Dense.Algorithm
1717
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Dense.Correctness
18+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan
19+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Algorithm
20+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Basic
21+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness
1822
import CompPoly.Bivariate.GuruswamiSudan.Polynomial
1923
import CompPoly.Bivariate.GuruswamiSudan.PolynomialCorrectness
2024
import CompPoly.Bivariate.GuruswamiSudan.Root.Alekhnovich.Algorithm

CompPoly/Bivariate/GuruswamiSudan/Implementations.lean

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ Authors: Valerii Huhnin
66

77
import CompPoly.Bivariate.GuruswamiSudan.Executable
88
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.Dense.Correctness
9+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness
910
import CompPoly.Bivariate.GuruswamiSudan.Root.FieldRoots.KoalaBear
1011
import CompPoly.Bivariate.GuruswamiSudan.Root.RothRuckenstein.Correctness
12+
import CompPoly.LinearAlgebra.PolynomialMatrix.MuldersStorjohannCorrectness.Fast
13+
import CompPoly.Univariate.BatchEval.Context
14+
import CompPoly.Univariate.NTT.KoalaBear
1115

1216
/-!
1317
# Guruswami-Sudan Concrete Implementations
1418
15-
Named concrete dense-interpolation/Roth-Ruckenstein implementations and
16-
correctness theorem specializations for the dense/RR decoder surface.
19+
Named concrete dense and Lee-O'Sullivan interpolation/Roth-Ruckenstein
20+
implementations and correctness theorem specializations for the decoder surface.
1721
-/
1822

1923
namespace CompPoly
@@ -28,6 +32,64 @@ def koalaBearDenseInterpContext : GSInterpContext KoalaBear.Field :=
2832
def fastKoalaBearDenseInterpContext : GSInterpContext KoalaBear.Fast.Field :=
2933
denseInterpContext KoalaBear.Fast.Field
3034

35+
/-- NTTFast-backed univariate multiplication over canonical KoalaBear. -/
36+
def koalaBearNttFastMulContext : CPolynomial.MulContext KoalaBear.Field :=
37+
CPolynomial.MulContext.nttFast CPolynomial.NTT.KoalaBear.bestDomainForLength?
38+
39+
/-- NTTFast-backed univariate monic remainders over canonical KoalaBear. -/
40+
def koalaBearNttFastModContext : CPolynomial.ModContext KoalaBear.Field :=
41+
CPolynomial.ModContext.reversalNttFast CPolynomial.NTT.KoalaBear.bestDomainForLength?
42+
43+
/-- NTTFast-backed subproduct batch evaluation over canonical KoalaBear. -/
44+
def koalaBearNttFastBatchEvalContext : CPolynomial.BatchEvalContext KoalaBear.Field :=
45+
CPolynomial.BatchEvalContext.subproduct KoalaBear.Field
46+
koalaBearNttFastMulContext koalaBearNttFastModContext
47+
48+
/-- NTTFast-backed univariate multiplication over native-word fast KoalaBear. -/
49+
def fastKoalaBearNttFastMulContext : CPolynomial.MulContext KoalaBear.Fast.Field :=
50+
CPolynomial.MulContext.nttFast CPolynomial.NTT.KoalaBear.fastBestDomainForLength?
51+
52+
/-- NTTFast-backed univariate monic remainders over native-word fast KoalaBear. -/
53+
def fastKoalaBearNttFastModContext : CPolynomial.ModContext KoalaBear.Fast.Field :=
54+
CPolynomial.ModContext.reversalNttFast CPolynomial.NTT.KoalaBear.fastBestDomainForLength?
55+
56+
/-- NTTFast-backed subproduct batch evaluation over native-word fast KoalaBear. -/
57+
def fastKoalaBearNttFastBatchEvalContext :
58+
CPolynomial.BatchEvalContext KoalaBear.Fast.Field :=
59+
CPolynomial.BatchEvalContext.subproduct KoalaBear.Fast.Field
60+
fastKoalaBearNttFastMulContext fastKoalaBearNttFastModContext
61+
62+
/-- Lee-O'Sullivan interpolation over canonical KoalaBear with direct vanishing setup. -/
63+
def koalaBearLeeDirectInterpContext : GSInterpContext KoalaBear.Field :=
64+
LeeOSullivan.leeOSullivanInterpContext
65+
(CPolynomial.VanishingPolynomialContext.direct (F := KoalaBear.Field))
66+
(CPolynomial.BatchEvalContext.horner KoalaBear.Field)
67+
(PolynomialMatrix.muldersStorjohannFastReducerContext KoalaBear.Field)
68+
69+
/-- Lee-O'Sullivan interpolation over canonical KoalaBear with subproduct-tree vanishing setup. -/
70+
def koalaBearLeeSubproductInterpContext : GSInterpContext KoalaBear.Field :=
71+
LeeOSullivan.leeOSullivanInterpContext
72+
(CPolynomial.VanishingPolynomialContext.subproduct
73+
koalaBearNttFastMulContext)
74+
koalaBearNttFastBatchEvalContext
75+
(PolynomialMatrix.muldersStorjohannFastReducerContext KoalaBear.Field)
76+
77+
/-- Lee-O'Sullivan interpolation over native-word fast KoalaBear with direct vanishing setup. -/
78+
def fastKoalaBearLeeDirectInterpContext : GSInterpContext KoalaBear.Fast.Field :=
79+
LeeOSullivan.leeOSullivanInterpContext
80+
(CPolynomial.VanishingPolynomialContext.direct (F := KoalaBear.Fast.Field))
81+
(CPolynomial.BatchEvalContext.horner KoalaBear.Fast.Field)
82+
(PolynomialMatrix.muldersStorjohannFastReducerContext KoalaBear.Fast.Field)
83+
84+
/-- Lee-O'Sullivan interpolation over native-word fast KoalaBear with
85+
subproduct-tree vanishing setup. -/
86+
def fastKoalaBearLeeSubproductInterpContext : GSInterpContext KoalaBear.Fast.Field :=
87+
LeeOSullivan.leeOSullivanInterpContext
88+
(CPolynomial.VanishingPolynomialContext.subproduct
89+
fastKoalaBearNttFastMulContext)
90+
fastKoalaBearNttFastBatchEvalContext
91+
(PolynomialMatrix.muldersStorjohannFastReducerContext KoalaBear.Fast.Field)
92+
3193
/-- Roth-Ruckenstein root backend over canonical KoalaBear. -/
3294
def koalaBearRothRootContext : GSRootContext KoalaBear.Field :=
3395
rothRuckensteinRootContext KoalaBear.Field koalaBearFieldRootContext
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/-
2+
Copyright (c) 2026 CompPoly Contributors. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Valerii Huhnin
5+
-/
6+
7+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Basic
8+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Algorithm
9+
import CompPoly.Bivariate.GuruswamiSudan.Interpolation.LeeOSullivan.Correctness
10+
11+
/-!
12+
# Lee-O'Sullivan Guruswami-Sudan Interpolation
13+
-/

0 commit comments

Comments
 (0)