WorksPhysics and Astronomy
Quantum Cryptography and Autoformalization in Lean
Abstract
Quantum key distribution provides secure communication by relying on physics principles and mathematical reasoning. Security proofs across the field can contain gaps, often between individually valid theorems integrated under mismatched assumptions. We produce an end-to-end security theorem formalized in the Lean proof assistant, eliminating hidden hypotheses by building only on Lean's standard axioms. Our proof covers composable security of the entanglement-based qubit BB84 protocol against coherent attacks by the postselection technique, accounting for finite block size, and is written in a language that enforces local operations and classical communication to help ensure a faithful representation of the protocol. The proof itself was enabled by LLM-based autoformalization, and with the proof complete, we used the same pipeline as a discovery machine, reducing the finite-size penalty on the key rate. Our work sets a reproducible standard for security arguments in quantum cryptography and shows how formal proof engines can accelerate discovery across quantum information science.
Introduction
Quantum key distribution (QKD) aims to establish shared secret keys for private communication, with their security derived from quantum theory under explicit assumptions about the devices and with authenticated classical communication. Advances in protocols [1], experimental platforms [2], and networks [3] have widened the range of proposed and demonstrated QKD systems. A central advance was composable security, which formalizes when a generated key can safely replace an ideal secret key in subsequent cryptographic applications [5] [4].
A complete security proof must use compatible assumptions throughout. For example, Nahar et al. [6] closed a gap first identified by Belzig [7] in the application of postselection [8] to QKD, obtaining a weaker security bound than previously claimed. A recent comprehensive review [9] documents gaps in security proofs for practical decoy-state implementations of the Bennett–Brassard 1984 (BB84) protocol [10], including incompatible assumptions when combining results from different papers. The review also identifies recent end-to-end proofs [11, 12].
In Lean 4 [13], a formal proof assistant, a small trusted kernel checks that each proof establishes its formal statement from the declared hypotheses and axioms. When a proof uses an earlier theorem, the kernel checks that its hypotheses are satisfied. Our review checks that the definitions and theorem statement describe the intended physical protocol and security claim.
Machine-checked security proofs are established in classical cryptography [14, 15]. In quantum information, formal methods have been used to verify protocols and circuits [16, 17, 18] and develop reasoning frameworks for quantum programs [19, 20]. For QKD, formal verifications of BB84 have used process calculi, Coq and model checking [21]. Nagarajan et al. [22] model-checked finite, noiseless instances of BB84 under intercept–resend attacks, Kubota et al. [23] verified protocol-equivalence steps in the Shor–Preskill proof, and Ax-Prover [24] formalized a lemma of the Lo–Chau argument. None of these works gives an end-to-end composable finite-key security bound against general attacks.
Large language models (LLMs) coupled to proof assistants are now used in research mathematics, including the Lean formalization of Fermat’s Last Theorem [25] and a proposed proof of finite-time blowup for smoothly forced three-dimensional Navier–Stokes flow [26]. Libraries such as Mathlib supply reusable mathematical definitions and results [27]; formalizing QKD also requires definitions of permitted local operations, public communication, and a security criterion.
We present, to our knowledge, the first end-to-end machine-verified composable finite-key security proof of entanglement-based qubit BB84 against coherent attacks (Figure 2). We model Alice’s and Bob’s operations in a language, defined in Lean, that enforces local operations and classical communication (LOCC) [28] by construction. For this explicit protocol, the proof combines the BB84 phase-error analysis [29, 30] with privacy amplification [4], finite-size entropy bounds [31, 32], and the postselection reduction that extends security against collective attacks to coherent attacks [6, 8]. The audit described in Sec. II checks that the definitions used by this theorem match the intended local operations and the information available to Eve. We also bound the protocol’s abort probability under a memoryless honest channel.
Figure 2. The machine-checked BB84 development (read bottom-up). The LOCC protocol construction and reusable quantum-information theorems support the BB84 security, key-length, and robustness results. The highlighted box marks the improved conditional-entropy variance bound of § 1.4.
We prove a tighter bound on the conditional-entropy variance of classical–quantum states than that of Ref. [32], reducing the finite-size penalty in the key length. The improved bound and the key-length condition built on it are proved in Lean.
We release the underlying Lean 4 quantum-information library as open source so that its definitions and results can be reused beyond this BB84 proof. It provides states and channels based on the standard finite-dimensional formalism [33], together with entropies, finite-size entropy bounds, and the LOCC protocol language. The same infrastructure has also been used to prove a quantum-optimization conjecture in Lean [34]. Our library complements existing formalizations of quantum information and physics, including Lean-QuantumInfo, now part of Physlib [35, 36], as well as other works on quantum error correction [37], quantum algorithms and circuits [38], and the foundations of quantum mechanics [39].
Section II describes the AI pipeline and the audit of definitions and theorem statements. Section III introduces the LOCC language and the security, robustness, and classicality definitions. Section IV constructs entanglement-based qubit BB84 and proves its security and robustness bounds. Section V presents the sharpened entropy-variance bound used by that guarantee and its finite-key consequences.
The AI proving pipeline and review
We developed the formalization through an iterative collaboration between researchers and LLM agents, using Lean to check the resulting proofs (Figure 1). Agents based on Claude and GPT translated statements from target papers into Lean, guided by type-checking feedback from the Lean compiler. They decomposed proofs into intermediate claims and developed the necessary definitions and supporting results based on Mathlib [27]. The agents reviewed candidate statements and used numerical checks, where applicable, to search for counterexamples or test proposed bounds before attempting formal proofs. For sustained work we used our loopy sequencer to launch agents with task-specific context, including dependency graphs for the library from lean-graph-tools, both of which are released open source. We also ran a locally hosted GLM-5.3-Flash model [40] through loopy on proving tasks set by Claude and reviewed by Claude and GPT (Sec. VI).
Figure 1. The proving workflow and review. Agents develop statements, definitions, and candidate proofs. Kernel checking validates the formal derivation, while manual review checks the intended meaning of the formal objects and guides proof strategy and library organization.
We guided the development of definitions and types and redirected overly specialized proof attempts toward general arguments. For example, we encouraged a proof of the postselection reduction for quantum channels [8] in place of one specialized to the BB84 representation then in use. We also reviewed the organization and naming of definitions and results to make the library easier to navigate and reuse, and checked agreement with the cited literature.
The Lean kernel type-checks each proof term against its theorem statement [13]. Our review can therefore focus on whether the statement, its hypotheses and its underlying definitions express the intended claim, without rechecking the proof body. This review has caught formalization errors. For example, an earlier AI-generated protocol computed the key as a hash of Alice’s and Bob’s key strings combined, although neither party had access to both. This error motivated our development of the LOCC language introduced in Sec. III, which enforces locality and makes public communication explicit.
The LOCC language and security definitions
This section develops the security definition for a protocol-independent representation of QKD as an LOCC program, in which steps are constructed as Kraus maps acting separately on each party’s register. Composing these maps along each branch and summing over branches gives a channel whose output records every announcement in a public register. The BB84 protocol is constructed and proved secure in Sec. IV. Throughout this and subsequent sections we link to our Lean library documentation below the relevant text.
Lean: QCryptLean
Appendix B provides a glossary of the main formal definitions used in the paper.
All our Hilbert spaces are finite-dimensional. Entropies are measured in bits, denotes the base-two logarithm and the natural logarithm. We follow the notation of Lean, in which every object has a type. We write , read “ has type ”. In set notation one would write . Types can depend on objects, for example , defined below, is the type of programs starting from the system , so says that is such a program.
LOCC Program
We enforce LOCC constructively by defining a type called Program whose inhabitants can only be constructed by composing local actions, potentially dependent on public classical communications. Before introducing this Program, we specify the multipartite system and the private and announced actions from which it is constructed. Each action is built from an instrument on one party’s local register, following the instrument description of LOCC in Ref. [28 Sec. II].
We consider a finite set of parties (Alice and Bob for QKD), each with a finite register basis label set . We define the family that specifies the channel’s multipartite input system:
Lean: MultipartiteSystem
An instrument for party , with finite-dimensional input and output spaces and , has a finite outcome set and finite Kraus index sets . The physical outcome is and is an internal Kraus label:
Lean: Instrument
For a specified input system , the structure PrivateAction packages the acting party , the outcome set and the instrument :
Lean: PrivateAction
The output system is computed. It is with party ’s register replaced by the output register of , so for every holds by construction. Since acts on alone, the action is local.
An announced action also specifies a report , where is a finite public alphabet and specifies which information about the outcome is announced. For a fixed-output instrument, the constructor for the announced action takes the data
Lean: ofInstrument
The general AnnouncedAction structure also allows the acting party’s output register to depend on the report. It stores the Kraus family directly
Lean: AnnouncedAction
with the same completeness condition as defined before. The output system of each public branch is computed in the same way.
Next, our goal is to construct some object that keeps track of private and announced actions and their dependent subsequent actions. Write for Alice’s actions and for Bob’s, schematically we want to represent trees such as
Here announces , and announces . All remaining actions are private, and done marks termination. The three public histories are .
In the library we introduce a type Prog for holding onto the information in such a branching protocol, where is the system the protocol starts from. It is defined by the following three constructors
Lean: Program
Here and are the private and announced action records defined above, acting on . Note that the systems and are not supplied by the author, they are determined by the actions as with the acting party’s register replaced by the action’s output register. A continuation must start from this system, otherwise the program does not type-check.
In practice the protocols are most easily assembled using a function then which continues an action with the program that follows it. For the example above, the Lean code would be
Lean: AnnouncedAction.then
Lean: PrivateAction.then
Programs can also be composed. For example, with the subprogram for the branch , the same protocol reads
So far we have described how the library stores the information that defines a protocol in the Prog type. However, as it stands, a program cannot be fed into a diamond norm or trace norm. To do that we still need to extract actual channels out of , this process is described below.
Consider a particular branch in a program, with raw outcomes and internal Kraus indices fixed. We first extend each local Kraus map by the identity on the other parties’ registers, then compose the resulting maps along the branch, including any private actions. For the first two steps of the earlier example write for Alice’s Kraus map and for Bob’s (which may depend on the announcement that Alice makes). Taking one Kraus operator per outcome for simplicity, the channel for these two steps is
Here and . Bob’s outcome remains private when and is announced when . Later steps multiply further local Kraus maps on the left of . The function denote does exactly this for every branch of the program and sums the resulting Kraus contributions to form the channel.
Lean: denote
Security, robustness, and classicality
Given a program its associated real channel is defined with the denote function we saw above,
Lean: real
Since this channel only composes and sums the program’s Kraus maps, it discards only the registers that those maps discard. Therefore, registers for local operations whose outcomes are meant to be private must be explicitly traced out in the program before denotation. If they are not, those registers remain in the channel output and enter the real–ideal security comparison as additional side information. Tracing out cannot remove announced information, since it is a private action, and private actions never act on the public register.
To define security one compares the real channel to an ideal channel,
Lean: ideal
where is a channel that erases the keys that Alice and Bob produced and writes one fresh, uniform random string of the same length into both key registers. It preserves the public transcript and all other registers, and leaves aborted runs unchanged. Therefore, on each accepting branch the ideal keys are equal, uniform, and independent of Eve’s information. Each done in a Prog can also carry an optional label; in a QKD program, uses these labels to determine which registers are the keys.
Lean: KeyEnd
For a QKD protocol with classical output keys, -security is
Lean: IsSecure
where the diamond norm is
Lean: diamondNorm
and with ranging over operators on the input together with a reference of the same dimension. Half the diamond norm is the distinguishing advantage [5], so the real and ideal outputs have trace distance at most . Applying the same subsequent channel to both outputs cannot increase their distinguishability, including processing conditioned on the public transcript and acting jointly with Eve’s reference.
Lean: diamondDist_comp_le
According to this definition, a protocol that always aborts will appear secure, hence this definition of security is coupled with robustness which bounds the abort probability. Summing over the aborting public histories for a given input state gives
where selects the output block for that history. The robustness bound for a specified input state, or class of inputs, is
We also define classicality of Alice’s and Bob’s actions, which Sec. IV.A uses for the BB84 post-processing. A program is classical when every local action preserves diagonality on Alice’s and Bob’s registers for each outcome, along every branch. The library checks this property recursively.
For a joint input that is classical on Alice’s and Bob’s registers and quantum on the reference, such a program has an equivalent implementation by local stochastic operations and classical communication.
Machine-verified security of BB84
We now apply the definitions of Sec. III to entanglement-based qubit BB84. We construct the protocol, state its finite-key security theorem, and bound its abort probability on honest inputs. The Lean kernel checks the theorems of this section and of § 1.4, and their proofs (Figure 2) use only Lean’s standard foundational axioms (propext, Classical.choice and Quot.sound).
The protocol
The protocol is a program in the LOCC language of Sec. III. Alice and Bob share an authenticated public classical channel, and initially hold qubit pairs possibly distributed by Eve who may keep a purification.
Alice and Bob measure every qubit in either the or the basis, drawing the basis choice randomly from their respective distributions and . A party with basis distribution measures with the instrument
where is the basis, is the eigenstate of the Pauli operator with eigenvalue , and is an orthogonal classical record of basis and outcome. The qubit is discarded and nothing is announced.
This is followed by classical post-processing. First Alice and Bob announce their basis strings, and Alice announces a uniformly random permutation of the rounds with agreeing bases. In the order of this permuted register, the first matched rounds form the raw key, the next the test block and the first matched rounds the test block, and each party keeps only its outcome bits in these
retained rounds; if the matched rounds cannot fill the three blocks, both parties instead discard their records and abort.
This is followed by parameter estimation, error correction and verification, and privacy amplification, which are not specific to BB84. In parameter estimation, Bob and then Alice announce their bits in every test round.
Alice then draws a verification seed and a privacy-amplification seed, binary matrices with columns and with and rows, uniformly and independently. She announces both seeds, the -bit verification tag given by the product of the verification seed and her raw key modulo , and the -bit syndrome of an error-correction scheme with syndrome map and decoder .
Bob computes his corrected key from his raw key . He announces acceptance if each test block is nonempty and its fraction of disagreeing bits lies in the window , with center and half-width , and if the tag of his corrected key equals Alice’s; otherwise he announces abort.
On acceptance, Alice’s final key is the -bit product of the privacy-amplification seed and her raw key modulo , and Bob’s is the same product with his corrected key. The parties discard all other private records on acceptance and all their private records on abort.
The measurement step leaves classical records by construction, and every action of the post-processing preserves diagonality on Alice’s and Bob’s registers, so the post-processing is classical in the sense of Sec. III.B.
Finite-key security theorem
We state the bounds first, then explain their terms.
Theorem 1 (finite-key security of BB84). For every translation-equivariant error-correction scheme (Appendix A) and every choice of analysis parameters satisfying the conditions below, the real and ideal channels of the protocol satisfy
so the protocol is -secure in the sense of Eq. (12), where is the error-verification error plus the postselection prefactor times the sum of the contributions of parameter estimation, smoothing and privacy amplification:
Lean: bellRenyiBudget
Here is the postselection prefactor for extending the IID analysis to arbitrary inputs [6, 8], and the bracket matches the bound of Ref. [6, Theorem 3] for mixtures of IID inputs. The prefactor is the dimension of the symmetric subspace of . Generic postselection for two qubits per round gives the larger prefactor , from the symmetric subspace of . The smaller factor exploits BB84’s Pauli symmetry: for a translation-equivariant error-correction scheme, applying the same Pauli operator to both qubits of any round relabels the classical outputs [6 Lemma 2]. We use the acceptance-test and verification bounds
Lean: phaseTail
where is the binary relative entropy in nats. Here bounds the probability that an IID input whose X-basis error rate exceeds the phase-error bound passes parameter estimation, by the Chernoff bound for the X test [41]. bounds the probability that a corrected key differing from Alice’s raw key passes verification for a uniformly random verification seed. This holds for every input, so is not multiplied by . The deviation , the smoothing parameter and the privacy-amplification error are chosen in the analysis.
Lean: componentAcceptProbability_le_exp_neg_mul_klBer
The bound holds provided that , , and are positive, that
and that the final key length obeys
Lean: isSecure_of_bellRenyiConditions
The key-length condition (22) starts from the entropy of the raw key at the phase-error bound, with the binary entropy in bits, and subtracts, in turn, the public leakage of the syndrome and the tag, the postselection charge, the finite-size penalty and the hashing cost; the leftover-hash lemma [30] [4], as required by Ref. [6, Eq. (11)]. The arises because bounds a trace distance, half of a trace norm. The finite-size penalty
Lean: renyiPenalty
bounds how far the smooth min-entropy of the raw key can fall below times its per-round von Neumann entropy. § 1.4.A shows where each term comes from, the first through the variance cap .
The parameters , , and are free and trade the error against the key length. A larger deviation between the window edge and the phase-error bound lowers but raises . The condition keeps increasing up to the bound, so every input covered by it has entropy at least per round. Smaller and lower the error but raise and , and balances the terms of within the range of Ref. [32, Cor. IV.2].
Robustness
Theorem 2 bounds the abort probability of Sec. III.B on an honest channel, which is the robustness of Ref. [5].
Theorem 2 (robustness of BB84). Let a memoryless channel without an eavesdropper deliver , where in matching bases the two-qubit state gives uniform outcome bits that disagree with probability , the quantum bit error rate (QBER). Let Bob’s corrected key differ from Alice’s raw key with probability at most , for every raw key of Alice’s, when his raw key differs from hers by independent bit flips with probability . Let the quotas and of matched rounds required by selection, the matched-basis probabilities and the window satisfy
Then
where the relative-entropy Chernoff bounds [41, Thm. 2.1
and Cor. 4.1]
bound the probabilities that a quota is not met and that a test block leaves the window.
Lean: one_sub_abortBound_le_acceptProbability
Proposition 4 in Appendix A gives a translation-equivariant error-correction scheme with this property, a linear syndrome of slightly more than bits, so Theorems 1 and 2 hold for the same protocol.
A tighter finite-key bound from the pipeline
This section describes the origin of the key length of Theorem 1. Its finite-size penalty rests on a new inequality, found with the pipeline of Sec. II: a bound on the conditional-entropy variance of classical–quantum states that improves that of Ref. [32] (Sec. V.A).
Variance bound and finite-size penalty
Let be a normalized classical–quantum state, with of dimension and arbitrary finite-dimensional quantum side information . Its conditional-entropy variance [32 Defs. III.1–III.2], in bits squared, is:
where is the marginal on and each logarithm is taken on its support.
Theorem 3 (conditional-entropy variance). Every such state satisfies
Lean: condVariance_le_logb_sq
This improves the bound of Ref. [32 Cor. III.5] for every . For a binary key it gives the cap used by Theorem 1,
Lean: condVariance_le_logb_sq_of_card_eq_two
in place of , both in bits squared.
Proof sketch. Write and in eigenbases. The Nussbaum–Szkoła weights and [32] are a probability distribution and a nonnegative weight function with , and is the variance under of the log-likelihood ratio . It satisfies , with the inverse on the support, because . It also satisfies . With the shift these bounds give . Let , so that . Every real satisfies
where is read as 2 when . Since the mean minimizes the mean squared deviation, taking and averaging under gives
where the last step uses . Dividing by gives (28).
For a binary key and independent rounds, the finite-size penalty bounds the gap between , with , and the smooth min-entropy that the leftover-hash lemma turns into key: for every ,
Lean: le_smoothMinEntropy_tensorPower_renyiPenalty
To see where the variance enters, split the gap at the Petz conditional Rényi entropy , with the negative power on the support:
with the arguments dropped. The first bracket is bounded by the conversion from Rényi to smooth min-entropy [31 Prop. 6.5 and Eqs. (6.91)–(6.92)], and the second by the continuity bound of Ref. [32 Lemma IV.1], with given in Ref. [32 Cor. IV.2]. Theorem 3 then caps by , and .
Discussion and Outlook
We used an AI-assisted proof pipeline to connect a typed LOCC description of BB84 to an end-to-end composable-security theorem. With the same pipeline we found a tighter bound on the conditional-entropy variance, which reduces the finite-size penalty in the key length of Theorem 1 (Sec. V).
The formalization also made hidden assumptions in the literature explicit. Let us give two examples, the proof of the postselection theorem of Ref. [8] restricts the diamond norm to density-operator inputs, which requires the map to preserve Hermiticity. This condition holds for the differences of channels to which the theorem is applied, and the formal statement assumes it. Likewise, the continuity bound of Ref. [32 Lemma IV.1] holds when the support of lies in that of , a condition its statement leaves implicit and the formal statement adds.
Several components of this development can also be used independently of BB84. These include quantum leftover hashing [30] [4] with its public seed retained in the security comparison, smooth-entropy bounds for classical–quantum tensor-power states derived from conditional Rényi entropy, and the postselection reduction of Ref. [8].
Lean: traceDistanceGen_output_le_of_le_smoothMinEntropyOpt
A new protocol would supply its own program and parameter estimation and reuse these results. Since the protocol language allows any finite set of parties, it could also describe protocols beyond key distribution, such as secure computation and digital signatures [42] or multiparty deep learning [43], each with its own security definition.
The library can be extended in several directions. To represent prepare-and-measure protocols directly, the protocol language could be extended to describe quantum transmission followed by LOCC processing. A more specialized protocol type could also enforce the measurement and subsequent classical-processing stages by construction, while security and robustness would remain properties to prove. Formal security proofs of optical QKD with decoy states [44, 45, 46] would additionally require suitable source, loss, and detector models. The same protocol definitions could support security proofs based on entropy accumulation [47] or uncertainty relations [48], allowing their assumptions and finite-size guarantees to be compared.
Several of the formal results above were written by the open-weight GLM-5.3-Flash model of Sec. II, run locally through loopy under the direction of Claude Opus 5. GLM worked on the generalization of Theorem 1 to a free privacy-amplification error, Rényi offset and deviation, and the relative-entropy tails of Theorem 2 and Proposition 4. The frontier model edited loopy prompts to tune the tasks of GLM, and Claude and GPT reviewed its PRs before they were merged into the library. GLM had Lean language-server tools but no shell. We hope to develop theorem proving with open-weight models further, through well-tuned harnesses and reinforcement learning.
Acknowledgments
We wish to thank Shlok Nahar, Devashish Tupkary, Uri Kol, Winston Yin, and Benjy Firester for useful discussions.
K.S. acknowledges support from the European Union’s Horizon Europe research and innovation programme under the Marie Skłodowska-Curie grant agreement No. 101202109. The research of M.B.S. is supported by the Knut and Alice Wallenberg Foundation, Grant KAW 2023.0490. J.M. acknowledges support from the MITRE Quantum Moonshot program, and the MIT Kalanıyot fellowship.
An admissible decoder
An error-correction scheme with syndrome map and decoder is translation-equivariant if for every bit string there is a permutation of the syndrome values with and for all raw keys and , where is bit-wise addition modulo 2.
Lean: IsTranslationEquivariant
Proposition 4 (an admissible decoder). Let , and let a decoding radius and a number of extra syndrome bits, both natural numbers, and a relative radius satisfy
Then there is a translation-equivariant error-correction scheme with an -bit syndrome that meets the decoding hypothesis of Theorem 2 at QBER with
Lean: exists_decodesWhp_of_entropy_le
The two terms bound the probabilities that more than errors occur [41 Thm. 2.1] and that another error pattern of weight at most has the same syndrome. The scheme is a linear syndrome with coset decoding, shown to exist by averaging over all binary linear syndrome maps; the proposition provides neither an explicit code nor an efficient decoder.
Glossary of formal definitions
Table I collects the main formal objects of the development and the Lean identifiers that realize them. It lists definitions only, grouped into the standard quantum-information primitives, the LOCC program language of Sec. III, and the security notions built on them. The identifiers match the names used in the text. An audit of the dependencies of the theorems of Secs. IV and § 1.4 finds only the standard axioms propext, Classical.choice and Quot.sound.
| Symbol / term | Lean identifier | Meaning |
| Operators and channels (standard quantum information) | ||
Op | Operators on a party’s finite register; the complex matrices on . | |
IsChannel | Predicate that a linear map is completely positive and trace-preserving, i.e. a quantum channel. | |
diamondNorm | Diamond norm over a same-dimension reference ; half the diamond norm of the difference of two channels is the largest trace distance between their outputs. | |
traceDistance | Trace distance between states. | |
fidelity | Fidelity between states (squared form fidelitySq). | |
| LOCC program language | ||
MultipartiteSystem | Local register bases of a multipartite quantum system. | |
| instrument | Instrument | Quantum instrument on one party’s register [28 Sec. II]. |
| private action | PrivateAction | Local action whose classical outcome is kept private. |
| announced action | AnnouncedAction | Local action that publicly announces a coarse-graining of its outcome. |
| then | PrivateAction.then | Sequences an action with its continuation (announced analogue AnnouncedAction.then). |
Program | An LOCC protocol as a tree of private and announced actions, constructible only by composing local actions. | |
Boundary | The public transcripts and the output space of each branch, computed from the program. | |
Exit | The set of complete public histories, one for each branch; Transcript is the transcript register of a fixed list of alphabets. | |
| denote | denote | Compiles a program into its channel, composing the branch Kraus maps and exposing announcements to Eve. |
| Security and classicality | ||
real | The real channel determined by the protocol. | |
ideal | , where replaces both key registers with a single fresh uniform string (so the keys are equal, uniform, and independent of Eve) and leaves the transcript, other registers, and aborting runs unchanged. | |
| key label | KeyEnd | Label carried by each done of a QKD program: abort, or accept with the part of Alice’s and Bob’s final registers that holds the -bit key. |
| -security | IsSecure | Composable full-interface security: the accepted keys are classical and , comparing the real and ideal channels jointly over both keys, the transcript, and Eve’s reference. |
| honest-classical | IsHonestClassical | Every local action preserves diagonality on Alice’s and Bob’s registers, along every branch. |
Table I. Glossary of the main formal definitions. Symbol or term, the Lean identifier that realizes it, and its meaning. is a party’s finite register, , are states, a linear map, and a reference system.
References
References
- [5]C. Portmann and R. Renner, Security in quantum cryptography, Reviews of Modern Physics 94, 025008 (2022).DOI
- [6]S. Nahar, D. Tupkary, Y. Zhao, N. Lütkenhaus, and E. Y.-Z. Tan, Postselection Technique for Optical Quantum Key Distribution with Improved Definition of Finite Reductions, PRX Quantum 5, 040315 (2024).DOI
- [7]P. Belzig, Studying Stabilizer de Finetti Theorems and Possible Applications in Quantum Information Processing (2024), master’s thesis, University of Cologne (2020), arXiv:2403.10592 [quant-ph].
- [8]M. Christandl, R. König, and R. Renner, Postselection Technique for Quantum Channels with Applications to Quantum Cryptography, Physical Review Letters 102, 020504 (2009).pubmed.ncbi.nlm.nih.gov/19257257
- [9]D. Tupkary, E. Y.-Z. Tan, S. Nahar, L. Kamin, and N. Lütkenhaus, Security proofs for practical QKD: Variations, gaps, and limitations, Reviews of Modern Physics 98, 035003 (2026).DOI
- [10]C. H. Bennett and G. Brassard, Quantum cryptography: Public key distribution and coin tossing, in Proceedings of the IEEE International Conference on Computers, Systems, and Signal Processing (1984) p. 175.
- [11]D. Tupkary, S. Nahar, A. Arqand, E. Y. Z. Tan, and N. Lütkenhaus, A rigorous and complete security proof of decoy-state BB84 quantum key distribution (2026), arXiv:2601.18035 [quant-ph].arxiv.org/abs/2601.18035
- [12]A. Mizutani, T. Sasaki, and G. Kato, Protocol-level description and self-contained security proof of decoy-state BB84 QKD protocol (2025), arXiv:2504.20417 [quant-ph].arxiv.org/abs/2504.20417
- [13]L. d. Moura and S. Ullrich, The Lean 4 Theorem Prover and Programming Language, in Automated Deduction – CADE 28 (Springer International Publishing, 2021) pp. 625–635.DOI
- [14]G. Barthe, B. Grégoire, S. Heraud, and S. Z. Béguelin, Computer-Aided Security Proofs for the Working Cryptographer, in Advances in Cryptology – CRYPTO 2011 (Springer Berlin Heidelberg, 2011) pp. 71–90.DOI
- [15]D. A. Basin, A. Lochbihler, and S. R. Sefidgar, CryptHOL: Game-Based Proofs in Higher-Order Logic, Journal of Cryptology 33, 494 (2020).
- [16]J. Boender, F. Kammüller, and R. Nagarajan, Formalization of Quantum Protocols using Coq, Electronic Proceedings in Theoretical Computer Science 195, 71 (2015).DOI
- [17]K. Hietala, R. Rand, S.-H. Hung, X. Wu, and M. Hicks, A verified optimizer for Quantum circuits, Proceedings of the ACM on Programming Languages 5, 1 (2021).
- [18]Y. Peng, K. Hietala, R. Tao, L. Li, R. Rand, M. Hicks, and X. Wu, A formally certified end-to-end implementation of Shor’s factorization algorithm, Proceedings of the National Academy of Sciences 120, e2218775120 (2023).DOI
- [19]L. Zhou, G. Barthe, P.-Y. Strub, J. Liu, and M. Ying, CoqQ: Foundational Verification of Quantum Programs, Proceedings of the ACM on Programming Languages 7, 833 (2023).arxiv.org/abs/2207.11350
- [20]A. Bordg, H. Lachnitt, and Y. He, Certified Quantum Computation in Isabelle/HOL, Journal of Automated Reasoning 65, 691 (2021).
- [21]C. Chareton, S. Bardin, D. Lee, B. Valiron, R. Vilmart, and Z. Xu, Formal Methods for Quantum Programs: A Survey (2022), arXiv:2109.06493 [cs.PL].arxiv.org/abs/2109.06493
- [22]R. Nagarajan, N. Papanikolaou, G. Bowen, and S. Gay, An Automated Analysis of the Security of Quantum Key Distribution (2005), arXiv:cs/0502048 [cs.CR].DOI
- [23]T. Kubota, Y. Kakutani, G. Kato, Y. Kawano, and H. Sakurada, Semi-automated verification of security proofs of quantum cryptographic protocols, Journal of Symbolic Computation 73, 192 (2016).DOI
- [24]B. Breen, M. Del Tredici, J. McCarran, J. Aspuru Mijares, W. W. Yin, K. Sulimany, J. M. Taylor, F. H. L. Koppens, and D. Englund, Ax-Prover: a deep reasoning agentic framework for theorem proving in mathematics and quantum physics, Machine Learning: Science and Technology 7, 045073 (2026).
- [25]Anthropic, Formalizing Fermat’s Last Theorem (2026), 4 September 2026; Lean formalization: https://github.com/anthropics/fermats-last-theorem.
- [26]OpenAI, Finite time blowup for Navier–Stokes (2026), 8 September 2026; Lean formalization: https://github.com/openai/NavierStokesAndEuler.hub.valency.io/works/W_u44zqgpa
- [27]The mathlib Community, The lean mathematical library, in Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs, POPL ’20 (ACM, 2020) pp. 367–381.DOI
- [28]E. Chitambar, D. Leung, M. Ozols, and A. Winter, Everything You Always Wanted to Know About LOCC (But Were Afraid to Ask), Communications in Mathematical Physics 328, 303 (2014).
- [29]P. W. Shor and J. Preskill, Simple Proof of Security of the BB84 Quantum Key Distribution Protocol, Physical Review Letters 85, 441 (2000).DOI
- [30]R. RENNER, SECURITY OF QUANTUM KEY DISTRIBUTION, International Journal of Quantum Information 06, 1 (2008).
- [31]M. Tomamichel, Quantum Information Processing with Finite Resources: Mathematical Foundations, Springer-Briefs in Mathematical Physics, Vol. 5 (Springer International Publishing, 2016).
- [32]F. Dupuis and O. Fawzi, Entropy Accumulation With Improved Second-Order Term, IEEE Transactions on Information Theory 65, 7596 (2019).DOI
- [33]J. Watrous, The Theory of Quantum Information (Cambridge University Press, 2018).DOI
- [34]U. Kol, M. Ben-Shahar, K. Sulimany, and D. Englund, A Machine-Verified Proof of a Quantum-Optimization Conjecture (2026), arXiv:2606.29687 [quant-ph].arxiv.org/abs/2606.29687
- [35]A. Meiburg, L. A. Z. Hesse, and R. Soldati, A Formalization of the Generalized Quantum Stein’s Lemma in Lean (2025), lean library: https://github.com/Timeroot/Lean-QuantumInfo, arXiv:2510.08672 [quant-ph].arxiv.org/abs/2510.08672
- [36]J. Tooby-Smith, HepLean: Digitalising high energy physics, Computer Physics Communications 308, 109457 (2025), lean library: https://github.com/leanprover-community/physlib.
- [37]Quantum error correction (), lean-QEC, https://github.com/VerifiedQCL/Lean-QEC; lean-qec-sslp, https://github.com/LionSR/lean-qec-sslp; QEC-CLean, https://github.com/Stavan-Jain/QECLLean.
- [38]Quantum algorithms, circuits, and simulation (), lean-Quantum, https://github.com/QnQWIRE/LeanQuantum; QLean, https://github.com/Paul-Lez/QLean; Lean-QuantumAlg, https://github.com/QudeLeap/Lean-QuantumAlg; QCLib, https://github.com/QuCompLean/QCLib; Quantum4Lean, https://github.com/Alektronnik/Quantum4Lean; QuantSem, https://github.com/Carson-9/QuantSem; Algolean, https://github.com/Shreyas4991/Algolean; MerLean, https://github.com/doctor6/MerLean-examples.
- [39]Foundations of quantum mechanics ( ), lean-quantum, https://github.com/Hayata-Yamasaki-Group/lean-quantum; Spectra, https://github.com/adambor/lean-Spectra; lean4-quantum, https://github.com/quest2180/lean4-quantum.
- [40]Z.ai, GLM-5.3-Flash: Frontier intelligence, flash cost (2026), 26 August 2026.
- [41]W. Mulzer, Five Proofs of Chernoff’s Bound with Applications (2019), arXiv:1801.03365 [cs.DM].arxiv.org/abs/1801.03365
- [42]M. Bozzio, C. Crépeau, P. Wallden, and P. Walth er, Quantum cryptography beyond key distribution: Theory and experiment, Reviews of Modern Physics 97, 045006 (2025).DOI
- [43]K. Sulimany, S. K. Vadlamani, R. Hamerly, P. Iyengar, and D. Englund, Quantum-Secure Multiparty Deep Learning, Physical Review X 15, 041056 (2025).DOI
- [44]W.-Y. Hwang, Quantum Key Distribution with High Loss: Toward Global Secure Communication, Physical Review Letters 91, 057901 (2003).pubmed.ncbi.nlm.nih.gov/12906634
- [45]H.-K. Lo, X. Ma, and K. Chen, Decoy State Quantum Key Distribution, Physical Review Letters 94, 230504 (2005).
- [46]X. Ma, B. Qi, J. Zhao, and H.-K. Lo, Practical decoy state for quantum key distribution, Physical Review A 72, 012326 (2005).DOI
- [47]F. Dupuis, O. Fawzi, and R. Renner, Entropy Accumulation, Communications in Mathematical Physics 379, 867 (2020).DOI
- [48]M. Tomamichel, C. C. W. Lim, N. Gisin, and R. Renner, Tight finite-key analysis for quantum cryptography, Nature Communications 3, 634 (2012).DOI

