From 8df73bbc60ef47a6c2e33adedb65749700fa64a8 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 28 Sep 2025 01:01:36 -0400 Subject: [PATCH 1/9] Multivariate Multicycle codes using Koszul Complexes --- .../QuantumCliffordOscarExt.jl | 5 +- .../multivariate_multicycle.jl | 166 ++++++++++++++++++ src/ecc/ECC.jl | 2 +- src/ecc/codes/qeccs_using_oscar.jl | 10 ++ test/test_ecc_trivariate_tricycle.jl | 9 + 5 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 ext/QuantumCliffordOscarExt/multivariate_multicycle.jl diff --git a/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl b/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl index b65df2b75..7ba8d41f3 100644 --- a/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl +++ b/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl @@ -17,12 +17,14 @@ import Oscar: free_group, small_group_identification, describe, order, FPGroupEl base_ring, ComplexOfMorphisms, coefficients, zero_matrix, hcat, circshift, size, zeros, enumerate, kronecker_product, FqMatrix, identity_matrix, iszero, FqPolyRingElem, laurent_polynomial_ring, hnf_with_transform, ideal, intersect, ==, is_coprime, quo, groebner_basis, length, FqMPolyRingElem, - first, length, MPolyQuoRingElem, FqMPolyRingElem, modulus, ideal, monomials, terms, coeff, degree, mod + first, length, MPolyQuoRingElem, FqMPolyRingElem, modulus, ideal, monomials, terms, coeff, degree, mod, + koszul_matrix import Oscar.Generic.MatSpaceElem import Oscar.Generic.DirectSumModule import Oscar.Generic.LaurentMPolyWrap import Oscar.Generic.exponent_vectors import Oscar.IdealGens +import Combinatorics: combinations import QuantumClifford.ECC: two_block_group_algebra_codes, twobga_from_direct_product, twobga_from_fp_group, boundary_maps, max_xy_exponents @@ -41,6 +43,7 @@ include("generalized_toric.jl") include("group_presentation.jl") include("d_dimensional_codes.jl") include("trivariate_tricycle.jl") +include("multivariate_multicycle.jl") include("homological_product_codes.jl") end # module diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl new file mode 100644 index 000000000..e68308442 --- /dev/null +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -0,0 +1,166 @@ + +""" +We introduce a novel class of quantum CSS codes — *Multivariate Multicycle* codes — constructed +from multivariate polynomial quotient ring formalism over finite fields over GF(2). Our discovery establishes +that the boundary maps of these codes are governed by the combinatorial structure of *Koszul* complexes. +Specifically, for a code defined by *t* polynomial relations, we demonstrate that the *k-th* boundary map +is obtained by taking the **Koszul matrix** in degree *k* and replacing each variable entry with the +corresponding circulant matrix derived from the code's defining relations. The **Koszul complex** provides +the framework for the boundary map construction, ensuring the commutativity properties essential for the code +construction. This correspondence reveals that multivariate multicycle codes possess the structure of +**Koszul complexes** with circulant coefficients. This family of codes generalizes the bivariate bicycle, +trivariate tricycle ([TrivariateTricycleCode](@ref)), and tetravariate tetracycle codes and it enables +full single shot decoding in both X and Z directions. + +# Special Cases + +## t = 2: Bivariate bicycle codes + +```jldoctest +julia> l=21; m=18; + +julia> R, (x, y) = polynomial_ring(GF(2), [:x, :y]); + +julia> I = ideal(R, [x^l-1, y^m-1]); + +julia> S, _ = quo(R, I); + +julia> A = S(x^3 + y^10 + y^17); + +julia> B = S(y^5 + x^3 + x^19); + +julia> c = MultivariateMulticycleCode([l,m], [A,B]) + +julia> code_n(c), code_k(c) +(756, 16) +``` + +## t = 3: Trivariate tricycle codes + +```jldoctest +julia> using Oscar; using QuantumClifford.ECC; + +julia> l, m, p = 6, 6, 4; + +julia> R, (x, y, z) = polynomial_ring(GF(2), [:x, :y, :z]); + +julia> I = ideal(R, [x^l - 1, y^m - 1, z^p - 1]); + +julia> S, _ = quo(R, I); + +julia> A = S(1 + x*y*z^3 + x^3*y^4*z^2); + +julia> B = S(1 + x^3*y*z^2 + x^3*y^2*z^3); + +julia> C = S(1 + x^4*y^3*z^3 + x^5*z^2); + +julia> c = MultivariateMulticycleCode([l,m, p], [A, B, C]); + +julia> code_n(c), code_k(c) +(432, 12) +``` + +## t = 4: Tetravariate Tetracycle Codes + +```jldoctest +julia> using Oscar; using QuantumClifford.ECC; + +julia> l, m, p, r = 4, 3, 3, 3; + +julia> R, (w, x, y, z) = polynomial_ring(GF(2), [:w, :x, :y, :z]); + +julia> I = ideal(R, [w^l - 1, x^m - 1, y^p - 1, z^r - 1]); + +julia> S, _ = quo(R, I); + +julia> A = S((1 + x^2 )*(1 + w*x*y*z^2)); + +julia> B = S((1 + x^2)*(1 + w*x^3*y^2*z)); + +julia> C = S(1 + w^2*x^2*y^2*z^2); + +julia> D = S(1 + w^3*x^3*y^3*z^3); + +julia> c = MultivariateMulticycleCode([l, m, p, r], [A, B, C, D]); + +julia> code_n(c), code_k(c) +(648, 18) +``` +""" +struct MultivariateMulticycleCode <: AbstractCSSCode + orders::Vector{Int} + polynomials::Vector{MPolyQuoRingElem{FqMPolyRingElem}} + function MultivariateMulticycleCode(orders::Vector{Int}, polys::Vector{<:MPolyQuoRingElem}) + length(orders) == length(polys) || throw(ArgumentError("Mismatch orders/polys")) + all(x->x>0, orders) || throw(ArgumentError("All orders must be positive")) + length(orders) ≥ 2 || throw(ArgumentError("Need at least 2 variables to define an CSS code")) + new(orders, collect(polys)) + end +end + +_gf2_to_int(M) = [iszero(M[i,j]) ? 0 : 1 for i in 1:size(M,1), j in 1:size(M,2)] + +function _polynomial_to_circulant_matrix(f::MPolyQuoRingElem, orders::Vector{Int}) + t = length(orders) + N = prod(orders) + M = zero_matrix(GF(2), N, N) + f_lift = lift(f) + for col_idx in 0:(N-1) + tmp = col_idx + idxs = Vector{Int}(undef, t) + for k in t:-1:1 + idxs[k] = tmp % orders[k] + tmp ÷= orders[k] + end + for term in terms(f_lift) + c = coeff(term, 1) + iszero(c) && continue + exps = [degree(term, k) for k in 1:t] + row_idx = 0 + for k in 1:t + row_idx = row_idx * orders[k] + mod(idxs[k] + exps[k], orders[k]) + end + M[row_idx+1, col_idx+1] += c + end + end + return M +end + +function boundary_maps(code::MultivariateMulticycleCode) + t = length(code.orders) + N = prod(code.orders) + circs = [_gf2_to_int(_polynomial_to_circulant_matrix(p, code.orders)) for p in code.polynomials] + maps = Vector{Matrix{Int}}(undef, t) + for k in 1:t + R, x = polynomial_ring(GF(2), ["x$i" for i in 1:t]) + KoszulMatrix = koszul_matrix(x, k) + nr, nc = size(KoszulMatrix) + M = zeros(Int, nr*N, nc*N) + for i in 1:nr, j in 1:nc + e = KoszulMatrix[i, j] + !iszero(e) || continue + for idx in 1:t + e == x[idx] || continue + r = ((i-1)*N+1):(i*N) + c = ((j-1)*N+1):(j*N) + M[r, c] .= circs[idx] + break + end + end + maps[k] = M + end + return maps +end + +function parity_matrix_xz(c::MultivariateMulticycleCode; qubit_degree::Union{Nothing,Int}=nothing) + maps = boundary_maps(c) + t = length(c.orders) + k = qubit_degree === nothing ? cld(t, 2) : qubit_degree + k >= 1 || throw(ArgumentError("qubit degree must be >= 1")) + (k+1) <= t || throw(ArgumentError("qubit degree too large for number of variables")) + hx, hz = transpose(maps[k]), maps[k+1] + return hx, hz +end +parity_matrix_x(c::MultivariateMulticycleCode) = parity_matrix_xz(c)[1] + +parity_matrix_z(c::MultivariateMulticycleCode) = parity_matrix_xz(c)[2] diff --git a/src/ecc/ECC.jl b/src/ecc/ECC.jl index 0ac80f7ee..0e92b9eff 100644 --- a/src/ecc/ECC.jl +++ b/src/ecc/ECC.jl @@ -41,7 +41,7 @@ export parity_checks, parity_matrix_x, parity_matrix_z, iscss, GeneralizedCirculantBivariateBicycle, GeneralizedHyperGraphProductCode, GeneralizedBicycleCode, ExtendedGeneralizedBicycleCode, HomologicalProductCode, DoubleHomologicalProductCode, - GeneralizedToricCode, TrivariateTricycleCode, + GeneralizedToricCode, TrivariateTricycleCode, MultivariateMulticycleCode, evaluate_decoder, CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup, TableDecoder, diff --git a/src/ecc/codes/qeccs_using_oscar.jl b/src/ecc/codes/qeccs_using_oscar.jl index 71db55148..99936dbb1 100644 --- a/src/ecc/codes/qeccs_using_oscar.jl +++ b/src/ecc/codes/qeccs_using_oscar.jl @@ -74,3 +74,13 @@ function TrivariateTricycleCode(args...; kwargs...) end return ext.TrivariateTricycleCode(args...; kwargs...) end + +"""Multivariate Multicycle codes. +Implemented as a package extension with `Oscar`. Check the [QuantumClifford documentation](http://qc.quantumsavory.org/stable/ECC_API/) for more details on that extension.""" +function MultivariateMulticycleCode(args...; kwargs...) + ext = Base.get_extension(QuantumClifford, :QuantumCliffordOscarExt) + if isnothing(ext) + throw("The `MultivariateMulticycleCode` depends on the package `Oscar` but you have not installed or imported it yet. Immediately after you import `Oscar`, the `MultivariateMulticycleCode` will be available.") + end + return ext.MultivariateMulticycleCode(args...; kwargs...) +end diff --git a/test/test_ecc_trivariate_tricycle.jl b/test/test_ecc_trivariate_tricycle.jl index 2d9a2fa58..b237031d1 100644 --- a/test/test_ecc_trivariate_tricycle.jl +++ b/test/test_ecc_trivariate_tricycle.jl @@ -78,6 +78,15 @@ @test code_k(c) == k == code_k(stab) @test stab_looks_good(stab, remove_redundant_rows=true) == true @test iszero(mod.(metacheck_matrix_z(c)*parity_matrix_z(c), 2)) + c = MultivariateMulticycleCode([ℓ, m, p], [A, B, C]) + stab = parity_checks(c) + mat = matrix(GF(2), stab_to_gf2(stab)) + computed_rank = rank(mat) + @test computed_rank == code_n(c) - code_k(c) + # A TT code is defined on n = 3*ℓ*m*p data qubits. + @test code_n(c) == n == code_n(stab) == 3*ℓ*m*p + @test code_k(c) == k == code_k(stab) + @test stab_looks_good(stab, remove_redundant_rows=true) == true end end end From 4510b1779eea7783519caa4b1097ddb845af9c03 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 28 Sep 2025 01:31:40 -0400 Subject: [PATCH 2/9] add tests in ECC Base --- test/test_ecc_base.jl | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/test/test_ecc_base.jl b/test/test_ecc_base.jl index 89460e987..93e03a67f 100644 --- a/test/test_ecc_base.jl +++ b/test/test_ecc_base.jl @@ -523,13 +523,53 @@ const code_instance_args = Dict( α1₆ = (0, 3) α2₆ = (19, 1) + # Multivariate Multicycle Codes + # t = 2; Bivariate Bicycle codes + # [[72, 12, 6]] + l_mm₁ =6; m_mm₁ = 6 + R_mm₁, (x, y) = polynomial_ring(GF(2), [:x, :y]) + I_mm₁ = ideal(R_mm₁, [x^l_mm₁-1, y^m_mm₁-1]) + S_mm₁, _ = quo(R_mm₁, I_mm₁) + A_mm₁ = S_mm₁(x^3 + y + y^2) + B_mm₁ = S_mm₁(y^3 + x + x^2) + + # [[90, 8, 10]] + l_mm₂ =15; m_mm₂ = 3 + R_mm₂, (x, y) = polynomial_ring(GF(2), [:x, :y]) + I_mm₂ = ideal(R_mm₂, [x^l_mm₂-1, y^m_mm₂-1]) + S_mm₂, _ = quo(R_mm₂, I_mm₂) + A_mm₂ = S_mm₂(x^9 + y + y^2) + B_mm₂ = S_mm₂(1 + x^2 + x^7) + + # t = 3; Trivariate Tricycle codes + # [[60, 3, 4]] + ℓ_mm₃, m_mm₃, p_mm₃ = 5, 2, 2 + F2_mm₃ = GF(2) + R_mm₃, (x, y, z) = polynomial_ring(F2_mm₃, [:x, :y, :z]) + I_mm₃ = ideal(R_mm₃, [x^ℓ_mm₃ - 1, y^m_mm₃ - 1, z^p_mm₃ - 1]) + S_mm₃, _ = quo(R_mm₃, I_mm₃) + A_mm₃ = S_mm₃(1 + x*z) + B_mm₃ = S_mm₃(1 + x*y) + C_mm₃ = S_mm₃(1 + x*y*z) + + # [[90, 3, 5]] + ℓ_mm₄, m_mm₄, p_mm₄ = 5, 3, 2 + F2_mm₄ = GF(2) + R_mm₄, (x, y, z) = polynomial_ring(F2_mm₄, [:x, :y, :z]) + I_mm₄ = ideal(R_mm₄, [x^ℓ_mm₄ - 1, y^m_mm₄ - 1, z^p_mm₄ - 1]) + S_mm₄, _ = quo(R_mm₄, I_mm₄) + A_mm₄ = S_mm₄(1 + x) + B_mm₄ = S_mm₄(1 + x*y) + C_mm₄ = S_mm₄(1 + x^2*y^2*z) + oscar_code_instance_args = Dict( :DDimensionalSurfaceCode => [(2, 3), (3, 2), (3, 3), (4, 2)], :DDimensionalToricCode => [(2, 3), (3, 2), (3, 3), (4, 2)], :GeneralizedToricCode => [(f₁, g₁, α1₁, α2₁), (f₂, g₂, α1₂, α2₂), (f₃, g₃, α1₃, α2₃), (f₄, g₄, α1₄, α2₄), (f₅, g₅, α1₅, α2₅), (f₆, g₆, α1₆, α2₆)], :HomologicalProductCode => [([H₁, transpose(H₁)], l₁), ([H₂, transpose(H₂)], l₂), ([H₃, transpose(H₃)],), ([δ₄, δ₄, δ₄],)], :DoubleHomologicalProductCode => [(δ₁,), (δ₂,)], - :TrivariateTricycleCode => [(ℓ₁, m₁, p₁, A₁, B₁, C₁), (ℓ₂, m₂, p₂, A₂, B₂, C₂), (ℓ₃, m₃, p₃, A₃, B₃, C₃), (ℓ₄, m₄, p₄, A₄, B₄, C₄)] + :TrivariateTricycleCode => [(ℓ₁, m₁, p₁, A₁, B₁, C₁), (ℓ₂, m₂, p₂, A₂, B₂, C₂), (ℓ₃, m₃, p₃, A₃, B₃, C₃), (ℓ₄, m₄, p₄, A₄, B₄, C₄)], + :MultivariateMulticycleCode =>[([l_mm₁,m_mm₁], [A_mm₁, B_mm₁]), ([l_mm₂,m_mm₂], [A_mm₂, B_mm₂]), ([ℓ_mm₃, m_mm₃, p_mm₃], [A_mm₃, B_mm₃, C_mm₃]), ([ℓ_mm₄, m_mm₄, p_mm₄], [A_mm₄, B_mm₄, C_mm₄])] ) merge!(code_instance_args, oscar_code_instance_args) end From 69be1f439ae20bf123f9b443b05e0fb50b845090 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sun, 28 Sep 2025 13:34:58 -0400 Subject: [PATCH 3/9] rm typo --- ext/QuantumCliffordOscarExt/multivariate_multicycle.jl | 1 + test/test_ecc_trivariate_tricycle.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index e68308442..dca8fb124 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -161,6 +161,7 @@ function parity_matrix_xz(c::MultivariateMulticycleCode; qubit_degree::Union{Not hx, hz = transpose(maps[k]), maps[k+1] return hx, hz end + parity_matrix_x(c::MultivariateMulticycleCode) = parity_matrix_xz(c)[1] parity_matrix_z(c::MultivariateMulticycleCode) = parity_matrix_xz(c)[2] diff --git a/test/test_ecc_trivariate_tricycle.jl b/test/test_ecc_trivariate_tricycle.jl index 328b1bd4b..54aa75bfd 100644 --- a/test/test_ecc_trivariate_tricycle.jl +++ b/test/test_ecc_trivariate_tricycle.jl @@ -87,6 +87,7 @@ @test code_n(c) == n == code_n(stab) == 3*ℓ*m*p @test code_k(c) == k == code_k(stab) @test stab_looks_good(stab, remove_redundant_rows=true) == true + @test iszero(mod.(metacheck_matrix_z(c)*parity_matrix_z(c), 2)) end end end From 80778a6f2e678a220e15f0b2f71ad77871334499 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Tue, 30 Sep 2025 03:52:44 -0400 Subject: [PATCH 4/9] enhancements: use koszul complex, test its exactness when creating boundary maps, add tests --- .../QuantumCliffordOscarExt.jl | 4 +- .../multivariate_multicycle.jl | 72 +++++++++++++------ test/test_ecc_trivariate_tricycle.jl | 2 +- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl b/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl index 7ba8d41f3..2f7c067fe 100644 --- a/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl +++ b/ext/QuantumCliffordOscarExt/QuantumCliffordOscarExt.jl @@ -17,8 +17,8 @@ import Oscar: free_group, small_group_identification, describe, order, FPGroupEl base_ring, ComplexOfMorphisms, coefficients, zero_matrix, hcat, circshift, size, zeros, enumerate, kronecker_product, FqMatrix, identity_matrix, iszero, FqPolyRingElem, laurent_polynomial_ring, hnf_with_transform, ideal, intersect, ==, is_coprime, quo, groebner_basis, length, FqMPolyRingElem, - first, length, MPolyQuoRingElem, FqMPolyRingElem, modulus, ideal, monomials, terms, coeff, degree, mod, - koszul_matrix + first, length, MPolyQuoRingElem, FqMPolyRingElem, modulus, ideal, monomials, terms, coeff, degree, mod +import Oscar.koszul_complex import Oscar.Generic.MatSpaceElem import Oscar.Generic.DirectSumModule import Oscar.Generic.LaurentMPolyWrap diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index dca8fb124..4a3aa2132 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -9,7 +9,7 @@ corresponding circulant matrix derived from the code's defining relations. The * the framework for the boundary map construction, ensuring the commutativity properties essential for the code construction. This correspondence reveals that multivariate multicycle codes possess the structure of **Koszul complexes** with circulant coefficients. This family of codes generalizes the bivariate bicycle, -trivariate tricycle ([TrivariateTricycleCode](@ref)), and tetravariate tetracycle codes and it enables +trivariate tricycle ([`TrivariateTricycleCode`](@ref)), and tetravariate tetracycle codes and it enables full single shot decoding in both X and Z directions. # Special Cases @@ -17,6 +17,8 @@ full single shot decoding in both X and Z directions. ## t = 2: Bivariate bicycle codes ```jldoctest +julia> using Oscar; using QuantumClifford.ECC; + julia> l=21; m=18; julia> R, (x, y) = polynomial_ring(GF(2), [:x, :y]); @@ -93,7 +95,7 @@ struct MultivariateMulticycleCode <: AbstractCSSCode function MultivariateMulticycleCode(orders::Vector{Int}, polys::Vector{<:MPolyQuoRingElem}) length(orders) == length(polys) || throw(ArgumentError("Mismatch orders/polys")) all(x->x>0, orders) || throw(ArgumentError("All orders must be positive")) - length(orders) ≥ 2 || throw(ArgumentError("Need at least 2 variables to define an CSS code")) + length(orders) ≥ 2 || throw(ArgumentError("Need at least 2 variables to define a CSS code")) new(orders, collect(polys)) end end @@ -119,7 +121,7 @@ function _polynomial_to_circulant_matrix(f::MPolyQuoRingElem, orders::Vector{Int row_idx = 0 for k in 1:t row_idx = row_idx * orders[k] + mod(idxs[k] + exps[k], orders[k]) - end + end M[row_idx+1, col_idx+1] += c end end @@ -130,38 +132,68 @@ function boundary_maps(code::MultivariateMulticycleCode) t = length(code.orders) N = prod(code.orders) circs = [_gf2_to_int(_polynomial_to_circulant_matrix(p, code.orders)) for p in code.polynomials] - maps = Vector{Matrix{Int}}(undef, t) - for k in 1:t + maps = Vector{Matrix{Int}}(undef, t+1) + for k in 0:t R, x = polynomial_ring(GF(2), ["x$i" for i in 1:t]) - KoszulMatrix = koszul_matrix(x, k) + K = koszul_complex(x) + boundary_map = map(K, k) + KoszulMatrix = matrix(boundary_map) nr, nc = size(KoszulMatrix) - M = zeros(Int, nr*N, nc*N) + M = zeros(Int, nr * N, nc * N) for i in 1:nr, j in 1:nc e = KoszulMatrix[i, j] !iszero(e) || continue for idx in 1:t - e == x[idx] || continue - r = ((i-1)*N+1):(i*N) - c = ((j-1)*N+1):(j*N) - M[r, c] .= circs[idx] - break + if e == x[idx] + row_range = ((i-1)*N+1):(i*N) + col_range = ((j-1)*N+1):(j*N) + M[row_range, col_range] .= circs[idx] + break + end end end - maps[k] = M + maps[k+1] = M + end + for k in 1:t + if !isempty(maps[k]) && !isempty(maps[k+1]) + @assert iszero(mod.(maps[k]*maps[k-1],2)) "Exactness check failed: ∂$(k-1)∘∂$k ≠ 0 mod 2" + end end return maps end -function parity_matrix_xz(c::MultivariateMulticycleCode; qubit_degree::Union{Nothing,Int}=nothing) - maps = boundary_maps(c) - t = length(c.orders) - k = qubit_degree === nothing ? cld(t, 2) : qubit_degree - k >= 1 || throw(ArgumentError("qubit degree must be >= 1")) - (k+1) <= t || throw(ArgumentError("qubit degree too large for number of variables")) - hx, hz = transpose(maps[k]), maps[k+1] +function parity_matrix_xz(code::MultivariateMulticycleCode) + maps = boundary_maps(code) + t = length(code.orders) + if t == 2 + hx = maps[3] + hz = transpose(maps[2]) + else + qd = t ÷ 2 + hx = maps[qd+2] + hz = transpose(maps[qd+1]) + end return hx, hz end parity_matrix_x(c::MultivariateMulticycleCode) = parity_matrix_xz(c)[1] parity_matrix_z(c::MultivariateMulticycleCode) = parity_matrix_xz(c)[2] + +"""For t ≥ 4, provides metachecks for X-stabilizers enabling single-shot decoding.""" +function metacheck_matrix_x(code::MultivariateMulticycleCode) + maps = boundary_maps(code) + t = length(code.orders) + t ≥ 4 || throw(ArgumentError("X-metachecks require t ≥ 4 variables")) + qd = t ÷ 2 + return transpose(maps[qd+1]) +end + +"""For t ≥ 3, provides metachecks for Z-stabilizers enabling single-shot decoding.""" +function metacheck_matrix_z(code::MultivariateMulticycleCode) + maps = boundary_maps(code) + t = length(code.orders) + t ≥ 3 || throw(ArgumentError("Z-metachecks require t ≥ 3 variables")) + qd = t ÷ 2 + return maps[qd+2] +end diff --git a/test/test_ecc_trivariate_tricycle.jl b/test/test_ecc_trivariate_tricycle.jl index 54aa75bfd..e82206d13 100644 --- a/test/test_ecc_trivariate_tricycle.jl +++ b/test/test_ecc_trivariate_tricycle.jl @@ -87,7 +87,7 @@ @test code_n(c) == n == code_n(stab) == 3*ℓ*m*p @test code_k(c) == k == code_k(stab) @test stab_looks_good(stab, remove_redundant_rows=true) == true - @test iszero(mod.(metacheck_matrix_z(c)*parity_matrix_z(c), 2)) + @test iszero(mod.(metacheck_matrix_z(c)*parity_matrix_z(c)', 2)) end end end From 9694c7926431790b6cf4f87a87dde6013d9a898b Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Tue, 30 Sep 2025 03:56:07 -0400 Subject: [PATCH 5/9] minor stylistic changes --- ext/QuantumCliffordOscarExt/multivariate_multicycle.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index 4a3aa2132..38a20fe4b 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -1,4 +1,3 @@ - """ We introduce a novel class of quantum CSS codes — *Multivariate Multicycle* codes — constructed from multivariate polynomial quotient ring formalism over finite fields over GF(2). Our discovery establishes @@ -120,7 +119,7 @@ function _polynomial_to_circulant_matrix(f::MPolyQuoRingElem, orders::Vector{Int exps = [degree(term, k) for k in 1:t] row_idx = 0 for k in 1:t - row_idx = row_idx * orders[k] + mod(idxs[k] + exps[k], orders[k]) + row_idx = row_idx*orders[k]+mod(idxs[k]+exps[k], orders[k]) end M[row_idx+1, col_idx+1] += c end @@ -139,7 +138,7 @@ function boundary_maps(code::MultivariateMulticycleCode) boundary_map = map(K, k) KoszulMatrix = matrix(boundary_map) nr, nc = size(KoszulMatrix) - M = zeros(Int, nr * N, nc * N) + M = zeros(Int, nr*N, nc*N) for i in 1:nr, j in 1:nc e = KoszulMatrix[i, j] !iszero(e) || continue @@ -185,7 +184,7 @@ function metacheck_matrix_x(code::MultivariateMulticycleCode) maps = boundary_maps(code) t = length(code.orders) t ≥ 4 || throw(ArgumentError("X-metachecks require t ≥ 4 variables")) - qd = t ÷ 2 + qd = t÷2 return transpose(maps[qd+1]) end @@ -194,6 +193,6 @@ function metacheck_matrix_z(code::MultivariateMulticycleCode) maps = boundary_maps(code) t = length(code.orders) t ≥ 3 || throw(ArgumentError("Z-metachecks require t ≥ 3 variables")) - qd = t ÷ 2 + qd = t÷2 return maps[qd+2] end From fc86310493ebfc3f4b4fcc3f265c8999469dabb8 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Tue, 30 Sep 2025 09:21:33 -0400 Subject: [PATCH 6/9] rm typo --- ext/QuantumCliffordOscarExt/multivariate_multicycle.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index 38a20fe4b..44078d18f 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -30,7 +30,7 @@ julia> A = S(x^3 + y^10 + y^17); julia> B = S(y^5 + x^3 + x^19); -julia> c = MultivariateMulticycleCode([l,m], [A,B]) +julia> c = MultivariateMulticycleCode([l,m], [A,B]); julia> code_n(c), code_k(c) (756, 16) From 348ab755fd0411e3dc1c59cc0776a71647c6963f Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 18 Oct 2025 23:44:24 -0400 Subject: [PATCH 7/9] add the exact reference from literature that provide the isomorphism between Koszul complexes and the tensor product of length 1 chain complexes in GF(2) --- docs/src/references.bib | 8 +++++ .../multivariate_multicycle.jl | 30 ++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/src/references.bib b/docs/src/references.bib index bd0910654..5914ebc1b 100644 --- a/docs/src/references.bib +++ b/docs/src/references.bib @@ -1142,3 +1142,11 @@ @article{quintavalle2021single year={2021}, publisher={APS} } + +@book{eisenbud2013commutative, + title={Commutative algebra: with a view toward algebraic geometry}, + author={Eisenbud, David}, + volume={150}, + year={2013}, + publisher={Springer Science \& Business Media} +} diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index 44078d18f..9ad801cc5 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -1,15 +1,25 @@ """ We introduce a novel class of quantum CSS codes — *Multivariate Multicycle* codes — constructed -from multivariate polynomial quotient ring formalism over finite fields over GF(2). Our discovery establishes -that the boundary maps of these codes are governed by the combinatorial structure of *Koszul* complexes. -Specifically, for a code defined by *t* polynomial relations, we demonstrate that the *k-th* boundary map -is obtained by taking the **Koszul matrix** in degree *k* and replacing each variable entry with the -corresponding circulant matrix derived from the code's defining relations. The **Koszul complex** provides -the framework for the boundary map construction, ensuring the commutativity properties essential for the code -construction. This correspondence reveals that multivariate multicycle codes possess the structure of -**Koszul complexes** with circulant coefficients. This family of codes generalizes the bivariate bicycle, -trivariate tricycle ([`TrivariateTricycleCode`](@ref)), and tetravariate tetracycle codes and it enables -full single shot decoding in both X and Z directions. +from multivariate polynomial quotient ring formalism over ``\\mathbb{F}_2``. + +Our discovery establishes that the boundary maps of these codes are governed by the combinatorial structure +of *Koszul* complexes. According to [eisenbud2013commutative](@cite) "Let ``a_1, \\dots, a_n`` be elements of +``R``. Then the Koszul complex ``\\mathrm{Kosz}(\\mathbf{a})`` is *isomorphic* to the total complex of the +tensor product ``(R \\xrightarrow{a_1} R) \\otimes (R \\xrightarrow{a_2} R) \\otimes \\cdots \\otimes (R \\xrightarrow{a_n} R)``. + +We note that the work that introduced Trivariate tricycle codes in [jacob2025single](@cite) utilize length-1 chain +complexes along with the structure of the boundary maps for the tensor-product of three length-1 chain complexes that +was provided in [breuckmann2024cupsgatesicohomology](@cite). See 5.3.2 Product of Λ ≥ 3 group algebra codes page 23 for more details. + +Specifically, for a code defined by *t* polynomial relations, we show that the *k-th* boundary map is obtained by +taking the **Koszul matrix** in degree *k* and replacing each variable entry with the corresponding circulant matrix +derived from the code's defining relations. The **Koszul complex** provides the framework for the boundary map construction, +ensuring the commutativity properties essential for the code construction. This correspondence reveals that multivariate +multicycle codes can be constructed using the framework of **Koszul complexes**. + +This family of codes generalizes the bivariate bicycle, trivariate tricycle ([`TrivariateTricycleCode`](@ref)), and +tetravariate tetracycle codes and it enables full single shot decoding in both X and Z directions, a capability that the +[`TrivariateTricycleCode`](@ref) lacks. # Special Cases From 8a4d0b0e20219f3ded8861367cd8a4c70876388b Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 18 Oct 2025 23:47:33 -0400 Subject: [PATCH 8/9] fix typo: it is the tensor product complex of length-1 chain complexes, not 'tensor product' --- ext/QuantumCliffordOscarExt/multivariate_multicycle.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index 9ad801cc5..c67a6536b 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -8,8 +8,9 @@ of *Koszul* complexes. According to [eisenbud2013commutative](@cite) "Let ``a_1, tensor product ``(R \\xrightarrow{a_1} R) \\otimes (R \\xrightarrow{a_2} R) \\otimes \\cdots \\otimes (R \\xrightarrow{a_n} R)``. We note that the work that introduced Trivariate tricycle codes in [jacob2025single](@cite) utilize length-1 chain -complexes along with the structure of the boundary maps for the tensor-product of three length-1 chain complexes that -was provided in [breuckmann2024cupsgatesicohomology](@cite). See 5.3.2 Product of Λ ≥ 3 group algebra codes page 23 for more details. +complexes along with the structure of the boundary maps for the tensor-product complex of three length-1 chain complexes +that was provided in [breuckmann2024cupsgatesicohomology](@cite). See 5.3.2 Product of Λ ≥ 3 group algebra codes page 23 +for more details. Specifically, for a code defined by *t* polynomial relations, we show that the *k-th* boundary map is obtained by taking the **Koszul matrix** in degree *k* and replacing each variable entry with the corresponding circulant matrix From a1378f499237e321c835391732ae5820d714f6e7 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Sat, 18 Oct 2025 23:51:28 -0400 Subject: [PATCH 9/9] add chapter of the book --- ext/QuantumCliffordOscarExt/multivariate_multicycle.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl index c67a6536b..c1a1844f0 100644 --- a/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl +++ b/ext/QuantumCliffordOscarExt/multivariate_multicycle.jl @@ -6,6 +6,7 @@ Our discovery establishes that the boundary maps of these codes are governed by of *Koszul* complexes. According to [eisenbud2013commutative](@cite) "Let ``a_1, \\dots, a_n`` be elements of ``R``. Then the Koszul complex ``\\mathrm{Kosz}(\\mathbf{a})`` is *isomorphic* to the total complex of the tensor product ``(R \\xrightarrow{a_1} R) \\otimes (R \\xrightarrow{a_2} R) \\otimes \\cdots \\otimes (R \\xrightarrow{a_n} R)``. +For more details, see Section 17.3. We note that the work that introduced Trivariate tricycle codes in [jacob2025single](@cite) utilize length-1 chain complexes along with the structure of the boundary maps for the tensor-product complex of three length-1 chain complexes