Bounds and Weight Enumerators

These functions answer the question of what parameters are possible, as opposed to what a particular code achieves. They fall into three groups.

Closed-form bounds such as the quantum Singleton and quantum Hamming bounds are cheap arithmetic relations among $n$, $k$, and $d$, with companion predicates that test whether a given triple satisfies them and existence bounds of Gilbert-Varshamov type that say when a code must exist.

Linear-programming bounds are stronger and more expensive. The Shor-Laflamme weight enumerator of a quantum code satisfies a set of linear constraints, so the nonexistence of a code with given parameters can be certified by showing the corresponding linear program is infeasible. Solving these requires the JuMP extension, which loads when JuMP and a solver are available. Take care with the numerics: enumerator coefficients span many orders of magnitude, with $A_0 = 1$ while other terms may reach $10^{23}$, so the constraint rows are built exactly in BigInt and normalized per row before being handed to the solver.

Check-weight bounds restrict the stabilizer generator weights in addition to $n$, $k$, and $d$, which is the regime relevant to quantum LDPC codes. These are the bounds where a low-weight constraint genuinely changes the answer, and the corresponding functions report both the bound and, where applicable, whether a construction attaining it is known.

CodingTheory.QuantumLPResultType
struct QuantumLPResult

Result of an arbitrary-precision quantum weight-enumerator LP. status is :feasible, :infeasible_numerical, or :unknown; numerical infeasibility is deliberately not presented as an exact certificate. Coefficients are constructed exactly as BigInt, independently normalized by constraint row, and converted to BigFloat only at the optimizer boundary.

source
CodingTheory.Singleton_boundMethod
Singleton_bound(S::AbstractSubsystemCode) -> Any

Return the quantum Singleton upper bound on the distance of S. This is an alias for quantum_Singleton_bound.

source
CodingTheory.is_MDSMethod
is_MDS(S::AbstractSubsystemCode) -> Any

Return whether the stored exact distance of S meets the quantum Singleton bound, and missing when that distance is unknown. This is an alias for is_quantum_MDS.

source
CodingTheory.is_quantum_MDSMethod
is_quantum_MDS(S::AbstractSubsystemCode) -> Any

Return whether the known exact (dressed, for subsystem codes) distance meets the quantum Singleton bound. Return missing when the exact distance is not stored.

source
CodingTheory.quantum_CSS_dimension_LP_boundMethod
quantum_CSS_dimension_LP_bound(
    n::Integer,
    d::Integer,
    check_weight::Integer;
    kwargs...
)

Return the best result after searching all CSS constituent-dimension splits in the Wang et al. LP, including the largest feasible quantum dimension. exclude_weight_one selects the second branch used in the paper's monotonic post-processing.

source
CodingTheory.quantum_CSS_subsystem_weight_two_distance_boundMethod
quantum_CSS_subsystem_weight_two_distance_bound(
    n::Integer,
    k::Integer
) -> Any

Return min(floor(sqrt(n)), floor(n/k)), the dressed-distance upper bound for a binary CSS subsystem code presented by gauge checks of weight at most two. This parameter API does not inspect a code object because CodingTheory does not yet retain the original gauge-check presentation required by the theorem. The predicate preserves the stronger asymmetric statements d_X*d_Z ≤ n, k*d_X ≤ n, and k*d_Z ≤ n.

source
CodingTheory.quantum_CSS_weight_enumerator_LPMethod
quantum_CSS_weight_enumerator_LP(
    n::Integer,
    k_X::Integer,
    k_Z::Integer,
    d::Integer;
    kwargs...
)

Return the result of the exact-coefficient CSS split-enumerator LP of Wang et al. Here C_X and C_Z have dimensions k_X and k_Z, so the quantum dimension is k_X + k_Z - n. Pass check_weight=w to add the paper's cumulative low-check-weight constraints, and exclude_weight_one=true for its second post-processing branch. model_hook(model, A) supports script-level extensions; entries A[1:n+1] and A[n+2:2n+2] are the X and Z dual-code enumerators, respectively.

source
CodingTheory.quantum_Gilbert_Varshamov_boundMethod
quantum_Gilbert_Varshamov_bound(
    n::Integer,
    k::Union{Integer, Rational},
    q::Integer;
    r,
    variant
) -> Any

Return the largest distance $d$ for which the selected quantum Gilbert–Varshamov existence inequality holds at the supplied length, dimension, alphabet size, and gauge dimension. This is an integer existence bound on distance, not a Boolean predicate.

source
CodingTheory.quantum_Gilbert_Varshamov_existsMethod
quantum_Gilbert_Varshamov_exists(
    n::Integer,
    k::Union{Integer, Rational},
    d::Integer,
    q::Integer;
    r,
    variant
) -> Any

Return whether a finite quantum Gilbert–Varshamov existence inequality holds for the target distance d. variant=:additive supports additive stabilizer and subsystem parameters, :linear selects the $\mathbb{F}_{q^2}$-linear Ketkar bound, and :pure_feng_ma selects the pure linear Feng–Ma bound.

source
CodingTheory.quantum_Hamming_boundMethod
quantum_Hamming_bound(
    n::Integer,
    k::Union{Integer, Rational},
    q::Integer;
    r
) -> Any

Return the largest distance not excluded by the pure quantum Hamming (sphere-packing) bound. The code method requires cached purity or an explicit assume_pure=true, because impure codes need not obey this bound.

source
CodingTheory.quantum_Krawtchouk_matrixMethod
quantum_Krawtchouk_matrix(
    n::Integer;
    alphabet_size,
    signed_columns
) -> Matrix{BigInt}

Return an exact Krawtchouk matrix M[i + 1, j + 1] = P_i(j; n) as Matrix{BigInt}. With signed_columns=true, column j is multiplied by (-1)^j, giving the signed matrix used in the Shor–Laflamme LP constraints. Use alphabet_size=2 for binary CSS constituent codes and 4 for binary Pauli weight enumerators.

source
CodingTheory.quantum_Singleton_boundMethod
quantum_Singleton_bound(
    n::Integer,
    k::Union{Integer, Rational};
    r,
    field_degree
) -> Any

Return the quantum Singleton upper bound on distance. For a stabilizer code, k ≤ n - 2d + 2; for a subsystem code, k + r/degree(F) ≤ n - 2d + 2, because library r counts prime-field gauge pairs. The code must encode a positive-dimensional protected subsystem. For subsystem code objects the bound is applied automatically only over prime fields, or when Fq-linearity or purity is certified; use assume_applicable=true to evaluate the formula outside those cases.

source
CodingTheory.quantum_check_weight_LP_postprocessMethod
quantum_check_weight_LP_postprocess(
    with_weight_one::AbstractDict{<:Tuple{Int64, Int64, Int64}, <:Integer},
    without_weight_one::AbstractDict{<:Tuple{Int64, Int64, Int64}, <:Integer}
) -> Dict{Tuple{Int64, Int64, Int64}, Int64}

Return Wang et al. Equation (18) applied to finite raw LP tables. Dictionary keys are (n,d,w) and values are maximum feasible k. The first table permits weight-one checks; the second imposes A₁=0 (on both CSS enumerators when applicable). The available keys define the finite n′ and w′ horizons. Only points for which both intermediate closures are defined are returned.

source
CodingTheory.quantum_check_weight_dimension_boundMethod
quantum_check_weight_dimension_bound(
    n::Integer,
    check_weight::Integer;
    min_distance
) -> Any

Return the corresponding upper bound k ≤ n - ceil(2n/check_weight) for a binary stabilizer code of distance at least two.

source
CodingTheory.quantum_low_weight_stabilizer_distance_boundMethod
quantum_low_weight_stabilizer_distance_bound(
    n::Integer,
    k::Integer,
    check_weight::Integer
) -> Union{Missing, Int64}

Return the finite distance upper bound for a binary stabilizer presentation whose generators all have weight at most three. A weight-at-most-two presentation has d ≤ 1; at weight three, d ≤ 2, strengthened to d ≤ 1 when k/n > 1/4. Return missing above weight three.

source
CodingTheory.quantum_stabilizer_check_weight_existence_boundMethod
quantum_stabilizer_check_weight_existence_bound(
    n::Integer,
    k::Integer,
    d::Integer
) -> Union{Missing, BigInt}

Return a constructive upper bound on the optimal maximum generator weight: three when d=2 and n ≥ 4k, or four when d≥3 and n ≥ k*d^2. Return missing when these constructions do not apply.

source
CodingTheory.quantum_stabilizer_dimension_LP_boundMethod
quantum_stabilizer_dimension_LP_bound(
    n::Integer,
    d::Integer,
    check_weight::Integer;
    kwargs...
)

Return the largest feasible quantum dimension found by the Wang et al. general-stabilizer LP dimension k. The result retains every trial and distinguishes numerical infeasibility from an exact certificate.

source
CodingTheory.quantum_stabilizer_generator_weight_LP_boundMethod
quantum_stabilizer_generator_weight_LP_bound(
    n::Integer,
    k::Integer,
    d::Integer;
    kwargs...
)

Return a lower bound on the maximum generator weight found by searching the refined Wei et al. LPs weight of a binary [[n,k,d]] stabilizer code. The returned named tuple records whether excluded weights are numerical LP conclusions or exact certificates. connected=true adds the paper's connected-overlap inequality; it asserts that tensor-factor decompositions have already been excluded.

source
CodingTheory.quantum_stabilizer_generator_weight_lower_boundMethod
quantum_stabilizer_generator_weight_lower_bound(
    n::Integer,
    k::Integer;
    min_distance
) -> Any

Return ceil(2n/(n-k)), the finite lower bound of Wei et al. on the optimal maximum generator weight of a binary stabilizer code, strengthened to six by their Proposition 20 at (n,k,d)=(12,7,2). The theorem requires k ≥ 1 and distance at least two.

source
CodingTheory.quantum_stabilizer_group_average_weightFunction
quantum_stabilizer_group_average_weight(n::Integer) -> Any
quantum_stabilizer_group_average_weight(
    n::Integer,
    A₁::Integer
) -> Any

Return the exact average Pauli weight $(3n-A_1)/4$ of a binary stabilizer group with A₁ weight-one elements, using Wei et al.'s identity for distance at least two.

source
CodingTheory.quantum_stabilizer_group_total_weightFunction
quantum_stabilizer_group_total_weight(
    n::Integer,
    k::Integer
) -> Any
quantum_stabilizer_group_total_weight(
    n::Integer,
    k::Integer,
    A₁::Integer
) -> Any

Return the exact total Pauli weight of a binary $[[n, k]]$ stabilizer group with A₁ weight-one elements, using the identity $\sum_j j A_j = 2^{n-k}(3n-A_1)/4$.

source
CodingTheory.quantum_weight_enumerator_LPMethod
quantum_weight_enumerator_LP(
    n::Integer,
    k::Integer,
    d::Integer;
    kwargs...
)

Return the result of the binary Shor–Laflamme/Rains weight-enumerator feasibility LP. formulation=:standard uses the MacWilliams and shadow constraints. :coarse additionally imposes the cumulative check-growth inequalities for check_weight. :refined adds the low-weight-generator constraints of Wei et al. and requires check_weight and num_max_weight_generators. Set include_shadow=false to reproduce Wang et al.'s general-stabilizer LP without the additional Rains shadow inequalities.

The optimizer runs in arbitrary precision through Tulip. Increase precisions, for example to (256, 512, 1024), when the returned status is :unknown or when numerical infeasibility needs stronger evidence. For family-specific experiments, model_hook(model, A) may add JuMP variables and constraints after the exact standard rows are installed. Such custom rows are enforced by the optimizer but are not included in max_normalized_violation. cumulative_lower_bounds accepts cutoff => count pairs imposing sum(A[0:cutoff]) ≥ count; this is the architecture/support-union interface used in Wei et al.'s geometry-aware LP.

source
CodingTheory.satisfies_quantum_CSS_subsystem_weight_two_boundsMethod
satisfies_quantum_CSS_subsystem_weight_two_bounds(
    n::Integer,
    k::Integer,
    d_X::Integer,
    d_Z::Integer
) -> Any

Return whether the parameters $n$, $k$, $d_X$, and $d_Z$ satisfy the weight-two gauge-check bounds $d_X d_Z \leq n$, $k d_X \leq n$, and $k d_Z \leq n$ for a binary CSS subsystem code.

Notes

  • These asymmetric statements are stronger than the single dressed-distance bound returned by quantum_CSS_subsystem_weight_two_distance_bound.
  • Like that function, this takes parameters rather than a code object, because the theorem needs the original weight-two gauge-check presentation, which is not retained on the code.
source
CodingTheory.satisfies_quantum_Hamming_boundMethod
satisfies_quantum_Hamming_bound(
    n::Integer,
    k::Union{Integer, Rational},
    d::Integer,
    q::Integer;
    r
) -> Any

Return whether the sphere-packing inequality holds for a pure q-ary [[n,k,d]] stabilizer code or pure [[n,k,r,d]] subsystem code. This is not valid for an impure code.

source

Weight enumerators

CodingTheory.ShorLaflammeWeightEnumeratorType
struct ShorLaflammeWeightEnumerator

Hamming-weight Shor–Laflamme enumerators. A is the stabilizer distribution and B is its trace-symplectic dual (the stabilizer normalizer distribution). Only coefficient dictionaries are stored; operator lists are never retained.

source
CodingTheory.SL_weight_enumeratorMethod
SL_weight_enumerator(
    S::AbstractSubsystemCode;
    kwargs...
) -> Any

Return the Hamming-weight Shor–Laflamme enumerator pair for S, normalized with $A_0 = B_0 = 1$. The $A$ enumerator counts stabilizer elements and the $B$ enumerator counts elements of its trace-symplectic dual.

source
CodingTheory.Shor_Laflamme_weight_enumeratorMethod
Shor_Laflamme_weight_enumerator(
    S::AbstractSubsystemCode;
    max_terms
) -> Any

Return the cached or newly computed Hamming-weight Shor–Laflamme pair (A, B). A is enumerated from the additive stabilizer group and B is obtained by the trace-symplectic MacWilliams transform. The cache stores only HammingWeightEnumerator coefficient data.

For subsystem codes this describes the full stabilized codespace; it is not a bare/dressed protected-subsystem enumerator.

source
CodingTheory.shor_laflamme_weight_enumeratorMethod
shor_laflamme_weight_enumerator(
    S::AbstractSubsystemCode;
    kwargs...
) -> Any

Return the Hamming-weight Shor–Laflamme enumerator pair for S, normalized with $A_0 = B_0 = 1$. The $A$ enumerator counts stabilizer elements and the $B$ enumerator counts elements of its trace-symplectic dual.

source
CodingTheory.weight_enumeratorMethod
weight_enumerator(
    S::AbstractSubsystemCode;
    set,
    type,
    alg,
    max_terms,
    verbose
) -> Any

Return Hamming-weight quantum enumerators. set=:all returns the ShorLaflammeWeightEnumerator; :stabilizers/:A, :normalizer/:B, and :quotient select one HammingWeightEnumerator.

source