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

[[4p, 2(p − 2), 4]] Delfosse-Reichardt repetition code #465

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,10 @@ @article{bhatia2018mceliece
journal={arXiv preprint arXiv:1811.06246},
year={2018}
}

@article{delfosse2020short,
title={Short shor-style syndrome sequences},
author={Delfosse, Nicolas and Reichardt, Ben W},
journal={arXiv preprint arXiv:2008.05051},
year={2020}
}
1 change: 1 addition & 0 deletions docs/src/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ For quantum code construction routines:
- [lin2024quantum](@cite)
- [bravyi2024high](@cite)
- [haah2011local](@cite)
- [delfosse2020short](@cite)

For classical code construction routines:
- [muller1954application](@cite)
Expand Down
3 changes: 2 additions & 1 deletion src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export parity_checks, parity_checks_x, parity_checks_z, iscss,
Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
Toric, Gottesman, Surface, Concat, CircuitCode, QuantumReedMuller,
LPCode, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes,
haah_cubic_codes,
haah_cubic_codes, DelfosseRepCode,
random_brickwork_circuit_code, random_all_to_all_circuit_code,
evaluate_decoder,
CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup,
Expand Down Expand Up @@ -385,6 +385,7 @@ include("codes/surface.jl")
include("codes/concat.jl")
include("codes/random_circuit.jl")
include("codes/quantumreedmuller.jl")
include("codes/delfosserepcode.jl")
include("codes/classical/reedmuller.jl")
include("codes/classical/recursivereedmuller.jl")
include("codes/classical/bch.jl")
Expand Down
91 changes: 91 additions & 0 deletions src/ecc/codes/delfosserepcode.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"""
The `[[4p, 2(p − 2), 4]]` Delfosse repetition code is derived from the classical
`[4, 1, 4]` repetition code and is used to construct quantum stabilizer code.

The `[4, 1, 4]` repetition code is a classical error-correcting code where each bit
is repeated four times to improve error detection and correction. It is defined by
the following parity-check matrix:

\$\$
\\begin{pmatrix}
1 & 1 & 1 & 1 \\\\
0 & 0 & 1 & 1 \\\\
0 & 1 & 0 & 1
\\end{pmatrix}
\$\$

The `[[4p, 2(p − 2), 4]]` codes were introduced by Delfosse and Reichardt in the
paper *Short Shor-style syndrome sequences* [delfosse2020short](@cite). The parameter
`p` specifies the **number of blocks** in the code construction. For the code to be
valid, `p` must be a multiple of 2.

An `[[24, 8, 4]]` Delfosse repetition code from [delfosse2020short](@cite).

```jldoctest
julia> using QuantumClifford; using QuantumClifford.ECC; # hide

julia> c = parity_checks(DelfosseRepCode(6))
+ XXXX____________________
+ ____XXXX________________
+ ________XXXX____________
+ ____________XXXX________
+ ________________XXXX____
+ ____________________XXXX
+ __XX__XX__XX__XX__XX__XX
+ _X_X_X_X_X_X_X_X_X_X_X_X
+ ZZZZ____________________
+ ____ZZZZ________________
+ ________ZZZZ____________
+ ____________ZZZZ________
+ ________________ZZZZ____
+ ____________________ZZZZ
+ __ZZ__ZZ__ZZ__ZZ__ZZ__ZZ
+ _Z_Z_Z_Z_Z_Z_Z_Z_Z_Z_Z_Z

julia> code_n(c), code_k(c)
(24, 8)
```
"""
struct DelfosseRepCode <: AbstractECC
blocks::Int
function DelfosseRepCode(blocks)
blocks < 2 && throw(ArgumentError("The number of blocks must be at least 2 to construct a valid code."))
blocks % 2 != 0 && throw(ArgumentError("The number of blocks must be a multiple of 2."))
new(blocks)
end
end

function iscss(::Type{DelfosseRepCode})
return true
end

function _extend_414_repetition_code(blocks::Int)
n = 4*blocks
H = zeros(Bool, 2+blocks, n)
@simd for i in 1:blocks
H[i, (4*(i-1)+1):(4*i)] .= 1
end
@simd for i in 1:blocks
H[blocks+1, (4*(i-1)+3):(4*(i-1)+4)] .= 1
end
@simd for i in 1:blocks
H[blocks+2, (4*(i-1)+2):(4*(i-1)+4):2] .= 1
end
H[end, 1:n] .= (1:n) .% 2 .== 0
return H
end

function parity_checks(c::DelfosseRepCode)
extended_mat = _extend_414_repetition_code(c.blocks)
hx, hz = extended_mat, extended_mat
code = CSS(hx, hz)
Stabilizer(code)
end

code_n(c::DelfosseRepCode) = 4*c.blocks

code_k(c::DelfosseRepCode) = 2*(c.blocks - 2)

parity_checks_x(c::DelfosseRepCode) = _extend_414_repetition_code(c.blocks)

parity_checks_z(c::DelfosseRepCode) = _extend_414_repetition_code(c.blocks)
3 changes: 2 additions & 1 deletion test/test_ecc_base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ const code_instance_args = Dict(
:Concat => [(Perfect5(), Perfect5()), (Perfect5(), Steane7()), (Steane7(), Cleve8()), (Toric(2, 2), Shor9())],
:CircuitCode => random_circuit_code_args,
:LPCode => (c -> (c.A, c.B)).(vcat(LP04, LP118, test_gb_codes, test_bb_codes, test_mbb_codes, test_coprimeBB_codes, test_hcubic_codes, other_lifted_product_codes)),
:QuantumReedMuller => [3, 4, 5]
:QuantumReedMuller => [3, 4, 5],
:DelfosseRepCode => [4, 6, 8, 10]
)

function all_testablable_code_instances(;maxn=nothing)
Expand Down
45 changes: 45 additions & 0 deletions test/test_ecc_delfosse_repcode.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@testitem "ECC [[4p, 2(p − 2), 4]] DelfosseRepCode" begin

using LinearAlgebra
using QuantumClifford.ECC
using QuantumClifford.ECC: DelfosseRepCode, _extend_414_repetition_code, logz_ops, logx_ops
using Nemo: matrix, GF

@testset "Testing [[4p, 2(p − 2), 4]] DelfosseRepCode properties" begin
for i in 1:50
p = 2*i
n = 4*p
k = 2*(p - 2)
stab = parity_checks(DelfosseRepCode(p))
H = stab_to_gf2(stab)
mat = matrix(GF(2), H)
computed_rank = rank(mat)
@test computed_rank == n - k
end

# crosscheck parity check matrices from VIII. 1 Generalizing the [4, 1, 4]
# classical repetition code, pg. 10 of https://arxiv.org/pdf/2008.05051
blocks = 1
@test _extend_414_repetition_code(blocks) == [1 1 1 1;
0 0 1 1;
0 1 0 1];
blocks = 4
# [16, 10, 4] classical linear code
@test _extend_414_repetition_code(blocks) == [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1;
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1;
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]
blocks = 6
# [24, 16, 4] classical linear code
@test _extend_414_repetition_code(blocks) == [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1;
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1;
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1];
end
end
Loading