1 Introduction
1.1 Definitions and notation
Let us start by defining the setup we will be considering, which is the standard framework in mathematical physics for describing (finite) spin lattice models. We denote by $\Lambda (L):=\{1,\ldots ,L\}^2$ the set of vertices (referred to as sites) of a square lattice of side $L\in \mathbb {N}$ , with $L\ge 2$ . ${{\mathcal {E}}}\subset \Lambda (L)\times \Lambda (L)$ will denote the set of directed edges of the square lattice, oriented so that $(i,j)\in \mathcal{E}$ implies that j lies north or east of i. We will consider both periodic and open boundary conditions. In the first case, the outer rows and columns are also connected along the same direction, so that $\Lambda (L)$ becomes a square lattice on a torus. In the second case, these connections are not present.
We associate to each site $i\in \Lambda (L)$ a Hilbert space , and to any subset $S\subseteq \Lambda (L)$ the tensor product $\bigotimes _{i\in S} {\mathcal {H}}^{(i)}$ . The interactions between neighbouring pairs $(i,j)\in \mathcal{E}$ are given by Hermitian operators $h^{(i,j)}\in {\mathcal {B}}({\mathcal {H}}^{(i)}\otimes {\mathcal {H}}^{(j)})$ . In addition, we may assign an onsite interaction given by a Hermitian matrix $h_1^{(k)}\in {\mathcal {B}}({\mathcal {H}}^{(k)})$ to each site $k\in \Lambda (L)$ .
We will restrict in this paper to models that are built up from such nearestneighbour and possibly onsite terms in a translationally invariant way. That is, when identifying the isomorphic Hilbert spaces on which they act, $h_1^{(k)}=h_1^{(l)}$ for all $k,l\in \Lambda (L)$ , and $h^{(i',j')}=h^{(i,j)}$ whenever there is a $v\in \mathbb {Z}^2$ such that $(i',j')=(i+v,j+v)$ . The total Hamiltonian for the system is then defined as
It is fully described for any system size L by three Hermitian matrices: a $d\times d$ matrix $h_1$ and two $d^2\times d^2$ matrices $h_{\text {row}}$ and $h_{\text {col}}$ , which define the interactions between neighbouring sites within any row and column respectively. Hence, it may alternatively be written as
$\max \{\h_{\text {row}}\, \h_{\text {col}}\, \h_1\\}$ is called the local interaction strength of the Hamiltonian and can be normalised to be $1$ .
The set of eigenvalues, or energy levels, of the Hamiltonian $H^{\Lambda (L)}$ will be denoted by . When the Hamiltonian is clear from context, we will sometimes omit it and just write $\{\lambda _0,\lambda _1,\dots \}$ . They are always assumed to be listed in nondecreasing order $\lambda _0\leq \lambda _1\leq \ldots $ . The smallest eigenvalue $\lambda _0(H^{\Lambda (L)})$ is called the ground state energy and the corresponding eigenvectors ground states. The ground state energy density is defined as
It is not difficult to show [Reference Anderson22] that this limit is well defined.
$H^{\Lambda (L)}$ is called frustrationfree if its ground state energy is zero while all $h^{(i,j)},h_1^{(k)}$ are positive semidefinite. That is, a ground state of a frustrationfree Hamiltonian minimises the energy of each interaction term individually. $H^{\Lambda (L)}$ is called classical if its defining interactions $h^{(i,j)},h_1^{(k)}$ are diagonal in a given product basis (e.g. the canonical one).
We can define now the main quantity under study: the spectral gap
In this paper we are considering the behaviour of $\Delta (H^{\Lambda (L)})$ in the thermodynamic limit, that is, when $L\rightarrow \infty $ . For that, we introduce the following definitions:
Definition 1 (Gapped)
We say that a family $\{H^{\Lambda (L)}\}$ of Hamiltonians, as described above, characterises a gapped system if there is a constant $\gamma>0$ and a system size $L_0$ such that for all $L>L_0$ , $\lambda _0(H^{\Lambda (L)})$ is nondegenerate and $\Delta (H^{\Lambda (L)})\geq \gamma $ . In this case, we say that the spectral gap is at least $\gamma $ .
Definition 2 (Gapless)
We say that a family $\{H^{\Lambda (L)}\}$ of Hamiltonians, as described above, characterises a gapless system if there is a constant $c>0$ such that for all $\varepsilon>0$ there is an $L_0\in \mathbb {N}$ so that for all $L>L_0$ any point in $[\lambda _0(H^{\Lambda (L)}),\lambda _0(H^{\Lambda (L)})+c]$ is within distance $\varepsilon $ from .
Note that gapped is not defined as the negation of gapless; there are systems that fall into neither class. The reason for choosing such strong definitions is to deliberately avoid ambiguous cases (such as systems with degenerate ground states). Our constructions will allow us to use these strong definitions, because we are able to guarantee that each instance falls into one of the two classes. Indeed, we could further strengthen the definition of gapless without changing our undecidability results or their proofs, below, by demanding that $c=c(L)$ grows with L so that $\lim _{L\rightarrow \infty }c(L)=\infty $ .
The ideas and techniques for the proof will mainly come from quantum information theory. We therefore use notation standard to that field, such as Dirac’s notation for linear algebra operations. A summary of all the relevant standard notation can be found, for example, in Chapter 2 of the classic book of Nielsen and Chuang [Reference Cubitt, Gu, Perales, PerezGarcia and Wolf62].
1.2 Main results
For each natural number n, we define $\varphi =\varphi (n)$ to be the rational number whose binary fraction expansion consists of the digits of n in reverse order after the decimal point. We also fix throughout a specific Universal Turing Machine, denoted by UTM.
Theorem 3 (Main theorem)
For any given universal Turing Machine UTM, we can construct explicitly a dimension d, $d^2\times d^2$ matrices $A,A',B,C,D,D'$ a $d\times d$ diagonal projector $\Pi $ and a rational number $\beta $ which can be as small as desired, with the following properties:

(i) A is diagonal with entries in .

(ii) $A'$ is Hermitian with entries in ,

(iii) $B,C$ have integer entries,

(iv) D is diagonal with entries in ,

(v) $D'$ is hermitian with entries in .
For each natural number n, define:
where $\alpha (n)\le \beta $ is an algebraic number computable from n. Then:

(i) The local interaction strength is bounded by 1, i.e. $\max ({\lVert {h_1(n)}\rVert }, {\lVert {h_{\text {row}}(n)}\rVert }, {\lVert {h_{\text {col}}(n)}\rVert }) \leq 1$ .

(ii) If UTM halts on input n, then the associated family of Hamiltonians $\{H^{\Lambda (L)}(n)\}$ is gapped in the strong sense of Definition 1 and, moreover, the gap $\gamma \ge 1$ .

(iii) If UTM does not halt on input n, then the associated family of Hamiltonians $\{H^{\Lambda (L)}(n)\}$ is gapless in the strong sense of Definition 2.
Some comments are in order:

• Using the classic result of Turing [Reference FernándezGonzález, Schuch, Wolf, Cirac and PérezGarcía72] that the Halting Problem for UTM on input n is undecidable, we can conclude that the spectral gap problem is also undecidable.

• The interaction terms in the Hamiltonians given in the Theorem are $\beta $ perturbations of the classical Hamiltonian given by $h_{\text {row}}=A,h_{\text {col}}=D$ . Since $\beta $ can be taken as small as desired, all interactions appearing in the Theorem are arbitrarily small quantum perturbations of a classical system.

• The only dependency on n in the interactions appears in some prefactors to a set of fixed interactions.

• In the gapped case, the size of the gap is larger than or equal to the local interaction strength, hence is as large as possible.

• It is straightforward (if tedious) to extract an explicit value for d in Theorem 3 and Corollary 4 from the construction described in this paper.

• By exploiting the well known connection between (algorithmic) undecidability and (axiomatic) independence (see e.g. [Reference Oliveira and Terhal68]) one immediately obtains the following corollary:
Corollary 4 (Axiomatic independence of the spectral gap)
Let $d\in \mathbb {N}$ be a sufficiently large constant. For any consistent formal system with a recursive set of axioms, there exists a translationally invariant nearestneighbour Hamiltonian on a 2D lattice with local dimension d and algebraic entries for which neither the presence nor the absence of a spectral gap is provable from the axioms.
Moreover, as a key intermediate step in the proof of Theorem 3, we will prove that the ground state energy density problem is also undecidable, a result clearly interesting on its own.
Theorem 5 (Undecidability of g.s. energy density)
Let $d\in \mathbb {N}$ be sufficiently large but fixed. We can explicitly construct a oneparameter family of translationally invariant nearestneighbour Hamiltonians on a 2D square lattice with open boundary conditions, local Hilbert space dimension d, algebraic matrix entries, and local interaction strengths bounded by 1 for which determining whether $E_\rho =0$ or $E_\rho>0$ is an undecidable problem.
A short version of this paper – including a statement of the main result, discussion of its implications, an outline of the main ideas behind the proof, together with a sketch of the argument – was published recently in Nature [Reference Anderson22]. We encourage the reader to consult it in order to gain some highlevel intuition about the full, rigorous proof given in this work.
1.3 Relation to physics
As already discussed in [Reference Anderson22], this result has a number of implications for condensed matter and mathematical physics, that we briefly recall here.
Quantum spin lattice models are ubiquitous in mathematical physics. They play a central role in condensed matter physics, in quantum computation and even in high energy physics, where one route to formalising the continuum is to consider quantum many body systems on a lattice and later sending the lattice spacing to zero. In all these contexts, one often starts from a description of the microscopic interactions that govern the system. The question is then how to infer the relevant observable macroscopic properties that emerge as the lattice size (number of particles) tends to infinity.
The spectral gap is amongst the most important properties of a quantum manybody Hamiltonian. It is intimately related to the physics of a quantum manybody system. Quantum phase transitions can only occur at critical points where the gap vanishes. The intuitive reason is that the spectral gap “protects” the ground state properties of the system against small perturbations, since an energy of the order of the gap must be pumped into the system to transition to a different state. Formalising this intuition is a major open question. Recently Bravyi, Hastings and Michalakis [Reference Affleck, Kennedy, Lieb and Tasaki19] and Michalakis and Pytel [Reference Lloyd57] proved this for the particular case of frustrationfree systems satisfying certain additional conditions, by proving that the spectral gap of these systems is stable under arbitrary local perturbations throughout the system.
The lowtemperature behaviour of a system is also governed by the spectral gap: gapped systems exhibit “noncritical” behaviour, with lowenergy excitations that behave as massive particles [Reference Komar35], preventing longrange correlations [Reference Wang42, Reference Bausch, Cubitt and Watson61]; gapless systems exhibit “critical” behaviour, with lowenergy excitations that behave as massless particles, allowing longrange correlations. This implies that ground states of gapped systems are somehow less complex. That intuition has been formalised in the area law conjecture [Reference Yan, Huse and White26], which has been proven for 1D spin systems [Reference Domany and Kinzel39], and in 2D if certain additional hypothesis on the spectrum are satisfied [Reference Omohundro40]. This in turn translates into better algorithms for computing properties of such systems [Reference Bausch, Cubitt and Ozols65]. A paradigmatic example of this line of research is the recent proof [Reference Cubitt, Cirac, Wolf and PérezGarcía51, Reference Haegeman, Michalakis, Nachtergaele, Osborne, Schuch and Verstraete7], based on an improved version of the 1D area law theorem [Reference Michalakis and Pytel6], that the ground state energy density problem for gapped quantum spin systems in 1D is in the complexity class P (i.e. the runtime of the algorithm scales polynomially in the system size).
Because of its central importance to manybody quantum systems, many seminal results in mathematical physics concern the spectral gap of specific systems. Examples include the LiebSchultzMattis theorem showing that the Heisenberg chain for halfinteger spins is gapless [Reference Elkouss and PérezGarcía53], extended to higher dimensional bipartite lattices by Hastings [Reference Fredkin and Toffoli38], and the proof of a spectral gap for the 1D AKLT model [Reference Cubitt, PerezGarcia and Wolf1]. More recently, shortly after this work first appeared on preprint servers, Bravyi and Gosset gave a complete characterisation of the spectral gap for the simplest nontrivial case of 1D chains of spin $\tfrac {1}{2}$ particles (qubits) with frustrationfree, nearestneighbour interactions [Reference Hastings18]. (The frustrated case remains open.)
The same is true of some of the most important open questions in the field. For instance, the Haldane conjecture [Reference Anderson36], first formulated in 1983, states that the integerspin antiferromagnetic Heisenberg model in 1D has a nonvanishing spectral gap. Despite strong supporting evidence from numerical simulations, a proof remains elusive. The analogous question in 2D for nonbipartite lattices can be traced back to the work of Anderson in 1973 [Reference Bravyi, Hastings and Michalakis5], where he suggested the existence of new types of materials, nowadays called topological quantum spin liquids. The existence of minerals in nature, such as herbertsmithite, whose interactions can be well approximated by the spin $\frac {1}{2}$ antiferromagnetic Heisenberg model on the Kagome lattice – hence are compelling candidates for systems with a topological quantum spin liquid phase [Reference PourEl and Richards37] – brought the problem of its spectral gap to the forefront of physics. The existence of a spectral gap in these systems is an active area of research, with techniques reducing the spectral gap problem to finitevolume criteria very recently being applied successfully (partially numerically) to certain cases such as the honeycomb lattice [Reference Van den Nest and Briegel52, Reference Kempe, Kitaev and Regev67], whilst other cases remain disputed even at the level of numerical evidence (see e.g. [Reference Kozen76, Reference Kanter44]).
Undecidability of the spectral gap has a number of immediate corollaries relevant to physics. It implies that one can write down models whose phase diagrams are so complex they are in fact uncomputable. It implies the standard approach of trying to gain insight into physics models by solving numerically for larger and larger lattice sizes necessarily fails for some systems; the system can display all the features of a gapless model, with the gap of the finite system decreasing monotonically with increasing size. Then, at some threshold size, it may suddenly switch to having a large gap. (In Section 2 we also construct models exhibiting the opposite transition, from gapped to gapless.) Not only can the threshold size be arbitrarily large; the threshold size itself is an uncomputable number. In a recent paper [Reference Hastings11], we constructed very simple models with small local dimensions which exhibit this type of “sizedriven phase transition” (without, however, the undecidability properties proven here). Our findings also imply that a result showing robustness of the spectral gap under perturbations, as for the case of frustrationfree Hamiltonians [Reference Lloyd57] and for freefermion systems [Reference Lemm, Sandvik and Wang24, Reference Gu, Weedbrook, Perales and Nielsen41], cannot hold for general gapped systems.
Phase diagrams with infinitely many phases are known in quantum systems in connection with the quantum Hall effect, where fractal diagrams like the Hofstadter butterfly can be obtained [Reference Kitaev, Shen and Vyalyi66, Reference Berger43]. Since membership in many fractal sets is not decidable (when formulated in the framework of real computation; see [Reference Lieb, Schultz and Mattis17]), it would be interesting to see whether quantum Hall systems could provide a realworld manifestation of our findings.
Conjectures about the spectral gap, such as the Haldane conjecture, the 2D AKLT conjecture, or the YangMills mass gap conjecture in quantum field theory, implicitly assume that these questions can be answered one way or the other. Our results prove that the answer to the general spectral gap question is not determined by the axioms of mathematics. Whilst our results are still a long way from proving that any of these specific conjectures are axiomatically undecidable, they at least open the door to the possibility that these – or similar – questions about physical models may be provably unanswerable.
The idea that some of the most difficult open problems in physics could be mathematically proven to be impossible to solve is not new. Indeed, proving the impossibility of obtaining exact formulae for certain physical quantities in natural physical models is highlighted as one of the main open problems in mathematical physics in the list published by the International Association of Mathematical Physics in the late 90’s, edited by Aizenman [Reference Turing3]. Apart from the pioneering work of Komar in this direction in 1964 [Reference Morton and Biamonte49], stating undecidable properties in Quantum Field Theories, and the influential paper of Anderson entitled “More is different” [Reference Poonen and Kennedy4] in 1972, most of the initial connections between physical problems and undecidability arose in the 80s and 90s. In 1981, [Reference Aharonov, Gottesman, Irani and Kempe69] studied noncomputable solutions to the wave equation. One year later, [Reference Osadchy and Avron31] found undecidable questions in models of hard frictionless balls. In 1984, Wolfram wrote the paper “Undecidability and Intractability in Theoretical Physics” where, motivated by the emergent complexity of very simple cellular automata, he conjectured that many natural problems in physics, and in particular in classical statistical physics, should be undecidable. Many results in this direction – using cellular automata to prove undecidability results in physical problems – have been shown since then (e.g [Reference Pomata and Wei25] or [Reference Gottesman and Irani64]). The work of Gu, Weedbrook, Perales and Nielsen [Reference Aizenmann34] in 2009 found undecidable properties in the 2D classical Ising model. Besides cellular automata, another natural connection between undecidability and physics, that we will exploit in this paper, came from tiling problems, shown to be undecidable by the works of Wang and Berger in the 60s [Reference Robinson74, Reference Arad, Landau, Vazirani and Vidick15]. This idea has been exploited for instance in 1990 by Kanter [Reference Moore45], finding undecidable properties in anisotropic 1D Potts Hamiltonians. That same year, in a completely different direction, Moore wrote one of the most influential papers on undecidability in physics [Reference Cubitt, PerezGarcia and Wolf59], proving undecidability of the longterm behaviour of a particleinabox problem. (See also [Reference Landau, Vazirani and Vidick14] for a nice commentary on that paper.)
In recent years, mainly motivated by quantum information theory and the link it established between physics and computer science, there has been a revival of interest in undecidability in quantum physics. Results in this direction have appeared in several contexts, such as measurement and control [Reference Iqbal, Poilblanc and Becca27, Reference Yu75], tensor networks [Reference Bausch, Cubitt, Lucia and PerezGarcia60, Reference Wolf, Cubitt and PerezGarcia48, Reference Haldane21], measurementbased quantum computation [Reference Yedidia and Aronson73], channel capacities [Reference Bausch, Lucia, PerezGarcia and Wolf28], or Bell inequalities [Reference Hastings12, Reference Grünbaum and Shephard71].
A precursor of those results, due to Lloyd, appeared already in 1993 [Reference Bendersky, Senno, de la Torre, Figueira and Acin54, Reference Slofstra55] in the early days of quantum information theory. There, it is argued that quantum computing implies certain spectral properties of quantum mechanical operators are undecidable. More precisely, the unitary evolution U associated to the evolution of a computer (classical or quantum) capable of universal computation has invariant subspaces with discrete spectrum (roots of unity) and other invariant subspaces with continuous spectrum (the whole unit sphere), corresponding respectively to computations that halt and do not halt. Then, since the halting problem is undecidable, Lloyd concludes that given a quantum state associated with a program in the infinite dimensional space in which U is defined, it is undecidable to know whether it has overlap with an invariant subspace having discrete spectrum or, conversely, it is supported on an invariant subspace in which the spectrum is the full unit circle. See [Reference Lloyd56, Reference Han, Helton, Chu, Nocera, RodriguezRivera, Broholm and Lee23] for a recent discussion between the relation between Lloyd’s result and the result of this paper.
In subsequent followup work, we have extended the undecidability results described here to 1D systems [Reference Hastings and Koma8] and to uncomputability of phase diagrams [Reference Nachtergaele and Sims9], and have used insights from our undecidability results to construct simple, explicit examples of the new type of “sizedriven” phase transition implied by undecidability of the spectral gap [Reference Hastings11].
We refer to a forthcoming review paper in collaboration with Gu and Perales [Reference Bravyi and Gosset20] for an extensive analysis and discussion of all results mentioned above, and many more, related to undecidability in physics.
1.4 Brief overview of the proof
An extended overview and discussion of the ideas behind our proof can be found in the Supplementary Material of [Reference Anderson22]. We will simply sketch here the four main steps of the proof, whose rigorous statements and proofs are given, respectively, in Sections 3 to 6.
Step 1: write n on the tape.
In order to feed an arbitrary input to the UTM, and at the same time keep a uniform upper bound on the local dimension of the Hilbert space of each site in the final Hamiltonian, we need to construct a Quantum Turing Machine (QTM) with a fixed number of internal states such that, when fed with an input given by any sequence of 1’s larger than the size of n, writes n deterministically on the tape and halts. We need also to keep strict control on the time and space required for this computation. The precise result we prove along these lines is given in Theorem 10, and Section 3 is devoted to proving it. The idea is to construct explicitly the QTM associated to the quantum phase estimation algorithm. To do this, we rely heavily on results and ideas from [Reference Arad, Kitaev, Landau and Vazirani16].
Step 2: construct, for each , a 1D Hamiltonian whose ground state energy on a finite chain depends on the behaviour of the UTM on input n.
For this, we heavily rely on the remarkable paper of Gottesman and Irani [Reference Hofstadter32] (see also [Reference Eisert, Cramer and Plenio10]), which can be seen as a milestone in a long history of papers [Reference Eisert, Müller and Gogolin47, Reference Bennett46, Reference Bernstein and Vazirani63, Reference Nielsen and Chuang2], dating back to Feynman [Reference Hastings30], relating the ground state energy of a Hamiltonian with the timeevolution of a quantum computation. In order to achieve the desired properties of our construction, we have to modify the original construction of Gottesman and Irani, but most of the essential ideas of this step appear already in [Reference Hofstadter32].
After these two steps, we have for each a 1D translationally invariant Hamiltonian whose ground state energy for a chain of size L and open boundary conditions is $0$ if the UTM does not halt on n in space less than $O(L)$ and time less than $O(c^L)$ (for any desired constant c). Otherwise, it has energy larger than $c^{L}$ . So there the difference in ground state energy depending on the halting behaviour of the UTM on n vanishes exponentially fast with chain length, and is zero in the thermodynamic limit. Theorem 32 states the precise result we obtain, and Section 4 is devoted to its proof.
Step 3: amplify the ground state energy difference.
For this, we turn to 2D lattices, and exploit the properties of an aperiodic tiling of the 2D plane due to Robinson. The idea is to construct a Hamiltonian whose ground state mimics the tiling pattern of Robinson’s tiling shown in Figure 9 and, at the same time, places the ground state of the 1D Hamiltonian constructed in Step 2 on top of each of the 1D borders appearing in this pattern. Using the fact that there is a constant density of squares of size $4^r$ for all , and making a shift in energies, we manage to show for the resulting Hamiltonian that, if the UTM halts on n, the ground state energy diverges to $+\infty $ , whereas in the nonhalting case it diverges to $\infty $ . From there, we conclude undecidability of the ground state energy density. Section 5 takes care of proving all the new results we require for Robinson’s tiling. The rest of the proof, together with the final step, appears in Section 6.
Step 4: from ground state energy difference to spectral gap.
The final step combines the Hamiltonian $H_u$ constructed in Step 3 with two others: a trivial Hamiltonian having ground state energy $0$ and a constant spectral gap, and a critical Hamiltonian $H_d$ having ground state energy $0$ and a spectrum that becomes dense in $[0,\infty )$ as the system size goes to infinity. We couple these Hamiltonians in such a way that the spectrum of the resulting Hamiltonian on $\Lambda (L)$ is
with $S_L\ge \min \left \{1, 1+\lambda _0(H_u^{\Lambda (L)})\right \}$ . This, together with the spectral properties of $H_u$ shown in Step 3, completes the proof.
2 Unconstrained local Hilbert space dimension
Before starting in Section 3 on the proof of the main theorem, in this section we will describe two approaches that exploit known undecidability results for tiling and completion problems. Based on these, we can derive simpler but weaker undecidability results for the spectral gap and for other low energy properties of translationally invariant, nearestneighbour Hamiltonians on a 2D square lattice, defined by their local interactions $\{(h_{\text {row}}(n),h_{\text {col}}(n))\}_{n\in \mathbb {N}}$ . In contrast to the main theorem of this paper, however, the families of Hamiltonians that we construct here have local Hilbert space dimension $d_n$ that differs for different elements n of the family, with no upper bound on $\{d_n\}_{n\in \mathbb {N}}$ .
2.1 Undecidability of the spectral gap via tiling
As in the more sophisticated constructions that will appear later, the idea is to reduce an undecidable ground state energy problem to the spectral gap problem. If we do not constrain the local Hilbert space dimension, then this reduction can be chosen such that it directly exploits the undecidability of a tiling problem. To this end, we need two ingredients:
2.1.1 Ingredient 1: a tiling Hamiltonian
We start by recalling the notion of Wang tilings and tiling problems. A unit square whose edges are coloured with colours chosen from a finite set is called a Wang tile. A finite set $\mathcal {K}$ of Wang tiles is said to tile the plane $\mathbb {Z}^2$ if there is an assignment $\mathbb {Z}^2\rightarrow \mathcal {K}$ such that abutting edges of adjacent tiles have the same colour. (Rotations or reflections of the tiles are not allowed here.) It is a classic result of Berger [Reference Arad, Landau, Vazirani and Vidick15] that, given any set of tiles as input, determining whether or not this set can tile the plane is undecidable.
There is an easy way to rewrite any tiling problem as a ground state energy problem for a classical Hamiltonian. If $\mathcal {K}=\{1,\ldots ,K\}$ we assign a Hilbert space to each site i of a square lattice, and define the local interactions via
where the set of constraints $C^{(i,j)}\subseteq \mathcal {K}\times \mathcal {K}$ includes all pairs of tiles $(m,n)$ which are incompatible when placed on adjacent sites i and j. The overall Hamiltonian on the lattice $\Lambda (L)$ is then simply
By construction, we have $h_c^{(i,j)}\geq 0$ , $H_c^{\Lambda (L)}$ is translationally invariant and its spectrum is contained in $\mathbb {N}_0$ . If there exists a tiling of the plane, then for open boundary conditions . Similarly, in the case of periodic boundary conditions, the existence of a periodic tiling implies that holds for an unbounded sequence of L’s. On the other hand, if there is no tiling, then there is an $L_0$ such that
This is due to Wang’s extension theorem (see e.g. [Reference Blum, Smale, Hirsch, Marsden and Shub33]).
2.1.2 Ingredient 2: a gapless frustrationfree Hamiltonian
As a second ingredient we will use that there are frustrationfree twobody Hamiltonians
such that for $L\rightarrow \infty $ we get in the sense that the spectrum of the finite system approaches a dense subset of [Reference De Roeck and Salmhofer29]. We will denote the corresponding single site Hilbert space by and we can in fact choose $D=2$ for instance by assigning to each row of the lattice the XYmodel with transversal field taken at a gapless point with product ground state. Note that in this case the entries of the matrices $h_q^{(i,j)}$ are rational.
2.1.3 Reducing tiling to spectral gap
In order to fruitfully merge the ingredients, we assign a Hilbert space to each site $i\in \Lambda (L)$ . A corresponding orthonormal set of basis vectors will be denoted by and , respectively. The Hamiltonian is then defined in terms of the twobody interactions
Here and denote the identity operators on ${\mathcal {H}}_c,{\mathcal {H}}_q$ and ${\mathcal {H}}_c{\otimes }{\mathcal {H}}_q$ , respectively. As before, we define the Hamiltonian on the square lattice $\Lambda (L)$ as
Theorem 6 (Reducing tiling to spectral gap)
Consider any set $\mathcal {K}$ of Wang tiles, and the corresponding family of twobody Hamiltonians $\{H^{\Lambda (L)}\}_{L}$ on square lattices $\Lambda (L)$ either with open or with periodic boundary conditions.

(i) The family of Hamiltonians is frustrationfree.

(ii) If $\mathcal {K}$ tiles the plane $\mathbb {Z}^2$ , then in the case of open boundary conditions, we have that for $L\rightarrow \infty $ , i.e., there is no gap and the excitation spectrum becomes dense in . Similarly, if $\mathcal {K}$ tiles any torus, then in the case of periodic boundary conditions for a subsequence $L_i\rightarrow \infty $ .

(iii) If $\mathcal {K}$ does not tile the plane, then there is an $L_0$ such that for all $L>L_0 \ H^{\Lambda (L)}$ has a unique ground state and a spectral gap of size at least one, i.e.
(2.9)
Proof. Frustrationfreeness is evident since $H^{(i,j)}\geq 0$ and . In order to arrive at the other assertions, we decompose the Hamiltonian as $ H^{\Lambda (L)}=:H_0+H_c+H_q$ , where the three terms on the right are defined by taking the sum over edges separately for the expressions in (2.5), (2.6) and (2.7), respectively. Let us now assign a signature $\sigma \in \{0,\ldots ,K\}^{L^2}$ to every state of our computational product basis, in the following way: is assigned the signature $\sigma _i=0$ , and is assigned the signature $\sigma _i=k$ irrespective of $\alpha $ . By collecting computational basis states with the same signature we can then decompose the Hilbert space as
The Hamiltonian is blockdiagonal w.r.t. this decomposition, i.e. it can be written as
In order to identify the spectra coming from different signatures we will distinguish three cases:

(i) $\sigma =(0,\ldots ,0)$ : this yields an eigenvalue $0$ as already mentioned.

(ii) $\sigma \neq (0,\ldots ,0)$ but $\sigma _i=0$ for some i: for any unit vector with such a signature we have . We will denote the part of the spectrum which corresponds to these signatures by $S\subset \mathbb {R}$ . The only property we will use is that $S\geq 1$ .

(iii) $\sigma \in \{1,\ldots ,K\}^{L^2}$ : In the subspace spanned by all states whose signature does not contain $0$ we have that $H_0=0$ and . Consequently, the spectrum stemming from this subspace equals .
Putting things together, we obtain
The equivalence between the impossibility of tiling with $\mathcal {K}$ and the existence of a spectral gap of size at least 1 now follows immediately from the properties of the ingredients $h_c$ and $h_q$ . Uniqueness of the ground state in cases where no tiling exists follows from the above argument when considering the spectra as multisets rather than sets.
From the undecidability of the tiling problem we now obtain the following corollary. Recall from Section 1.1 that a pair of Hermitian matrices $(h_{\text {row}},h_{\text {col}})$ defines a Hamiltonian $H^{\Lambda (L)}$ for each square $\Lambda (L)$ via (1.2), where we are now choosing open boundary conditions.Footnote ^{1}
Corollary 7 (Undecidability of the spectral gap for unconstrained dimension)
Let $\epsilon>0$ . There is no algorithm that, on input $(h_{\text {row}},h_{\text {col}})$ with rational entries and operator norm smaller than $1+\epsilon $ , decides whether the associated family of Hamiltonians $\{H^{\Lambda (L)}\}$ describe a gapped or a gapless system (according to the definitions given in Section 1.1). This holds even under the promise that one of these is true, that $H^{\Lambda (L)}$ is frustration free for all $\Lambda $ , and that in the gapped case the spectral gap is at least 1.
Here, the norm bound follows from the observation that where $h_q^{(i,j)}$ can be rescaled to arbitrarily small norm.
For the case of periodic boundary conditions we obtain the same statement if we replace our strong definition of ‘gapless’ by the weaker requirement that $\exists c>0\; \forall \epsilon >0 \; \forall L_0 \; \exists L>L_0$ so that every point in $[\lambda _0(H^{\Lambda (L)}),\lambda _0(H^{\Lambda (L)})+c]$ is within distance $\epsilon $ from . The reason for this is, that if the period of the torus does not match the required one, then a gap can be generated that, however, disappears again if we enlarge the size of the system.
We emphasise that, so far, there is no constraint on the local Hilbert space dimension. Since every instance in the above construction has a finite local Hilbert space we can, however, at least conclude axiomatic undecidability for finite local Hilbert spaces. That is, for any given consistent formal system with a recursive set of axioms, one can construct a specific instance of a Hamiltonian with properties as in the corollary and finitedimensional local Hilbert space, such that neither the presence nor the absence of a spectral gap can be proven from the axioms.Footnote ^{2} . However, the local dimension, whilst finite, depends on the choice of axiomatic system and there is no upperbound on the values it can take. The main aim of this paper is to prove the much stronger Theorem 3, which shows that the spectral gap problem remains undecidable even for a fixed value of the local Hilbert space dimension. This in turn implies that for any consistent, recursive formal system, axiomatic independence holds for Hamiltonians with this fixed local dimension; the local dimension is now independent of the choice of axioms.
In the above construction, gapped cases are related to the impossibility of tiling. Since the latter always admits a proof, the axiomatically undecidable cases coming from this construction have to be gapless. The following section will provide a construction where this asymmetry is reversed.
2.2 Undecidability of low energy properties
2.2.1 Reducing tile completion to a ground state energy problem
We now modify the above construction in order to show that not only the spectral gap but many other low energy properties are undecidable as well. The idea is to invert the relation between gap and existence of tiling. In the previous construction, the existence of a gap was associated with the impossibility of a tiling. Now we want to associate it with the existence of a tiling. A drawback is that we loose the frustrationfree property. On the other hand, we do not have to rely on the undecidability of tiling (which is a rather nontrivial result [Reference Arad, Landau, Vazirani and Vidick15, Reference Feynman70]), but can exploit the simpler undecidability of the completion problem, already proven by Wang [Reference Robinson74]. In the tiling completion problem, one fixes a tile at the leftbottom corner and asks whether the first quadrant can be tiled.
Undecidability of the completion problem is relatively simple by reduction from the Halting Problem for Turing Machines (TM), and explained in full detail in Robinson [Reference Feynman70, Section 4]. There are many different, computationally equivalent definitions of Turing Machines. (The Halting Problem is undecidable for any of these variants.) For the completion problem, the most convenient is to take a Turing Machine to be specified by a finite number of states $Q=\{q_0, q_1,\ldots \}$ with $q_0$ the initial state, a finite alphabet of tape symbols $S=\{s_0,s_1,\ldots \}$ with $s_0$ the blank symbol, together with a finite set of transition rules specified by quintuples of the form
The TM has a halfinfinite tape of cells indexed by , and a single read/write tape head that moves along the tape. The machine starts in state $q_0$ with the head in tape cell 0. If the TM is currently in state q and reads the symbol s from the current tape cell, then it writes $s'$ into the current tape cell, transitions to state $q'$ , and moves in the direction D. For each $q,s$ , there must be at most one valid quintuplet. If there is none, then the machine halts.Footnote ^{3}
Following Robinson [Reference Feynman70], we use the Wang tiles shown in Figure 1. For clarity, edges here are marked with labelled arrows rather than colours, and adjacent edges match if arrow heads abut arrow tails with the same label; clearly these tile markings can be identified with different colours to recover a set of standard Wang tiles. We denote the set of tiles by $\mathcal {K}$ , which contains at most $K:=\mathcal {K}\leq 2+ (3Q+1)S$ elements.
If the tile that appears in the bottomleft corner in Figure 1, which we denote by , is fixed in the bottomleft corner of an $L\times L$ lattice, then any valid tiling corresponds to the evolution of the Turing Machine on the blank tape up to time L, where time goes up in the vertical direction and each row of tiles corresponds to the total configuration (including the tape) of the Turing machine in two consecutive instants of time (represented by the bottom and upper edges of that row of tiles). Hence,

(1) There exists a valid tile completion for all $L\times L$ squares if and only if the Turing Machine, when running on an initially blank tape, does not halt.

(2) If such a tiling exists, then it is unique.
Now, the completion problem can be represented as a ground state energy problem in the following straightforward way. Consider a square lattice $\Lambda (L)$ with open boundary conditions and corresponding edge set ${\mathcal {E}}$ .
Assign a weight $w_{(i,j)}(m,n)\in \mathbb {Z}$ to edge $(i,j)\in {\mathcal {E}}$ on which a pair of tiles $(m,n)\subseteq \mathcal {K}\times \mathcal {K}$ is placed. The choice of weights is summarised in the following table. Here stands for any tile different from , the unbracketed numbers define the weights for nonmatching adjacent tiles, and the numbers in brackets define the weights for cases where the tiles match (i.e. all abutting labels and arrows match).
Assign a Hilbert space ${\mathcal {H}}_u^{(i)}\simeq \mathbb {C}^{K}$ to each site $i\in \Lambda (L)$ whose computational basis states are labelled by tiles. We define a Hamiltonian $H_u^{\Lambda (L)}:=\sum _{(i,j)\in {\mathcal {E}}}h_u^{(i,j)},$ with
so that positive and negative weights become energy “penalties” or “bonuses” in the Hamiltonian. By construction, the Hamiltonian is diagonal in computational basis, its eigenvectors correspond to tile configurations $\Lambda (L)\rightarrow \mathcal {K}$ and, since all weights are integers, its spectrum lies in $\mathbb {Z}$ . In order to determine the ground state energy note that the tile is the only one that can lead to negative weights. Assume first that a tile is placed on a site different from the bottomleft corner. Then this tile will have at least one neighbour below with an arrow pointing upwards or one neighbour to the left with an arrow pointing to the right. In either case there will be an energy penalty $+4$ so that the weights involving this tile will sum up to at least $2$ . If, however, is placed in the bottomleft corner, then no such energy penalty is picked up and the tile can contribute $2$ to the energy.
If the tiling is then completed following the evolution of the encoded Turing machine on a blank tape, then no additional penalty will occur on $\Lambda (L)$ if the Turing machine does not halt within L timesteps. Hence $\lambda _0(H_u^{\Lambda (L)})=2$ , the ground state will be unique, and will be given by a product state. If the Turing machine halts, then the completion problem has no solution beyond some $L_0$ and every configuration with at its bottomleft corner will get an additional penalty of at least $2$ , leading to nonnegative energy. Since there is always a configuration that achieves zero energy (e.g. one using only the tile types at the topleft of Figure 1), we obtain:
Lemma 8 (Relating ground state energy to the halting problem)
Consider any Turing machine with state set Q and tape alphabet S running on an initially blank tape such that its head never moves left of the starting cell. There is a family of translationally invariant nearest neighbour Hamiltonians $\{H_u^{\Lambda (L)}\}_L$ (specified above) on the 2D square lattice with open boundary conditions and local Hilbert space dimension at most $S(3Q+1)+2$ such that

(i) If the Turing Machine does not halt within L timesteps, then $\lambda _0(H_u^{\Lambda (L)})=2$ . In this case the corresponding ground state is a product state, and is the unique eigenstate with negative energy.

(ii) If the Turing machine halts, then $\exists L_0$ (given by the halting time) such that $ \forall L>L_0:\lambda _0(H_u^{\Lambda (L)})= 0$ .
Since every Turing machine can be simulated by one with a halfinfinite tape, which automatically satisfies the constraint that its head never moves to the left of the origin, the above construction leads to an undecidable ground state energy problem, which we will exploit in the following.
2.2.2 Reduction of the halting problem to arbitrary low energy properties
Consider translationally invariant Hamiltonians on square lattices with open boundary conditions. Let $H_q^{\Lambda (L)}$ describe such a family of Hamiltonians on $L\times L$ lattices. Our aim is to prove the undecidability of essentially any low energy property displayed by this Hamiltonian in the thermodynamic limit that distinguishes it from a gapped system with unique product ground state, e.g. the existence of topological order, or nonvanishing correlation functions. This is implied by the following theorem:
Theorem 9 (Relating low energy properties to the halting problem)
Let TM be a Turing machine with state set Q and alphabet S running on an initially blank tape. Consider the class of translationally invariant Hamiltonians on square lattices with open boundary conditions. Let $H_q^{\Lambda (L)}$ with nearestneighbour interaction $h_q^{(i,j)}\in {\mathcal {B}}({\mathcal {H}}_q^{(i)}{\otimes }{\mathcal {H}}_q^{(j)})$ , ${\mathcal {H}}_q^{(i)}\simeq \mathbb {C}^q$ , and onsite term $h_{q1}^{(k)}\in {\mathcal {B}}({\mathcal {H}}_q^{(k)})$ describe such a Hamiltonian. Assume that there is a $c\in \mathbb {R}$ such that $\lambda _0\big(H_q^{\Lambda (L)}\big)cL^2\in [\frac 12,\frac 12]$ for all lattice sizes L. Then we can construct a family of Hamiltonians $H^{\Lambda (L)}$ with the following properties:

(i) $H^{\Lambda (L)}$ is translationally invariant on the square lattice with open boundary conditions and local Hilbert spaces ${\mathcal {H}}^{(i)}\simeq \mathbb {C}^d$ of dimension $d\leq 2(q+1)+S(3Q+1)$ .

(ii) The interactions of $H^{\Lambda (L)}$ are nearestneighbour (possibly with onsite terms), computable and independent of L.

(iii) If the TM does not halt within L timesteps, then $H^{\Lambda (L)}$ has a nondegenerate product ground state and a spectral gap $\Delta (H^{\Lambda (L)})\geq \frac 12$ .

(iv) If TM halts, then $\exists L_0$ (determined by the halting time) such that $\forall L>L_0$ the following identity between multisets holds in the interval $[0,\frac 12)$ :
(2.15)In this case there exist isometries $V^{(i)}:{\mathcal {H}}_q^{(i)}\rightarrow {\mathcal {H}}^{(i)}$ , $V:=\bigotimes _i V^{(i)}$ such that, for this part of the spectrum, any eigenstate of $H_q^{\Lambda (L)}$ is mapped to the corresponding eigenstate of $H^{\Lambda (L)}$ via .
Some remarks before the proof. Since, on the Turing machine level, (ii) and (iii) cannot be told apart by any effective algorithm, the same has to hold for any property that distinguishes a gapped system with product ground state from the low energy sector of some frustrationfree Hamiltonian. With small modifications in the proof, the nearest neighbour assumption for $h_q$ could be replaced by any fixed local interaction geometry. In this case, $H^{\Lambda (L)}$ will of course inherit this interaction geometry.
Proof. W.l.o.g. $c=0$ since we can always compensate for it by adding a multiple of the identity to the onsite part of the Hamiltonian.
We first embed the Hamiltonian given in the Theorem in a larger system, such that its ground state energy is shifted by $1$ . Define a translationally invariant, nearestneighbour Hamiltonian on an auxiliary system with local Hilbert space ${\mathcal {H}}_a^{(i)}\simeq \mathbb {C}^2$ , via
Note that this is nothing but $\frac 12 \times $ the Hamiltonian defined by (2.13) (with the number in brackets), where equals and is the blank tile. Hence $\lambda _0(\eta )=1$ and $\Delta (\eta )=1$ .
Now introduce ${\mathcal {H}}_Q^{(i)}:={\mathcal {H}}_a^{(i)}{\otimes }{\mathcal {H}}_q^{(i)}$ and set
acting on ${\mathcal {H}}_Q^{(i)}{\otimes }{\mathcal {H}}_Q^{(j)}$ . Then
has the property that in the interval $(\infty ,\lambda _0(H_q^{\Lambda (L)}))$ we have that
holds as an identity between multisets (i.e. including multiplicities) and the corresponding eigenstates are related via a local isometric embedding.
We now combine this with the Hamiltonian from the previous subsection by enlarging the local Hilbert space to ${\mathcal {H}}^{(i)}:={\mathcal {H}}_u^{(i)}\oplus {\mathcal {H}}_Q^{(i)}$ and defining
where $h_Q^{(i,j)}$ and $h_u^{(i,j)}$ act nontrivially on ${\mathcal {H}}^{(i)}_Q{\otimes } {\mathcal {H}}_Q^{(j)}$ and ${\mathcal {H}}_u^{(i)}{\otimes } {\mathcal {H}}_u^{(j)}$ respectively and and denote the projectors onto the respective subspaces. The Hamiltonian on the square $\Lambda (L)$ is now
To analyse the ground state of $H^{\Lambda (L)}$ , notice that all the terms in the Hamiltonian commute with each other. Let $\tilde {H}_q = \sum _{(i,j)\in {\mathcal {E}}} h_q^{(i,j)} + h_{q1}^{(i,j)}$ , , and . We can then decompose $H^{\Lambda (L)}=\tilde {H}_q + \tilde {H}_u + \tilde {H}_\eta $ where the three Hamiltonians commute with each other.
We now assign a signature $\sigma \in \{0,1,2\}^{L^2}$ to every state of our computational product basis, so that is identified with $\sigma _j\in \{0,1\}$ for all of the form and $\sigma _j=2$ for all . By collecting computational basis states with the same signature, we can then decompose the Hilbert space as
The Hamiltonian is block diagonal w.r.t. this decomposition, i.e. it can be written as
In order to identify the spectra and eigenstates coming from different signatures we will distinguish three cases:
Case 1:
$\sigma =(2,\ldots ,2)$ . Restricted to this sector (i.e. the ${\mathcal {H}}_\sigma $ component of the direct sum), the Hamiltonian acts as $H_u^{\Lambda (L)}=\sum _{(i,j)\in {\mathcal {E}}} h^{(i,j)}_u$ . But according to Lemma 8, if up to time L the TM did not halt, then $H_u^{\Lambda (L)}$ has one negative eigenvalue $2$ whose associated eigenstate is a product. However, if $L\ge L_0$ where $L_0$ is related to the halting time, then .
Case 2:
$\sigma _j=1$ for all $j\in \Lambda (L)$ , except in the lowest left corner, where $\sigma _j=0$ . In this sector we have the following identity between multisets:
Case 3:
Any other signature $\sigma $ . It is easy to see that the energy given by $\tilde {H}_\eta $ in the sector ${\mathcal {H}}_\sigma $ is exactly the energy given to the configuration $\sigma $ by the tiling Hamiltonian (2.14) with colours $\{0,1,2\}$ and weights given by the following tables from (2.13), hence the energy is $\ge 0$ .
Similarly, one can show that $\tilde {H}_u\ge 0$ . Therefore, in this Case 3, the energy of $H^{\Lambda (L)}$ in the sector ${\mathcal {H}}_\sigma $ is $\ge \lambda _0(H_q^{\Lambda (L)})$ . Theorem 9 now follows straightforwardly.
3 Quantum Phase Estimation Turing Machine
We will see in Section 4 how to encode an arbitrary Quantum Turing Machine (QTM) into a translationally invariant nearestneighbour Hamiltonian, in such a way that the local Hilbert space dimension is a function only of the alphabet size and number of internal states. This will allow us to encode any specific universal (reversible) Turing Machine in a Hamiltonian with fixed local dimension. However, to prove undecidability by reduction from the Halting Problem, we will need a way to feed any desired input to this universal TM.
To this end, the main result of this section is to construct a family of quantum Turing Machines, all of which have the same alphabet size and number of internal states, but whose transition rules vary. For any given $n\in \mathbb {N}$ , we can choose the transition rules such that the QTM, when started from a sequence of N ones (N any number larger than the number of bits $n$ in the binary representation of n) writes out the binary representation of n to its tape and then halts deterministically.
Given n, we recall from Section 1.2 that $\varphi =\varphi (n)$ is defined as the rational number whose binary fraction expansion contains the digits of n in reverse order after the decimal.Footnote ^{4}
The QTM that we construct will be based on the quantum phase estimation algorithm [Reference Miękisz78, Reference Cubitt, Gu, Perales, PerezGarcia and Wolf62], applied to the single qubit unitary $U_\varphi =\left (\begin {smallmatrix}1&0\\0&e^{i\pi \varphi }\end {smallmatrix}\right )$ , to obtain the phase $\varphi $ . The input N can be any upper bound on the number of binary digits in the output of the quantum phase estimation algorithm, such that $\varphi $ can be represented exactly as a binary fraction, with no approximation error. Note that the transition rules of the QTM are not allowed to depend on N, though they can depend on $\varphi $ (and hence on n).
The important role played by N can be sketched as follows. Firstly, N fixes the number of output qubits to be used in the quantum phase estimation algorithm, such that an exact binary fraction representation of $\varphi $ is possible. But N has a more subtle use in the last step of the quantum phase estimation algorithm, where one needs to implement an inverse quantum Fourier transform (QFT). To implement such a QFT in the standard way on the full set of output qubits, one would require quantum gates implementing phase rotations by angles that depend on N. But this would require Ndependent QTM transition rule amplitudes, which is not allowed. The solution is to use N as a way to locate the least significant bit of $\varphi $ , which will in turn allow the QFT to be implemented using gates that depend only on $\varphi $ . (This is explained in more detail when we give the precise description and analysis of the QTM, later in this section.)
This way of carrying out the QFT on a QTM comes at a cost of exponential runtime, so would not be useful if using the QFT to solve some computational problem. But for our peculiar use of the phaseestimation algorithm to generate an input string for a universal TM, which may anyway run indefinitely, this exponential runtime is not an issue. (Though it will entail a new clock construction when we come to encode the evolution of this QTM in a Hamiltonian, see Section 4.)
More precisely, we will prove the following result (see below for the necessary basic definitions, notations, and facts about QTMs).
Theorem 10 (Phaseestimation QTM)
There exists a family of wellformed, normal form, unidirectional QTMs $P_n$ indexed by with the following properties:

(i) Both the alphabet and the set of internal states are identical for all $P_n$ ; only the transition rules differ.

(ii) On input $N\geq {\lvert {n}\rvert }$ written in unary, $P_n$ behaves properly, halts deterministically after steps, uses $N+3$ space, and outputs the binary expansion of n (padded to N digits with leading 0’s). (Here, ${\lvert {n}\rvert }$ denotes length of the binary expansion of n.)

(iii) For any n, and for each choice of states $p,q$ , alphabet symbols $ \sigma , \tau $ and directions D, the transition amplitude $\delta (p,\sigma ,\tau ,q,D)$ is one of the elements of the set
(3.1) $$ \begin{align} \left\{0,1,\pm \frac{1}{\sqrt{2}},e^{i\pi\varphi}, e^{i\pi 2^{{\lvert{\varphi}\rvert}}}\right\} \end{align} $$where .
We emphasise again that the input N does not determine the output string that gets written to the tape; it only determines the number of binary digits in the output. The number represented by that output is determined (up to padding with leading zeros) by the choice of the parameter n for the QTM $P_n$ .
Theorem 10 is essentially the only inherently quantum ingredient in our result, and the precise properties asserted there will be absolutely crucial to the proof. For example, if instead of writing out the string and halting deterministically, the QTM did this only with arbitrarily high probability, our proof would not go through.
It is therefore not at all clear a priori whether QTMs fulfilling these strict requirements exist. Since our proof depends so delicately on the precise properties of these QTMs, we cannot appeal to previous results. Instead, in this section we give a detailed and explicit construction of a QTM based on the quantum phase estimation algorithm, that fulfils all the requirements of Theorem 10.
3.1 Quantum Turing Machinery
For completeness we quote the basic definitions of Turing Machines and Quantum Turing Machines verbatim from [Reference Arad, Kitaev, Landau and Vazirani16].
Definition 11 (Turing Machine – Definition 3.2 in [Reference Arad, Kitaev, Landau and Vazirani16])
A (deterministic) Turing Machine (TM) is defined by a triplet $(\Sigma , Q, \delta )$ where $\Sigma $ is a finite alphabet with an identified blank symbol $\#$ , Q is a finite set of states with an identified initial state $q_0$ and final state $q_f\not = q_0$ , and $\delta $ is a transition function
The TM has a twoway infinite tape of cells indexed by and a single read/write tape head that moves along the tape. A configuration of the TM is a complete description of the contents of the tape, the location of the tape head and the state $q\in Q$ of the finite control. At any time, only a finite number of the tape cells may contain nonblank symbols.
For any configuration c of the TM, the successor configuration $c'$ is defined by applying the transition function to the current state and the symbol scanned by the head, replacing them by those specified in the transition function and moving the head left (L) or right (R) according to $\delta $ .
By convention, the initial configuration satisfies the following conditions: the head is in cell $0$ , called the starting cell, and the machine is in state $q_0$ . We say that an initial configuration has input $x\in (\Sigma \setminus \#)^*$ if x is written on the tape in positions $0,1,2,\cdots $ and all other tape cells are blank. The TM halts on input x if it eventually enters the final state $q_f$ . The number of steps a TM takes to halt on input x is its running time on input x. If a TM halts, then its output is the string in $\Sigma ^*$ consisting of those tape contents from the leftmost nonblank symbol to the rightmost nonblank symbol, or the empty string if the entire tape is blank. A TM is called reversible if each configuration has at most one predecessor.
As amplitudes in quantum mechanics can take arbitrary complex values, one has to be careful when defining quantum Turing Machines to ensure the transition amplitudes are themselves computable. Following [Reference Arad, Kitaev, Landau and Vazirani16, Definition 3.2], we restrict the transition function to computable numbers in the standard way. Let be the set consisting of $\alpha $ such that there is a deterministic classical Turing Machine $M_\alpha $ that, given input , outputs the real and imaginary parts of $\alpha $ to within $2^{n}$ in time polynomial in n.Footnote ^{5}
Definition 12 (Quantum Turing Machine – Definition 3.2 in [Reference Arad, Kitaev, Landau and Vazirani16])
A quantum Turing Machine (QTM) is defined by a triplet $(\Sigma , Q, \delta )$ where $\Sigma $ is a finite alphabet with an identified blank symbol $\#$ , Q is a finite set of states with an identified initial state $q_0$ and final state $q_f\neq q_0$ , and $\delta $ – the quantum transition function – is a function
The QTM has a twoway infinite tape of cells indexed by and a single read/write tape head that moves along the tape. We define configurations, initial configurations and final configurations exactly as for deterministic TMs.
Let $\mathcal {S}$ be the innerproduct space of finite complex linear combinations of configurations of M with the Euclidean norm. We call each element $\phi \in \mathcal {S}$ a superposition of M. The QTM M defines a linear operator $U_M: \mathcal {S}\rightarrow \mathcal {S}$ , called the time evolution operator of M, as follows: if M starts in configuration c with current state p and scanned symbol $\sigma $ , then after one step M will be in a superposition of configurations $\psi =\sum _i\alpha _ic_i$ , where each nonzero $\alpha _i$ corresponds to the amplitude $\delta (p,\sigma ,\tau ,q,d)$ of in the transition $\delta (p,\sigma )$ and $c_i$ is the new configuration obtained by writing $\tau $ , changing the internal state to q and moving the head in the direction of d. Extending this map to the entire $\mathcal {S}$ through linearity gives the linear time evolution operator $U_M$ .
Here, for convenience of programming, we will consider generalised TMs and QTMs in which the head can also stay still (Nomovement), as well as move Left or Right.
Definition 13 (Generalised TM and QTM)
A generalised TM or generalised QTM is defined exactly as a standard TM (Definition 11) or standard QTM (Definition 12) except that the set of head movement directions is $\{L,R,N\}$ instead of just $\{L,R\}$ .
Following Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16], we define various classes of deterministic and quantum Turing Machines:
Definition 14 (Wellformed – Definition 3.3 in [Reference Arad, Kitaev, Landau and Vazirani16])
We say that a QTM is wellformed if its time evolution operator is an isometry, that is, it preserves the Euclidean norm.
It is easy to see (Theorem 4.2 in [Reference Arad, Kitaev, Landau and Vazirani16]) that any reversible TM is also a wellformed QTM where the quantum transition function $\delta (p,\sigma , q,\tau , d)=1$ if $\delta (p,\sigma )=(q,\tau ,d)$ for the reversible TM and $0$ otherwise.
Definition 15 (Normal form – Definition 3.13 in [Reference Arad, Kitaev, Landau and Vazirani16])
A wellformed QTM or reversible TM $M = (\Sigma ,Q,\delta )$ is in normal form if
In [Reference Arad, Kitaev, Landau and Vazirani16] the normalform condition is . However, the choice of final direction is just an arbitrary convention, since the machine already halted and never carries out those transitions. We replace R with N in the definition for technical reasons (see the Reversal Lemma 22, below).
There is a specific class of QTMs, called unidirectional, that play an important role in the general theory developed by Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16].
Definition 16 (Unidirectional – Definition 3.14 in [Reference Arad, Kitaev, Landau and Vazirani16])
A QTM $M = (\Sigma ,Q,\delta ))$ is unidirectional if each state can be entered from only one direction. In other words, if $\delta (p_1, \sigma _1, \tau _1, q, d_1)$ and $\delta (p_2, \sigma _2, \tau _2, q, d_2)$ are both nonzero, then $d_1$ = $d_2$ .
Note that in a unidirectional QTM, the direction component in any transition rule triple is fully determined by the state . Thus we can recover the complete transition rules from the components alone, without the direction component. We call these the reduced transition rules, . (Equivalently, there exists an isometry that maps the reduced transition rules to the original transition rules: $V\delta _r(p,\tau ) = \delta (p,\tau )$ .)
The following theorem gives necessary and sufficient conditions for a (partial) transition function to define a reversible Turing Machine.
Theorem 17 (Local wellformedness – Thm. B.1 and Cor. B.3 in [Reference Arad, Kitaev, Landau and Vazirani16])
A TM M is reversible iff its transition function satisfies the following conditions:

Unidirection Each state of M can be entered while moving in only one direction. In other words, if $\delta (p_1,\sigma _1) = (\tau _1, q, d_1)$ and $\delta (p_2,\sigma _2) = (\tau _2, q, d_2)$ then $d_1 = d_2$ .

Onetoone The transition function is onetoone when direction is ignored.
Furthermore, a partial transition function satisfying these conditions can always be completed to the transition function of a reversible TM.
Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16] proved that one can w.l.o.g. restrict to unidirectional QTMs. We therefore restrict the following quantum analogue of Theorem 17 to the unidirectional case:
Theorem 18 (Quantum local wellformedness)
A unidirectional QTM $M=(\Sigma ,Q,\delta )$ is wellformed iff its quantum transition function $\delta $ satisfies the following conditions:

Normalisation
(3.5a) $$ \begin{align} \forall p,\sigma \in Q\times\Sigma \quad {\lVert{\delta(p,\sigma)}\rVert} = 1. \end{align} $$ 
Orthogonality
(3.5b) $$ \begin{align} \forall (p_1,\sigma_1) \neq (p_2,\sigma_2) \in Q\times\Sigma \quad \left\langle\delta_r(p_1,\sigma_1),\delta_r(p_2,\sigma_2)\right\rangle = 0. \end{align} $$
Furthermore, a partial quantum transition function satisfying these conditions can always be completed to a wellformed transition function.
Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16] proved this result for standard QTMs, that is, where the head must move left or right in each time step. (In fact, they prove it without the restriction to unidirectional QTMs; see Theorem 5.2.2 and Lemma 5.3.4 in [Reference Arad, Kitaev, Landau and Vazirani16].) We therefore extend the proof of Theorem 18 to generalised QTMs, which is not difficult – indeed, it is made particularly straightforward by our restriction to unidirectional machines.
Proof of Theorem 18. Let U be the time evolution operator of the QTM M. By definition M is wellformed iff U is an isometry, or equivalently iff the columns of U have unit length and are mutually orthogonal. Clearly, the normalisation condition specifies exactly that each column has unit length.
Pairs of configurations whose tapes differ in a cell not under either of the heads, or whose tape heads are more than two cells apart, cannot yield the same configuration in a single time step. Therefore, all such pairs of columns are guaranteed to be orthogonal. The orthogonality condition imposes orthogonality of pairs of columns for configurations that differ only in that one is in state $p_1$ reading $\sigma _1$ while the other is in state $p_2$ reading $\sigma _2$ .
It remains to consider pairs of configurations whose heads are one or two cells apart, differing at most in the symbol written in these cells and in their states. However, unidirectionality implies that any update triples that share the same state must share the same direction. Thus either the state or the head location necessarily differs for all such pairs of columns, hence these too are orthogonal.
The final claim follows straightforwardly from the fact that the normalisation and orthogonality conditions imply that a partial unidirectional reduced transition function $\delta _r$ is wellformed iff it defines an isometry on the space of states and tape symbols, and this can always be extended to a unitary. This fills in the undefined entries of $\delta _r$ by extending $\delta _r(q,\sigma )$ to an orthonormal basis for the space of states and symbols.
We will often only be interested in the behaviour of a QTM (or reversible TM) on a particular subset of inputs, since the machine will only be run on those. A proper machine is guaranteed to behave appropriately on some subset of inputs, but not necessarily on all possible inputs.
Definition 19 (Proper QTM)
A QTM behaves properly (or is proper) on a subset $\mathcal {X}$ of initial superpositions if whenever initialised in $\phi \in \mathcal {X}$ , the QTM halts in a final superposition where each configuration has the tape head in the start cellFootnote ^{6} , the head never moved to the left of the starting cell, and the QTM never enters a configuration in which the head is in a superposition of different locations. We will refer to this latter property as deterministic head movement.
Similarly, we say that a deterministic TM behaves properly (or is proper) on $\mathcal {X}\subset (\Sigma \backslash \{\#\})^*$ if the head never moves to the left of the starting cell, and it halts on every input $x\in \mathcal {X}$ with its tape head back in the starting cell.
When the set $\mathcal {X}$ is clear from the context, we will omit it.
Note that, for a QTM to have deterministic head movement, it is not sufficient that none of its transition rules $\delta (\sigma ,\tau )$ produce a superposition of head directions. The head can also end up in a superposition of different locations because the tape state is in a superposition, so that two transition rules with different deterministic head movements apply in superposition.
Behaving properly is not a severe restriction on classical Turing Machines.Footnote ^{7} In fact, given any TM, there is always an equivalent proper TM that computes the same function. One way to see this is to recall that all computable functions are computable by Turing Machines restricted to oneway infinite tapes (see any standard text book on the theory of computation, e.g. Kozen [Reference Kliesch, Gross and Eisert50]), and these clearly behave properly if the tape is extended to be twoway infinite. (Returning the head to the starting cell at the end of the computation poses no great difficulty.) In particular, this means that there exist proper universal Turing Machines.
Quantum Turing Machines were originally defined in Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16] to have twoway infinite tapes. Indeed, those authors point out that there are trivial wellformed machines (such as the alwaysmoveright machine) whose evolution would not be unitary on a oneway infinite tape, since the starting configuration would have no predecessor. However, when we come to encode our QTMs into local Hamiltonians, we will only be able to simulate tapes with a boundary.Footnote ^{8} To avoid technical issues, we follow Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16] in defining QTMs on twoway infinite tapes, but we will ensure that none of the QTMs (or reversible TMs) that we construct ever move their head before the starting cell. Thus, when encoding the QTM in a Hamiltonian, we can ignore all of the tape to the left of the starting cell.
In fact, the local Hamiltonians encoding the QTMs will only be able to simulate the evolution on a finite (but arbitrarily large) section of tape. We will therefore be interested in keeping very tight control on the space requirements of all the reversible and quantum TMs that we construct. By carefully controlling the space overhead, it will then be sufficient for our purposes to simulate the evolution of the QTM on a finite portion of tape that is essentially no longer than the input.
3.1.1 Turing Machine Programming
For a multitrack Turing machine with k tracks and alphabet $\Sigma _i$ on track i, we will denote the contents of a tape cell by a tuple of symbols $[\sigma _1,\sigma _2,\ldots ,\sigma _k] \in \Sigma _1\times \Sigma _2\times \dots \times \Sigma _k$ specifying the symbol written on each track. Similarly, the configuration of the tape will be specified by a tuple $[c_1,c_2,\dots ,c_n] \in \Sigma _1^*\times \Sigma _2^*\times \dots \times \Sigma _k^*$ , where by convention all $c_i$ are aligned to start in the same cell (which will be the starting cell unless otherwise specified). We will use ${}\cdot {}$ to stand for an arbitrary track symbol. We will often describe Turing machines that act only on a subset of tracks, and leave the contents of all other tracks alone. In this case, we will only write out the states of the actedupon tracks in the transition function; this transition function should be understood to be extended to the remaining tracks in the obvious way.
As a shorthand, a transition rule on a tuple containing a ${}\cdot {}$ on one or more tracks should be understood to stand for the set of transition rules that leave the tracks marked ${}\cdot {}$ unchanged, and act as indicated on the remaining tracks. We will often only specify some of the elements of a transition function when defining a reversible or quantum TM. We will call such partial transition functions “wellformed” if the elements that are defined satisfy the conditions of Theorem 17 or Theorem 18, since by those theorems this is sufficient to guarantee that the partial transition functions can be completed to wellformed transition functions. QTM (or reversible TM) will sometimes use a finite number of auxiliary tracks. These are assumed always to start and finish in the all blank configuration.
We will have frequent recourse to the following basic TM and QTM programming primitives from Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16], which we slightly generalise here to account for additional properties of the resulting QTMs that will be important to us later. These primitives allow different QTMs to be combined in various ways to build up a more complex QTM.
Lemma 20 (Subroutine Lemma)
Let $M_1$ be a twotrack, normal form, reversible TM and $M_2$ a twotrack normal form reversible TM (or wellformed, normal form, unidirectional QTM) with the same alphabet and the following properties:

(i) $M_1$ is proper on initial configurations in $\mathcal {X}_1$ and $M_2$ is proper on $\mathcal {X}_2$ .

(ii) When started on $\mathcal {X}_1$ , $M_1$ leaves the second track untouched; when started on $\mathcal {X}_2$ , $M_2$ leaves the first track untouched.

(iii) There is a state q on $M_1$ that, when started on $\mathcal {X}_1$ , can only be entered with the head in the starting cell.

(iv) $\mathcal {X}_2$ contains all the output superpositions (with $q_f$ replaced by $q_0$ ) of k consecutive executions of $M_2$ started from an initial configuration in $\mathcal {X}_2$ for all $0\le k\le r$ , where is the maximum number of times that q is entered when $M_1$ runs on input in $\mathcal {X}_1$ .
Then there is a normal form, reversible TM (or wellformed, normal form, unidirectional QTM) M which behaves properly on $\mathcal {X}_1$ and acts as $M_1$ except that each time it would enter state q, it instead runs machine $M_2$ .
Proof. Exactly as Lemma 4.8 in [Reference Arad, Kitaev, Landau and Vazirani16].
Lemma 21 (Dovetailing Lemma)
Let $M_1$ and $M_2$ be wellformed normal form unidirectional QTMs (resp. normal form reversible TMs) with the same alphabet, so that $M_1$ is proper on $\mathcal {X}_1$ , $M_2$ is proper on $\mathcal {X}_2$ and $\mathcal {X}_2$ contains all final superpositions (resp. configurations) of $M_1$ started on $\mathcal {X}_1$ . Then, there is a wellformed normal form unidirectional QTM (resp. normal form reversible TM) M which carries out the computation of $M_1$ followed by the computation of $M_2$ and that is also proper on $\mathcal {X}_1$ .
Proof. Exactly as Lemma 4.9 in [Reference Arad, Kitaev, Landau and Vazirani16].
Lemma 22 (Reversal Lemma)
If M is a wellformed, normal form, unidirectional QTM (resp. normal form reversible TM) then there is a well formed, normal form, unidirectional QTM (resp. normal form reversible TM) $M^{\dagger }$ that reverses the computation of M while taking two extra time steps and using the same amount of space. Moreover, if M is proper on $\mathcal {X}$ , then $M^{\dagger }$ is proper on the set of final superpositions (resp. configurations) of M started on $\mathcal {X}$ .
Proof. The proof is very similar to that of Lemma 4.12 in [Reference Arad, Kitaev, Landau and Vazirani16]. We will prove it for QTMs, since reversible TMs are a special case of these. Consider an initial superposition , and let be the evolved sequence obtained by , where is a final superposition. Since M is normal form, do not have support on $q_0$ .
Let be the superposition obtained by replacing the state $q_f$ in with the initial state of the new machine $q_0'$ . Let be the superposition obtained by replacing the state $q_f$ in with the new final state $q_f'$ . We want to construct a QTM $M^{\dagger }$ that, when started from , halts on in $n+2$ steps. $M^\dagger $ will have the same alphabet and set of states as M, together with the new initial and final states $q_0',q_f'$ . We define the transition function $\delta '$ in the following way:

(i) .

(ii) For each $q\in Q\backslash \{q_0\}$ and each $\tau \in \Sigma $ ,
(3.6) 
(iii) .

(iv) .
Here, for any state q, $d_q$ is the unique direction in which that state can be entered, and $\bar {d_q}$ is the opposite direction. Since M is unidirectional, Theorem 18 implies that $M^{\dagger }$ is a wellformed, normal form, unidirectional QTM. Given a configuration c in state q, $\pi (c)$ is defined as the configuration derived from c by moving the head one step in the direction $\bar {d_q}$ . $\pi $ can be extended by linearity to $\mathcal {S}$ .
Let us now analyse the behaviour of $M^{\dagger }$ started from . By (i), $M^{\dagger }$ maps in one step to . Now consider (ii). Since M is normal form, it maps superposition to superposition with no support on state $q_0$ if and only if has no support on state $q_f$ . Denote $Q_0 = Q\backslash \{q_0\}$ , $Q_f = Q\backslash \{q_f\}$ . If M takes a configuration $c_1$ with a state from $Q_f$ with amplitude $\alpha $ to a configuration $c_2$ (necessarily with a state in $Q_0$ ), then (ii) ensures that $M^{\dagger }$ takes configuration $\pi (c_2)$ to configuration $\pi (c_1)$ with amplitude $\alpha ^*$ . Let $S_0$ (resp. $S_f$ ) be the space of superpositions using only states in $Q_0$ (resp. $Q_f$ ). Since M is wellformed, the restriction of the evolution operator $U_M$ to $S_f$ is an isometry into $S_0$ . Hence $M^{\dagger }$ implements, up to conjugation by $\pi $ , the inverse of $U_M$ restricted to $U_M(S_f)$ .
As an aside, note that this implies that the evolution operator of M is indeed a unitary and not just an isometry. Indeed, by (i) to (iv) above, the evolution operator of $M^{\dagger }$ is also an isometry from $S_0$ into $S_f$ . Since $\pi $ is trivially a unitary on $\mathcal {S}$ , this implies that $U_M$ restricted to $S_f$ is a unitary onto $S_0$ . Now, since M is normal form, $U_M$ achieves any possible configuration with state $q_0$ by starting from the same configuration but with $q_0$ replaced by $q_f$ . These two facts together show that $U_M$ is indeed surjective and hence a unitary.
Returning to the proof of the lemma, we have seen how (ii) implies that $M^{\dagger }$ executes the sequence of n steps . Finally, by (iv), in the $(n+2)$ ’th step, $M^{\dagger }$ maps to as desired.
Moreover, it is trivial to see that $M^{\dagger }$ uses exactly the same space as M, and behaves properly.
Note that our way of defining normal form (Definition 15 as opposed to that in [Reference Arad, Kitaev, Landau and Vazirani16]) is crucial to guarantee that the reversal machine is proper. As a corollary of the proof, we have also shown that the evolution of a wellformed, normal form unidirectional QTM is a unitary operator. (The proof of this fact for nonunidirectional QTMs is much more involved, and can be found in [Reference Arad, Kitaev, Landau and Vazirani16]).
In the following sections, we give explicit constructions of the reversible and quantum Turing Machines that, when combined appropriately using Lemmas 20 to 22 as described below, implement a phaseestimation QTM with the properties required to prove Theorem 10. The formal definitions of all these Turing Machines are given by their transition rule tables, which can directly be verified to satisfy the wellformedness conditions of Theorems 17 and 18.
Since understanding how a TM works just from a table of transition rules is not always straightforward, we additionally give an informal pseudocode description of how each machine operates on suitable input. These pseudocode descriptions also help in verifying that the machines specified in the transition rule tables behave properly and satisfy the claimed space and runtime bounds.
Each pseudocode listing describes how the Turing Machine moves its head and reads and writes tape symbols as the algorithm proceeds, in order to implement the claimed operation. The internal state that the TM transitions into after carrying out the corresponding line of pseudocode is indicated in the margin.Footnote ^{9} The internal state that the TM is in at the beginning of an algorithm or subroutine is also indicated in the margin. Where no internal state is indicated in the margin, this means the internal state is left unchanged. Conditional branches in the pseudocode (i.e. if, else if and else statements) are structured to reflect how the different computational paths that can be followed by the TM during the computation branch off and are then remerged to ensure reversibility.
However, it should be emphasised that these pseudocode listings are not rigorous specifications of the corresponding Turing Machines; the formal, mathematically rigorous specifications are the transition rule tables.
3.1.2 Reversible Turing Machine Toolbox
It will be helpful to have a toolbox of reversible TMs which carry out various elementary computations. In order to satisfy the space constraints of Theorem 10, we will be interested in keeping tight control of the space requirements of all our constructions.
Lemma 23 (Copying machine)
There is a twotrack, normal form, reversible TM with alphabet $\Sigma \times \Sigma $ that, on input s written on the first track, behaves properly, copies the input to the second track and runs for time $2{\lvert {s}\rvert }+1$ , using ${\lvert {s}\rvert }+1$ space.
Proof. We simply step the head right, copying the symbol from the first track to the second. However, we defer copying the starting cell until the end of the computation, so that we can locate the starting cell again. In pseudocode:
It is straightforward to verify that the following normal form transition function implements :
This partial transition function verifies the two conditions of Theorem 17, so it is wellformed and can be completed to give a reversible TM.
Lemma 24 (Shiftright machine)
There exists a normal form, reversible TM with alphabet $\Sigma $ that, on input s behaves properly, shifts s one cell to the right and runs for time $2{\lvert {s}\rvert }+2$ , using space ${\lvert {s}\rvert }+2$ .
Proof. The Turing Machine has a separate internal state $q^\sigma $ corresponding to each tape symbol $\sigma $ . It reads the symbol into this internal state, overwrites it with the preceding symbol, and steps right. In pseudocode:
The reason for including two different states $q_2$ and $q_3$ is to guarantee the unidirectionality requirement of Theorem 17. The state $q_2$ is entered from the right and the state $q_3$ from the left. The effect of this is that, if the input is the empty string, this Turing Machine program still steps right and then left before halting.
It is straightforward to verify that the following normalform transition function implements :
As this partial transition function verifies the two conditions of Theorem 17, it is wellformed and can be completed to give a reversible TM.
Lemma 25 (Equality machine)
There is a threetrack, normal form, reversible TM with alphabet $\Sigma \times \Sigma \times \{\#,0,1\}$ that, on input $s;t;b$ , where s and t are arbitrary input strings and b is a single bit, behaves properly and outputs $s;t;b'$ , where $b'=\neg b$ if $s=t$ and $b'=b$ otherwise. Furthermore, runs for time $4{\lvert {s}\rvert }+1$ and uses ${\lvert {s}\rvert }+1$ space.
Implementing a nonreversible equalitytesting machine is trivial: just scan the head right checking if the symbols on the two input tracks match. If we reach the end of the input without encountering a nonmatching pair, return to the starting cell and flip the output bit. If we encounter a nonmatching pair, return to the starting cell and leave the output bit unchanged.
Doing this reversibly requires more care. The problem is that the computation splits into two possible paths, depending on whether a nonmatch was encountered or not, and we must merge these two divergent computations back together again reversibly. For example, we cannot simply halt after either flipping the output bit or leaving it unchanged, as that would give multiple transitions into the final state that write the same symbol to the starting cell. The trick is to return to the point at which the computational paths diverged (either the first nonmatching pair of symbols, or the end of the input) after setting the output bit, in order to merge the two computational paths back together, before returning to the starting cell again to halt.
To accomplish this, we use a state $q_4$ that is the only state that can transition to $q_f$ (except for the special case in which the first symbols in both input strings already differ, which is handled immediately). The state $q_1$ searches along the strings, until it either finds the end of both strings (first computational path), or it finds a point where the symbols in the two inputs differ (second computational path).
In the first path, state $q_2$ will return to the starting cell, switch the output bit and transition to $q_3$ . State $q_3$ will move right again doing the same as $q_1$ did and, at the end of both strings, will transition to $q_4$ . Note that we need two different states for this, due to unidirectionality: $q_2$ will be entered from the left and $q_3$ from the right.
In the second path, states $q_2'$ and $q_3'$ play the corresponding roles of $q_2$ and $q_3$ , respectively. In both paths, $q_4$ will return to the starting cell and halt. Within each path there is no issue with reversibility. The key to this is that, when both computational paths are merged into state $q_4$ , they do so on exactly the same input states as when the paths diverged (with $q_1$ replaced by $q_3$ or $q_3'$ depending on the path). Thus these transitions fulfil the properties required for a wellformed (partial) transition function by Theorem 17.
This implementation requires being able to identify the starting cell, so that we can return to it again. This is also important since we want to avoid ever moving the head before the starting cell, to ensure the TM is proper, see Definition 19.) If the symbols in the first cell differ, we can set the output bit immediately and halt. If they are identical, we temporarily change the symbol on the second input track to a $\#$ to mark the starting cell. We can recover the original secondtrack input at the end of the computation in this case, by copying over the symbol from the first track. (This is not the only way one could handle this.)
Proof of Lemma 25. In pseudocode, the Turing Machine program for
does the following:
The following normalform transition function carries out this procedure:
One can verify that this partial transition function satisfies the two conditions of Theorem 17, so it is wellformed and can be completed to give a reversible TM, as required.
It is somewhat easier to construct reversible implementations of basic arithmetic operations if the numbers are written on the tape in littleendian order (i.e. leastsignificant bit first), as it avoids any need to shift the entire number to the right to accommodate additional digits. We adopt this convention for all the following basic arithmetic machines. We do not allow numbers to be padded with leading 0’s as that would allow multiple binary representations of the same number, which is inconvenient when constructing reversible machines. Note that this means the number zero is represented by the blank string, not the string “0”.
Lemma 26 (Increment and decrement machines)
There exist normal form, reversible TMs and with alphabet $\{\#,0,1\}$ that, on littleendian binary input n (with $n>1$ for ), behave properly and output $n+1$ or $n1$ respectively. Both machines run for time $O(\log n)$ and use at most ${\lvert {n}\rvert }+2$ space.
Incrementing a binary number on a nonreversible TM is straightforward: simply step the head along the number starting from the least significant bit, flipping 1’s to 0’s to propagate the carry until the first 0 or #, then flip that 0 or # to 1 and halt. (Littleendian order avoids any need to shift the whole input to the right to accommodate an additional digit, should one be required.) However, making this procedure reversible is more fiddly. One option of course is to use the general procedure for reversible simulation and uncomputation of a nonreversible TM due to Bennett [Reference Orús13], but this comes at a cost of polynomial space overhead. A more careful construction allows us to implement directly, using just two additional tape cells.
Proof of Lemma 26. We first use the machine from Lemma 24 to shift the entire input one cell to the right, as a convenient way of getting a $\#$ in the starting cell so that we can return to it later. We then reversibly increment the binary number written on the tape, and finish by running (the reversal of the machine, constructed using Lemma 22) to shift the output back one cell to the left.
To implement reversibly the incrementing part of this procedure, we assign states as follows. State $q_1$ will search along the input for the first $0$ to change it to a $1$ , and along the way will change all $1$ s to $0$ s. In this way, the carry from incrementing the first (least significant) bit is propagated along the binary string to the appropriate bit. If no such $0$ exists, a $1$ will be appended to the end of the input string by changing the blank symbol $\#$ there to a $1$ .
These two possible computation paths have to be merged back into a state $q_4$ , which will then return the TM head to the starting cell and halt. To merge these two paths, which end up in states $q_2$ and $q_2'$ respectively, we add an extra state $q_3$ together with transition rules from $q_2$ and $q^{\prime }_2$ into $q_3$ , such that both computational paths arrive at a configuration in which the TM is in state $q_3$ and reading a $1$ . Thereupon, the TM can transition into $q_4$ and complete the computation.
In pseudocode:
The following normalform transition function implements this:
This partial transition function verifies the two conditions of Theorem 17, so it is wellformed and can be completed to give a reversible TM.
This completes the construction of . To implement , simply construct the reversal of using Lemma 22.
We can use the construction to construct a looping primitive. (This gives a slightly more general version of the Looping Lemma from [Reference Arad, Kitaev, Landau and Vazirani16, Lemma 4.13], which also has tighter control on the space requirements.)
Lemma 27 (Looping Lemma)
There is a twotrack, normal form, reversible TM with alphabet $\{\#,0,1\}$ , which has the following properties. On input $n;m$ , with $n< m$ both littleendian binary numbers, behaves properly, runs for time $O((mn)\log m)$ , uses space ${\lvert {m}\rvert }+2$ and halts with its tape unchanged. Moreover, has a special state q such that on input $n;m$ , it visits state q exactly $mn$ times, each time with its tape head back in the starting cell.
There is also a onetrack, normal form, proper, reversible TM which, on input $m\ge 1$ , behaves as on input $0;m$ .
Proof. Our construction closely follows the proof of Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16, Lemma 4.2.10]. We will use two auxiliary tracks in addition to the two input tracks, both with alphabet $\{\#,0,1\}$ and both initially blank.
The core of the machine is a reversible TM $M'$ constructed out of two proper, normal form, reversible TMs $M_1$ and $M_2$ .
$M_1$ has initial and final states $q_0,q_f$ , and transforms input $n;m;x;b$ into $n;m;x+1;b'$ , where b is a bit and $b'=\neg b$ if $x=n$ or $x=m1$ but not both, otherwise $b'=b$ . $M_1$ can be constructed by dovetailing together the machine from Lemma 25 (with the first and third tracks as its input tracks and the fourth track as its output), then the machine from Lemma 26 (acting only on the third track), and finally another machine (this time with the second and third tracks as its input tracks and the fourth track as its output). By Lemma 21 and the fact that all the constituent machines are proper, normal form and reversible, $M_1$ is proper, normal form and reversible. From Lemmas 25 and 26, $M_1$ runs for time $O(\log m)$ and takes at most ${\lvert {m}\rvert }+2$ space.
$M_2$ has new initial and final states $q_\alpha ,q_\omega $ , with $q_0$ and $q_f$ as its only other normal (i.e. not initial or final) internal states. $M_2$ behaves as follows:

(i) If it is in state $q_\alpha $ with $b=0$ , it flips b to 1 and enters state $q_0$ .

(ii) If it is in state $q_f$ with $b=0$ , it enters state $q_0$ .

(iii) If it is in state $q_f$ with $b=1$ , it flips b to 0 and halts.
The following normal form, partial transition function for $M_2$ is essentially the same as the corresponding construction in Lemma 4.2.6 of Bernstein and Vazirani [Reference Arad, Kitaev, Landau and Vazirani16], but we can simplify slightly by exploiting the fact that we are allowing generalised TMs. It acts only on the fourth track, and implements a machine $M_2$ that clearly satisfies the requirements (i) to (iii), above:
$M_2$ is clearly normal form, and satisfies the two conditions of Theorem 17.
The transition rules for $M'$ are constructed by deleting the $q_f$ to $q_0$ transition rules from $M_1$ , and adding all the remaining $M_1$ rules to those of $M_2$ . The initial and final states of $M'$ are $q_\alpha ,q_\omega $ . On input $\mbox {n;m;n;0}$ , $M'$ will therefore run $M_2$ until it enters the $q_0$ state, then run $M_1$ until it halts and reenters $M_2$ . It will continue to alternate in this way between $M_2$ and $M_1$ until the former halts. Thus $M'$ goes through the following sequence of configurations:
It therefore runs exactly $mn$ times and enters the state $q_f$ once in each run, so we can take $q_f$ as the special state q.
To initialise the tracks, we dovetail a proper, reversible TM before $M'$ which transforms the input $n;m;\#;\#$ into the configuration $n;m;n;0$ . This is easily constructed by dovetailing the machine from Lemma 23 (acting on the first and third tracks) with a simple reversible TM which changes the first cell of the fourth track from $\#$ to 0 and halts. (Implementing the latter is trivial.) To return all tracks to their initial configuration at the end, we dovetail another proper, reversible TM after $M'$ which transforms the configuration $n;m;m;0$ into the final output $n;m;\#;\#$ . This is easily constructed by dovetailing the reversal of the copying machine from Lemma 23 (acting on the second and third tracks) with a simple reversible TM which changes the first cell of the fourth track from 0 back to $\#$ . From Lemma 28, these initialisation and reset machines run for time $O(\log n)$ and $O((mn)\log m)$ , respectively, and use ${\lvert {n}\rvert }+1$ and ${\lvert {m}\rvert }+1$ space.
It remains to show that combining $M_1$ and $M_2$ as described above to form $M'$ gives a proper, normal form, reversible TM. Since $M_1$ is normal form, it has no transitions into $q_0$ or out of $q_f$ other than the ones we deleted before combining it with $M_2$ to construct $M'$ . All remaining internal states of $M_1$ and $M_2$ are distinct. Thus, since $M_1$ is reversible, the transition rules for $M'$ also satisfy the two conditions of Theorem 17. $M'$ can therefore be completed to a normal form, reversible TM. Since $M_1$ is proper, it is easy to see that $M'$ is also proper.
$M'$ loops on $M_1 \ mn$ times (with constant time overhead and no additional space overhead coming from $M_2$ ). Each run of $M_1$ takes time $O(\log m)$ , so the complete implementation takes time $O(\log m)$ . None of the constituent TMs use more than ${\lvert {m}\rvert }+2$ space, so neither does . This completes the construction of .
To construct , we simply remove the second input track from the machine, and replace the machine that acts on that track with a trivial machine that checks whether the starting cell of the third track contains the $\#$ symbol.
The reversible incrementing, decrementing, and looping machines constructed above are sufficient to implement all arithmetic operations. The only ones we will need are addition and subtraction. These are now easy to construct.
Lemma 28 (Binary adder)
There exist twotrack, normal form, reversible TMs and with alphabet $\{\#,0,1\}^{\times 3}$ , which have the following properties. On input $n;m$ with n and m both littleendian binary numbers and $m\ge 1$ ,