arXiv:2608.29380cs.LOAug 2026

Manuscript Offprint

arXiv:2608.29380

A quantum let within the lambda calculus

Alejandro Díaz-Caro, Tomás Miguez

Alejandro Díaz-Caro 1,2^{1,2} and Tomás Miguez 3,∗^{3,*}

1^{1} Université de Lorraine, CNRS, Inria, LORIA, F-54000 Nancy, France

2^{2} InCo, FIng, Universidad de la República, Colonia del Sacramento, Uruguay

adiazcaro@fing.edu.uy

3^{3} DC, FCEN, Universidad de Buenos Aires, CABA, Argentina

tomasmiguez99@gmail.com

Abstract. Since the seminal work of Selinger and Valiron, the standard design for quantum lambda calculi has kept the quantum state outside the program: terms manipulate pointers to an external register. This is largely due to the difficulty of eliminating tensor products. For example, the calculus λρ∘\lambda_{\rho}^{\circ} embeds density matrices directly within terms, where terms carry the entire computation state, a feature particularly appealing for program verification. However, lacking a tensor elimination construct, it can neither access the individual qubits of a compound state nor discard them. Borgna showed that this inability to discard qubits makes the calculus strictly less expressive than the quantum lambda calculus of Selinger and Valiron.

In this paper we show that tensor elimination is possible in this setting. The key observation is that the Pauli decomposition, combined with the spectral decomposition of the Pauli matrices, allows any n-qubit density matrix to be expressed as a real linear combination of tensor products of single-qubit density matrices. Exploiting this fact, we extend λρ∘\lambda_{\rho}^{\circ} with a construct let x⊗n=ρx^{\otimes n} = \rho in tt, which binds each xix_i to a single-qubit density matrix arising from the decomposition of ρ\rho.

We equip the extended calculus with a rewrite system, a type system, and a denotational semantics, and prove Subject Reduction, Progress, Strong Normalisation, Soundness, and Adequacy. The new construct also recovers the missing ability to discard qubits, thereby restoring expressiveness. Moreover, we show that this is achieved in a physically principled way: a variable unused in t is interpreted exactly as being partial-traced out, as dictated by the no-deleting theorem. We illustrate the resulting compositionality through quantum teleportation and the three-qubit bit-flip code.

Keywords: Quantum lambda calculus · Lambda calculus · Classical control.

1 Introduction

Quantum programming languages provide a hardware-independent, high-level description of quantum algorithms. Since the seminal work of Selinger and Valiron [13], the standard design for higher-order quantum languages has followed

∗^{*} This paper is based on the second's author Master's thesis [10].

A. Díaz-Caro and T. Miguez

the quantum data / classical control paradigm: the quantum state is kept in an external register, while terms manipulate names (pointers) to the qubits stored in it. This design sidesteps the problem of decomposing entangled compound states within the language itself. By contrast, calculi that represent quantum states directly as terms must confront this problem explicitly.

Another line of quantum lambda calculi takes a different route, embedding the computation state directly as a constant within terms, instead of keeping it in an external store. Reasoning in such calculi more directly reflects the evolution of the computation state, which makes them especially appealing for program verification [2]: since a term carries its entire computation state, program equivalences can be established by reasoning within the calculus itself, rather than about configurations of an external store. One such calculus is λρ∘\lambda_{\rho}^{\circ} [5], which uses density matrices to represent states as part of terms.

This internal-state approach has recently been used as the basis for an expectation-based analysis of higher-order quantum programs [2]. That work considers a derivative calculus using vectors instead of density matrices and adding recursion, among other extensions, and exploits its similarities with a probabilistic classical language [1]. In that setting, the calculus serves as an intermediate language: a higher-order quantum program can be compiled into it, and the analysis can then be performed there.

The need for such an intermediate-language role is partly due to a limitation of λρ∘\lambda_{\rho}^{\circ} and its derivative calculi: they lack a tensor elimination construct, or let-tensor. As a consequence, although compound quantum states can be represented, they cannot be decomposed within the language itself. The difficulty is not specific to λρ∘\lambda_{\rho}^{\circ}: being unable to split the state of a multi-qubit system into its components, precisely because of entanglement, is a limitation shared by other calculi for quantum computation, such as those of Hasuo and Hoshino [8] and Delbecque [4]. This affects compositionality. A single quantum computation can still be expressed by encoding operations directly at the matrix level, so the language can still serve its purpose as an intermediate language. However, the individual qubits of a compound state cannot be addressed independently.

Consider a concrete scenario: given a two-qubit state ρ\rho, suppose that we want to apply a function ff to the first qubit and a function gg to the second qubit independently. In λρ∘\lambda_{\rho}^{\circ}, there is no way to express this as f(x1)f(x_1) and g(x2)g(x_2), where x1x_1 and x2x_2 are the individual qubits of ρ\rho. One must instead encode the operation at the matrix level, using an operator such as Uf⊗UgU_f \otimes U_g applied to the whole state, losing the modularity that lambda calculi are designed to provide.

This limitation also has an expressiveness-level counterpart. Since λρ∘\lambda_{\rho}^{\circ} provides no mechanism for decomposing a state, it also provides no mechanism for discarding qubits. Borgna [3] showed that, as a consequence, some quantum computations cannot be directly encoded in it.

In this paper we present an extension of λρ∘\lambda_{\rho}^{\circ} that addresses both concerns. It provides compositional access to the individual qubits of a state and, through affine discard (an affine type system being one that admits weakening but not contraction), recovers the ability to discard qubits, thereby restoring expres-siveness. Moreover, the resulting notion of discard is shown to coincide exactly with the partial trace, yielding a physically meaningful interpretation of affine weakening.

The key observation is that combining the Pauli decomposition of density matrices with the spectral decomposition of the Pauli matrices [11] allows any n-qubit density matrix to be expressed as a real linear combination of tensor products of single-qubit density matrices. We exploit this fact to extend λρ∘\lambda_{\rho}^{\circ} with a construct let x⊗n=ρx^{\otimes n} = \rho in t that binds the individual qubit components of a compound state within a body, so that programs may operate on them in an algebraically coherent way.

Contributions. We make the following contributions.

  1. A compositional let construct. We extend λρ∘\lambda_{\rho}^{\circ} with a construct let x⊗n=ρx^{\otimes n} = \rho in tt that binds the variables x1,…,xnx_1, \ldots, x_n to the single-qubit density matrices arising from the decomposition of ρ\rho within the body tt. The decomposition is obtained by combining the Pauli decomposition with the spectral decomposition of the Pauli matrices: the state ρ\rho is expressed as a weighted sum of tensor products of single-qubit density matrices, and the body tt is evaluated for each such tensor product, weighted accordingly.

  2. A denotational semantics. We provide a denotational semantics for the extended calculus, interpreting the new let construct through the corresponding decomposition of density matrices.

  3. Metatheoretical properties. We prove Subject Reduction, Progress, Strong Normalisation, Soundness, and Adequacy for the extended calculus. We also prove the central result specific to this extension: discard coincides with partial trace. This establishes that the let construct is faithful to the no-deleting theorem.

  4. Illustrative examples. We implement quantum teleportation and the three-qubit bit-flip error correction code in the extended calculus. Both examples demonstrate how the let construct enables compositional programming over multi-qubit states, including the separation of roles in teleportation and ancilla management in error correction. Throughout the paper, we also use the Bell state as a running example: we exhibit its Pauli and combined decompositions and use it to show how discarding a qubit computes the partial trace.