Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Definitions for Composable security proof for continuous-variable quantum key distribution with coherent states

Definition
QAlgorithms_Papers_Independent_Intake100_P61

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

prove2quantum

The objects the formalized statements of Composable security proof for continuous-variable quantum key distribution with coherent states (arXiv:1408.5689) are stated in. Each was checked against the paper by a blind read-back and a moderator.

  • vectorSquare: PDF pp.20–22: Euclidean squared norm of unbundled coordinates.
  • realDot: PDF pp.21–22: real Euclidean inner product.
  • firstCoordinates: PDF pp.20–22: first k coordinates, padded with zeros in the original space.
  • halfProjection: PDF pp.20–21: actual projection U* P_k U v. A normalized invariant Borel probability on U(m) or O(m) is Haar; the range U* span(e_0,...,e_(k-1)) is uniform.
  • pairDensityLaw: PDF p.22: actual density Q(X,Y) against 8n-dimensional Lebesgue measure.
  • transposeRotation: PDF p.22: literal symmetry (X,Y) -> (O X,O^T Y). No identification with the passive optical U(2n) action is made.
  • nonnegativeVolume: PDF pp.22–23: nonnegative half-line Lebesgue reference measure.
  • quadrantLaw: PDF pp.22–23: one joint law constructed from p on the nonnegative quadrant.
  • firstMarginalDensity: PDF pp.22–23: marginal density from that same p.
  • densityConditionalMean: PDF pp.22–23, E21/E28: extended conditional mean from p(y|x)=p(x,y)/p_X(x). This differs from Advance50.P02.conditionalMean, which is a finite cq entropy. Zero or infinite marginal-density fibers are null for a probability law and are assigned zero. Infinite means on positive finite fibers remain infinity.
  • empiricalEntropy: PDF pp.17–18, D26: plug-in one-symbol entropy in bits.
  • iidWordProbability: PDF pp.17–18: iid event probability with actual product weights from p.
Definition code
import Mathlib
import Definitions.Def_QAlgorithms_Papers_Independent_Advance50_P30

/-! Leverrier, arXiv:1408.5689v3. Classical components with explicit laws.
Source corrections and deferred quantum interfaces are recorded in the unit.
Compilation is pending the separate mechanical handoff. -/

noncomputable section

open MeasureTheory Filter
open scoped BigOperators ENNReal Topology

namespace QAlgorithms.Papers.Independent.Intake100.P61

attribute [local instance] Classical.propDecidable Classical.decEq

-- The frozen frequency formula specializes exactly to the source alphabet Fin (2 ^ d).
open QAlgorithms.Papers.Independent.Advance50.P30 (empiricalFrequency)

/-- PDF pp.20–21: Borel outcomes on U(m) over C or O(m) over R. -/
instance rotationMeasurable (K : Type) [RCLike K] (m : ℕ) :
    MeasurableSpace (Matrix.unitaryGroup (Fin m) K) := borel _

/-- PDF pp.20–21: the preceding sigma algebra is precisely Borel. -/
instance rotationBorel (K : Type) [RCLike K] (m : ℕ) :
    BorelSpace (Matrix.unitaryGroup (Fin m) K) := ⟨rfl⟩

/-- PDF pp.20–22: Euclidean squared norm of unbundled coordinates. -/
def vectorSquare {K : Type} [RCLike K] {m : ℕ} (v : Fin m → K) : ℝ :=
  ∑ i, ‖v i‖ ^ 2

/-- PDF pp.21–22: real Euclidean inner product. -/
def realDot {m : ℕ} (v w : Fin m → ℝ) : ℝ := ∑ i, v i * w i

/-- PDF pp.20–22: first k coordinates, padded with zeros in the original space. -/
def firstCoordinates {K : Type} [Zero K] {m : ℕ} (k : ℕ) (v : Fin m → K) : Fin m → K :=
  fun i => if i.val < k then v i else 0

/-- PDF pp.20–21: actual projection U* P_k U v. A normalized invariant Borel
probability on U(m) or O(m) is Haar; the range U* span(e_0,...,e_(k-1)) is uniform. -/
def halfProjection {K : Type} [RCLike K] {m : ℕ}
    (U : Matrix.unitaryGroup (Fin m) K) (k : ℕ) (v : Fin m → K) : Fin m → K :=
  (star (U : Matrix (Fin m) (Fin m) K)).mulVec
    (firstCoordinates k ((U : Matrix (Fin m) (Fin m) K).mulVec v))

example {K : Type} [RCLike K] {m : ℕ} : vectorSquare (0 : Fin m → K) = 0 := by
  simp [vectorSquare]

example {m : ℕ} (v : Fin m → ℝ) : realDot v 0 = 0 := by
  simp [realDot]

example {K : Type} [Zero K] {m : ℕ} (v : Fin m → K) : firstCoordinates 0 v = 0 := by
  funext i
  simp [firstCoordinates]

example {K : Type} [RCLike K] {m : ℕ}
    (U : Matrix.unitaryGroup (Fin m) K) (k : ℕ) : halfProjection U k 0 = 0 := by
  have hzero : firstCoordinates k (0 : Fin m → K) = 0 := by
    funext i
    simp [firstCoordinates]
  simp only [halfProjection, Matrix.mulVec_zero, hzero]

/-- PDF p.22: actual density Q(X,Y) against 8n-dimensional Lebesgue measure. -/
def pairDensityLaw (n : ℕ)
    (q : ((Fin (4 * n) → ℝ) × (Fin (4 * n) → ℝ)) → ℝ≥0∞) :
    Measure ((Fin (4 * n) → ℝ) × (Fin (4 * n) → ℝ)) := volume.withDensity q

/-- PDF p.22: literal symmetry (X,Y) -> (O X,O^T Y).
No identification with the passive optical U(2n) action is made. -/
def transposeRotation {m : ℕ} (O : Matrix.unitaryGroup (Fin m) ℝ)
    (v : (Fin m → ℝ) × (Fin m → ℝ)) : (Fin m → ℝ) × (Fin m → ℝ) :=
  ((O : Matrix (Fin m) (Fin m) ℝ).mulVec v.1,
    (O : Matrix (Fin m) (Fin m) ℝ).transpose.mulVec v.2)

example (n : ℕ) : pairDensityLaw n (fun _ => 0) = 0 := by
  simp [pairDensityLaw]

example {m : ℕ} (O : Matrix.unitaryGroup (Fin m) ℝ) :
    transposeRotation O (0, 0) = (0, 0) := by
  simp [transposeRotation, Matrix.mulVec]

/-- PDF pp.22–23: nonnegative half-line Lebesgue reference measure. -/
def nonnegativeVolume : Measure ℝ := volume.restrict (Set.Ici 0)

/-- PDF pp.22–23: one joint law constructed from p on the nonnegative quadrant. -/
def quadrantLaw (p : ℝ × ℝ → ℝ≥0∞) : Measure (ℝ × ℝ) :=
  (nonnegativeVolume.prod nonnegativeVolume).withDensity p

/-- PDF pp.22–23: marginal density from that same p. -/
def firstMarginalDensity (p : ℝ × ℝ → ℝ≥0∞) (x : ℝ) : ℝ≥0∞ :=
  ∫⁻ y, p (x, y) ∂nonnegativeVolume

/-- PDF pp.22–23, E21/E28: extended conditional mean from p(y|x)=p(x,y)/p_X(x).
This differs from Advance50.P02.conditionalMean, which is a finite cq entropy.
Zero or infinite marginal-density fibers are null for a probability law and
are assigned zero. Infinite means on positive finite fibers remain infinity. -/
def densityConditionalMean (p : ℝ × ℝ → ℝ≥0∞) (x : ℝ) : ℝ≥0∞ :=
  let px := firstMarginalDensity p x
  if px = 0 ∨ px = ⊤ then 0
  else ∫⁻ y, ENNReal.ofReal y * (p (x, y) / px) ∂nonnegativeVolume

example : quadrantLaw (fun _ => 0) = 0 := by
  simp [quadrantLaw]

example (x : ℝ) : firstMarginalDensity (fun _ => 0) x = 0 := by
  simp [firstMarginalDensity]

example (x : ℝ) : densityConditionalMean (fun _ => 0) x = 0 := by
  simp [densityConditionalMean, firstMarginalDensity]

/-- PDF pp.17–18, D26: plug-in one-symbol entropy in bits. -/
def empiricalEntropy {d n : ℕ} (word : Fin n → Fin (2 ^ d)) : ℝ :=
  -∑ a, empiricalFrequency word a * Real.logb 2 (empiricalFrequency word a)

/-- PDF pp.17–18: iid event probability with actual product weights from p. -/
def iidWordProbability {d : ℕ} (p : Fin (2 ^ d) → ℝ) (n : ℕ)
    (event : (Fin n → Fin (2 ^ d)) → Prop) : ℝ :=
  ∑ word : Fin n → Fin (2 ^ d), if event word then ∏ i, p (word i) else 0

example {d n : ℕ} (a : Fin (2 ^ d)) :
    empiricalFrequency (fun _ : Fin n => a) a = (n : ℝ) / n := by
  simp [empiricalFrequency]

example {d : ℕ} (p : Fin (2 ^ d) → ℝ) (n : ℕ) :
    iidWordProbability p n (fun _ => False) = 0 := by
  simp [iidWordProbability]

example {d : ℕ} (word : Fin 0 → Fin (2 ^ d)) : empiricalEntropy word = 0 := by
  simp [empiricalEntropy, empiricalFrequency]

end QAlgorithms.Papers.Independent.Intake100.P61
Source
Composable security proof for continuous-variable quantum key distribution with coherent states, arXiv:1408.5689v3, https://arxiv.org/abs/1408.5689v3
Read-back

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

QAlgorithms.Papers.Independent.Intake100.P61.densityConditionalMean

For any function p:R2→[0,∞]p:\mathbb R^2\to[0,\infty]p:R2→[0,∞] and any x∈Rx\in\mathbb Rx∈R, put p1(x)=∫[0,∞)p(x,y) dyp_1(x)=\int_{[0,\infty)}p(x,y)\,dyp1​(x)=∫[0,∞)​p(x,y)dy. This defines the extended-real quantity

mp(x)={0,p1(x)=0 or p1(x)=∞,∫[0,∞)max⁡(y,0) p(x,y)p1(x) dy,0<p1(x)<∞.m_p(x)= \begin{cases} 0,&p_1(x)=0\text{ or }p_1(x)=\infty,\\[2mm] \displaystyle\int_{[0,\infty)}\max(y,0)\,\frac{p(x,y)}{p_1(x)}\,dy, &0<p_1(x)<\infty. \end{cases}mp​(x)=⎩⎨⎧​0,∫[0,∞)​max(y,0)p1​(x)p(x,y)​dy,​p1​(x)=0 or p1​(x)=∞,0<p1​(x)<∞.​

Here max⁡(y,0)\max(y,0)max(y,0) is regarded as a nonnegative extended real and equals yyy on the integration domain. The second branch can itself be infinite. No measurability or probability assumption is required, and the definition also applies when x<0x<0x<0.

QAlgorithms.Papers.Independent.Intake100.P61.empiricalEntropy

For arbitrary natural numbers d,nd,nd,n, including zero, and a word w:{0,…,n−1}→{0,…,2d−1}w:\{0,\ldots,n-1\}\to\{0,\ldots,2^d-1\}w:{0,…,n−1}→{0,…,2d−1}, define its empirical frequency at symbol aaa by

p^w(a)=∣{i<n:wi=a}∣n.\widehat p_w(a)=\frac{|\{i<n:w_i=a\}|}{n}.p​w​(a)=n∣{i<n:wi​=a}∣​.

This declaration defines the real number

H^(w)=−∑a=02d−1p^w(a)log⁡2p^w(a).\widehat H(w)=-\sum_{a=0}^{2^d-1}\widehat p_w(a)\log_2\widehat p_w(a).H(w)=−a=0∑2d−1​p​w​(a)log2​p​w​(a).

Real division and logarithms are totalized: division by zero and log⁡20\log_2 0log2​0 both give zero. Thus unobserved symbols contribute zero, and when n=0n=0n=0, every empirical frequency and the resulting entropy are zero. When d=0d=0d=0, the alphabet has one symbol.

QAlgorithms.Papers.Independent.Intake100.P61.firstCoordinates

For every type KKK with a specified zero element, every natural number mmm, every natural number kkk, and every vector v:{0,…,m−1}→Kv:\{0,\ldots,m-1\}\to Kv:{0,…,m−1}→K, define a vector PkvP_kvPk​v of the same length by

(Pkv)i={vi,i<k,0,i≥k.(P_kv)_i= \begin{cases} v_i,&i<k,\\ 0,&i\ge k. \end{cases}(Pk​v)i​={vi​,0,​i<k,i≥k.​

No condition k≤mk\le mk≤m is imposed: P0v=0P_0v=0P0​v=0, and Pkv=vP_kv=vPk​v=v whenever k≥mk\ge mk≥m. For m=0m=0m=0, the result is the unique vector on the empty index set.

QAlgorithms.Papers.Independent.Intake100.P61.firstMarginalDensity

For any function p:R2→[0,∞]p:\mathbb R^2\to[0,\infty]p:R2→[0,∞] and any real number xxx, this defines

p1(x)=∫[0,∞)p(x,y) dyp_1(x)=\int_{[0,\infty)}p(x,y)\,dyp1​(x)=∫[0,∞)​p(x,y)dy

as a nonnegative extended-real integral. The result may be zero or infinite. The definition applies to negative xxx as well, and imposes no measurability or normalization assumption on ppp.

QAlgorithms.Papers.Independent.Intake100.P61.halfProjection

For every field KKK equipped with a real-or-complex scalar structure, every natural number mmm, every unitary m×mm\times mm×m matrix UUU over KKK, every natural number kkk, and every vector v∈Kmv\in K^mv∈Km, define

halfProjection⁡(U,k,v)=U∗PkUv,\operatorname{halfProjection}(U,k,v)=U^*P_kUv,halfProjection(U,k,v)=U∗Pk​Uv,

where U∗U^*U∗ is the conjugate transpose and (Pkw)i=wi(P_kw)_i=w_i(Pk​w)i​=wi​ for i<ki<ki<k and 000 otherwise. The parameter kkk is unrestricted: the result is 000 for k=0k=0k=0 and vvv for k≥mk\ge mk≥m. This also includes m=0m=0m=0.

QAlgorithms.Papers.Independent.Intake100.P61.iidWordProbability

For any natural number ddd, any real-valued function ppp on the alphabet {0,…,2d−1}\{0,\ldots,2^d-1\}{0,…,2d−1}, any natural number nnn, and any predicate EEE on words of length nnn over that alphabet, this defines

∑w:{0,…,n−1}→{0,…,2d−1}E(w)∏i=0n−1p(wi).\sum_{\substack{w:\{0,\ldots,n-1\}\to\{0,\ldots,2^d-1\}\\E(w)}} \prod_{i=0}^{n-1}p(w_i).w:{0,…,n−1}→{0,…,2d−1}E(w)​∑​i=0∏n−1​p(wi​).

There is no requirement that the values of ppp be nonnegative or sum to one, so this real number need not be a probability. For n=0n=0n=0, there is one empty word and its product is 111, giving 111 if that word satisfies EEE and 000 otherwise; d=0d=0d=0 gives a one-symbol alphabet.

QAlgorithms.Papers.Independent.Intake100.P61.nonnegativeVolume

Define a measure on R\mathbb RR by restricting Lebesgue measure to the closed nonnegative half-line [0,∞)[0,\infty)[0,∞); thus a measurable set BBB has measure equal to the Lebesgue measure of B∩[0,∞)B\cap[0,\infty)B∩[0,∞).

QAlgorithms.Papers.Independent.Intake100.P61.pairDensityLaw

For every natural number nnn and every function q:R4n×R4n→[0,∞]q:\mathbb R^{4n}\times\mathbb R^{4n}\to[0,\infty]q:R4n×R4n→[0,∞], define the measure ν\nuν obtained by weighting Lebesgue measure by qqq:

ν(B)=∫Bq(v) dv\nu(B)=\int_B q(v)\,dvν(B)=∫B​q(v)dv

for measurable sets B⊆R4n×R4nB\subseteq\mathbb R^{4n}\times\mathbb R^{4n}B⊆R4n×R4n. No measurability, finiteness, or normalization assumption on qqq is included in this definition, and n=0n=0n=0 is allowed.

QAlgorithms.Papers.Independent.Intake100.P61.quadrantLaw

For any function p:R2→[0,∞]p:\mathbb R^2\to[0,\infty]p:R2→[0,∞], this defines the measure obtained by weighting the product of two copies of Lebesgue measure restricted to [0,∞)[0,\infty)[0,∞) by the density ppp. No measurability, normalization, or finiteness assumption is imposed on ppp; in particular, the resulting measure is not required to be a probability measure.

QAlgorithms.Papers.Independent.Intake100.P61.realDot

For every natural number mmm and every pair of real vectors v,w:{0,…,m−1}→Rv,w:\{0,\ldots,m-1\}\to\mathbb Rv,w:{0,…,m−1}→R, define

realDot⁡(v,w)=∑i=0m−1viwi.\operatorname{realDot}(v,w)=\sum_{i=0}^{m-1}v_iw_i.realDot(v,w)=i=0∑m−1​vi​wi​.

When m=0m=0m=0, this empty sum is 000.

QAlgorithms.Papers.Independent.Intake100.P61.rotationBorel

For every field KKK equipped with a real-or-complex scalar structure and every natural number mmm, the measurable structure on the group of unitary m×mm\times mm×m matrices over KKK is its Borel measurable structure. This includes m=0m=0m=0.

QAlgorithms.Papers.Independent.Intake100.P61.rotationMeasurable

For every field KKK equipped with a real-or-complex scalar structure, including its norm and conjugation, and every natural number mmm, the group of unitary m×mm\times mm×m matrices over KKK is equipped with the Borel measurable structure generated by its topology. This includes m=0m=0m=0.

QAlgorithms.Papers.Independent.Intake100.P61.transposeRotation

For every natural number mmm, every real orthogonal m×mm\times mm×m matrix OOO, and every pair (v,w)∈Rm×Rm(v,w)\in\mathbb R^m\times\mathbb R^m(v,w)∈Rm×Rm, define

transposeRotation⁡(O,(v,w))=(Ov,OTw).\operatorname{transposeRotation}(O,(v,w))=(Ov,O^{\mathsf T}w).transposeRotation(O,(v,w))=(Ov,OTw).

Thus the first component is multiplied by OOO and the second by its transpose. This includes m=0m=0m=0.

QAlgorithms.Papers.Independent.Intake100.P61.vectorSquare

For every field KKK equipped with a real-or-complex scalar structure, every natural number mmm, and every vector v:{0,…,m−1}→Kv:\{0,\ldots,m-1\}\to Kv:{0,…,m−1}→K, define the real number

vectorSquare⁡(v)=∑i=0m−1∥vi∥2.\operatorname{vectorSquare}(v)=\sum_{i=0}^{m-1}\|v_i\|^2.vectorSquare(v)=i=0∑m−1​∥vi​∥2.

When m=0m=0m=0, this empty sum is 000.

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

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 30, 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