Linear Lambda-Calculus is Linear

We prove a linearity theorem for an extension of linear logic with addition and multiplication by a scalar: the proofs of some propositions in this logic are linear in the algebraic sense. This work is part of a wider research program that aims at defining a logic whose proof language is a quantum programming language. 2012 ACM Subject Classification Theory of computation → Proof theory; Theory of computation → Lambda calculus; Theory of computation → Linear logic; Theory of computation → Quantum computation theory


Introduction
The name of linear logic [10] suggests that this logic has some relation with the algebraic notion of linearity.A common account of this relation is that a proof of a linear implication between two propositions A and B should not be any function mapping proofs of A to proofs of B, but a linear one.This idea has been fruitfully exploited to build models of linear logic (for example [3,9,11]), but it seems difficult to even formulate it within the proof language itself.Indeed, expressing the properties f (u + v) = f (u) + f (v) and f (a.u) = a.f (u) requires an addition and a multiplication by a scalar, that are usually not present in proof languages.
The situation has changed with quantum programming languages [1,2,4,6,8,12,14] and the algebraic λ-calculus [13], that mix some usual constructions of programming languages with algebraic operations.More specifically, several extensions of the lambda-calculus, or of a language of proof-terms, with addition and multiplication by a scalar have been proposed [2,5,13].
In this paper, we investigate an extension of linear logic with addition and multiplication by a scalar, the L S -logic (where S denotes the field of scalars used), and we prove a linearity theorem: if f is a proof of an implication between two propositions of some specific form, then f (u + v) = f (u) + f (v) and f (a.u) = a.f (u).

Interstitial rules
To extend linear logic with addition and multiplication by a scalar, we proceed, like in [5, long version], in two steps: we first add interstitial rules and then scalars.
An interstitial rule is a deduction rule whose premises are identical to its conclusion.In the L S -logic, we consider two such rules Adding these rules permits to build proofs that cannot be reduced, because the introduction rule of some connective and its elimination rule are separated by an interstitial rule, for example Reducing such a proof, sometimes called a commuting cut, requires reduction rules to commute the rule sum either with the elimination rule below or with the introduction rules above.
As the commutation with the introduction rules above is not always possible, for example in the proof the commutation with the elimination rule below is often preferred.In this paper, we favour the commutation of the interstitial rules with the introduction rules, rather than with the elimination rules, whenever it is possible, that is for all connectives except the disjunction.For example, the proof Such a commutation yields a stronger introduction property for the considered connective.
For coherence, we commute both rules sum and prod with the elimination rule of the disjunction, rather that with its introduction rules.But, for the rule prod, both choices are possible.

Scalars
We then consider a field S of scalars and replace the introduction rule of the connective ⊤ with a family of rules ⊤-i(a), one for each scalar, and the rule prod with a family of rules prod(a), also one for each scalar

The connective ⊙
Besides interstitial rules and scalars, we have introduced, in [5, long version], a new connective ⊙ (read "sup" for "superposition"), that has an introduction rule ⊙-i similar to that of the conjunction, two elimination rules ⊙-e1 and ⊙-e2 similar to those of the conjunction, but also a third elimination rule ⊙-e similar to that of the disjunction.
The elimination rules ⊙-e1 and ⊙-e2 are used to express the information-preserving, reversible, and deterministic operations, such as the unitary transformations of quantum computing.The elimination rule ⊙-e is used to express the information-erasing, non-reversible, and non-deterministic operations, such as quantum measurement.We will come back to this full system at Section 6.1 (the ⊙ rules are listed at Figure 4).
Starting from propositional logic with the interstitial rules sum and prod, we can thus either add scalars, or the connective ⊙, or both.This yields the four logics on the right face of the cube of Figure 1: PL is propositional logic with the interstitial rules sum and prod, PL S is propositional logic with the interstitial rules and scalars, ⊙ is propositional logic with the interstitial rules and the connective ⊙, and ⊙ S is propositional logic with the interstitial rules, the connective ⊙, and scalars.

Linearity
The proof language of the ⊙ S -logic is a quantum programming language, as quantum algorithms can be expressed in it.However, this language addresses the question of quantum measurement, but not the that of linearity, and non-linear functions, such as cloning operators, can also be expressed in it.
This leads to introduce, in this paper, a linear variant of the ⊙ S -logic, and prove a linearity theorem for it.
More generally, we can introduce, on the left face of the cube of Figure 1, a linear variant for each of the four logics of the right face: L is linear logic with the interstitial rules sum and prod, L S is linear logic with the interstitial rules and scalars, L⊙ is linear logic with the interstitial rules and the connective ⊙, and L⊙ S is linear logic with the interstitial rules, the connective ⊙, and scalars.
Our goal is to prove a linearity theorem for the proof language of the L⊙ S -logic.But such a theorem does not hold for the full L⊙ S -logic, that contains the rule ⊙-e, that enables to express measurement operators, which are not linear.Thus, our linearity theorem should concern the fragment of the L⊙ S -logic without this rule.But, if ⊙-e rule is excluded, the connective ⊙ is just the conjunction, and this fragment of the L⊙ S -logic is the L S -logic.
So, for a greater generality, we prove our linearity theorem for the L S -logic: linear logic with the interstitial rules and scalars, but without the ⊙ connective, and discuss, at the end of the paper, how this result extends to the L⊙ S -logic.

Linear connectives
In the L S -logic, we have to make a choice of connectives.
In intuitionistic linear logic, there is no multiplicative falsehood, no additive implication, and no multiplicative disjunction.Thus, we have two possible truths and two possible conjunctions, but only one possible falsehood, implication, and disjunction.
In the L S -logic, we have chosen a multiplicative truth, an additive falsehood, a multiplicative implication, an additive conjunction, and an additive disjunction.The rule sum also is additive.The reasons for this choice of connectives will be justified in Remarks 2.1, 5.1, and 5.2.
These symbols are often written 1, 0, ⊸, &, and ⊕.As we use only one conjunction, one disjunction, etc., to make our paper more accessible to readers who are not familiar with linear logic (and also because we have several zeros, for scalars, vectors, etc.), we use the usual symbols ⊤, ⊥, ⇒, ∧, and ∨ instead.Of course, notations are arbitrary and the notations of linear logic can also be used.
The introduction rule for the additive conjunction is the same as that in usual natural deduction In particular, the proofs of A and B are in the same context Γ.But, in the elimination rule the proof of A ∧ B and that of C must be in contexts Γ and ∆, A.

21:5
x The deduction rules of the L S -calculus.
In this paper, we first define the L S -logic and its proof-language: the L S -calculus, and prove that it verifies the subject reduction, confluence, termination, and introduction properties (Section 2).We then show how the vectors of S n can be expressed in this calculus and how the irreducible closed proofs of some propositions are equipped with a structure of vector space (Section 3).We prove that all linear functions from S m to S n can be expressed as proofs of an implication between such propositions (Section 4).We then prove the main result of this paper: that, conversely, all the proofs of implications between such propositions are linear (Section 5).Finally, we show how this result extents to the proof language of the L⊙ S -logic and how this language is a quantum programming language (Section 6).
Most proofs are omitted from this conference paper, they can be found in its long version.

The L S -calculus
Let S be a field of scalars, for instance Q, R, or C. The propositions of the L S -logic are those of propositional logic The proof-terms of this logic are where a is a scalar.
The variables x express the proofs built with the rule axiom, the terms t + u those built with the rule sum, the terms a • t those built with the family of rules prod(a), the terms a.⋆ those built with the family of rules ⊤-i(a), the terms δ ⊤ (t, u) those built with the rule ⊤-e, the terms δ ⊥ (t) those built with the rule ⊥-e, the terms λx.t those built with the rule ⇒-i, the terms t u those built with the rule ⇒-e, the terms ⟨t, u⟩ those built with the rule ∧-i, The reduction rules of the L S -calculus.
The α-equivalence relation and the free and bound variables of a proof-term are defined as usual.Proof-terms are defined modulo α-equivalence.A proof-term is closed if it contains no free variables.We write (u/x)t for the substitution of u for x in t and if F V (t) ⊆ {x}, we also use the notation t{u}.
The typing rules are those of Figure 2.These typing rules are exactly deduction rules of linear natural deduction for the multiplicative truth, the additive falsehood, the multiplicative implication, the additive conjunction, and the additive disjunction, with proof-terms, with two differences: the interstitial rules and the scalars.
The reduction rules are those of Figure 3.As usual, the reduction relation is written −→, its inverse ←−, its reflexive-transitive closure −→ * , the reflexive-transitive closure of its inverse * ←−, and its reflexive-symmetric-transitive closure ≡.The first six rules correspond to the reduction of cuts on the connectives ⊤, ⇒, ∧, and ∨.The eight others enable to commute the interstitial rules sum and prod with the introduction rules of the connectives ⊤, ⇒, and ∧, and with the elimination rule of the connective ∨.For instance, the rule ⟨t, u⟩ + ⟨v, w⟩ −→ ⟨t + v, u + w⟩ pushes the symbol + inside the pair.In a calculus without scalars we would have the zero-ary commutation rules In the rules with scalars the scalars are added in the first case and multiplied in the second Γ, but Γ 1 and Γ ′ 1 could be different, and we would not be able to type t + v.This is the justification for the choice of the additive disjunction in the L S -calculus and the exclusion of the multiplicative one.This remark is also key in the subject reduction proof below.
The L S -calculus has the subject reduction, confluence, termination, and introduction properties.The subject reduction property is non trivial as shown by the remark above, but its proof uses standard methods.The termination property and the introduction properties are consequences of the termination and of the introduction properties of the ⊙ S -calculus.The full proofs are given in the long version of the paper.

▶ Theorem 2.5 (Introduction). Let t be a closed irreducible proof of A.
If A has the form ⊤, then t has the form a.⋆.

Vectors
As there is one rule ⊤-i for each scalar a, there is one closed irreducible proof a.⋆ for each scalar a.Thus, the closed irreducible proofs a.⋆ of ⊤ are in one-to-one correspondence with the elements of S. Therefore, the proofs ⟨a.⋆, b.⋆⟩ of ⊤ ∧ ⊤ are in one-to-one with the elements of S 2 , the proofs ⟨⟨a.⋆, b.⋆⟩, c.⋆⟩ of (⊤ ∧ ⊤) ∧ ⊤, and also the proofs ⟨a.⋆, ⟨b.⋆, c.⋆⟩⟩ of ⊤ ∧ (⊤ ∧ ⊤), are in one-to-one correspondence with the elements of S 3 , etc. Thus, as any vector space of finite dimension n is isomorphic to S n , we have a way to express the vectors of any S-vector space of finite dimension.Yet, choosing an isomorphism between a vector space and S n amounts to choosing a basis in this vector space, thus the expression of a vector depends on the choice of a basis.This situation is analogous to that of matrix formalisms.Matrices can represent vectors and linear functions, but the matrix representation is restricted to finite dimensional vector spaces, and the representation of a vector depends on the choice of a basis.A change of basis in the vector space is reflected by the use of a transformation matrix.
▶ Definition 3.1 (The set V).The set V is inductively defined as follows: ⊤ ∈ V, and if A and B are in V, then so is A ∧ B.
We now show that if A ∈ V, then the set of closed irreducible proofs of A has a vector space structure.

(Additive inverse). If A ∈ V, and t is a proof of A, we define the proof −t of A by induction on
▶ Lemma 3.4.If A ∈ V and t, t 1 , t 2 , and t 3 are closed proofs of A, then

(Dimension of a propositon in V). To each proposition A ∈ V, we associate a positive natural number d(A), which is the number of occurrences of the symbol
If A ∈ V and d(A) = n, then the closed normal proofs of A and the vectors of S n are in one-to-one correspondence: to each closed irreducible proof t of A, we associate a vector t of S n and to each vector u of S n , we associate a closed irreducible proof u A of A.
▶ Definition 3.6 (One-to-one correspondance).Let A ∈ V with d(A) = n.To each closed irreducible proof t of A, we associate a vector t of S n as follows.
We let t be the vector with two blocks u and v: t = u v .
To each vector u of S n , we associate a closed irreducible proof u A of A.
let n 1 and n 2 be the dimensions of A 1 and A 2 .Let u 1 and u 2 be the two blocks of u of n 1 and n 2 lines, so u = ( u1 u2 ).We let We extend the definition of t to any closed proof of A, t is by definition t ′ where t ′ is the irreducible form of t.
The next lemmas show that the symbol + expresses the sum of vectors and the symbol •, the product of a vector by a scalar.
▶ Lemma 3.7 (Sum of two vectors).Let A ∈ V, and u and v be two closed proofs of A. Then, ▶ Lemma 3.8 (Product of a vector by a scalar).Let A ∈ V and u be a closed proof of A. Then a • u = au.▶ Remark 3.9.We have seen that the rules come from the rules of a calculus without scalars that are commutation rules between the interstitial rules, sum and prod, and introduction rules ⊤-i and ∧-i.Now, these rules appear to be also vector calculation rules.

Matrices
We now want to prove that if A, B ∈ V with d(A) = m and d(B) = n, and F is a linear function from S m to S n , then there exists a closed proof f of A ⇒ B such that, for all vectors u ∈ S m , f u A = F (u).This can equivalently be formulated as the fact that if M is a matrix with m columns and n lines, then there exists a closed proof f of A ⇒ B such that for all vectors u ∈ S m , f u A = M u.This theorem has been proved for the ⊙ S -calculus in [5, long version].The proof of the following theorem is just a check that the construction given there verifies the linearity constraints of the L S -calculus.

▶ Theorem 4.1 (Matrices). Let A, B ∈ V with d(A) = m and d(B)
= n and let M be a matrix with m columns and n lines, then there exists a closed proof t of A ⇒ B such that, for all vectors u ∈ S m , t u A = M u.

Proof. By induction on A.
If A = ⊤, then M is a matrix of one column and n lines.Hence, it is also a vector of n lines.We take Let u ∈ S 1 , u has the form ( a ) and u A = a.⋆.Then, using Lemma 3.8, we have Let M 1 and M 2 be the two blocks of M of m 1 and m 2 columns, so M = ( M1 M2 ).By induction hypothesis, there exist closed proofs t 1 and t 2 of the propositions A 1 ⇒ B and A 2 ⇒ B such that, for all vectors u 1 ∈ S m1 and u 2 ∈ S m2 , we have t 1 u 1 A1 = M 1 u 1 and t 2 u 2 A2 = M 2 u 2 .We take Let u ∈ S m , and u 1 and u 2 be the two blocks of m 1 and m 2 lines of u, so u = ( u1 u2 ), and In the proofs δ ⊤ (x, M B ), δ 1 ∧ (x, y.(t 1 y), and δ 2 ∧ (x, z.(t 2 z)), the variable x occurs in one argument of the symbols δ ⊤ , δ 1 ∧ , and δ 2 ∧ , but not in the other.In contrast, in the proof δ 1 ∧ (x, y.(t 1 y)) + δ 2 ∧ (x, z.(t 2 z)), it occurs in both arguments of the symbol +.Thus, these proofs are well-typed in the system of Figure 2.
∧ (⟨t, u⟩, x.v) −→ (u/x)v were introduced as cut reduction rules.Now, these rules appear to be also matrix calculation rules.

21:10 Linear Lambda-Calculus is Linear
And applying the rules of Figure 3, we get

Linearity
We now prove the converse: if A, B ∈ V, then each proof t of A ⇒ B expresses a linear function, that is A first idea could be to generalize this statement and prove that these properties hold for all closed proofs t, whatever their type.But this generalization is too strong.For example, if and these two irreducible proofs are different.So we will prove that these properties hold when A is arbitrary and B ∈ V.
▶ Remark 5.1.The fact that we want all proofs of ⊤ ⇒ ⊤ to be linear functions from S to S explains why the symbol ⊤ must be multiplicative.If it were additive, the proposition ▶ Remark 5.2.The fact that we want all proofs of ⊤ ⇒ ⊤ to be linear functions from S to S explains why the rule sum must be additive.If it were multiplicative, the proposition ⊤ ⇒ ⊤ would have the proof g = λx.(x + 1.⋆) that is not linear as g (1.⋆ + 1.⋆) −→ * 3.⋆ ̸ ≡ 4.⋆ * ←− (g 1.⋆) + (g 1.⋆).

Size of a proof
The proof of the linearity theorem proceeds by induction on the size of the proof, and the first part of this proof is the definition of such a size function µ.Our goal could be to build a size function such that if t is proof of B in a context Γ, x : A and u is a proof of A, then µ((u/x)t) = µ(t) + µ(u).This would be the case, for the usual notion of size, if x had exactly one occurrence in t.But, due to additive connectives, the variable x may have zero, one, or several occurrences in t.First, as the rule ⊥-e is additive, it may happen that δ ⊥ (t) is a proof in the context Γ, x : A, and x has no occurrence in t.Thus, we lower our expectations to µ((u/x)t) ≤ µ(t) + µ(u), which is sufficient for the linearity theorem.
Then, as the rules +, ∧-i, and ∨-e rules are additive, if u + v is proof of B in a context Γ, x : A, x may occur both in u and in v.And the same holds for the proofs ⟨u, v⟩, and δ ∨ (t, x.u, y.v).In these cases, we modify the definition of the size function and take µ(t + u) = 1 + max(µ(t), µ(u)), instead of µ(t + u) = 1 + µ(t) + µ(u), etc. making the function µ a mix between a size function and a depth function.Note that the depth function itself cannot be used, as Lemma 5.8 does not hold for the depth function.
This leads to the following definition.
As a corollary, we get a similar size preservation theorem for reduction.

Elimination contexts
The second part of the proof is a standard generalization of the notion of head variable.In the we can decompose a term t as a sequence of applications t = u v 1 . . .v n , with terms v 1 , . . ., v n and a term u, which is not an application.Then u may either be a variable, in which case it is the head variable of the term, or an abstraction.
In a similar way, any proof in the L S -calculus can be decomposed into a sequence of elimination rules, forming an elimination context, and a proof u that is either a variable, an introduction, a sum, or a product.

▶ Definition 5.7 (Elimination context). An elimination context is a proof with a single free variable, written _, that is in the language
where u is a closed proof, F V (r) ⊆ {x}, and F V (s) ⊆ {y}.
In the case of elimination contexts, Lemma 5.4 can be strengthened.
Note that in Example 5.5, (_/x)t is not a context as _ does not occur in it.
▶ Lemma 5.9 (Decomposition of a proof).If t is an irreducible proof such that x : C ⊢ t : A, then there exist an elimination context K, a proof u, and a proposition B such that _ : B ⊢ K : A, x : C ⊢ u : B, u is either the variable x, an introduction, a sum, or a product, and t = K{u}.
A final lemma shows that, in the same way we can always decompose a non-empty list into a smaller list and its last element, we can always decompose an elimination context K different from _ into an elimination context K 1 and a last elimination rule K 2 .

Linearity
We now have the tools to prove the linearity theorem.Instead of proving the theorem for a closed proof t of A ⇒ B, it is more convenient to prove it for a proof t of B in the context x : A. The result for the proofs of A ⇒ B is Corollary 5.12.
▶ Theorem 5.11 (Linearity).For every proposition A, proposition B ∈ V, proofs t, u 1 , and u 2 , such that x : A ⊢ t : B, t is irreducible, ⊢ u 1 : A, and ⊢ u 2 : A. Then Proof (Sketch).The proof proceeds by induction on the size µ(t) of the proof t, but the organization of the cases is complex.We first consider the different forms for t: it can be a variable, a sum, a product, an introduction, or an elimination.If it is an introduction, as B ∈ V, it must be a pair.The key point here is that taking B ∈ V, we avoid the case of the abstraction that would lead to a failure, as show by the counter-example above.
The case where t is an elimination leads to a second case analysis.We first use Lemma 5.9 to decompose the proof t into an elimination context K and a proof v. Then we consider the different possible forms of v: it can be neither an introduction nor an elimination, hence it is a variable, a sum, or a product.
Finally, in the case it is a variable, we have a third case analysis: we use Lemma 5.10 to decompose K into a context K ′ and a last elimination rule and we consider the different possible cases for this last elimination rule.
In all these cases, we use various cases of the Lemma 3.4 to prove the convertibility of the proofs, and the Lemmas 5.4, 5.6, and 5.8 to show that the induction hypothesis applies to smaller proofs.◀ ▶ Corollary 5.12.Let A be a proposition and B ∈ V. Let t be a closed proof of A ⇒ B and u and v be closed proofs of A. Then The deduction rules of the L⊙ S -calculus.
Indeed, applying Corollary 5.12 with the proof λx (s (t x)), we obtain that the first proof is convertible with (s (t 1.⋆)) + (s (t 2.⋆)) and applying it to s we obtain that the second is convertible with this same proof.
▶ Corollary 5.14.Let A, B ∈ V, such that d(A) = m and d(B) = n, and t be a closed proof of A ⇒ B. Then the function F from S m to S n , defined as F (u) = t u A is linear.

No-cloning
In the PL S -calculus, that is in the proof language of propositional logic extended with interstitial rules and scalars, the cloning function from S 2 to S 4 , mapping ( a b ) to λx.δThis proof cannot be expressed in L S -calculus, as it uses twice an elimination symbol of the conjunction with the variable x occurring in both arguments.Moreover, by Corollary 5.14, this function cannot be expressed as a proof of the proposition (⊤ ∧ ⊤) ⇒ ((⊤ ∧ ⊤) ∧ (⊤ ∧ ⊤)) in the L S -calculus, because it is not linear.

6
The L⊙ S -calculus and its application to quantum computing

The L⊙ S -calculus
The L⊙ S -calculus is obtained by adding the symbols [, ], δ 1 ⊙ , δ 2 ⊙ , δ ⊙ , the deduction rules of Figure 4, and the reduction rules of Figure 5, to the L S -calculus.It is similar to the ⊙ S -calculus [5, long version] except that its typing rules are linear.

Quantum computing
Like the ⊙ C -calculus, the L⊙ C -calculus, with a reduction strategy restricting the reduction of δ ⊙ ([t, u], x.v, y.w) to the cases where t and u are closed irreducible proofs, can be used to express quantum algorithms.The following reproduces the Section 4 of [5, long version], focusing on the differences due to linearity.

F S C D 2 0 2 2
If n is a non-zero natural number, we can define the measurement operator π n , measuring the first qubit of an n-qubit, as the proof , such that ∥t∥ 2 = ∥u 1 ∥ 2 + ∥u 2 ∥ 2 ̸ = 0, expressing the state of an n-qubit, then the proof π n t of the proposition Q n reduces, with probabilities Note that, as the L⊙ S -calculus is purely linear, it cannot express the measurement operator λx.δ ⊙ (x, y.0, z.1) that returns the "classical" result of the measure and that could be expressed in the ⊙ S -calculus.Typing this measurement operator would require to extend the type system to express that, in the premises ∆, A ⊢ C and ∆, B ⊢ C of the rule ⊙-e, the hypotheses A and B may be weakened.
Instead, our measurement operators return the state of the full system after the measure.In the first case, this state is a linear combination of the first 2 n−1 vectors |00 . . .0⟩ . . .|01 . . .1⟩ of the basis: those starting with a 0, in the second, this state is a linear combination of the last 2 n−1 vectors |10 . . .0⟩ . . .|11 . . .1⟩ of the basis: those starting with a 1.In the first case, the result of the measurement is |0⟩, in the second it is |1⟩.
As we have a representation of linear functions and measurement operators, we can express in the L⊙ S -calculus, all quantum algorithms, for instance Deutsch's algorithm.

Linearity
The main motivation for introducing this linear variant of the ⊙ C -calculus was to prove a linearity theorem for this calculus.But, the L⊙ C -calculus contains the δ ⊙ symbol, that enables to express measurement operators, which are not linear.
Thus, our linearity theorem should be that using the δ ⊙ symbol is the only way to construct a non-linear function.In other words, that, in the fragment of the L⊙ S -calculus excluding the δ ⊙ symbol, only linear functions can be expressed.But, if ⊙-e rule is excluded, ⊙ is just another conjunction, and this fragment of the L⊙ S -logic is the L S -logic with two copies of the conjunction.As a corollary of the Corollary 5.14, only linear functions can be expressed in this calculus and cloning cannot.

Conclusion
We can now attempt a possible answer to the question stated in the introduction: in which way must propositional logic be extended or restricted, so that its proof language becomes a quantum programming language.This answer is in four parts: we need to extend it with interstitial rules, scalars, and the connective ⊙, and we need to restrict it by making it linear.We obtain this way the L⊙ S -logic that addresses both the question of linearity and, for instance, avoids cloning, and that of the information-erasure, non-reversibility, and non-determinism of the measurement.
Another issue is to restrict the logic further so that linear functions are unitary.We can either enforce unitarity, following the methods of [1,6,7], or let these unitarity constraints as properties of the program that must be proved for each program, rather than enforced by the type system.