Definitions for Secure Identification and QKD in the Bounded-Quantum-Storage Model
DefinitionQAlgorithms_Papers_Independent_Intakenext100_P14The objects the formalized statements of Secure Identification and QKD in the Bounded-Quantum-Storage Model (arXiv:0708.2557) are stated in. Each was checked against the paper by a blind read-back and a moderator.
pushMass: PDF p.6: push forward a possibly subnormalized classical law.guessingMass: PDF p.6: average guessing probability, the sum of maxima of JOINT masses. The finite, nonempty maximum has no empty/unbounded-supremum default.IsRetained: PDF p.6: retained event mass, with fractional conditional event probabilities allowed. The event is deleted without renormalizing.smoothGuess: PDF p.6: minimum retained guessing probability. For epsilon >= 0 and normalized p the feasible set is nonempty and compact, so its infimum is attained. For epsilon >= 1 zero retention is feasible and the value is zero (entropy +infinity).conditionMass: PDF p.6: conditioning an actual probability law on an event. The zero-event branch is zero and is used only in identities with zero weight; all entropy uses below have positive conditioning probability.blockMass: PDF p.5: the classical probability of a CQ block.cqPush: PDF p.5: relabel classical registers and take their marginal.markov: PDF pp.5-6: Markov reconstruction, keeping the actual classical joint law. Zero-mass fibers contribute zero, including for subnormalized event blocks.cqCondition: PDF p.5: event conditioning with an arbitrary original-state version at mass zero.andPassword: PDF p.3: prescribed private-input maps for the passive AND reduction.PassiveExecution: PDF p.3: an honest identification execution's local views, including its common publicly announced decision. This is an execution kernel, not a security assumption on an arbitrary replacement functionality.PassiveEqualitySecurity: PDF p.3: passive equality identification correctness and statistical privacy. Privacy compares unequal passwords for the other party at a fixed own input; accept/reject is retained in both views.packedRestriction: PDF p.10: pack a restriction in increasing coordinate order, then right-pad with zeros.xorTag: PDF p.10: xor of the two ell-bit tags.StrongUniversal: PDF p.7: strong universal-2, with an independent uniform seed.QIDParameters: PDF p.10: public Q-ID parameters. Code distance is a guaranteed minimum; seed alphabets are finite nonempty types supplied at use sites.qidTag: PDF p.10, steps 3-6: the exact tag computed from the packed restriction.bb84Probability: PDF pp.4,10: Born probability for measuring an encoded product state.honestAcceptance: PDF p.10, complete honest execution of steps 1-6. Uniform independent x,theta,f,g are averaged; xprime is drawn using the Born measurement law.ServerAttack: PDF p.10, Prop.3.4: arbitrary password-independent server strategy. Only the checkpoint quantum register is bounded. Classical Y, final E, and all computation are unrestricted; the post-revelation map chooses g adaptively.serverOutput: PDF pp.10-11: actual Q-ID output against this server, retaining the full classical history (theta,f,y,g,z). No map has the unknown password as an input.markovRight: PDF pp.5-6,8: Markov reconstruction with the transcript H in the quantum observer's side of the partition. The transcript is NOT discarded.IsGuessExtension: PDF p.8: a classical guess extension of the actual output, with independence of the password; every register and quantum block is preserved when the extra guess is discarded.GuessSecrecy: PDF p.8, Definitions 3.2/3.3: compare the conditioned actual state to its OWN Markov reconstruction, retaining the final announced decision.HasIndependentGuess: PDF p.8, Definition 3.2: the existential independent-guess witness is an extension of the actual protocol output, not a new assumed output law.qidUncertaintyExponent: PDF p.7: the corrected, PDF-verified uncertainty exponent. Only the source's security range 0 < lambda < 1/4 is used below.UserAttack: PDF pp.10-12: all operations before receiving g can be represented by a password-independent CQ ensemble of the transmitted register and retained R. The response instrument chooses an arbitrary tag or abort (none), after seeing g. A final channel may depend on the announced decision. There is no quantum-storage bound on R or E.measuredResidual: PDF p.10 step 2: unnormalized residual state on R after the honest server's actual measurement in the password code basis.UserHistory: PDF p.10: user attack transcript includes the final announced decision. The optional tag none is an abort and is always rejected.userOutput: PDF pp.10-12: complete original Q-ID execution against an arbitrary user. The honest server measures in c(w) before theta,f are revealed, and chooses g uniformly and independently. The user can process its state after receiving the announced decision. All attack operations are password independent.ServerSecurity: PDF p.8, Definition 3.3: the same independent guess supplies exact acceptance on equality, bounded acceptance on mismatch, and postdecision secrecy. The acceptance conditions use weighted events, so a zero-mass equality event adds no positivity assumption. Mismatch has mass at least 1/2 in Prop.3.5.affineTag: PDF p.15: the fixed binary coordinates of GF(2^N), followed by projection onto the first ell coordinates; the tag alphabet's additive group is GF(2^ell). Only its addition is used, so binary coordinate vectors give exactly that group.keyMass: PDF p.15: uniform independent key, with exactly field-degree N rather than the unrelated transmitted-qubit count.classicalTagLaw: PDF p.15: actual classical tag/key/side-information distribution.classicalIdealTagLaw: PDF p.15: ideal independent uniform tag, preserving the same key and Z law.quantumTagLaw: PDF p.15: the actual CQ tag/key/Z/E state. E depends only on X,Z, while the key is independent and uniform.quantumIdealTagLaw: PDF p.15: I/2^ell tensor rho_K tensor rho_ZE, with actual marginals.
import Mathlib
import Definitions.Def_QAlgorithms_Defs_Channel
import Definitions.Def_QAlgorithms_Defs_Measurement
import Definitions.Def_QAlgorithms_Defs_Gates
import Definitions.Def_QAlgorithms_Defs_QuantumOutputMetrics
import Definitions.Def_QAlgorithms_Papers_Independent_Dependency50_P47
import Definitions.Def_QAlgorithms_Papers_Independent_Gap48_P11
import Definitions.Def_QAlgorithms_Papers_Independent_Claimed50_P31
import Definitions.Def_QAlgorithms_Papers_Independent_Advance50_P05
/-!
Damgard, Fehr, Salvail and Schaffner, arXiv:0708.2557v3.
Accepted primitives supply finite classical laws, CQ blocks, BB84 vectors, and
rectangular instruments. Local definitions implement event-deletion smoothing,
CQ Markov reconstruction, and the six-step ideal-channel Q-ID execution.
All basis strings use false = computational, true = Hadamard.
-/
noncomputable section
namespace QAlgorithms.Papers.Independent.Intakenext100.P14
open scoped Matrix ComplexConjugate
open QAlgorithms.Papers.Independent.Dependency50.P47 (Law)
open QAlgorithms.Papers.Independent.Gap48.P11 (blockMatrix cqDistance)
open QAlgorithms.Papers.Independent.Claimed50.P31 (bb84Vector)
open QAlgorithms.Papers.Independent.Advance50.P05 (RectangularInstrument)
attribute [local instance] Classical.propDecidable
attribute [local instance] Classical.decEq
/-- PDF p.6: push forward a possibly subnormalized classical law. -/
def pushMass {S A : Type*} [Fintype S] (p : S → ℝ) (X : S → A) (a : A) : ℝ :=
∑ s, if X s = a then p s else 0
/-- PDF p.6: average guessing probability, the sum of maxima of JOINT masses.
The finite, nonempty maximum has no empty/unbounded-supremum default. -/
def guessingMass {S A B : Type*} [Fintype S] [Fintype A] [Nonempty A]
[Fintype B] (p : S → ℝ) (X : S → A) (Y : S → B) : ℝ :=
∑ b, Finset.univ.sup' Finset.univ_nonempty
(fun a => pushMass p (fun s => (X s, Y s)) (a, b))
/-- PDF p.6: retained event mass, with fractional conditional event probabilities
allowed. The event is deleted without renormalizing. -/
def IsRetained {S : Type*} [Fintype S] (p r : S → ℝ) (epsilon : ℝ) : Prop :=
(∀ s, 0 ≤ r s ∧ r s ≤ p s) ∧ 1 - epsilon ≤ ∑ s, r s
/-- PDF p.6: minimum retained guessing probability. For epsilon >= 0 and
normalized p the feasible set is nonempty and compact, so its infimum is attained.
For epsilon >= 1 zero retention is feasible and the value is zero (entropy +infinity). -/
def smoothGuess {S A B : Type*} [Fintype S] [Fintype A] [Nonempty A]
[Fintype B] (p : S → ℝ) (X : S → A) (Y : S → B) (epsilon : ℝ) : ℝ :=
sInf {g : ℝ | ∃ r : S → ℝ, IsRetained p r epsilon ∧ g = guessingMass r X Y}
/-- PDF p.6: conditioning an actual probability law on an event.
The zero-event branch is zero and is used only in identities with zero weight;
all entropy uses below have positive conditioning probability. -/
def conditionMass {S : Type*} [Fintype S] (p : S → ℝ) (event : S → Prop) : S → ℝ :=
fun s => if event s then p s / (∑ t, if event t then p t else 0) else 0
/-- PDF p.5: the classical probability of a CQ block. -/
def blockMass {C E : Type*} [Fintype E] (r : C → Matrix E E ℂ) (c : C) : ℝ :=
(r c).trace.re
/-- PDF p.5: relabel classical registers and take their marginal. -/
def cqPush {C D E : Type*} [Fintype C] (r : C → Matrix E E ℂ) (f : C → D) :
D → Matrix E E ℂ :=
fun d => ∑ c, if f c = d then r c else 0
/-- PDF pp.5-6: Markov reconstruction, keeping the actual classical joint law.
Zero-mass fibers contribute zero, including for subnormalized event blocks. -/
def markov {X Y E : Type*} [Fintype X] [Fintype Y] [Fintype E]
(r : (X × Y) → Matrix E E ℂ) : (X × Y) → Matrix E E ℂ :=
fun xy => ((blockMass r xy / blockMass (cqPush r Prod.snd) xy.2 : ℝ) : ℂ) •
cqPush r Prod.snd xy.2
/-- PDF p.5: event conditioning with an arbitrary original-state version at mass zero. -/
def cqCondition {C E : Type*} [Fintype C] [Fintype E]
(r : C → Matrix E E ℂ) (event : C → Prop) : C → Matrix E E ℂ :=
let p := ∑ c, if event c then blockMass r c else 0
if 0 < p then fun c => if event c then ((p⁻¹ : ℝ) : ℂ) • r c else 0 else r
/-- Positive list length and inhabited fibers supply the tagged union's inhabitant.
This derived instance adds no hypothesis to Lemma 2.2. -/
local instance {m : ℕ} [NeZero m] {A : Fin m → Type*}
[∀ i, Nonempty (A i)] : Nonempty (Sigma A) :=
⟨⟨0, Classical.choice (inferInstance : Nonempty (A 0))⟩⟩
/-- PDF p.3: prescribed private-input maps for the passive AND reduction. -/
def andPassword {W : Type*} (wzero wone : W) (b : Bool) : W :=
if b then wone else wzero
/-- PDF p.3: an honest identification execution's local views, including
its common publicly announced decision. This is an execution kernel, not a
security assumption on an arbitrary replacement functionality. -/
structure PassiveExecution (W EA EB : Type*) where
alice : W → W → (Bool → Matrix EA EA ℂ)
bob : W → W → (Bool → Matrix EB EB ℂ)
/-- PDF p.3: passive equality identification correctness and statistical privacy.
Privacy compares unequal passwords for the other party at a fixed own input;
accept/reject is retained in both views. -/
def PassiveEqualitySecurity {W EA EB : Type*} [Fintype EA] [Fintype EB]
(P : PassiveExecution W EA EB) (delta epsilon : ℝ) : Prop :=
0 ≤ delta ∧ 0 ≤ epsilon ∧
(∀ a b, QAlgorithms.IsDensityMatrix (blockMatrix (P.alice a b)) ∧
QAlgorithms.IsDensityMatrix (blockMatrix (P.bob a b)) ∧
(∀ t, blockMass (P.alice a b) t = blockMass (P.bob a b) t) ∧
blockMass (P.bob a b) (decide (a = b)) ≥ 1 - delta) ∧
(∀ a b c, b ≠ a → c ≠ a → cqDistance (P.alice a b) (P.alice a c) ≤ epsilon) ∧
(∀ b a c, a ≠ b → c ≠ b → cqDistance (P.bob a b) (P.bob c b) ≤ epsilon)
/-- PDF p.10: pack a restriction in increasing coordinate order, then right-pad with zeros. -/
def packedRestriction {n : ℕ} (x theta c : QAlgorithms.Qubits n) : QAlgorithms.Qubits n :=
fun j => (((List.finRange n).filter (fun i => theta i == c i)).map x).getD j.val false
/-- PDF p.10: xor of the two ell-bit tags. -/
def xorTag {ell : ℕ} (a b : QAlgorithms.Qubits ell) : QAlgorithms.Qubits ell :=
fun i => xor (a i) (b i)
/-- PDF p.7: strong universal-2, with an independent uniform seed. -/
def StrongUniversal {I A B : Type*} [Fintype I] [Fintype B]
(f : I → A → B) : Prop :=
∀ x y, x ≠ y → ∀ u v,
((Finset.univ.filter (fun i => f i x = u ∧ f i y = v)).card : ℝ) /
Fintype.card I = ((Fintype.card B : ℝ) ^ 2)⁻¹
/-- PDF p.10: public Q-ID parameters. Code distance is a guaranteed minimum;
seed alphabets are finite nonempty types supplied at use sites. -/
structure QIDParameters (n ell m d : ℕ) (F G : Type*) [Fintype F] [Fintype G] where
code : Fin m → QAlgorithms.Qubits n
injective : Function.Injective code
distance : ∀ a b, a ≠ b → d ≤ hammingDist (code a) (code b)
hashF : F → QAlgorithms.Qubits n → QAlgorithms.Qubits ell
hashG : G → Fin m → QAlgorithms.Qubits ell
strongF : StrongUniversal hashF
strongG : StrongUniversal hashG
/-- PDF p.10, steps 3-6: the exact tag computed from the packed restriction. -/
def qidTag {n ell m d : ℕ} {F G : Type*} [Fintype F] [Fintype G]
(P : QIDParameters n ell m d F G) (w : Fin m)
(x theta : QAlgorithms.Qubits n) (f : F) (g : G) : QAlgorithms.Qubits ell :=
xorTag (P.hashF f (packedRestriction x theta (P.code w))) (P.hashG g w)
/-- PDF pp.4,10: Born probability for measuring an encoded product state. -/
def bb84Probability {n : ℕ} (x theta y c : QAlgorithms.Qubits n) : ℝ :=
Complex.normSq (∑ t, conj (bb84Vector y c t) * bb84Vector x theta t)
/-- PDF p.10, complete honest execution of steps 1-6. Uniform independent
x,theta,f,g are averaged; xprime is drawn using the Born measurement law. -/
def honestAcceptance {n ell m d : ℕ} {F G : Type*} [Fintype F] [Fintype G]
(P : QIDParameters n ell m d F G) (w : Fin m) : ℝ :=
((Fintype.card (QAlgorithms.Qubits n) : ℝ) ^ 2 * Fintype.card F * Fintype.card G)⁻¹ *
∑ x, ∑ theta, ∑ f, ∑ g, ∑ y,
bb84Probability x theta y (P.code w) *
(if qidTag P w x theta f g = qidTag P w y theta f g then 1 else 0)
/-- PDF p.10, Prop.3.4: arbitrary password-independent server strategy.
Only the checkpoint quantum register is bounded. Classical Y, final E, and
all computation are unrestricted; the post-revelation map chooses g adaptively. -/
structure ServerAttack (n ell q : ℕ) (F : Type*) (G Y E : Type)
[Fintype F] [Fintype G] [Fintype Y] [Fintype E] where
checkpoint : RectangularInstrument (QAlgorithms.Qubits n) (QAlgorithms.Qubits q) Y
chooseG : QAlgorithms.Qubits n → F → Y → RectangularInstrument (QAlgorithms.Qubits q) E G
finish : QAlgorithms.Qubits n → F → Y → G → QAlgorithms.Qubits ell →
QAlgorithms.Superop E E
finish_channel : ∀ theta f y g z, QAlgorithms.IsChannel (finish theta f y g z)
/-- PDF pp.10-11: actual Q-ID output against this server, retaining the full
classical history (theta,f,y,g,z). No map has the unknown password as an input. -/
def serverOutput {n ell m d q : ℕ} {F : Type*} {G Y E : Type}
[Fintype F] [Fintype G] [Fintype Y] [Fintype E]
(P : QIDParameters n ell m d F G) (W : Law (Fin m))
(A : ServerAttack n ell q F G Y E) :
(Fin m × (QAlgorithms.Qubits n × F × Y × G × QAlgorithms.Qubits ell)) → Matrix E E ℂ :=
fun wh =>
let w := wh.1
let theta := wh.2.1
let f := wh.2.2.1
let y := wh.2.2.2.1
let g := wh.2.2.2.2.1
let z := wh.2.2.2.2.2
((W.prob w / ((Fintype.card (QAlgorithms.Qubits n) : ℝ) ^ 2 * Fintype.card F) : ℝ) : ℂ) •
∑ x, if z = qidTag P w x theta f g then
A.finish theta f y g z
(RectangularInstrument.branch (A.chooseG theta f y) g
(RectangularInstrument.branch A.checkpoint y (QAlgorithms.pureDensity (bb84Vector x theta))))
else 0
/-- PDF pp.5-6,8: Markov reconstruction with the transcript H in the
quantum observer's side of the partition. The transcript is NOT discarded. -/
def markovRight {W J H E : Type*} [Fintype W] [Fintype J]
[Fintype H] [Fintype E] (r : ((W × J) × H) → Matrix E E ℂ) :
((W × J) × H) → Matrix E E ℂ :=
fun c =>
((blockMass (cqPush r Prod.fst) c.1 /
blockMass (cqPush r (fun c => c.1.2)) c.1.2 : ℝ) : ℂ) •
cqPush r (fun c => (c.1.2, c.2)) (c.1.2, c.2)
/-- PDF p.8: a classical guess extension of the actual output, with
independence of the password; every register and quantum block is preserved
when the extra guess is discarded. -/
def IsGuessExtension {W J H E : Type*} [Fintype W] [Fintype J]
[Fintype H] [Fintype E] (rho : (W × H) → Matrix E E ℂ)
(ext : ((W × J) × H) → Matrix E E ℂ) : Prop :=
QAlgorithms.IsDensityMatrix (blockMatrix ext) ∧
cqPush ext (fun c => (c.1.1, c.2)) = rho ∧
∀ w j, blockMass (cqPush ext Prod.fst) (w, j) =
blockMass (cqPush rho Prod.fst) w *
blockMass (cqPush ext (fun c => c.1.2)) j
/-- PDF p.8, Definitions 3.2/3.3: compare the conditioned actual state
to its OWN Markov reconstruction, retaining the final announced decision. -/
def GuessSecrecy {W J H E : Type*} [Fintype W] [Fintype J]
[Fintype H] [Fintype E] (ext : ((W × J) × H) → Matrix E E ℂ)
(guessValue : J → Option W) (epsilon : ℝ) : Prop :=
let r := cqCondition ext (fun c => some c.1.1 ≠ guessValue c.1.2)
cqDistance r (markovRight r) ≤ epsilon
/-- PDF p.8, Definition 3.2: the existential independent-guess witness
is an extension of the actual protocol output, not a new assumed output law. -/
def HasIndependentGuess {W H E J : Type*} [Fintype W] [Fintype H]
[Fintype E] [Fintype J] (rho : (W × H) → Matrix E E ℂ)
(guessValue : J → Option W) (epsilon : ℝ) : Prop :=
∃ ext : ((W × J) × H) → Matrix E E ℂ,
IsGuessExtension rho ext ∧ GuessSecrecy ext guessValue epsilon
/-- PDF p.7: the corrected, PDF-verified uncertainty exponent.
Only the source's security range 0 < lambda < 1/4 is used below. -/
def qidUncertaintyExponent (lambda : ℝ) : ℝ :=
lambda ^ 2 * Real.logb 2 (Real.exp 1) / (32 * (2 - Real.logb 2 lambda) ^ 2)
/-- PDF pp.10-12: all operations before receiving g can be represented
by a password-independent CQ ensemble of the transmitted register and retained R.
The response instrument chooses an arbitrary tag or abort (none), after seeing g.
A final channel may depend on the announced decision. There is no
quantum-storage bound on R or E. -/
structure UserAttack (n ell : ℕ) (F G : Type*) (R E : Type)
[Fintype F] [Fintype G] [Fintype R] [Fintype E] where
prepared : (QAlgorithms.Qubits n × F) →
Matrix (QAlgorithms.Qubits n × R) (QAlgorithms.Qubits n × R) ℂ
normalized : QAlgorithms.IsDensityMatrix (blockMatrix prepared)
respond : QAlgorithms.Qubits n → F → G →
RectangularInstrument R E (Option (QAlgorithms.Qubits ell))
finish : QAlgorithms.Qubits n → F → G → Option (QAlgorithms.Qubits ell) →
Bool → QAlgorithms.Superop E E
finish_channel : ∀ theta f g z accepted,
QAlgorithms.IsChannel (finish theta f g z accepted)
/-- PDF p.10 step 2: unnormalized residual state on R after the honest
server's actual measurement in the password code basis. -/
def measuredResidual {n : ℕ} {R : Type*} (rho :
Matrix (QAlgorithms.Qubits n × R) (QAlgorithms.Qubits n × R) ℂ)
(y c : QAlgorithms.Qubits n) : Matrix R R ℂ :=
fun r s => ∑ i, ∑ j,
conj (bb84Vector y c i) * rho (i, r) (j, s) * bb84Vector y c j
/-- PDF p.10: user attack transcript includes the final announced decision.
The optional tag none is an abort and is always rejected. -/
abbrev UserHistory (n ell : ℕ) (F G : Type*) :=
QAlgorithms.Qubits n × F × G × Option (QAlgorithms.Qubits ell) × Bool
/-- PDF pp.10-12: complete original Q-ID execution against an arbitrary user.
The honest server measures in c(w) before theta,f are revealed, and chooses g
uniformly and independently. The user can process its state after receiving the
announced decision. All attack operations are password independent. -/
def userOutput {n ell m d : ℕ} {F G : Type*} {R E : Type}
[Fintype F] [Fintype G] [Fintype R] [Fintype E]
(P : QIDParameters n ell m d F G) (W : Law (Fin m))
(A : UserAttack n ell F G R E) :
(Fin m × UserHistory n ell F G) → Matrix E E ℂ :=
fun wh =>
let w := wh.1
let theta := wh.2.1
let f := wh.2.2.1
let g := wh.2.2.2.1
let z := wh.2.2.2.2.1
let accepted := wh.2.2.2.2.2
((W.prob w / Fintype.card G : ℝ) : ℂ) • ∑ y,
if decide (z = some (qidTag P w y theta f g)) = accepted then
A.finish theta f g z accepted
(RectangularInstrument.branch (A.respond theta f g) z
(measuredResidual (A.prepared (theta, f)) y (P.code w)))
else 0
/-- PDF p.8, Definition 3.3: the same independent guess supplies exact
acceptance on equality, bounded acceptance on mismatch, and postdecision secrecy.
The acceptance conditions use weighted events, so a zero-mass equality event
adds no positivity assumption. Mismatch has mass at least 1/2 in Prop.3.5. -/
def ServerSecurity {n ell m : ℕ} {F G E : Type*}
[Fintype F] [Fintype G] [Fintype E]
(rho : (Fin m × UserHistory n ell F G) → Matrix E E ℂ) (epsilon : ℝ) : Prop :=
∃ ext : (((Fin m) × Option (Fin m)) × UserHistory n ell F G) → Matrix E E ℂ,
IsGuessExtension rho ext ∧ GuessSecrecy ext id epsilon ∧
(∑ c, if some c.1.1 = c.1.2 ∧ c.2.2.2.2.2 = false
then blockMass ext c else 0) = 0 ∧
(∑ c, if some c.1.1 ≠ c.1.2 ∧ c.2.2.2.2.2 = true
then blockMass ext c else 0) ≤
epsilon * (∑ c, if some c.1.1 ≠ c.1.2 then blockMass ext c else 0)
/-- PDF p.15: the fixed binary coordinates of GF(2^N), followed by projection
onto the first ell coordinates; the tag alphabet's additive group is GF(2^ell).
Only its addition is used, so binary coordinate vectors give exactly that group. -/
def affineTag {K : Type*} [Field K] [Algebra (ZMod 2) K] {N ell : ℕ}
(coordinates : K ≃ₗ[ZMod 2] (Fin N → ZMod 2)) (hell : ell ≤ N)
(key : K × (Fin ell → ZMod 2)) (x : K) : Fin ell → ZMod 2 :=
fun i => coordinates (key.1 * x) (Fin.castLE hell i) + key.2 i
/-- PDF p.15: uniform independent key, with exactly field-degree N rather
than the unrelated transmitted-qubit count. -/
def keyMass {K : Type*} [Fintype K] (ell : ℕ) : ℝ :=
((Fintype.card K : ℝ) * (2 : ℝ) ^ ell)⁻¹
/-- PDF p.15: actual classical tag/key/side-information distribution. -/
def classicalTagLaw {K : Type*} {S : Type} {Z : Type*} [Field K] [Fintype K] [Algebra (ZMod 2) K]
[Fintype S] {N ell : ℕ}
(coordinates : K ≃ₗ[ZMod 2] (Fin N → ZMod 2)) (hell : ell ≤ N)
(p : Law S) (X : S → K) (z : S → Z) :
((Fin ell → ZMod 2) × (K × (Fin ell → ZMod 2)) × Z) → ℝ :=
fun t => keyMass (K := K) ell * ∑ s,
if t.1 = affineTag coordinates hell t.2.1 (X s) ∧ t.2.2 = z s then p.prob s else 0
/-- PDF p.15: ideal independent uniform tag, preserving the same key and Z law. -/
def classicalIdealTagLaw {K : Type*} {S : Type} {Z : Type*} [Fintype K] [Fintype S] (ell : ℕ)
(p : Law S) (z : S → Z) :
((Fin ell → ZMod 2) × (K × (Fin ell → ZMod 2)) × Z) → ℝ :=
fun t => ((2 : ℝ) ^ ell)⁻¹ * keyMass (K := K) ell * pushMass p.prob z t.2.2
/-- PDF p.15: the actual CQ tag/key/Z/E state. E depends only on X,Z,
while the key is independent and uniform. -/
def quantumTagLaw {K : Type*} {S : Type} {Z : Type*} [Field K] [Fintype K] [Algebra (ZMod 2) K]
[Fintype S] {N ell q : ℕ}
(coordinates : K ≃ₗ[ZMod 2] (Fin N → ZMod 2)) (hell : ell ≤ N)
(p : Law S) (X : S → K) (z : S → Z)
(rho : K → Z → Matrix (QAlgorithms.Qubits q) (QAlgorithms.Qubits q) ℂ) :
((Fin ell → ZMod 2) × (K × (Fin ell → ZMod 2)) × Z) →
Matrix (QAlgorithms.Qubits q) (QAlgorithms.Qubits q) ℂ :=
fun t => ((keyMass (K := K) ell : ℝ) : ℂ) • ∑ s,
if t.1 = affineTag coordinates hell t.2.1 (X s) ∧ t.2.2 = z s
then (p.prob s : ℂ) • rho (X s) (z s) else 0
/-- PDF p.15: I/2^ell tensor rho_K tensor rho_ZE, with actual marginals. -/
def quantumIdealTagLaw {K : Type*} {S : Type} {Z : Type*} [Fintype K] [Fintype S] (ell : ℕ) {q : ℕ}
(p : Law S) (X : S → K) (z : S → Z)
(rho : K → Z → Matrix (QAlgorithms.Qubits q) (QAlgorithms.Qubits q) ℂ) :
((Fin ell → ZMod 2) × (K × (Fin ell → ZMod 2)) × Z) →
Matrix (QAlgorithms.Qubits q) (QAlgorithms.Qubits q) ℂ :=
fun t => ((((2 : ℝ) ^ ell)⁻¹ * keyMass (K := K) ell : ℝ) : ℂ) • ∑ s,
if z s = t.2.2 then (p.prob s : ℂ) • rho (X s) (z s) else 0
example (a b : Bool) : andPassword a b true = b := rfl
/-- Retaining the full event is feasible at every nonnegative smoothing level. -/
example {S : Type} [Fintype S] (p : Law S)
(epsilon : ℝ) (hepsilon : 0 ≤ epsilon) : IsRetained p.prob p.prob epsilon := by
constructor
· intro s
exact ⟨p.nonneg s, le_rfl⟩
· rw [p.total]
linarith
/-- A zero event block has zero weighted Markov reconstruction. -/
example {X Y E : Type*} [Fintype X] [Fintype Y] [Fintype E] :
markov (0 : (X × Y) → Matrix E E ℂ) = 0 := by
funext xy
simp [markov, blockMass, cqPush]
example {C E : Type*} (r : C → Matrix E E ℂ) (c : C) (i j : E) :
blockMatrix r (c, i) (c, j) = r c i j := by simp [blockMatrix]
example {S : Type*} [Fintype S] (p : S → ℝ) :
conditionMass p (fun _ => False) = 0 := by
funext s
simp [conditionMass]
example (x theta : QAlgorithms.Qubits 0) : bb84Vector x theta (fun i => Fin.elim0 i) = 1 := by
simp [bb84Vector]
example {K : Type*} [Field K] [Algebra (ZMod 2) K] {N ell : ℕ}
(coordinates : K ≃ₗ[ZMod 2] (Fin N → ZMod 2)) (hell : ell ≤ N)
(a : K) (b : Fin ell → ZMod 2) : affineTag coordinates hell (a, b) 0 = b := by
funext i
simp [affineTag]
example : Law Unit where
prob := fun _ => 1
nonneg := by intro a; norm_num
total := by simp
example {I O J : Type} [Fintype I] [Fintype O] [Fintype J]
(M : RectangularInstrument I J O) (o : O) : RectangularInstrument.branch M o 0 = 0 := by
simp [RectangularInstrument.branch, QAlgorithms.krausApply]
example (x theta y : QAlgorithms.Qubits 1) :
bb84Vector x theta y =
if theta 0 then QAlgorithms.hadamard (y 0) (x 0)
else if y 0 = x 0 then 1 else 0 := by
simp [bb84Vector]
example {n : ℕ} (x theta c : QAlgorithms.Qubits n)
(hnomatch : ∀ i, theta i ≠ c i) : packedRestriction x theta c = fun _ => false := by
funext j
have hempty : (List.finRange n).filter (fun i => theta i == c i) = [] := by
apply List.filter_eq_nil_iff.mpr
intro i hi
simp [hnomatch i]
simp [packedRestriction, hempty]
end QAlgorithms.Papers.Independent.Intakenext100.P14
Read-back
What the Lean code literally says, in plain math · gpt-6.1-sol
QAlgorithms.Papers.Independent.Intakenext100.P14.GuessSecrecy
For finite types , any matrix family , a function , and any real , let mean , so that always satisfies . Set . If , define on and zero elsewhere; if , define . Define
The proposition is , where is the block-diagonal matrix whose block is . Zero denominators in give zero scalars. No positivity, normalization, nonemptiness, or nonnegativity assumption on is included.
QAlgorithms.Papers.Independent.Intakenext100.P14.HasIndependentGuess
For finite types , a family , a function , and a real , this asserts the existence of matrices such that their block-diagonal matrix is positive semidefinite with trace , , and their classical masses satisfy
In addition, restrict to the event and divide by its total trace mass when that mass is positive, obtaining ; if that mass is nonpositive, use . The trace distance between the block-diagonal matrix of and that of
must be at most , where trace distance means and division by zero gives zero. No sign restriction on is assumed; an empty , or makes the required normalized extension impossible.
QAlgorithms.Papers.Independent.Intakenext100.P14.IsGuessExtension
For finite types , a matrix family , and a proposed family , this proposition requires all three of the following: the block-diagonal matrix with entries is positive semidefinite and has complex trace ; for every ; and, writing ,
The last equality is independence of the classical and masses after summing out and tracing out . The finite types are not explicitly assumed nonempty, but the trace-one requirement is impossible if any of them is empty.
QAlgorithms.Papers.Independent.Intakenext100.P14.IsRetained
For any finite type , real functions , and real number , this predicate means
There is no separate assumption that is a probability distribution or that . A negative value of makes the predicate impossible; when is empty, it holds exactly when .
QAlgorithms.Papers.Independent.Intakenext100.P14.PassiveEqualitySecurity
Let be any type, let be finite types, let supply matrix families and indexed by and Boolean , and let . For a family , write , write , and define
Passive equality security means that ; for every , both and are positive semidefinite with trace , their masses agree for each Boolean , and ; for every with and , ; and for every with and , . Here is the Boolean truth value of equality. No upper bounds on are imposed, and need not be finite or nonempty; if is empty, all conditions involving its elements are vacuous.
QAlgorithms.Papers.Independent.Intakenext100.P14.PassiveExecution
For arbitrary types , a passive execution consists of two families of complex square matrices,
The families are named Alice’s and Bob’s, respectively. The structure imposes no positivity, normalization, agreement, or correctness conditions, and none of the three types is required to be finite or nonempty.
QAlgorithms.Papers.Independent.Intakenext100.P14.QIDParameters
For natural numbers and finite types , let denote the Boolean strings of length . A parameter record consists of an injective function , satisfying
and functions and . They must satisfy, for all distinct and all ,
and, for all distinct and all ,
All four natural parameters may be zero, and neither key type is explicitly required to be nonempty; quotients with zero denominator are zero. The distance and second hash conditions are vacuous when , and the first hash condition is vacuous when . For , the code has empty domain; for , the tag space contains the single empty string.
QAlgorithms.Papers.Independent.Intakenext100.P14.ServerAttack
For natural numbers and finite types , a server attack consists of a checkpoint instrument from the space indexed by length- Boolean strings to that indexed by length- Boolean strings, with outcomes ; a choice of another instrument from the latter space to the space indexed by , with outcomes , for every ; and a map from complex matrices to themselves for every additional . Explicitly, the checkpoint supplies a natural number and matrices with
each chosen instrument supplies a natural number and matrices with
Every finishing map must admit a finite Kraus representation: there exist and such that and for every matrix . The definition imposes no positivity requirements on , no nonemptiness requirements on the finite types, and no additional relations between these choices; the completeness equations themselves can exclude choices with empty outcome sets.
QAlgorithms.Papers.Independent.Intakenext100.P14.ServerSecurity
For natural numbers , finite types , an arbitrary matrix family , and a real , let histories be with , , , optional tag , and Boolean . This proposition asserts the existence of matrices with and such that their block-diagonal matrix is positive semidefinite with trace , , and, writing ,
For the event , form by restricting to and dividing by its trace mass when ; when , use . The block-diagonal matrices of and
must have trace distance at most , meaning for their difference , with zero denominators giving zero. Finally, the extension must satisfy
A missing guess belongs to the incorrect-guess event for every . No nonnegativity assumption on is included; empty indexing spaces that make the block matrix zero cannot satisfy its trace-one requirement.
QAlgorithms.Papers.Independent.Intakenext100.P14.StrongUniversal
For arbitrary types , with and finite, a function is strongly universal precisely when, for every pair of distinct and every ,
No finiteness assumption on , and no nonemptiness assumption on or , is included. Division by zero is defined to be zero. If has no distinct pair, or if is empty, the corresponding universal conditions are vacuous; if is empty, is nonempty, and has a distinct pair, the displayed requirement cannot hold.
QAlgorithms.Papers.Independent.Intakenext100.P14.UserAttack
For natural numbers , finite types , and , this structure consists of a family , indexed by , whose block-diagonal matrix is positive semidefinite and has trace ; for every , , and , an instrument from to with outcomes or for ; and, for every , optional tag , and Boolean , a channel from to itself. Each response instrument supplies a natural-number Kraus count and matrices with , and its branch sends to . Each finishing map has a finite Kraus representation with . The individual are not required to have trace ; normalization applies to their combined block matrix. Zero register lengths are allowed; the normalized preparation cannot exist if or is empty.
QAlgorithms.Papers.Independent.Intakenext100.P14.UserHistory
For natural numbers and arbitrary types , this is the type of tuples , where , , , is either or for , and is a Boolean. No consistency condition is imposed on these components. Length-zero bit strings are included, and the history type is empty if or is empty.
QAlgorithms.Papers.Independent.Intakenext100.P14.affineTag
Let be a field equipped with an algebra structure over , let be natural numbers with , and let be an -linear equivalence. For every key and input , this definition returns the vector
where the coordinate is viewed as one of the first coordinates of , and addition is in . No finiteness assumption on is separately supplied. The case returns the unique empty vector; cannot admit the stipulated linear equivalence from a field.
QAlgorithms.Papers.Independent.Intakenext100.P14.andPassword
For any type , arbitrary elements , and Boolean , this defines
The two supplied elements are not required to be distinct.
QAlgorithms.Papers.Independent.Intakenext100.P14.bb84Probability
For every natural number and Boolean strings , define a vector by
where bits in the exponent are interpreted as or . The defined real number is the squared complex modulus
When , the products are empty products equal to , the sum has one term, and the value is .
QAlgorithms.Papers.Independent.Intakenext100.P14.blockMass
For any type , finite type , family , and , this defines
The matrices need not be positive, Hermitian, or normalized, so this value need not be nonnegative. It is zero when is empty.
QAlgorithms.Papers.Independent.Intakenext100.P14.classicalIdealTagLaw
For any finite types , arbitrary type , natural number , probability weights satisfying and , and function , this definition assigns to each the value
Thus the value does not depend on . No field structure or nonemptiness assumption on , and no finiteness assumption on , is required. An empty makes the coefficient zero under the convention , and also makes the function’s domain empty. The existence of excludes empty ; is included.
QAlgorithms.Papers.Independent.Intakenext100.P14.classicalTagLaw
Let be a finite field equipped with an -algebra structure, a finite type, an arbitrary type, natural numbers with , and an -linear equivalence. Let satisfy and , and let and be arbitrary functions. This definition assigns to each the real value
The coordinate arithmetic is in . No finiteness assumption on or strict positivity assumption on the individual is imposed; the existence of excludes empty . For , the tag condition is vacuous and the tag and offset vectors are empty.
QAlgorithms.Papers.Independent.Intakenext100.P14.conditionMass
For any finite type , arbitrary , and predicate on , this defines a function on by
There are no positivity or normalization assumptions. Division by zero is defined to be zero, so if the event has total mass zero, the resulting function is identically zero, even if that total vanishes through cancellation of signed masses.
QAlgorithms.Papers.Independent.Intakenext100.P14.cqCondition
For finite types , any family , and predicate on , let
This defines
The real scaling factor is embedded in . No positivity or normalization is assumed; in particular, when the event mass is zero or negative, the entire original family is returned.
QAlgorithms.Papers.Independent.Intakenext100.P14.cqPush
For any finite type , arbitrary types , family , and function , this defines the matrix family
No positivity or normalization is assumed, and neither nor is required to be finite. Empty fibers give the zero matrix.
QAlgorithms.Papers.Independent.Intakenext100.P14.guessingMass
For finite types , with nonempty, arbitrary , and functions and , this defines
The maximum is over every element of , including values with empty fibers. No nonnegativity or normalization is assumed. If or is empty, the result is zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.honestAcceptance
Let be natural numbers, finite types, and a record with an injective code of minimum pairwise Hamming distance at least , and hash families , , each requiring the fraction of keys mapping any distinct input pair to any specified output pair to equal . Fix . Define by packing the bits with , in increasing index order, into the beginning of a length- string and padding with false, and define coordinatewise. For , set , where if is true and otherwise. Honest acceptance is the real number
Here all quotients with zero denominator are zero; in particular, if a key type is empty, this expression is zero. Zero string or tag lengths are permitted, with empty products equal to .
QAlgorithms.Papers.Independent.Intakenext100.P14.keyMass
For every finite type and natural number , this definition returns the real number
No nonemptiness assumption on is required: if is empty, the value is zero because the inverse of zero is defined to be zero. When , the value is , with the same convention.
QAlgorithms.Papers.Independent.Intakenext100.P14.markov
For arbitrary finite types and any matrix family , set . This defines
where the real scalar is regarded as complex when multiplying the matrix. No positivity, normalization, or nonemptiness is assumed. A zero denominator gives the zero matrix at that .
QAlgorithms.Papers.Independent.Intakenext100.P14.markovRight
For arbitrary finite types and any family of complex matrices , with no positivity or normalization assumption, define . The resulting family is
Thus the scalar uses the trace masses of the and marginals, and multiplies the matrix marginal. A zero denominator gives scalar zero, even if the numerator is nonzero; empty index types are permitted and their sums are zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.measuredResidual
For any natural number , any type without a finiteness assumption, an arbitrary complex matrix indexed by , and strings , this defines the -indexed matrix
No positivity or normalization assumption is imposed on . When , the product is and the sums have one term, so .
QAlgorithms.Papers.Independent.Intakenext100.P14.packedRestriction
For every natural number and every three Boolean strings , form the increasing list of all indices satisfying . The packed restriction is the Boolean string of length given by
Thus the selected bits are moved to the beginning in index order and the remaining positions are filled with false. When no indices match, the result is entirely false; when , it is the unique empty string.
QAlgorithms.Papers.Independent.Intakenext100.P14.pushMass
For any finite type , any type , any real function , any function , and any , this defines
No nonnegativity or normalization is required of . An empty fiber, including when is empty, contributes zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.qidTag
Let be natural numbers and finite types. Let contain an injective code whose distinct codewords have Hamming distance at least , together with hash families and , each satisfying that the fraction of keys sending any two distinct inputs to any prescribed pair of outputs is , with division by zero interpreted as zero. For , , , and , list in increasing order the indices where , copy the corresponding bits of to the beginning of a length- string, and fill its remaining positions with false; call this string . The tag is
The arguments must exist for an instance of this definition to be evaluated; and are allowed.
QAlgorithms.Papers.Independent.Intakenext100.P14.qidUncertaintyExponent
For every real , this defines
There is no positivity or interval restriction on . Here the real logarithm is total: , and for negative arguments ; division by zero is zero. In particular, and the vanishing denominators at and also give value zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.quantumIdealTagLaw
For finite types , an arbitrary type , natural numbers , probability weights satisfying and , functions and , and arbitrary complex matrices indexed by , this definition returns
for . The value is independent of . There is no field assumption on , no finiteness assumption on , and no density-matrix assumption on . The existence of and forces and to be nonempty; the coefficient nevertheless uses the total inverse convention . Both and are included, with empty tag vectors and matrices, respectively.
QAlgorithms.Papers.Independent.Intakenext100.P14.quantumTagLaw
Let be a finite field equipped with an -algebra structure, a finite type, an arbitrary type, natural numbers with , and an -linear equivalence. Let satisfy and , let and , and let be arbitrary complex matrices indexed by the -bit strings . This definition returns the matrix-valued function
on , with real coefficients acting as complex scalars. No positivity, trace, or normalization requirement is imposed on the matrices . The type need not be finite, zero weights are allowed, and cannot exist on empty . When , the tag condition is vacuous; when , the matrices are , since there is one empty bit string.
QAlgorithms.Papers.Independent.Intakenext100.P14.serverOutput
For natural numbers , finite types , and (including its single empty string when ), this defines an -indexed complex matrix for each . The parameter supplies probabilities with . The parameter supplies an injective map , with Hamming distance at least between distinct images, and hash families and ; for either family, every pair of distinct inputs and every pair of prescribed outputs occurs for a fraction of the keys. Write , where packing lists, in increasing coordinate order, the bits for which , then pads the list with false bits to length , and is coordinatewise XOR. The parameter supplies a checkpoint instrument from to with outcomes , an instrument from to with outcomes for each , and a channel on for every transcript. An instrument branch is , with a finite common Kraus count within each instrument and ; each finishing channel has a finite Kraus representation with the same completeness condition. With on coordinates where is true and Kronecker-delta factors on the other coordinates, where , the definition is
There are no separate positivity assumptions on the natural-number parameters; cannot exist when , and division by a zero denominator is defined to be zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.smoothGuess
For finite types , with nonempty, arbitrary , functions and , and arbitrary , this defines the real infimum
Neither normalization nor nonnegativity of , nor a range restriction on , is assumed. If there is no admissible , the real infimum used here is zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.userOutput
For natural numbers , finite types , and , this defines an -indexed matrix for every password and history . The parameter gives nonnegative weights summing to . The parameter gives an injective code with pairwise Hamming distance at least , and hash families and for which each prescribed output pair on distinct inputs occurs for a fraction of keys. Set , with packing retaining matching-basis bits in increasing order and padding with zeros. The attack supplies preparation blocks on whose combined block-diagonal matrix is positive semidefinite with trace , response branches with , and finishing channels on , each having a finite complete Kraus representation. Let
where is the product of when and otherwise. The output is
In particular, a missing tag contributes only to histories with . Zero register lengths are allowed, excludes , and division by is defined to be zero.
QAlgorithms.Papers.Independent.Intakenext100.P14.xorTag
For every natural number and Boolean strings of length , their XOR tag is the length- string defined coordinatewise by
where the result is true exactly when the two bits differ. The definition includes , in which case the result is the unique empty string.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.