Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Security of quantum key distribution with imperfect devices

Definition
QAlgorithms_Papers_Independent_Intake100_P99

by Gohan · Oct 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

The objects the formalized statements of Security of quantum key distribution with imperfect devices (arXiv:quant-ph/0212066) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • ExponentiallySmall: PDF pp.5,9,11: a failure probability is exponentially small in the family index. For the standalone coin results that index is the number of coins, n. Constants may depend on the state family and the fixed positive accuracy slack.
  • entropyGap: PDF p.11, (20): the nonnegative entropy-gap branch. On [0,1/2] the set is nonempty, compact and a singleton, by continuity and strict monotonicity of binary entropy on [0,1/2]. Outside that source domain the explicit default is zero and no result below uses that default.
  • densityEvent: PDF pp.10--11: probability of an event in a computational-basis measurement of a density matrix. Every use in the theorems carries trace-one positivity.
  • coinXFailure: PDF pp.9--11: probability of the complement of the strict event NX < n delta. Hadamard conjugation converts X measurement into the fixed computational basis.
  • coinZFailure: PDF p.11, (19): probability of the complement of |n/2 - NZ| < n(f(delta)+epsilon), in the Z measurement of the same state.
  • PairBits: PDF pp.9--11: Alice's n qubits first, Bob's n qubits second.
  • PairCoinBits: PDF pp.9--11: pair registers followed by their n virtual basis coins.
  • bellChange: PDF p.10, (10)--(11): columns are product Bell states labelled by their bit-error string b and phase-error string p. The amplitude at (u,v) is zero unless v=u xor b, and otherwise is 2^(-n/2) (-1)^(u dot p).
  • controlledBilateralHadamard: PDF p.9, (9): the actual final bilateral Hadamards controlled by the matching coins. These act AFTER the state whose X-coin disturbance is bounded.
  • phaseBitGapFailure: PDF pp.10--11, (13),(24): full Bell-measurement tail after the final coin-controlled bilateral Hadamards. The counts are joint random variables, not expectations. The coins are also measured in Z and their result discarded.
  • retainedMinusCount: PDF p.12, (32): number of X-minus coins whose corresponding signals survive an actual removal mask. A true mask bit denotes a lost signal.
  • retainedMinusFraction: PDF p.12, (32): the disturbed fraction of the retained coins, computed from the same measurement outcome and mask. The denominator is positive on supported masks for positive n and loss < 1; its n=0 default is never used asymptotically.
  • LossBudget: PDF p.12, (32): the removal mask deletes at most the specified fraction of signals. The first register contains all original virtual coins, the second the classical loss flags. Zero marginal weight excludes every excessive mask; the joint state may otherwise correlate the mask with the coins arbitrarily.
  • retainedLossFailure: PDF p.12, (32): tail of the surviving disturbed fraction, measured jointly with the loss flags. The event uses delta/(1-loss), not a free new disturbance parameter. No conditioning on a rare block-acceptance event is introduced.
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Measurement
import Definitions.Def_QAlgorithms_Defs_MatrixDistances
import Definitions.Def_QAlgorithms_Papers_Independent_Information100_P69
import Definitions.Def_QAlgorithms_Papers_Independent_Dependency50_P48

/-!
Gottesman--Lo--Lutkenhaus--Preskill, arXiv:quant-ph/0212066v3.
PDF pages are used throughout. Only standalone results with complete experiment
semantics are stated here. Operational extraction results are individually deferred
in HARD.md and GAPS.json; no numerical rate certificate replaces their conclusions.
Compilation is pending the batch handoff.
-/

noncomputable section

open scoped Matrix ComplexConjugate BigOperators

namespace QAlgorithms.Papers.Independent.Intake100.P99

attribute [local instance] Classical.propDecidable Classical.decEq

open QAlgorithms
open QAlgorithms.Papers.Independent.Information100.P69 (diamond)
open QAlgorithms.Papers.Independent.Dependency50.P48 (IsDilation receiver)

/-- PDF pp.5,9,11: a failure probability is exponentially small in the family
index. For the standalone coin results that index is the number of coins, n.
Constants may depend on the state family and the fixed positive accuracy slack. -/
def ExponentiallySmall (p : ℕ → ℝ) : Prop :=
  ∃ C : ℝ, 0 < C ∧ ∃ n0 : ℕ, ∀ n : ℕ, n0 ≤ n →
    p n ≤ Real.exp (-C * (n : ℝ))

/-- PDF p.11, (20): the nonnegative entropy-gap branch. On [0,1/2] the
set is nonempty, compact and a singleton, by continuity and strict monotonicity
of binary entropy on [0,1/2]. Outside that source domain the explicit default
is zero and no result below uses that default. -/
def entropyGap (delta : ℝ) : ℝ :=
  if 0 ≤ delta ∧ delta ≤ 1 / 2 then
    sInf {f : ℝ | 0 ≤ f ∧ f ≤ 1 / 2 ∧
      binEntropy2 (1 / 2 - f) + binEntropy2 delta = 1}
  else 0

/-- PDF pp.10--11: probability of an event in a computational-basis measurement
of a density matrix. Every use in the theorems carries trace-one positivity. -/
def densityEvent {A : Type*} [Fintype A] (rho : Matrix A A ℂ) (P : A → Prop) : ℝ :=
  ∑ x, if P x then densityProb rho x else 0

/-- PDF pp.9--11: probability of the complement of the strict event NX < n delta.
Hadamard conjugation converts X measurement into the fixed computational basis. -/
def coinXFailure {n : ℕ} (rho : Matrix (Qubits n) (Qubits n) ℂ) (delta : ℝ) : ℝ :=
  densityEvent (hadamardN n * rho * (hadamardN n).conjTranspose)
    (fun x => (n : ℝ) * delta ≤ (hammingWeight x : ℝ))

/-- PDF p.11, (19): probability of the complement of
|n/2 - NZ| < n(f(delta)+epsilon), in the Z measurement of the same state. -/
def coinZFailure {n : ℕ} (rho : Matrix (Qubits n) (Qubits n) ℂ)
    (delta epsilon : ℝ) : ℝ :=
  densityEvent rho (fun z => (n : ℝ) * (entropyGap delta + epsilon) ≤
    |(n : ℝ) / 2 - (hammingWeight z : ℝ)|)

/-- PDF pp.9--11: Alice's n qubits first, Bob's n qubits second. -/
abbrev PairBits (n : ℕ) := Qubits n × Qubits n

/-- PDF pp.9--11: pair registers followed by their n virtual basis coins. -/
abbrev PairCoinBits (n : ℕ) := PairBits n × Qubits n

/-- PDF p.10, (10)--(11): columns are product Bell states labelled by their
bit-error string b and phase-error string p. The amplitude at (u,v) is zero
unless v=u xor b, and otherwise is 2^(-n/2) (-1)^(u dot p). -/
def bellChange (n : ℕ) : Matrix (PairBits n) (PairBits n) ℂ :=
  fun uv bp => ∏ i : Fin n,
    if uv.2 i = Bool.xor (uv.1 i) (bp.1 i) then
      if (uv.1 i && bp.2 i) then -((Real.sqrt 2)⁻¹ : ℂ)
      else ((Real.sqrt 2)⁻¹ : ℂ)
    else 0

/-- PDF p.9, (9): the actual final bilateral Hadamards controlled by the
matching coins. These act AFTER the state whose X-coin disturbance is bounded. -/
def controlledBilateralHadamard (n : ℕ) :
    Matrix (PairCoinBits n) (PairCoinBits n) ℂ :=
  fun x y => if x.2 = y.2 then
    ∏ i : Fin n,
      (if x.2 i then hadamard (x.1.1 i) (y.1.1 i)
        else if x.1.1 i = y.1.1 i then 1 else 0) *
      (if x.2 i then hadamard (x.1.2 i) (y.1.2 i)
        else if x.1.2 i = y.1.2 i then 1 else 0)
    else 0

/-- PDF pp.10--11, (13),(24): full Bell-measurement tail after the final
coin-controlled bilateral Hadamards. The counts are joint random variables,
not expectations. The coins are also measured in Z and their result discarded. -/
def phaseBitGapFailure {n : ℕ}
    (rho : Matrix (PairCoinBits n) (PairCoinBits n) ℂ) (delta epsilon : ℝ) : ℝ :=
  let B := Matrix.kronecker (bellChange n) (1 : Matrix (Qubits n) (Qubits n) ℂ)
  let H := controlledBilateralHadamard n
  densityEvent (B.conjTranspose * H * rho * H.conjTranspose * B)
    (fun z => 2 * (entropyGap delta + epsilon) ≤
      |(hammingWeight z.1.2 : ℝ) / (n : ℝ) -
        (hammingWeight z.1.1 : ℝ) / (n : ℝ)|)

/-- PDF p.12, (32): number of X-minus coins whose corresponding signals survive
an actual removal mask. A true mask bit denotes a lost signal. -/
def retainedMinusCount {n : ℕ} (mask x : Qubits n) : ℕ :=
  (Finset.univ.filter fun i => mask i = false ∧ x i = true).card

/-- PDF p.12, (32): the disturbed fraction of the retained coins, computed from
the same measurement outcome and mask. The denominator is positive on supported
masks for positive n and loss < 1; its n=0 default is never used asymptotically. -/
def retainedMinusFraction {n : ℕ} (mask x : Qubits n) : ℝ :=
  (retainedMinusCount mask x : ℝ) / ((n : ℝ) - (hammingWeight mask : ℝ))

/-- PDF p.12, (32): the removal mask deletes at most the specified fraction of
signals. The first register contains all original virtual coins, the second the
classical loss flags. Zero marginal weight excludes every excessive mask; the
joint state may otherwise correlate the mask with the coins arbitrarily. -/
def LossBudget {n : ℕ}
    (rho : Matrix (Qubits n × Qubits n) (Qubits n × Qubits n) ℂ) (loss : ℝ) : Prop :=
  ∀ mask : Qubits n, loss * (n : ℝ) < (hammingWeight mask : ℝ) →
    densityProb (traceLeft rho) mask = 0

/-- PDF p.12, (32): tail of the surviving disturbed fraction, measured jointly
with the loss flags. The event uses delta/(1-loss), not a free new disturbance
parameter. No conditioning on a rare block-acceptance event is introduced. -/
def retainedLossFailure {n : ℕ}
    (rho : Matrix (Qubits n × Qubits n) (Qubits n × Qubits n) ℂ)
    (delta loss : ℝ) : ℝ :=
  let B := Matrix.kronecker (hadamardN n) (1 : Matrix (Qubits n) (Qubits n) ℂ)
  densityEvent (B * rho * B.conjTranspose)
    (fun z => delta / (1 - loss) ≤ retainedMinusFraction z.2 z.1)

/-! Small sanity checks; these are definition checks, not proofs of the targets. -/

example : ExponentiallySmall (fun _ => 0) := by
  exact ⟨1, by norm_num, 0, fun n _ => (Real.exp_pos _).le⟩

example : binEntropy2 0 = 0 := by
  simp [binEntropy2]

example (delta : ℝ) (h : ¬ (0 ≤ delta ∧ delta ≤ 1 / 2)) : entropyGap delta = 0 := by
  unfold entropyGap
  rw [if_neg h]

example : entropyGap 0 = 0 := by
  have hhalf : binEntropy2 (1 / 2) = 1 := by
    rw [binEntropy2, show (1 / 2 : ℝ) = 2⁻¹ by norm_num, Real.binEntropy_two_inv]
    exact div_self (Real.log_pos (by norm_num : (1 : ℝ) < 2)).ne'
  have hz : (0 : ℝ) ∈ {f : ℝ | 0 ≤ f ∧ f ≤ 1 / 2 ∧
      binEntropy2 (1 / 2 - f) + binEntropy2 0 = 1} := by
    refine ⟨le_rfl, by norm_num, ?_⟩
    simpa only [sub_zero, show binEntropy2 0 = 0 by simp [binEntropy2], add_zero]
      using hhalf
  unfold entropyGap
  rw [if_pos (by norm_num : 0 ≤ (0 : ℝ) ∧ (0 : ℝ) ≤ 1 / 2)]
  apply le_antisymm
  · exact csInf_le ⟨0, fun f hf => hf.1⟩ hz
  · exact le_csInf ⟨0, hz⟩ (fun f hf => hf.1)

example {A : Type*} [Fintype A] (rho : Matrix A A ℂ) :
    densityEvent rho (fun _ => False) = 0 := by
  simp [densityEvent]

example : bellChange 0 = (1 : Matrix (PairBits 0) (PairBits 0) ℂ) := by
  ext x y
  have h : x = y := Subsingleton.elim _ _
  subst y
  simp [bellChange]

example : bellChange 1 (fun _ => false, fun _ => false)
    (fun _ => false, fun _ => true) = ((Real.sqrt 2)⁻¹ : ℂ) := by
  simp [bellChange]

example {n : ℕ} (x : Qubits n) :
    retainedMinusCount (fun _ => true) x = 0 := by
  simp [retainedMinusCount]

example : controlledBilateralHadamard 0 =
    (1 : Matrix (PairCoinBits 0) (PairCoinBits 0) ℂ) := by
  ext x y
  have h : x = y := Subsingleton.elim _ _
  subst y
  simp [controlledBilateralHadamard]

example : bellChange 1 (fun _ => true, fun _ => true)
    (fun _ => false, fun _ => true) = -((Real.sqrt 2)⁻¹ : ℂ) := by
  simp [bellChange]

-- The frozen predicate records isometry; its frozen receiver records the channel.
example : IsDilation (1 : Matrix (Fin 1 × Fin 1) (Fin 1 × Fin 1) ℂ) := by
  simp [IsDilation]

example (X : Matrix (Fin 1 × Fin 1) (Fin 1 × Fin 1) ℂ) :
    receiver (1 : Matrix (Fin 1 × Fin 1) (Fin 1 × Fin 1) ℂ) X = traceRight X := by
  simp [receiver]

end QAlgorithms.Papers.Independent.Intake100.P99
Source
Security of quantum key distribution with imperfect devices, arXiv:quant-ph/0212066v3, https://arxiv.org/abs/quant-ph/0212066v3
Read-back

What the Lean code literally says, in plain math · gpt-6.1-sol

QAlgorithms.Papers.Independent.Intake100.P99.ExponentiallySmall

For any function p:N→Rp:\mathbb N\to\mathbb Rp:N→R, this property means that there exist a real constant C>0C>0C>0 and a natural number n0n_0n0​ such that, for every natural number n≥n0n\ge n_0n≥n0​, p(n)≤e−Cnp(n)\le e^{-Cn}p(n)≤e−Cn. No nonnegativity or absolute-value bound on p(n)p(n)p(n) is required, and no restriction is imposed for n<n0n<n_0n<n0​; the threshold n0n_0n0​ may be zero.

QAlgorithms.Papers.Independent.Intake100.P99.LossBudget

For a natural number nnn, write Qn={0,1}nQ_n=\{0,1\}^nQn​={0,1}n and let ∣m∣|m|∣m∣ denote the number of true bits in m∈Qnm\in Q_nm∈Qn​. For any complex matrix ρ\rhoρ indexed by Qn×QnQ_n\times Q_nQn​×Qn​ and any real number ℓ\ellℓ, this predicate means

∀m∈Qn,ℓn<∣m∣ ⟹ Re⁡ ⁣(∑x∈Qnρ(x,m),(x,m))=0.\forall m\in Q_n,\qquad \ell n<|m|\ \Longrightarrow\ \operatorname{Re}\!\left(\sum_{x\in Q_n}\rho_{(x,m),(x,m)}\right)=0.∀m∈Qn​,ℓn<∣m∣ ⟹ Re​x∈Qn​∑​ρ(x,m),(x,m)​​=0.

Thus it restricts the real diagonal entries of the marginal obtained by tracing out the first register, using a strict inequality for the weight threshold. The definition imposes no positivity or trace condition on ρ\rhoρ and no range restriction on ℓ\ellℓ. For n=0n=0n=0, or for ℓ≥1\ell\ge1ℓ≥1, its implication is vacuous. If n>0n>0n>0 and ℓ<0\ell<0ℓ<0, it requires every real diagonal entry of that marginal to vanish, which cannot hold when ρ\rhoρ is positive semidefinite with trace one.

QAlgorithms.Papers.Independent.Intake100.P99.PairBits

For every natural number nnn, this is the type of ordered pairs (u,v)(u,v)(u,v) of functions {0,…,n−1}→{false,true}\{0,\ldots,n-1\}\to\{\mathrm{false},\mathrm{true}\}{0,…,n−1}→{false,true}, equivalently ordered pairs of length-nnn bit strings. For n=0n=0n=0, both strings are empty and this type has exactly one element.

QAlgorithms.Papers.Independent.Intake100.P99.PairCoinBits

For every natural number nnn, this is the type of elements ((u,v),c)((u,v),c)((u,v),c), where u,v,cu,v,cu,v,c are each functions {0,…,n−1}→{false,true}\{0,\ldots,n-1\}\to\{\mathrm{false},\mathrm{true}\}{0,…,n−1}→{false,true}, equivalently three length-nnn bit strings with the first two grouped as an ordered pair. For n=0n=0n=0, this type has exactly one element.

QAlgorithms.Papers.Independent.Intake100.P99.bellChange

For every natural number nnn, this definition gives a complex matrix indexed by ordered pairs of length-nnn bit strings. Its entry in row (u,v)(u,v)(u,v) and column (b,p)(b,p)(b,p) is

∏i=0n−1{−12,vi=ui⊕bi, ui=true, pi=true,12,vi=ui⊕bi and ui,pi are not both true,0,vi≠ui⊕bi,\prod_{i=0}^{n-1} \begin{cases} -\dfrac1{\sqrt2},&v_i=u_i\mathbin{\oplus}b_i,\ u_i=\mathrm{true},\ p_i=\mathrm{true},\\ \dfrac1{\sqrt2},&v_i=u_i\mathbin{\oplus}b_i \text{ and }u_i,p_i\text{ are not both true},\\ 0,&v_i\ne u_i\mathbin{\oplus}b_i, \end{cases}i=0∏n−1​⎩⎨⎧​−2​1​,2​1​,0,​vi​=ui​⊕bi​, ui​=true, pi​=true,vi​=ui​⊕bi​ and ui​,pi​ are not both true,vi​=ui​⊕bi​,​

where ⊕\oplus⊕ is Boolean exclusive-or and the displayed real numbers are regarded as complex numbers. When n=0n=0n=0, the empty product is one, so the matrix is [1][1][1].

QAlgorithms.Papers.Independent.Intake100.P99.coinXFailure

For any natural number nnn, any complex matrix ρ\rhoρ indexed by the bit strings {0,1}n\{0,1\}^n{0,1}n, and any real δ\deltaδ, let ∣x∣|x|∣x∣ denote the number of true bits of xxx, and define the matrix HnH_nHn​ by

(Hn)y,x=2−n/2(−1)∑i=0n−1xiyi,(H_n)_{y,x}=2^{-n/2}(-1)^{\sum_{i=0}^{n-1}x_i y_i},(Hn​)y,x​=2−n/2(−1)∑i=0n−1​xi​yi​,

where bits are interpreted as 000 or 111. This definition gives

∑x∈{0,1}nnδ≤∣x∣Re⁡((HnρHn†)x,x).\sum_{\substack{x\in\{0,1\}^n\\n\delta\le |x|}} \operatorname{Re}\bigl((H_n\rho H_n^\dagger)_{x,x}\bigr).x∈{0,1}nnδ≤∣x∣​∑​Re((Hn​ρHn†​)x,x​).

No density-matrix condition on ρ\rhoρ or restriction on δ\deltaδ is imposed. When n=0n=0n=0, there is one empty bit string, H0=[1]H_0=[1]H0​=[1], and the condition holds, so the value is the real part of the sole entry of ρ\rhoρ.

QAlgorithms.Papers.Independent.Intake100.P99.coinZFailure

For any natural number nnn, any complex matrix ρ\rhoρ indexed by {0,1}n\{0,1\}^n{0,1}n, and any real numbers δ,ϵ\delta,\epsilonδ,ϵ, write ∣z∣|z|∣z∣ for the number of true bits of zzz. Define h(p)=(−pln⁡p−(1−p)ln⁡(1−p))/ln⁡2h(p)=\bigl(-p\ln p-(1-p)\ln(1-p)\bigr)/\ln2h(p)=(−plnp−(1−p)ln(1−p))/ln2 on [0,1][0,1][0,1], with 0ln⁡0=00\ln0=00ln0=0, and let g(δ)g(\delta)g(δ) be the real infimum of {f∈[0,12]:h(12−f)+h(δ)=1}\{f\in[0,\tfrac12]:h(\tfrac12-f)+h(\delta)=1\}{f∈[0,21​]:h(21​−f)+h(δ)=1} when δ∈[0,12]\delta\in[0,\tfrac12]δ∈[0,21​], and zero otherwise, using zero for an empty real infimum. This definition gives

∑z∈{0,1}nn(g(δ)+ϵ)≤∣n/2−∣z∣∣Re⁡(ρz,z).\sum_{\substack{z\in\{0,1\}^n\\ n(g(\delta)+\epsilon)\le |n/2-|z||}} \operatorname{Re}(\rho_{z,z}).z∈{0,1}nn(g(δ)+ϵ)≤∣n/2−∣z∣∣​∑​Re(ρz,z​).

There is no density-matrix assumption or restriction on δ,ϵ\delta,\epsilonδ,ϵ. For n=0n=0n=0, the condition holds for the unique empty bit string, so the value is the real part of the sole entry of ρ\rhoρ.

QAlgorithms.Papers.Independent.Intake100.P99.controlledBilateralHadamard

For every natural number nnn, this definition gives a complex matrix indexed by triples ((u,v),c)((u,v),c)((u,v),c) of length-nnn bit strings. Put h(a,b)=−1/2h(a,b)=-1/\sqrt2h(a,b)=−1/2​ if the bits a,ba,ba,b are both true, and h(a,b)=1/2h(a,b)=1/\sqrt2h(a,b)=1/2​ otherwise, and let 1a=b\mathbf1_{a=b}1a=b​ be one when a=ba=ba=b and zero otherwise. The row-((u,v),c)((u,v),c)((u,v),c), column-((u′,v′),c′)((u',v'),c')((u′,v′),c′) entry is zero if c≠c′c\ne c'c=c′, and otherwise is

∏i=0n−1({h(ui,ui′),ci=true,1ui=ui′,ci=false)({h(vi,vi′),ci=true,1vi=vi′,ci=false).\prod_{i=0}^{n-1} \left(\begin{cases}h(u_i,u'_i),&c_i=\mathrm{true},\\ \mathbf1_{u_i=u'_i},&c_i=\mathrm{false}\end{cases}\right) \left(\begin{cases}h(v_i,v'_i),&c_i=\mathrm{true},\\ \mathbf1_{v_i=v'_i},&c_i=\mathrm{false}\end{cases}\right).i=0∏n−1​({h(ui​,ui′​),1ui​=ui′​​,​ci​=true,ci​=false​)({h(vi​,vi′​),1vi​=vi′​​,​ci​=true,ci​=false​).

For n=0n=0n=0, this is the one-entry matrix [1][1][1].

QAlgorithms.Papers.Independent.Intake100.P99.densityEvent

For any finite type AAA, any complex matrix ρ\rhoρ indexed by A×AA\times AA×A, and any predicate PPP on AAA, this definition gives the real number

∑x∈AP(x)Re⁡(ρx,x).\sum_{\substack{x\in A\\P(x)}}\operatorname{Re}(\rho_{x,x}).x∈AP(x)​∑​Re(ρx,x​).

There is no assumption that ρ\rhoρ is positive semidefinite or has trace one. If AAA is empty, or no element satisfies PPP, the sum is zero.

QAlgorithms.Papers.Independent.Intake100.P99.entropyGap

For every real δ\deltaδ, define h(p)=(−pln⁡p−(1−p)ln⁡(1−p))/ln⁡2h(p)=\bigl(-p\ln p-(1-p)\ln(1-p)\bigr)/\ln 2h(p)=(−plnp−(1−p)ln(1−p))/ln2 on [0,1][0,1][0,1], with 0ln⁡0=00\ln0=00ln0=0. The value of this definition is

{inf⁡{f∈R:0≤f≤12, h(12−f)+h(δ)=1},0≤δ≤12,0,otherwise.\begin{cases} \displaystyle\inf\{f\in\mathbb R:0\le f\le\tfrac12,\ h(\tfrac12-f)+h(\delta)=1\}, &0\le\delta\le\tfrac12,\\ 0,&\text{otherwise}. \end{cases}{inf{f∈R:0≤f≤21​, h(21​−f)+h(δ)=1},0,​0≤δ≤21​,otherwise.​

Here the infimum is taken in R\mathbb RR, whose empty-set infimum convention is zero.

QAlgorithms.Papers.Independent.Intake100.P99.phaseBitGapFailure

For any natural number nnn, any complex matrix ρ\rhoρ indexed by triples ((u,v),c)((u,v),c)((u,v),c) of length-nnn bit strings, and any real δ,ϵ\delta,\epsilonδ,ϵ, define h(p)=(−pln⁡p−(1−p)ln⁡(1−p))/ln⁡2h(p)=\bigl(-p\ln p-(1-p)\ln(1-p)\bigr)/\ln2h(p)=(−plnp−(1−p)ln(1−p))/ln2 on [0,1][0,1][0,1], with 0ln⁡0=00\ln0=00ln0=0, and define g(δ)=inf⁡{f∈[0,12]:h(12−f)+h(δ)=1}g(\delta)=\inf\{f\in[0,\tfrac12]:h(\tfrac12-f)+h(\delta)=1\}g(δ)=inf{f∈[0,21​]:h(21​−f)+h(δ)=1} for δ∈[0,12]\delta\in[0,\tfrac12]δ∈[0,21​], and g(δ)=0g(\delta)=0g(δ)=0 otherwise, with empty real infimum zero. For bits a,ba,ba,b, put ha,b=(−1)ab/2h_{a,b}=(-1)^{ab}/\sqrt2ha,b​=(−1)ab/2​, interpreting bits numerically. Define matrices B,HB,HB,H by

B((u,v),c),((b,p),d)=1c=d∏i=0n−11vi=ui⊕bi hui,pi,H((u,v),c),((u′,v′),d)=1c=d∏i=0n−1{hui,ui′hvi,vi′,ci=true,1ui=ui′1vi=vi′,ci=false.B_{((u,v),c),((b,p),d)} =\mathbf1_{c=d}\prod_{i=0}^{n-1} \mathbf1_{v_i=u_i\oplus b_i}\,h_{u_i,p_i}, \qquad H_{((u,v),c),((u',v'),d)} =\mathbf1_{c=d}\prod_{i=0}^{n-1} \begin{cases} h_{u_i,u'_i}h_{v_i,v'_i},&c_i=\mathrm{true},\\ \mathbf1_{u_i=u'_i}\mathbf1_{v_i=v'_i},&c_i=\mathrm{false}. \end{cases}B((u,v),c),((b,p),d)​=1c=d​i=0∏n−1​1vi​=ui​⊕bi​​hui​,pi​​,H((u,v),c),((u′,v′),d)​=1c=d​i=0∏n−1​{hui​,ui′​​hvi​,vi′​​,1ui​=ui′​​1vi​=vi′​​,​ci​=true,ci​=false.​

Here 1\mathbf11 denotes a zero-or-one indicator and ⊕\oplus⊕ is exclusive-or. The defined value is

∑((u,v),c)2(g(δ)+ϵ)≤∣∣v∣/n−∣u∣/n∣Re⁡((B†HρH†B)((u,v),c),((u,v),c)),\sum_{\substack{((u,v),c)\\ 2(g(\delta)+\epsilon)\le \left||v|/n-|u|/n\right|}} \operatorname{Re}\bigl((B^\dagger H\rho H^\dagger B)_{((u,v),c),((u,v),c)}\bigr),((u,v),c)2(g(δ)+ϵ)≤∣∣v∣/n−∣u∣/n∣​∑​Re((B†HρH†B)((u,v),c),((u,v),c)​),

where ∣u∣,∣v∣|u|,|v|∣u∣,∣v∣ count true bits. No density-matrix or parameter-range assumptions are imposed. Division is real division with division by zero equal to zero; thus for n=0n=0n=0 the value is the real part of the sole entry of ρ\rhoρ if 2(g(δ)+ϵ)≤02(g(\delta)+\epsilon)\le02(g(δ)+ϵ)≤0, and zero otherwise.

QAlgorithms.Papers.Independent.Intake100.P99.retainedLossFailure

For any natural number nnn, let Qn={0,1}nQ_n=\{0,1\}^nQn​={0,1}n, let ∣m∣|m|∣m∣ count the true bits of mmm, and define the matrix HnH_nHn​, indexed by QnQ_nQn​, by

(Hn)y,x=2−n/2(−1)∑i=0n−1xiyi.(H_n)_{y,x}=2^{-n/2}(-1)^{\sum_{i=0}^{n-1}x_i y_i}.(Hn​)y,x​=2−n/2(−1)∑i=0n−1​xi​yi​.

For any complex matrix ρ\rhoρ indexed by Qn×QnQ_n\times Q_nQn​×Qn​ and any real numbers δ,ℓ\delta,\ellδ,ℓ, this definition returns the real number

∑x,m∈Qnδ/(1−ℓ)≤#{i:mi=0, xi=1}/(n−∣m∣)Re⁡ ⁣[(Hn⊗I)ρ(Hn⊗I)†](x,m),(x,m).\sum_{\substack{x,m\in Q_n\\ \displaystyle \delta/(1-\ell)\le \#\{i:m_i=0,\ x_i=1\}/(n-|m|)}} \operatorname{Re}\!\left[ (H_n\otimes I)\rho(H_n\otimes I)^\dagger \right]_{(x,m),(x,m)}.x,m∈Qn​δ/(1−ℓ)≤#{i:mi​=0, xi​=1}/(n−∣m∣)​∑​Re[(Hn​⊗I)ρ(Hn​⊗I)†](x,m),(x,m)​.

Both divisions are real divisions, with division by zero equal to zero. In particular, the retained fraction is zero for an all-true mask, including the unique mask when n=0n=0n=0. The threshold comparison includes equality. When ℓ=1\ell=1ℓ=1, the threshold is zero and every pair satisfies the comparison. The definition accepts arbitrary ρ,δ,ℓ\rho,\delta,\ellρ,δ,ℓ; without a density-matrix assumption, the displayed sum need not be a probability.

QAlgorithms.Papers.Independent.Intake100.P99.retainedMinusCount

For any natural number nnn and any length-nnn bit strings mask\mathrm{mask}mask and xxx, this definition gives the natural number

#{i∈{0,…,n−1}:maski=false and xi=true}.\#\{i\in\{0,\ldots,n-1\}:\mathrm{mask}_i=\mathrm{false} \ \text{and}\ x_i=\mathrm{true}\}.#{i∈{0,…,n−1}:maski​=false and xi​=true}.

It is zero when n=0n=0n=0, when every mask bit is true, or whenever no position satisfies both conditions.

QAlgorithms.Papers.Independent.Intake100.P99.retainedMinusFraction

For any natural number nnn and any length-nnn bit strings mask\mathrm{mask}mask and xxx, this definition gives the real number

#{i:maski=false and xi=true}n−#{i:maski=true}.\frac{\#\{i:\mathrm{mask}_i=\mathrm{false}\ \text{and}\ x_i=\mathrm{true}\}} {n-\#\{i:\mathrm{mask}_i=\mathrm{true}\}}.n−#{i:maski​=true}#{i:maski​=false and xi​=true}​.

The subtraction in the denominator is real subtraction, and the denominator equals the number of false mask bits. Real division by zero is defined to be zero, so the value is zero when every mask bit is true, including when n=0n=0n=0.

Human review
  • Endorsed by Shuze Chen · Oct 31, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 31, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me