From 429f21c8f7121de81bd8b943ea277cd0607efd3b Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Thu, 24 Oct 2024 03:07:57 +0500 Subject: [PATCH 1/5] Check representation matrix commutation relation for the CSS orthogonality condition of the 2BGA code --- .../QuantumCliffordHeckeExt.jl | 5 +++-- ext/QuantumCliffordHeckeExt/util.jl | 15 +++++++++++++++ src/ecc/ECC.jl | 2 +- src/ecc/codes/lifted_product.jl | 3 +++ test/test_ecc_base.jl | 1 + 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 ext/QuantumCliffordHeckeExt/util.jl diff --git a/ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl b/ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl index 29e9de8ce..b8508ff66 100644 --- a/ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl +++ b/ext/QuantumCliffordHeckeExt/QuantumCliffordHeckeExt.jl @@ -5,14 +5,15 @@ using DocStringExtensions import QuantumClifford, LinearAlgebra import Hecke: Group, GroupElem, AdditiveGroup, AdditiveGroupElem, GroupAlgebra, GroupAlgebraElem, FqFieldElem, representation_matrix, dim, base_ring, - multiplication_table, coefficients, abelian_group, group_algebra + multiplication_table, coefficients, abelian_group, group_algebra, rand import Nemo import Nemo: characteristic, matrix_repr, GF, ZZ, lift import QuantumClifford.ECC: AbstractECC, CSS, ClassicalCode, hgp, code_k, code_n, code_s, iscss, parity_checks, parity_checks_x, parity_checks_z, parity_checks_xz, - two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes + two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes, check_repr_commutation_relation +include("util.jl") include("types.jl") include("lifted.jl") include("lifted_product.jl") diff --git a/ext/QuantumCliffordHeckeExt/util.jl b/ext/QuantumCliffordHeckeExt/util.jl new file mode 100644 index 000000000..cc4431e59 --- /dev/null +++ b/ext/QuantumCliffordHeckeExt/util.jl @@ -0,0 +1,15 @@ +""" +Checks the commutation relation between the left and right representation matrices +for two elements `a` and `b` in the group algebra `ℱ[G]` with a general group `G`. +It verifies the commutation relation that states, `L(a)·R(b) = R(b)·L(a)`. This +property shows that matrices from the left and right representation sets commute +with each other, which is an important property related to the CSS orthogonality +condition. +""" +function check_repr_commutation_relation(GA::GroupAlgebra) + a, b = rand(GA), rand(GA) + # Check commutation relation: L(a) R(b) == R(b) L(a) + L_a = representation_matrix(a) + R_a = representation_matrix(b, :right) + return L_a * R_a == R_a * L_a +end diff --git a/src/ecc/ECC.jl b/src/ecc/ECC.jl index cdda7742e..39753e42a 100644 --- a/src/ecc/ECC.jl +++ b/src/ecc/ECC.jl @@ -15,7 +15,7 @@ abstract type AbstractECC end export parity_checks, parity_checks_x, parity_checks_z, iscss, code_n, code_s, code_k, rate, distance, - isdegenerate, faults_matrix, + isdegenerate, faults_matrix, check_repr_commutation_relation, naive_syndrome_circuit, shor_syndrome_circuit, naive_encoding_circuit, RepCode, LiftedCode, CSS, diff --git a/src/ecc/codes/lifted_product.jl b/src/ecc/codes/lifted_product.jl index 338880702..8800a7734 100644 --- a/src/ecc/codes/lifted_product.jl +++ b/src/ecc/codes/lifted_product.jl @@ -17,3 +17,6 @@ function generalized_bicycle_codes end """Implemented in a package extension with Hecke.""" function bicycle_codes end + +"""Implemented in a package extension with Hecke.""" +function check_repr_commutation_relation end diff --git a/test/test_ecc_base.jl b/test/test_ecc_base.jl index 9f4a5ec9e..f91653a63 100644 --- a/test/test_ecc_base.jl +++ b/test/test_ecc_base.jl @@ -46,6 +46,7 @@ other_lifted_product_codes = [] # [[882, 24, d≤24]] code from (B1) in Appendix B of [panteleev2021degenerate](@cite) l = 63 GA = group_algebra(GF(2), abelian_group(l)) +@test check_repr_commutation_relation(GA) == true A = zeros(GA, 7, 7) x = gens(GA)[] A[LinearAlgebra.diagind(A)] .= x^27 From fb86505288d2f69968ed291f1b5d7b35b152d88d Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Fri, 25 Oct 2024 12:05:52 +0500 Subject: [PATCH 2/5] code review suggestions --- ext/QuantumCliffordHeckeExt/util.jl | 2 +- src/ecc/ECC.jl | 2 +- test/test_ecc_base.jl | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/QuantumCliffordHeckeExt/util.jl b/ext/QuantumCliffordHeckeExt/util.jl index cc4431e59..50c686dcc 100644 --- a/ext/QuantumCliffordHeckeExt/util.jl +++ b/ext/QuantumCliffordHeckeExt/util.jl @@ -8,7 +8,7 @@ condition. """ function check_repr_commutation_relation(GA::GroupAlgebra) a, b = rand(GA), rand(GA) - # Check commutation relation: L(a) R(b) == R(b) L(a) + # Check commutation relation: L(a)R(b) = R(b)L(a) L_a = representation_matrix(a) R_a = representation_matrix(b, :right) return L_a * R_a == R_a * L_a diff --git a/src/ecc/ECC.jl b/src/ecc/ECC.jl index 39753e42a..cdda7742e 100644 --- a/src/ecc/ECC.jl +++ b/src/ecc/ECC.jl @@ -15,7 +15,7 @@ abstract type AbstractECC end export parity_checks, parity_checks_x, parity_checks_z, iscss, code_n, code_s, code_k, rate, distance, - isdegenerate, faults_matrix, check_repr_commutation_relation, + isdegenerate, faults_matrix, naive_syndrome_circuit, shor_syndrome_circuit, naive_encoding_circuit, RepCode, LiftedCode, CSS, diff --git a/test/test_ecc_base.jl b/test/test_ecc_base.jl index f91653a63..a16546e33 100644 --- a/test/test_ecc_base.jl +++ b/test/test_ecc_base.jl @@ -1,6 +1,7 @@ using Test using QuantumClifford using QuantumClifford.ECC +using QuantumClifford.ECC: check_repr_commutation_relation using InteractiveUtils import Nemo: GF @@ -46,7 +47,7 @@ other_lifted_product_codes = [] # [[882, 24, d≤24]] code from (B1) in Appendix B of [panteleev2021degenerate](@cite) l = 63 GA = group_algebra(GF(2), abelian_group(l)) -@test check_repr_commutation_relation(GA) == true +@test check_repr_commutation_relation(GA) A = zeros(GA, 7, 7) x = gens(GA)[] A[LinearAlgebra.diagind(A)] .= x^27 From a0a1ec61f5e76af3caca5d51c5ecb241bc2eb0a1 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Tue, 29 Oct 2024 09:13:32 +0500 Subject: [PATCH 3/5] fix typo --- ext/QuantumCliffordHeckeExt/util.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/QuantumCliffordHeckeExt/util.jl b/ext/QuantumCliffordHeckeExt/util.jl index 50c686dcc..2c24a4602 100644 --- a/ext/QuantumCliffordHeckeExt/util.jl +++ b/ext/QuantumCliffordHeckeExt/util.jl @@ -10,6 +10,6 @@ function check_repr_commutation_relation(GA::GroupAlgebra) a, b = rand(GA), rand(GA) # Check commutation relation: L(a)R(b) = R(b)L(a) L_a = representation_matrix(a) - R_a = representation_matrix(b, :right) - return L_a * R_a == R_a * L_a + R_b = representation_matrix(b, :right) + return L_a * R_b == R_b * L_a end From 2ff2d3e98d1530a65b15e96d6bde6b383a42f8d0 Mon Sep 17 00:00:00 2001 From: Fe-r-oz Date: Tue, 29 Oct 2024 10:24:56 +0500 Subject: [PATCH 4/5] move consistency check to util.l --- src/ecc/codes/lifted_product.jl | 3 --- src/ecc/codes/util.jl | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ecc/codes/lifted_product.jl b/src/ecc/codes/lifted_product.jl index 8800a7734..338880702 100644 --- a/src/ecc/codes/lifted_product.jl +++ b/src/ecc/codes/lifted_product.jl @@ -17,6 +17,3 @@ function generalized_bicycle_codes end """Implemented in a package extension with Hecke.""" function bicycle_codes end - -"""Implemented in a package extension with Hecke.""" -function check_repr_commutation_relation end diff --git a/src/ecc/codes/util.jl b/src/ecc/codes/util.jl index 1063785f9..b96a75120 100644 --- a/src/ecc/codes/util.jl +++ b/src/ecc/codes/util.jl @@ -6,3 +6,6 @@ function hgp(h₁,h₂) hz = hcat(kron(LinearAlgebra.I(n₁), h₂), kron(h₁', LinearAlgebra.I(r₂))) hx, hz end + +"""Implemented in a package extension with Hecke.""" +function check_repr_commutation_relation end From dda1502dbac2346939264fd0788640f0ae75a968 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Mon, 4 Nov 2024 22:38:42 -0500 Subject: [PATCH 5/5] minor documentation notes --- ext/QuantumCliffordHeckeExt/util.jl | 2 +- test/test_ecc_base.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/QuantumCliffordHeckeExt/util.jl b/ext/QuantumCliffordHeckeExt/util.jl index 2c24a4602..d8fc65e85 100644 --- a/ext/QuantumCliffordHeckeExt/util.jl +++ b/ext/QuantumCliffordHeckeExt/util.jl @@ -1,6 +1,6 @@ """ Checks the commutation relation between the left and right representation matrices -for two elements `a` and `b` in the group algebra `ℱ[G]` with a general group `G`. +for two randomly-sampled elements `a` and `b` in the group algebra `ℱ[G]` with a general group `G`. It verifies the commutation relation that states, `L(a)·R(b) = R(b)·L(a)`. This property shows that matrices from the left and right representation sets commute with each other, which is an important property related to the CSS orthogonality diff --git a/test/test_ecc_base.jl b/test/test_ecc_base.jl index a16546e33..26b00c8f3 100644 --- a/test/test_ecc_base.jl +++ b/test/test_ecc_base.jl @@ -47,7 +47,7 @@ other_lifted_product_codes = [] # [[882, 24, d≤24]] code from (B1) in Appendix B of [panteleev2021degenerate](@cite) l = 63 GA = group_algebra(GF(2), abelian_group(l)) -@test check_repr_commutation_relation(GA) +@test check_repr_commutation_relation(GA) # TODO use this check more pervasively throughout the test suite A = zeros(GA, 7, 7) x = gens(GA)[] A[LinearAlgebra.diagind(A)] .= x^27