Definitions for Structured Codes Improve the Bennett-Brassard-84 Quantum Key Rate
DefinitionQAlgorithms_Papers_Independent_Advance50_P15The objects the formalized statements of Structured Codes Improve the Bennett-Brassard-84 Quantum Key Rate (arXiv:quant-ph/0607018) are stated in. Each was checked against the paper by a blind read-back and a moderator.
repetitionSyndrome: PDF p.2, Lemma 2: the syndrome of the Z_1 Z_j checks; source wire 1 is wire 0.repetitionCoordinates: PDF p.2, Lemma 2: the bijective coherent decoder, retaining wire 0 and all check outcomes. It does not perform majority correction or discard syndromes.repetitionEncode: PDF p.2: the repetition-code embedding of a logical vector in the span of |0...0> and |1...1>.repetitionDecode: PDF pp.2--3: coherent decoding is a permutation of the computational basis.phaseSign: PDF p.2, Eq.(4): the phase (-1)^(v dot x), using the frozen modulo-two dot product.physicalPauli: PDF p.2, Lemma 2: the ordered Pauli X^u Z^v (Z acts first). The input coordinate at output y is y xor u.logicalPauli: PDF p.2, Lemma 2: the logical operator X^u Z^v, in the same order as the physical Pauli.bernoulliWord: PDF p.2, Eq.(3): an independent Bernoulli(p) word, including the endpoints. The empty word has mass one.logicalSyndromeProb: PDF p.2, Lemma 2: the actual pushforward of independent physical bit errors under the decoder, for one specific syndrome string.bellWeight: PDF p.2, definition of Gamma_p and Eq.(4): Bell/Pauli weights, indexed by (bit error, phase error). On 0 <= p <= 1/2, exactly 0 <= t <= p is allowed.pauliWordProb: PDF p.2, Eq.(4): the m-fold product distribution of the single-pair law. This is not an arbitrary correlated distribution with the same marginals.EveRegister: PDF pp.2--3, Eq.(5)--(8): Eve's register includes Alice's PUBLIC syndrome, then the entire channel-purifying registers E1 and E2. Alice's private noise register is excluded.eveGivenBit: PDF pp.2--3, Eq.(5)--(8), with the public V explicitly retained: Eve's normalized conditional density given Alice's noisy first bit a. For the public syndrome s, z = decoder^(-1)(a,s) is the noisy word, and x = z xor f was the original uniform word. Summing the independent private f incoherently traces out Alice's noise register. The uniform syndrome contributes 2^(-k). No conditional distribution at a zero-probability error word is used.eveInformation: PDF p.3, Eq.(8): I(A;E V), the Holevo information of the uniform retained bit in Eve's full system, including all public syndrome information.phaseRay: PDF p.2, Theorem 1: the two normalized rays phi_+ and phi_-.phaseDensity: PDF p.2, Theorem 1: rho_(p,q) = (1-q)|phi_+><phi_+| + q|phi_-><phi_-|.repetitionPhaseMixture: PDF p.2, Eq.(2): the equal mixture of rho^tensor m and its conjugate by Z^tensor m. Both signs are real, so the right factor is its own adjoint.logicalConditionalEntropy: PDF pp.2--3, Eq.(2): H(logical bit | syndrome) as H(joint)-H(syndrome). This equals the weighted sum over every individual syndrome, including its multiplicity; it never divides by the mass of an impossible syndrome.repetitionExpression: PDF p.2, Eq.(2): the displayed entropic expression per sifted signal. It can be negative and is not defined to be an operational capacity.
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Ensemble
import Definitions.Def_QAlgorithms_Defs_BinaryStabilizer
import Definitions.Def_QAlgorithms_Papers_Independent_Support50_P40
/-!
Smith--Renes--Smolin, arXiv:quant-ph/0607018v2, PDF pp.2--4.
The finite decoder, adversary-information maximum, and numerical positivity are
stated here. The operational Theorem 1 and the full single-letter comparison
are deferred in the unit's HARD.md, rather than replaced by entropic surrogates.
New paper-specific definitions are local; finite Shannon entropy is reused
directly from the pinned accepted Support50.P40 module. The parameter k denotes m - 1,
so that every repetition block has the positive length m = k + 1.
-/
noncomputable section
namespace QAlgorithms.Papers.Independent.Advance50.P15
open QAlgorithms
open scoped ComplexConjugate
attribute [local instance] Classical.propDecidable Classical.decEq
/-- PDF p.2, Lemma 2: the syndrome of the Z_1 Z_j checks; source wire 1 is wire 0. -/
def repetitionSyndrome {k : ℕ} (x : Qubits (k + 1)) : Qubits k :=
fun j => Bool.xor (x 0) (x j.succ)
/-- PDF p.2, Lemma 2: the bijective coherent decoder, retaining wire 0 and all
check outcomes. It does not perform majority correction or discard syndromes. -/
def repetitionCoordinates (k : ℕ) : Qubits (k + 1) ≃ Bool × Qubits k where
toFun x := (x 0, repetitionSyndrome x)
invFun z := Fin.cases z.1 (fun j => Bool.xor z.1 (z.2 j))
left_inv x := by
funext i
refine Fin.cases ?_ (fun j => ?_) i
· rfl
· change Bool.xor (x 0) (Bool.xor (x 0) (x j.succ)) = x j.succ
rw [← Bool.xor_assoc, Bool.xor_self]
simp
right_inv z := by
apply Prod.ext
· rfl
· funext j
change Bool.xor z.1 (Bool.xor z.1 (z.2 j)) = z.2 j
rw [← Bool.xor_assoc, Bool.xor_self]
simp
/-- PDF p.2: the repetition-code embedding of a logical vector in the span of
|0...0> and |1...1>. -/
def repetitionEncode (k : ℕ) (psi : EuclideanSpace ℂ Bool) :
EuclideanSpace ℂ (Qubits (k + 1)) :=
WithLp.toLp 2 fun x => if ∀ i, x i = x 0 then psi (x 0) else 0
/-- PDF pp.2--3: coherent decoding is a permutation of the computational basis. -/
def repetitionDecode {k : ℕ} (psi : EuclideanSpace ℂ (Qubits (k + 1))) :
EuclideanSpace ℂ (Bool × Qubits k) :=
WithLp.toLp 2 fun z => psi ((repetitionCoordinates k).symm z)
/-- PDF p.2, Eq.(4): the phase (-1)^(v dot x), using the frozen modulo-two dot product. -/
def phaseSign {m : ℕ} (v x : Qubits m) : ℂ :=
if dotBits v x then -1 else 1
/-- PDF p.2, Lemma 2: the ordered Pauli X^u Z^v (Z acts first).
The input coordinate at output y is y xor u. -/
def physicalPauli {m : ℕ} (u v : Qubits m)
(psi : EuclideanSpace ℂ (Qubits m)) : EuclideanSpace ℂ (Qubits m) :=
WithLp.toLp 2 fun y => phaseSign v (y + u) * psi (y + u)
/-- PDF p.2, Lemma 2: the logical operator X^u Z^v, in the same order as the
physical Pauli. -/
def logicalPauli (u v : Bool) (psi : EuclideanSpace ℂ Bool) :
EuclideanSpace ℂ Bool :=
WithLp.toLp 2 fun y =>
(if v && Bool.xor y u then (-1 : ℂ) else 1) * psi (Bool.xor y u)
/-- PDF p.2, Eq.(3): an independent Bernoulli(p) word, including the endpoints.
The empty word has mass one. -/
def bernoulliWord {m : ℕ} (p : ℝ) (u : Qubits m) : ℝ :=
∏ i, if u i then p else 1 - p
/-- PDF p.2, Lemma 2: the actual pushforward of independent physical bit errors
under the decoder, for one specific syndrome string. -/
def logicalSyndromeProb (k : ℕ) (p : ℝ) (a : Bool) (s : Qubits k) : ℝ :=
∑ u : Qubits (k + 1), if u 0 = a ∧ repetitionSyndrome u = s then bernoulliWord p u else 0
/-- PDF p.2, definition of Gamma_p and Eq.(4): Bell/Pauli weights, indexed by
(bit error, phase error). On 0 <= p <= 1/2, exactly 0 <= t <= p is allowed. -/
def bellWeight (p t : ℝ) (u v : Bool) : ℝ :=
if u then (if v then t else p - t)
else (if v then p - t else 1 + t - 2 * p)
/-- PDF p.2, Eq.(4): the m-fold product distribution of the single-pair law.
This is not an arbitrary correlated distribution with the same marginals. -/
def pauliWordProb {m : ℕ} (p t : ℝ) (u v : Qubits m) : ℝ :=
∏ i, bellWeight p t (u i) (v i)
/-- PDF pp.2--3, Eq.(5)--(8): Eve's register includes Alice's PUBLIC syndrome,
then the entire channel-purifying registers E1 and E2. Alice's private noise
register is excluded. -/
abbrev EveRegister (k : ℕ) := Qubits k × (Qubits (k + 1) × Qubits (k + 1))
/-- PDF pp.2--3, Eq.(5)--(8), with the public V explicitly retained: Eve's
normalized conditional density given Alice's noisy first bit a. For the public
syndrome s, z = decoder^(-1)(a,s) is the noisy word, and x = z xor f was the
original uniform word. Summing the independent private f incoherently traces
out Alice's noise register. The uniform syndrome contributes 2^(-k).
No conditional distribution at a zero-probability error word is used. -/
def eveGivenBit (k : ℕ) (p q t : ℝ) (a : Bool) :
Matrix (EveRegister k) (EveRegister k) ℂ :=
fun e d => if e.1 = d.1 ∧ e.2.1 = d.2.1 then
((2 : ℂ) ^ k)⁻¹ * ∑ f : Qubits (k + 1),
let x := ((repetitionCoordinates k).symm (a, e.1) + f)
(bernoulliWord q f : ℂ) *
(Real.sqrt (pauliWordProb p t e.2.1 e.2.2) : ℂ) *
(Real.sqrt (pauliWordProb p t e.2.1 d.2.2) : ℂ) *
phaseSign e.2.2 x * conj (phaseSign d.2.2 x)
else 0
/-- PDF p.3, Eq.(8): I(A;E V), the Holevo information of the uniform retained
bit in Eve's full system, including all public syndrome information. -/
def eveInformation (k : ℕ) (p q t : ℝ) : ℝ :=
let r0 := eveGivenBit k p q t false
let r1 := eveGivenBit k p q t true
vnEntropy (((1 / 2 : ℂ) • r0) + ((1 / 2 : ℂ) • r1)) -
(vnEntropy r0 + vnEntropy r1) / 2
/-- PDF p.2, Theorem 1: the two normalized rays phi_+ and phi_-. -/
def phaseRay (p : ℝ) (minus : Bool) : EuclideanSpace ℂ Bool :=
WithLp.toLp 2 fun b => if b then
(if minus then (-1 : ℂ) else 1) * (Real.sqrt p : ℂ)
else (Real.sqrt (1 - p) : ℂ)
/-- PDF p.2, Theorem 1: rho_(p,q) = (1-q)|phi_+><phi_+| + q|phi_-><phi_-|. -/
def phaseDensity (p q : ℝ) : Matrix Bool Bool ℂ :=
((1 - q : ℝ) : ℂ) • pureDensity (phaseRay p false) +
(q : ℂ) • pureDensity (phaseRay p true)
/-- PDF p.2, Eq.(2): the equal mixture of rho^tensor m and its conjugate by
Z^tensor m. Both signs are real, so the right factor is its own adjoint. -/
def repetitionPhaseMixture (m : ℕ) (p q : ℝ) : Matrix (Qubits m) (Qubits m) ℂ :=
fun x y => (1 / 2 : ℂ) * kronAll (fun _ : Fin m => phaseDensity p q) x y +
(1 / 2 : ℂ) * (-1 : ℂ) ^ hammingWeight x *
kronAll (fun _ : Fin m => phaseDensity p q) x y * (-1 : ℂ) ^ hammingWeight y
/-- PDF pp.2--3, Eq.(2): H(logical bit | syndrome) as H(joint)-H(syndrome).
This equals the weighted sum over every individual syndrome, including its
multiplicity; it never divides by the mass of an impossible syndrome. -/
def logicalConditionalEntropy (k : ℕ) (p : ℝ) : ℝ :=
QAlgorithms.Papers.Independent.Support50.P40.finiteEntropyBits (fun z : Bool × Qubits k => logicalSyndromeProb k p z.1 z.2) -
QAlgorithms.Papers.Independent.Support50.P40.finiteEntropyBits (fun s : Qubits k => ∑ a : Bool, logicalSyndromeProb k p a s)
/-- PDF p.2, Eq.(2): the displayed entropic expression per sifted signal.
It can be negative and is not defined to be an operational capacity. -/
def repetitionExpression (k : ℕ) (p q : ℝ) : ℝ :=
(1 - logicalConditionalEntropy k (p * (1 - q) + q * (1 - p)) +
((k + 1 : ℕ) : ℝ) * vnEntropy (phaseDensity p q) -
vnEntropy (repetitionPhaseMixture (k + 1) p q)) / ((k + 1 : ℕ) : ℝ)
/-! Sanity examples for the new interfaces. -/
example (k : ℕ) (a : Bool) (s : Qubits k) :
(repetitionCoordinates k).symm (a, s) 0 = a := rfl
example (k : ℕ) : repetitionSyndrome (fun _ : Fin (k + 1) => false) =
(fun _ : Fin k => false) := by
funext j
rfl
example (x : Qubits 0) : hammingWeight x = 0 := by
simp [hammingWeight]
example (p : ℝ) (x : Qubits 0) : bernoulliWord p x = 1 := by
simp [bernoulliWord]
example (v x : Qubits 0) : phaseSign v x = 1 := by
simp [phaseSign, dotBits]
example (p : ℝ) : bellWeight p (p ^ 2) true true = p ^ 2 := rfl
example (k : ℕ) (p q t : ℝ) (a : Bool) (e d : EveRegister k)
(h : e.1 ≠ d.1) : eveGivenBit k p q t a e d = 0 := by
simp [eveGivenBit, h]
example (p : ℝ) : phaseDensity p 0 = pureDensity (phaseRay p false) := by
simp [phaseDensity]
example (rho : Matrix Bool Bool ℂ) (x y : Qubits 0) :
kronAll (fun _ : Fin 0 => rho) x y = 1 := by
simp [kronAll]
example {I : Type*} [Fintype I] : QAlgorithms.Papers.Independent.Support50.P40.finiteEntropyBits (fun _ : I => 0) = 0 := by
simp [QAlgorithms.Papers.Independent.Support50.P40.finiteEntropyBits]
end QAlgorithms.Papers.Independent.Advance50.P15
Read-back
What the Lean code literally says, in plain math · gpt-6.1-sol
QAlgorithms.Papers.Independent.Advance50.P15.EveRegister
For every natural number , this abbreviates the type of triples , where is a Boolean string of length and are Boolean strings of length . For , is the unique empty string and each of has one bit.
QAlgorithms.Papers.Independent.Advance50.P15.bellWeight
For every pair of real numbers and Boolean values , this defines a real number: it is when , when is either or , and when . No restrictions on or nonnegativity of these values are assumed.
QAlgorithms.Papers.Independent.Advance50.P15.bernoulliWord
For every natural number , real number , and Boolean string of length , this defines the real number , where when is true and when is false. There is no assumption that lies in . For , the empty product is .
QAlgorithms.Papers.Independent.Advance50.P15.eveGivenBit
For every natural number , real numbers , and bit , this defines a complex matrix whose rows and columns are indexed by triples , where is a -bit string and are -bit strings. Write for bitwise exclusive-or, for the parity of , and for the -bit string with and . Define
where
The matrix entry is
All real factors are regarded as complex numbers. There are no restrictions on ; real square roots of negative arguments are defined to be zero. The definition includes , when the syndrome string is empty.
QAlgorithms.Papers.Independent.Advance50.P15.eveInformation
For every natural number and real numbers , this defines
where is formed using the real continuous functional calculus. Here , for , is indexed by triples , with entries zero unless the two indices have the same and , and otherwise
Bits in exponents are identified with , each dot product denotes parity, , , and the four values of , in the order , are . No parameter bounds or density-matrix assumptions are imposed, and is included. Real square roots of negative numbers are zero; the real logarithm used here has and for negative , so in particular .
QAlgorithms.Papers.Independent.Advance50.P15.logicalConditionalEntropy
For every natural number and real number , this defines
where
Thus the definition subtracts the finite entropy expression of the syndrome marginal from that of the joint bit-and-syndrome array. No restriction on is imposed. The real logarithm has value zero at zero and uses for negative arguments, so zero summands contribute zero even without nonnegativity assumptions. The definition includes , when there is one empty syndrome.
QAlgorithms.Papers.Independent.Advance50.P15.logicalPauli
For every pair of Boolean values and every vector , this defines a vector whose amplitude at a Boolean value is multiplied by if both and are true, and by otherwise, where denotes exclusive OR. No normalization of is assumed.
QAlgorithms.Papers.Independent.Advance50.P15.logicalSyndromeProb
For every natural number , real number , Boolean value , and Boolean string of length , this defines the sum, over all Boolean strings of length satisfying and for every , of , where if is true and otherwise; denotes exclusive OR. Strings failing either condition contribute zero. No restriction on is imposed. For , is empty and the value is if is true and if is false.
QAlgorithms.Papers.Independent.Advance50.P15.pauliWordProb
For every natural number , real numbers , and Boolean strings of length , this defines the real number , where if , if exactly one of is true, and if both are false. No restrictions on or nonnegativity are assumed. For , the empty product is .
QAlgorithms.Papers.Independent.Advance50.P15.phaseDensity
For every pair of real numbers , this defines the complex matrix
in the coordinate order , where , , and the outer product has entry . Both parameters are unrestricted real numbers; square roots of negative arguments are zero. The definition itself imposes no positivity, trace, or normalization conditions.
QAlgorithms.Papers.Independent.Advance50.P15.phaseRay
For every real number and bit , this defines a vector in the complex Euclidean space indexed by the two bits, with coordinates
The square roots are real and then embedded in . There is no assumption that and no normalization hypothesis; a real square root with negative argument is zero.
QAlgorithms.Papers.Independent.Advance50.P15.phaseSign
For every natural number and Boolean strings of length , this defines a complex number equal to if the number of indices with both and true is odd, and equal to if that number is even. In particular, for it equals .
QAlgorithms.Papers.Independent.Advance50.P15.physicalPauli
For every natural number , Boolean strings of length , and complex Euclidean vector indexed by Boolean strings of length , this defines the vector whose amplitude at a Boolean string is , where denotes coordinatewise exclusive OR and is the number of indices for which both and are true. No normalization of is assumed. For , the empty sum determining the sign is zero, and the resulting vector equals .
QAlgorithms.Papers.Independent.Advance50.P15.repetitionCoordinates
For every natural number , this defines a bijection from Boolean strings of length to pairs consisting of a Boolean value and a Boolean string of length . It sends to with and for , where is exclusive OR. Its inverse sends to the string satisfying and . The two maps are inverse in both directions. For , this bijection pairs the sole bit with the empty string.
QAlgorithms.Papers.Independent.Advance50.P15.repetitionDecode
For every natural number and every complex Euclidean vector indexed by Boolean strings of length , this defines a vector indexed by pairs , where is Boolean and is a Boolean string of length . Its amplitude at is , where and for every , with denoting exclusive OR. No normalization of is assumed. For , the amplitude at is evaluated at the one-bit string whose bit is .
QAlgorithms.Papers.Independent.Advance50.P15.repetitionEncode
For every natural number and every vector , this defines a vector indexed by Boolean strings of length : its amplitude at is if for every , and is otherwise. No normalization of is assumed. For , every one-bit string satisfies the condition, so its amplitude is .
QAlgorithms.Papers.Independent.Advance50.P15.repetitionExpression
For every natural number and real numbers , this defines
Here
for -bit strings , with counting the -bits. For any real , set
and
Finally, , where is applied by real continuous functional calculus. Bits in exponents mean . There are no parameter bounds: negative square-root arguments give zero, the real logarithm is zero at zero and uses the absolute value on negative arguments, and is included. The denominator is always positive.
QAlgorithms.Papers.Independent.Advance50.P15.repetitionPhaseMixture
For every natural number and real numbers , this defines a complex matrix indexed by -bit strings , with entries
where and count the entries equal to , and the rows and columns of are ordered . There are no restrictions on ; negative square-root arguments give zero. The case is included: the empty product is , and the matrix has its single entry equal to .
QAlgorithms.Papers.Independent.Advance50.P15.repetitionSyndrome
For every natural number and Boolean string of length , this defines the Boolean string of length by for , where denotes exclusive OR. For , the result is the unique empty Boolean string.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.