Skip to content

Commit 1ea24e1

Browse files
committed
Generalized Toric Codes
1 parent 5344bf9 commit 1ea24e1

File tree

4 files changed

+365
-1
lines changed

4 files changed

+365
-1
lines changed

src/CodingTheory.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const CTPolyRingElem = PolyRingElem{<:CTFieldElem}
5454
const CTGroupAlgebra = GroupAlgebraElem{fpFieldElem, GroupAlgebra{fpFieldElem, FinGenAbGroup, FinGenAbGroupElem}}
5555
const CTChainComplex = Union{ComplexOfMorphisms{AbstractAlgebra.FPModule{fpFieldElem}}} # residue and group algebras later
5656
const CTPolyMatrix = Union{AbstractAlgebra.Generic.MatSpaceElem{fpPolyRingElem}, AbstractAlgebra.Generic.MatSpaceElem{FqPolyRingElem}}
57+
const CTLRPolyElem = AbstractAlgebra.Generic.LaurentMPolyWrap{fpFieldElem, fpMPolyRingElem,
58+
AbstractAlgebra.Generic.LaurentMPolyWrapRing{fpFieldElem, fpMPolyRing}}
5759

5860
include("Classical/types.jl")
5961
export AbstractCode, AbstractNonadditiveCode, AbstractNonlinearCode, AbstractAdditiveCode,
@@ -72,7 +74,8 @@ include("Quantum/types.jl")
7274
export AbstractSubsystemCode, AbstractSubsystemCodeCSS, AbstractStabilizerCode, AbstractStabilizerCodeCSS,
7375
AbstractGraphStateSubsystem, AbstractGraphStateSubsystemCSS, AbstractGraphStateStabilizer,
7476
AbstractGraphStateStabilizerCSS, AbstractHypergraphProductCode, AbstractEASubsystemCode,
75-
AbstractEASubsystemCodeCSS, AbstractEAStabilizerCode, AbstractEAStabilizerCodeCSS
77+
AbstractEASubsystemCodeCSS, AbstractEAStabilizerCode, AbstractEAStabilizerCodeCSS, AbstractGeneralizedToricCode
78+
7679
# misc
7780
export LogicalTrait, GaugeTrait, CSSTrait, HasLogicals, HasNoLogicals, HasGauges, HasNoGauges,
7881
IsCSS, IsNotCSS, copy, ChainComplex
@@ -473,4 +476,12 @@ export copying, gauging, thickening_and_choose_heights, coning, quantum_weight_r
473476
include("Quantum/homological_measurements.jl")
474477
export homological_measurement, Cheeger_constant
475478

479+
#############################
480+
# Quantum/GeneralizedToricCode.jl
481+
#############################
482+
483+
include("Quantum/GeneralizedToricCode.jl")
484+
export GeneralizedToricCode, FiniteGeneralizedToricCode, maximum_dimension,
485+
Laurent_polynomial_ring, defining_polynomials, twist_vectors
486+
476487
end
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Copyright (c) 2025 Eric Sabo
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
#############################
8+
# constructors
9+
#############################
10+
11+
function GeneralizedToricCode(f::CTLRPolyElem, g::CTLRPolyElem)
12+
LR = parent(f)
13+
LR == parent(g) || throw(ArgumentError("The polynomials must be over the same ring."))
14+
length(symbols(LR)) == 2 || throw(ArgumentError("The polynomials must be over a Laurent polynomial ring in two variables."))
15+
return GeneralizedToricCode(LR, base_ring(LR), f, g)
16+
end
17+
18+
function FiniteGeneralizedToricCode(f::CTLRPolyElem, g::CTLRPolyElem, a1::Tuple{Int, Int},
19+
a2::Tuple{Int, Int})
20+
21+
LR = parent(f)
22+
LR == parent(g) || throw(ArgumentError("The polynomials must be over the same ring."))
23+
length(symbols(LR)) == 2 || throw(ArgumentError("The polynomials must be over a Laurent polynomial ring in two variables."))
24+
return FiniteGeneralizedToricCode(LR, base_ring(LR), f, g, a1, a2)
25+
end
26+
27+
#############################
28+
# getter functions
29+
#############################
30+
31+
Laurent_polynomial_ring(S::AbstractGeneralizedToricCode) = S.LR
32+
33+
field(S::AbstractGeneralizedToricCode) = S.F
34+
35+
defining_polynomials(S::AbstractGeneralizedToricCode) = S.f, S.g
36+
37+
twist_vectors(S::FiniteGeneralizedToricCode) = S.a1, S.a2
38+
39+
#############################
40+
# setter functions
41+
#############################
42+
43+
#############################
44+
# general functions
45+
#############################
46+
47+
function maximum_dimension(S::AbstractGeneralizedToricCode)
48+
R2 = Oscar._polyringquo(S.LR)
49+
R = codomain(R2)
50+
(x, y) = gens(S.LR)
51+
if isa(S, FiniteGeneralizedToricCode)
52+
I = ideal(S.LR, [S.f, S.g, x^S.a1[1] * y^S.a1[2] - 1, x^S.a2[1] * y^S.a2[2] - 1])
53+
else
54+
I = ideal(S.LR, [S.f, S.g])
55+
end
56+
II = ideal(R, R2.(gens(I)))
57+
Q, ϕ = quo(R, II)
58+
return 2 * vector_space_dimension(Q)
59+
end
60+
61+
function CSSCode(S::FiniteGeneralizedToricCode)
62+
R2 = Oscar._polyringquo(S.LR)
63+
R = codomain(R2)
64+
(x, y) = gens(S.LR)
65+
swap = hom(S.LR, S.LR, [x^-1, y^-1])
66+
f_anti = swap(S.f)
67+
g_anti = swap(S.g)
68+
f_R2 = R2(S.f)
69+
g_R2 = R2(S.g)
70+
f_anti_R2 = R2(f_anti)
71+
g_anti_R2 = R2(g_anti)
72+
I = ideal(S.LR, [x^S.a1[1] * y^S.a1[2] - 1, x^S.a2[1] * y^S.a2[2] - 1])
73+
II = ideal(R, R2.(gens(I)))
74+
Q, ϕ = quo(R, II)
75+
76+
mono = monomial_basis(Q)
77+
len_mon = length(mono)
78+
n = 2 * len_mon
79+
LR_edge_index = Dict{fpMPolyRingElem, Int}(mono[i] => i for i in 1:len_mon)
80+
TB_edge_index = Dict{fpMPolyRingElem, Int}(mono[i] => i + len_mon for i in 1:len_mon)
81+
82+
Fone = S.F(1)
83+
row = 1
84+
X_stabs = zero_matrix(S.F, len_mon, n)
85+
Z_stabs = zero_matrix(S.F, len_mon, n)
86+
for edge in mono
87+
f_shift = simplify(ϕ(edge * f_R2))
88+
for term in terms(f_shift.f)
89+
# X_12
90+
X_stabs[row, TB_edge_index[term]] = Fone
91+
end
92+
g_shift = simplify(ϕ(edge * g_R2))
93+
for term in terms(g_shift.f)
94+
# X_14
95+
X_stabs[row, LR_edge_index[term]] = Fone
96+
end
97+
98+
g_shift = simplify(ϕ(edge * g_anti_R2))
99+
for term in terms(g_shift.f)
100+
# Z_12
101+
Z_stabs[row, TB_edge_index[term]] = Fone
102+
end
103+
f_shift = simplify(ϕ(edge * f_anti_R2))
104+
for term in terms(f_shift.f)
105+
# Z_14
106+
Z_stabs[row, LR_edge_index[term]] = Fone
107+
end
108+
row += 1
109+
end
110+
# println("X stabs")
111+
# display(X_stabs)
112+
# println("Z stabs")
113+
# display(Z_stabs)
114+
115+
return CSSCode(X_stabs, Z_stabs)
116+
end
117+
118+
function show(io::IO, S::AbstractGeneralizedToricCode)
119+
if isa(S, FiniteGeneralizedToricCode)
120+
println(io, "Finite Generalized Toric Code:")
121+
println(io, "\tf: $(S.f)")
122+
println(io, "\tg: $(S.g)")
123+
println(io, "\ta1: $(S.a1)")
124+
println(io, "\ta2: $(S.a2)")
125+
else
126+
println(io, "Generalized Toric Code:")
127+
println(io, "\tf: $(S.f)")
128+
println(io, "\tg: $(S.g)")
129+
end
130+
end

src/Quantum/types.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ abstract type AbstractEASubsystemCode <: AbstractSubsystemCode end
2121
abstract type AbstractEASubsystemCodeCSS <: AbstractEASubsystemCode end
2222
abstract type AbstractEAStabilizerCode <: AbstractStabilizerCode end
2323
abstract type AbstractEAStabilizerCodeCSS <: AbstractEAStabilizerCode end
24+
abstract type AbstractGeneralizedToricCode <: AbstractStabilizerCodeCSS end
2425

2526
# AbstractQuantumLDPCCode, AbstractQuantumLDPCCSSCode?
2627

@@ -336,6 +337,26 @@ mutable struct HypergraphProductCode <: AbstractHypergraphProductCode
336337
Z_metacheck::Union{CTMatrixTypes, Missing}
337338
end
338339

340+
#############################
341+
# Quantum/GeneralizedToricCode.jl
342+
#############################
343+
344+
struct GeneralizedToricCode <: AbstractGeneralizedToricCode
345+
LR::AbstractAlgebra.Generic.LaurentMPolyWrapRing{fpFieldElem, fpMPolyRing}
346+
F::CTFieldTypes
347+
f::CTLRPolyElem
348+
g::CTLRPolyElem
349+
end
350+
351+
struct FiniteGeneralizedToricCode <: AbstractGeneralizedToricCode
352+
LR::AbstractAlgebra.Generic.LaurentMPolyWrapRing{fpFieldElem, fpMPolyRing}
353+
F::CTFieldTypes
354+
f::CTLRPolyElem
355+
g::CTLRPolyElem
356+
a1::Tuple{Int, Int}
357+
a2::Tuple{Int, Int}
358+
end
359+
339360
#############################
340361
# traits
341362
#############################

0 commit comments

Comments
 (0)