Bolean To Hamilton
Bolean To Hamilton
Quantum Artificial Intelligence Lab, NASA Ames Research Center, Moffett Field, CA
94035
USRA Research Institute for Advanced Computer Science, Mountain View, CA 94043
Department of Computer Science, Columbia University, New York, NY 10027
Abstract
Mapping functions on bits to Hamiltonians acting on qubits has many applications in quantum
computing. In particular, Hamiltonians representing Boolean functions are required for applications
of quantum annealing or the quantum approximate optimization algorithm to combinatorial optimiza-
tion problems. We show how such functions are naturally represented by Hamiltonians given as sums
of Pauli Z operators (Ising spin operators) with the terms of the sum corresponding to the function’s
Fourier expansion. For many classes of Boolean functions which are given by a compact description, such
as a Boolean formula in conjunctive normal form that gives an instance of the satisfiability problem, it
is #P-hard to compute its Hamiltonian representation, i.e., as hard as computing its number of satis-
fying assignments. On the other hand, no such difficulty exists generally for constructing Hamiltonians
representing a real function such as a sum of local Boolean clauses each acting on a fixed number of bits
as is common in constraint satisfaction problems. We show composition rules for explicitly constructing
Hamiltonians representing a wide variety of Boolean and real functions by combining Hamiltonians rep-
resenting simpler clauses as building blocks, which are particularly suitable for direct implementation as
classical software. We further apply our results to the construction of controlled-unitary operators, and
to the special case of operators that compute function values in an ancilla qubit register. Finally, we
outline several additional applications and extensions of our results to quantum algorithms for optimiza-
tion. A goal of this work is to provide a design toolkit for quantum optimization which may be utilized
by experts and practitioners alike in the construction and analysis of new quantum algorithms, and at
the same time to provide a unified framework for the various constructions appearing in the literature.
1 Introduction
A basic requirement of many quantum algorithms is the ability to translate between mathematical functions
acting on a domain, typically strings of bits, and quantum mechanical Hamiltonian operators acting on qubits.
In particular, mapping Boolean or real functions to Hamiltonians has important applications in quantum
algorithms and heuristics for solving decision or optimization problems such as quantum annealing and
adiabatic quantum optimization [1–3], or the quantum approximate optimization algorithm and quantum
alternating operator ansatz (QAOA) [4–6], or the related variational quantum eigensolver [7]. Explicit
Hamiltonian constructions for the application of these algorithms to a variety of prototypical problems can
be found in [6, 8], though prior work has mostly focused on reductions to quadratic Hamiltonians at the
expense of additional qubits, for example in the penalty term approach of quantum annealing; we explain
∗ email: [email protected] / [email protected]
1
how direct (not necessarily quadratic) mappings are desirable for quantum gate model algorithms. Such
quantum algorithms are promising, in particular, as possible paths towards performing useful computation
on near-term quantum computing devices. Indeed, decision and optimization problems are ubiquitous across
science and engineering, yet often appear to be computationally difficult. Despite years of investigation,
efficient algorithms often remain elusive [9, 10]. Hence, the potential for new approaches to tackling these
problems on quantum computers is an exciting development.
Nevertheless, the conceptual barrier to entry to studying these quantum algorithms and providing new
insights remains high, especially for practitioners in the domain where a given problem arises, who may not be
familiar with quantum computing beyond the basics. It is thus important to develop tools and methodologies
which are accessible to scientists and researchers from different domains, and are as independent of knowing
the low-level details of quantum computing as possible, towards enabling easier cross-fertilization of different
ideas and techniques. At the same time, it is useful to provide a rigorous general foundation for existing
constructions and tools found in the literature, often in a specific context. Thus, a motivating goal of
this work is to provide a design toolkit of basic results and methodologies which can be used by experts
or laymen alike to design, implement, and analyze quantum algorithms. To this end, our results allow for
straightforward implementation as computer programs such that Hamiltonian and quantum circuit mappings
for many classes of problems may be automatically generated.
In this paper we show a general theory of mappings of Boolean and real functions to diagonal Hamiltonians
acting on qubits, and give simple logical rules for the explicit construction of these Hamiltonians which include
many common classes of functions such as Boolean formulas and circuits. We also address the question of
when such Hamiltonians may or may not be constructed efficiently. We show how our results may be applied
to the construction of unitary operators controlled by Boolean predicates, which are used, for example, in
several of the QAOA mixing operator constructions of [6]. Our results are general and give a methodical
approach to derive many of the mappings in the literature such as those of [6, 8]. We emphasize that our
results have applications to quantum algorithms beyond quantum annealing or QAOA, and we discuss a
number of examples.
We elaborate on our results, which we summarize in the next section. Consider a function f acting on n
bits. We say a Hamiltonian Hf represents f if it satisfies
for each input string x ∈ {0, 1}n with corresponding (i.e., encoded as) computational basis state |xi. (We will
typically assume f is decidable and moreover can be efficiently evaluated classically; see for example [11] for a
discussion of Hamiltonian families that encode the halting problem.) We show how arbitrary n-bit Boolean
or real functions are naturally represented as diagonal Hamiltonians given by weighted sums of Pauli Z
operators, with terms corresponding to the function’s Fourier expansion, as summarized in Theorem 1 below.
Such Hamiltonians generalize the Ising model of interacting spin-1/2 particles well-known in physics. Our
results rely on the Fourier analysis of Boolean functions, which has a long history of important applications in
computer science [12–17] and in particular quantum computing [18–21]. We use our results to derive explicit
Hamiltonian representations of a number of basic Boolean predicates shown in Table 1 below. Combining
the rules of classical propositional logic with the properties of the Fourier expansion leads to composition
rules for constructing Hamiltonians representing conjunctions, disjunctions, exclusive or, and other functions
of simpler clauses by combining their Hamiltonian representations in particular ways; see Theorem 2 below.
Furthermore, these mappings directly extend to constructing Hamiltonians representing weighted sums of
clauses, which are a primary class of Hamiltonians considered in quantum annealing and QAOA, for example,
for constraint satisfaction problems.
We also consider the computational complexity of such Hamiltonian constructions, which naturally de-
pends on how the function f is provided as input. Many combinatorial properties of a given function can be
“read off” from its Fourier coefficients [22]. This presents an obstruction to computing the Hamiltonian repre-
sentation for general Boolean functions; we show that computing the identity component of Hf = fb(∅)I +. . . ,
which is given by the first Fourier coefficient fb(∅) of f , is as hard as counting the the number of inputs such
that f = 1, which in general is computationally intractable. For example, if f is a Boolean formula on n
variables given in conjunctive normal formula form with a poly(n) size description, i.e., an instance of the
satisfiability problem (SAT), then this task is #P-hard and hence it is not believed possible to efficiently
2
compute fb(∅) in general; if such a classical polynomial-time algorithm existed then we would have P=NP.
Hence, we cannot efficiently construct explicit Hamiltonian representations of many n-bit Boolean functions,
even when such a function may be efficiently evaluated. We apply our results to show a similar result holds
for computing the Pauli operator expansion of quantum circuits that compute f in a register.
Nevertheless, there is no such difficulty for local Boolean functions fj where each fj acts on a constant
number of bits. This
Pm allows us to efficiently construct Hamiltonians representing pseudo-Boolean functions of
the form f (x) = j=1 wj fj (x), with wj ∈ R and m = poly(n). Such real functions (and their corresponding
Hamiltonians) may be constructed to directly encode optimization problems of interest, or such that their
minimum value arguments (ground state eigenvectors) encodes the solution to a corresponding decision
problem; similar to, for example, how solving the MAX-SAT problem (finding the maximum possible number
of satisfied clauses) also solves SAT. For a pseudo-Boolean function, its Fourier coefficients do not allow its
extremal values to be “read off” in the same way and so its Hamiltonian representation can often be computed
efficiently. Indeed, this is a common approach to encoding decision problems such as SAT into the framework
of quantum annealing [8]. Our results likewise apply to designing penalty term approaches for problems or
encodings with hard feasibility constraints which we discuss in Section 3.1.
1 1 Lk 1 1
x1 ⊕ x2 2 I − 2 Z1 Z2 xj 2 I − 2 Z1 Z2 . . . Zk
1 1
Vkj=1 1
Q
x1 ∧ x2 4I − 4 (Z1 + Z2 − Z1 Z2 ) xj j (I − Zj )
3 1
Wj=1
k
2k
1
Q
x1 ∨ x2 4I − 4 (Z1 + Z2 + Z1 Z2 ) j=1 xj I − 2k j (I + Zj )
3 1 3
x1 x2 4I + 4 (Z1 + Z2 − Z1 Z2 ) x1 ⇒ x2 4I + 41 (Z1 − Z2 + Z1 Z2 )
3
satisfy fb(∅) ∈ [0, 1], fb(S) ∈ [− 21 , 12 ] for S 6= ∅,
X
fb(S) = f (0n ) (4)
S⊂[n]
Corollary 1. Computing the identity coefficient fb(∅) of the Hamiltonian Hf representing a Boolean satisfi-
ability (SAT) formula f (given in conjunctive normal form) is #P -hard. Deciding if fb(∅) = 0 is equivalent
to deciding if f is unsatisfiable, in which case Hf reduces to the 0 matrix.
Hence, given a Boolean function f such that counting its number of satisfying inputs is #P -hard, comput-
ing the identity coefficient fb(∅) of its Hamiltonian representation will be #P -hard also. Such hard counting
problems include not only functions corresponding to NP-hard decision problems such as SAT, but also
certain functions corresponding to decision problems decidable in polynomial time, such as counting the
number of perfect matchings in a bipartite graph; see, e.g., [10]. We emphasize that even if we can compute
the value of each Fourier coefficient, a Hamiltonian Hf representing a general Boolean or real function on n
bits may require a number of Pauli Z terms that is exponentially large with respect to n; such an example
is the logical AND of n variables (see Table 1).
On the other hand, when a Boolean clause f acts only a number of bits k < n that is constant or
logarithmically scaling we may always efficiently construct its Hamiltonian representation as the number of
nonzero terms in the sum (2) (the size of Hf ) is in this case at most 2k . The degree of Hf , deg(Hf ) =
deg(f ) = d, is the maximum locality (number of qubits acted on) of any such term. Bounded-degree
P Q
Hamiltonians Hf = S⊂[k],|S|≤d fb(S) j∈S Zj , k ≤ n, are similarly always efficiently representable1 as we
show size(Hf ) ≤ (e/d)d−1 k d + 1 which is always polynomial in n if d = O(1). For example, bounded-locality
constraint satisfaction problems such as MAX-CUT or MAX-ℓ-SAT (up to ℓ = O(log n)) are described by
sums of local clauses and hence are always efficiently representable as Hamiltonians. We summarize mappings
of some important basic clauses in Table 1 above.
4
Theorem 2 (Composition rules). Let f, g be Boolean functions represented by Hamiltonians Hf , Hg . Then
the Hamiltonians representing basic operations on f and g are given by
• H¬f = Hf = I − Hf • Hf ⇒g = I − Hf + Hf Hg
• Hf ∧g = Hf g = Hf Hg • Hf ∨g = Hf + Hg − Hf Hg
• Hf ⊕g = Hf + Hg − 2Hf Hg • Haf +bg = aHf + bHg a, b ∈ R.
The proof of theorem is given in Section 2.2. Hamiltonians for a wide variety of functions can be easily
constructed using the composition rules and results for basic clauses as in Table 1, in particular Boolean
formulas and circuits.
Remark 1. Theorems 1, 2, and 3 below facilitate straightforward software implementation for generating
diagonal Hamiltonians, for example, automating QAOA mappings for constraint satisfaction problems with
increasingly general types of constraints. Examples of three variable clauses are generated in Table 2 below.
Such Hamiltonians may be useful intermediate representations in applications.
where each fj acts on a subset of the n bits, and in the applications we consider often m = poly(n). Objective
functions for constraint satisfaction problems, considered for example in QAOA, are often expressed in this
form, with each fj given by a Boolean clause. A different example is the penalty term approach of quantum
annealing, where the objective function is augmented with a number of high-weight penalty terms which
perform (typically, local) checks that a state is valid; see Sec. 3.1 for a discussion. For such pseudo-Boolean
functions we have the following result generalizing Thm. 1, which is shown in Section 2.3. Pseudo-Boolean
optimization is a rich topic and we refer the reader to [27] for an overview.
Theorem 3. For an n-bit real function f : {0, 1}n → R the unique Hamiltonian on n qubits satisfying
Hf |xi = f (x)|xi is
X Y
Hf = fb(S) Zj , (6)
S⊂[n] j∈S
P Q
with coefficients fb(S) = 21n x∈{0,1}n f (x)(−1)S·x = 21n tr(Hf j∈S Zj ) ∈ R.
Pm
In particular, for a pseudo-Boolean function f (x) = j=1 wj fj (x), wj ∈ R, where the fj are Boolean
functions corresponding to Hamiltonians Hfj as in (2), we have
m
X X
Hf = wj Hfj and fb(S) = fbj (S) ∈ R (7)
j=1 j
P
with d := deg(Hf ) ≤ maxj deg(fj ) and size(Hf ) ≤ min{ j size(Hfj ), (e/d)d−1 nd + 1}.
5
Our results also yield direct cost estimates for quantum simulation of diagonal Hamiltonians, which we
elaborate on in Section 3.3, though we emphasize that simulation is not the motivating application our results;
nevertheless, it is an important piece of our design toolkit. Indeed, such operators occur for example in QAOA
or Grover’s algorithm. As the terms in (6) mutually commute, we can simulate such an a Hamiltonian, i.e.,
implement the operator U = exp(−iHf t) for some fixed t ∈ R, using O(deg(Hf ) · size(Hf )) many basic
quantum gates. Indeed, similar constructions for implementing diagonal unitaries have been previously
proposed [23, 24], though more efficient circuits often result by utilizing ancilla qubits such as the operators
we consider in Proposition 2 below [28, 29].
The remaining two items of the section demonstrate how our results may be applied to the construction
of more general (non-diagonal) Hamiltonians and unitary operators.
The proof follows from from exponentiating (8) directly, see Section 4.1. We emphasize the Proposition
may be applied to generic control functions beyond the AND functions commonly considered in the literature
(e.g., multi-controlled Toffoli gates).
Remark 2 (Advanced mixing operators for QAOA). Proposition 1 may be applied together with the Theorems
above to design controlled mixing operators for QAOA mappings of various optimization problems with hard
constraints, with the important property of restricting the quantum evolution to the subspace of feasible
states [6, 31]. In particular, several mixing operators Λf (e−iHα ) proposed in [6] implement evolution under
a local mixing Hamiltonian B controlled by a Boolean function f , where the control function checks that the
mixing action on a given basis state will maintain feasibility and acts nontrivially only when this is the case.
For example, for MaxIndependentSet on a given graph, the transverse-field (bit-flip) mixer is applied for each
vertex controlled by the variables corresponding to the its neighbors in the graph; see [6] for details.
We next consider the special case where the target Hamiltonian H corresponds to a bit flip such that
each computational basis state |yi|0i is mapped to |yi|f (y)i.
6
Proposition 2. For an n-bit Boolean function f represented by a Hamiltonian Hf , let Gf be the unitary
self-adjoint operator on n + 1 qubits which acts on computational basis states |xi|ai as
As Boolean functions
P satisfy f 2 = f we have Hf2 = Hf , so Hf is a projector2 of rank r = #f := |{x :
f (x) = 1}| = x f (x). Hence, the Hamiltonian Hf for a Boolean function f is equivalent to the projector
onto the subspace spanned by basis vectors |xi such that f (x) = 1, and given an f such a projector may
be constructed using our results below. Hence, determining if f is satisfiable is equivalent to determining if
2 Projectors give quantum observables. In particular, for an arbitrary normalized n-qubit state |ψi, the probability p of a
1
computational basis measurement returning a satisfying bit string (i.e., an x such that f (x) = 1) is given by p1 = hψ|Hf |ψi,
i.e., is equal to the expected value of repeated measurements of Hf on the state |ψi.
7
Hf is not identically 0, and determining Hf explicitly in the form of (13) is at least as hard as counting the
number of satisfying assignments of f , or equivalently, computing r = rank(Hf ).
We consider the standard computational basis of eigenstates of Pauli Z operators (often written as σz ),
defined by the relations Z|0i = |0i and Z|1i = −|1i. We use Zj = I ⊗ . . . I ⊗ Z ⊗ I · · · ⊗ I to denote Z acting
on the jth qubit. Products of Zj over a set of qubits act as
Y
Zj |xi = χS (x)|xi, (14)
j∈S
where each parity function χS (x) : {0, 1}n → {−1, +1} gives the parity of the bits of x in the subset S ⊂ [n],
i.e., is +1 if and only if the number P
of bits of x set to 1 is even. Identifying each S with its characteristic
vector S ∈ {0, 1}n such that S · x = j∈S xj , we have
called the Fourier expansion (or, sometimes, Walsh or Hadamard expansion [35], or phase polynomial [25])
with Fourier coefficients given by the inner products of f with the parity functions
1 X
fb(S) = n f (x)χS (x) = hf, χS i, (18)
2
x∈{0,1}n
8
We emphasize that the Hamiltonian coefficients fb(S) depend only on the function values f (x), and are
independent of how such a function may be represented as input (e.g., formula, circuit, truth table, etc.).
Many typical compact representations of Boolean functions as computational input such as Boolean formulas
or Boolean circuits can be directly transformed to Hamiltonians using the composition rules of Theorem 2
which we derive below.
Remark 3. The identification of Boolean functions as real polynomials allows application of Theorem 1 to
different domains or targets. Changing the target from {0, 1} to {1, −1} for a given f (x) corresponds to the
function g(x) = 2f (x) − 1 with Hamiltonian coefficients bg(∅) = 1 − 2fb(∅) and gb(S) = −2f(S)
b for S 6= ∅, so
this can change size(Hf ) by at most 1. (In this case there are several differences from the {0, 1} approach;
P
for example, Parseval’s identity trivially becomes S⊂[n] fb(S)2 = 1.)
Similarly, indeed, the Fourier expansion (17) itself corresponds to changing the domain from {0, 1}n to
{1, −1}n (i.e., the polynomial obtained replacing each Zj in (6) by the variable zj = (−1)xi ∈ {−1, 1}).
On the other hand, Theorem 1 shows that computing the Hamiltonian representation of a Boolean func-
tion is as hard as computing its number of satisfying assignments, which is believed to be a computationally
intractable problem in general [10]. We illustrate this explicitly in Corollary 1 above where we show com-
puting fb(∅) can be #P-hard. Moreover, arbitrary Boolean functions may have size (sparsity) exponential in
n, in which case, even if we know somehow its Hamiltonian representation, we cannot implement or simulate
this Hamiltonian efficiently (with respect to n) with the usual direct approaches.
As explained, Hamiltonians representing pseudo-Boolean functions often avoid these difficulties; for ex-
ample, constraint satisfaction problems with objective function given as the sum of a number of local clauses
each clause acting on at most k = O(log n) bits (e.g., Max-k-Sat), and so the Hamiltonians representing
each clause have degree O(log n) and size O(poly(n)), and hence can be efficiently constructed. Applying
the well-known results of [15, Thm. 1 & 2] for such functions to Theorem 1 immediately gives the following
useful Hamiltonian degree bounds.
Corollary 3. For a function f ∈ Bn that depends only on k ≤ n variables, represented as a Hamiltonian
Hf acting on n qubits, the degree of Hf satisfies
where D(f ) is the decision tree complexity of f and D(f ) = O(poly(deg(Hf ))).
We emphasize that further results from the literature concerning the Fourier analysis of Boolean functions
may be similarly adapted to obtain properties of corresponding Hamiltonians. In particular additional useful
details of the Fourier coefficients may be found in [22, 25, 34].
1 1
Hxj = I ⊗j−1 ⊗ |1j ih1j | ⊗ I ⊗n−j = I − Zj , (21)
2 2
9
which acts according to the value of the jth bit as Hxj |xi = xj |xi. Similarly, the logical negation of the
jth variable is represented as Hxj = I/2 + Zj /2. For clarity we will avoid writing tensor factors of identity
operators explicitly when there is no ambiguity, and for convenience we sometimes write xj to mean the
Hamiltonian Hxj , and likewise for other basic functions such as xj .
Applying the laws of propositional logical leads to the composition rules of Theorem 2.
Proof of Thm. 2. The logical values 1 and 0 (i.e., true and false) are represented as the identity matrix I
and the zero matrix, respectively. Each result follows from the natural embedding of f, g ∈ Bn into Rn , the
real vector space of real functions on n bits. From linearity of the Fourier transform, we immediately have
Haf +bg = aHf + bHg for a, b ∈ R. Using standard identities, the Boolean operations (·, ∨, ⊕, . . . ) on f, g can
be translated into (·, +) formulas, i.e., linear combinations of f and g. Linearity then gives the resulting
Hamiltonian in terms of Hf and Hg . Explicitly, for the complement of a function f , as f = 1 − f , we have
Hf = I − Hf . Similarly, the logical identities f ∧ g = f g, f ∨ g = f + g − f g, f ⊕ g = f + g − 2f g, and
f ⇒ g = f + f g, respectively, imply the remaining results of the theorem.
We summarize the Hamiltonian representations of several basic Boolean functions in Table 1 above,
which are easily derived from Theorem 1. Applying the laws of Theorem 2 we may derive Hamiltonians
representing more complicated Boolean formulas than those of Table 1, such as expressions with arbitrary
numbers of variables, mixed types of clauses, or given as Boolean circuits. Some typical examples of Boolean
functions on 3 variables are the Majority (M AJ), Not-All-Equal (N AE), and 1-in-3 functions, which behave
as their names indicate. The Mod3 function is 1 when the sum x1 + x2 + x3 is divisible by 3, and satisfies
Mod3 = N AE. We show the Hamiltonians representing these functions in Table 2, which may be derived
using either the composition rules of Theorem 2 or the Fourier expansion approach of Theorem 1. For
example, H1in3 follows applying Thm. 2 with the identity 1in3(x1 , x2 , x3 ) = x1 x2 x3 + x1 x2 x3 + x1 x2 x3 .
The rules of Theorem 2 may be applied recursively to construct Hamiltonians representing more com-
plicated Boolean functions, corresponding e.g. to parentheses in logical formulas, or wires in Boolean cir-
cuits. For example, the Hamiltonian representing the Boolean clause f ∨ g ∨ h = f ∨ (g ∨ h) is given by
Hf ∨g∨h = Hf + Hg∨h − Hf Hg∨h , which simplifies to
Hf ∨g∨h = Hf + Hg + Hh − Hf Hg − Hf Hh − Hg Hh + Hf Hg Hh .
Another example is the Majority function which satisfies
HMAJ(f,g,h) = −2Hf Hg Hh + Hf Hg + Hf Hh + Hg Hh .
Together, the rules of Theorem 2 and Table 1 show how to construct Hamiltonians representing functions
given as arbitrary Boolean algebra (∧, ∨) or Boolean ring (·, ⊕) elements, which are functionally complete
in the sense of representing all possible Boolean functions [36].
and satisfy Parseval’s identity as stated in (19). We are particularly interested in pseudo-Boolean functions
given as a weighted sum of logical clauses
m
X
f (x) = wj fj (x), (23)
j=1
10
where fj ∈ Bn and wj ∈ R. Note that we do not deal explicitly with how the real numbers wj are represented
and stored; for many applications they are bounded rational numbers and this issue is relatively minor; see,
e.g., the constructions in [6, 8]. Indeed, in a constraint satisfaction problem, typically all wj = 1 and hence
f (x) gives the number of satisfied clauses (constraints).
We have the following result which extends the previous results for Boolean functions.
Proof of Theorem 3. By the linearity of the Fourier expansion and Theorem
P 1 we have that an n-bit real
function f : {0, 1}n → R is represented as the Hamiltonian Hf = b(S) Q
f b
j∈S Zj with f (S) =
1 Q Pm S⊂[n]
hf, χs i = 2n tr(Hf j∈S Zj ) ∈ R. For pseudo-Boolean functions f = j=1 wj fj the bounds d := deg(Hf ) ≤
P
maxj deg(fj ) and size(Hf ) ≤ min{ j size(Hfj ), (e/d)d−1 nd + 1} follow from simple counting as in the proof
of Theorem 1.
Thus the results of Theorems 1 and 2 for Boolean functions also apply to the construction of Hamiltonians
representing real functions, though with several important distinctions. Various subclasses of so-called
pseudo-Boolean functions with particular attributes (e.g., submodularity) are important in applications and
their properties may be further studied; see [27] for an overview.
Pm
Remark 4. In contrast to Theorem 1, for a constraint satisfaction problem f = j=1 fj , with fj ∈ Bn ,
applying Parseval’s identity (19) we have
X X X
fb(S)2 = E[f ] + 2 hfi , fj i = fb(∅) + 2 E[fi ∧ fj ] ≥ E[f ],
S⊂[n] i<j i<j
P
where E[f ] := 21n x∈{0,1}n f (x) gives the expected value of f (x) over the uniform distribution. In particular,
P b 2
S⊂[n] f (S) = E[f ] if and only if hfi , fj i = 0 for all i, j. If there does exist an i, j such that hfi , fj i = 0,
then the conjunction of the clauses is unsatisfiable, i.e. ∧j fj = 0.
where the Hamiltonians Hf and Hgj represent f and the gj as in Theorems 3 and 1, respectively. The wj are
positive weights which may be selected appropriately such that infeasible basis states are eigenvectors of Hp
with eigenvalues shifted away from those of f (e.g., wj > max(x)f (x)), and feasible states are eigenvectors
with eigenvalues f (x). Hence, the ground state subspace of Hp is spanned by states representing optimal
feasible problem solutions. Theorems 2, 1, and 3 may be applied to the functions gj to construct the penalty
terms Hgj just as for the cost term Hf .
11
Thus, our results may also be applied to explicitly construct problem mappings with penalty terms for
constrained problems. See [8] for a number of specific problem mappings; we emphasize our approach may be
applied directly to problems not considered therein. Furthermore, similar ideas apply to related approaches
for constrained optimization such as Lagrange multipliers [37].
An alternative approach to constrained optimization is to map the hard constraint functions to diagonal
Hamiltonians, which may be used to design mixing Hamiltonian that preserves the subspace of feasible
states. This approach is proposed in constraint-preserving generalizations of quantum annealing [38, 39]
and QAOA [6, 31], and can offer advantages over penalty-term approaches; see [6, 31, 38, 39] for details and
example problem mappings.
Hg = I ⊗ xa + Hf ⊗ Za (24)
represents the Boolean function g ∈ Bn+1 which satisfies g(x, y) = 0 if and only if y = f (x), and has ground
state subspace given by
span{|xi|f (x)i : x ∈ {0, 1}n}.
Simpler Hamiltonians with the same ground state subspace may be found for specific classes of Boolean
functions f ; see, e.g., [44]. An advantage of the construction (24) is that it applies generally.
Fig. 1: Quantum circuit performing the operation U = exp(−iγZ1 Z2 Z3 ) on three qubits labeled 1, 2,
and 3. The middle operator is a Z-rotation gate, and the other gates are controlled-NOT (CNOT) gates
with a black circle indicating the control qubit and cross indicating the target. By similar circuits, U =
exp(−iγZ1 Z2 . . . Zℓ ) can be implemented with 2(ℓ − 1) CNOT gates and one RZ gate. Different circuit
compilations are possible, including compilation to different gate sets.
12
In many applications we desire to simulate a Hamiltonian H for some time γ ∈ R, i.e., implement exactly
or approximately the unitary operator U (γ) = e−iγH . When H is diagonal, efficient quantum circuits may be
obtained using Fourier analysis [23–25] or other approaches. Consider the simulation of a Hamiltonian Hf
representing a real or Boolean function f . It is well known that if f can be efficiently computed classically,
and if ancilla qubits are available, then the Hamiltonian Hf can be simulated efficiently by computing f
in a scratchpad register and performing a sequence of controlled rotations; see, e.g., [29]. These methods
typically avoid computing the Fourier expansion of f explicitly. On the other hand, there exist applications
where an explicit Hamiltonian-based implementation is desirable, such as quantum annealing, or cases where
we wish to minimize the need for ancilla qubits, such as, for example, near-term implementations. Efficient
circuits simulating products of Pauli Z operators are well-known [28, 29], as shown in Figure 1. As Pauli Z
terms mutually commute, circuits simulating individual terms in the Hamiltonians (2) or (6) can be applied
in any sequence as to simulate their sum. Thus, when size(Hf ) = O(poly(n)) we can always simulate Hf
efficiently in this way. We summarize this observation in the following.
Corollary 4. A Hamiltonian Hf representing a Boolean or real function f as in (2) or (6) can be simulated,
i.e., the operation exp(−iγHf ) implemented, with n qubits and O(deg(Hf ) · size(Hf )) basic quantum gates.
In particular, Hamiltonians Hf with bounded maximum degree d := deg(Hf ) = O(1) can be simulated
with O(nd ) basic gates. Ancilla qubits are not necessary in either case.
Here, by basic quantum gates we mean the set of CNOT and single qubit rotation gates, which is a
standard universal set [28, 40]. We remark that the Hamiltonian simulation considered in the corollary
is exact in the sense that if each of the basic gates is implemented exactly, then so is exp(−iγHf ). The
approximation of quantum gates and operators is an important topic but we do not deal with it here; see,
e.g., [40].
Example 1. [Application to Grover’s algorithm] For a Boolean function f , simulating Hf for time π gives
the standard oracle query for Grover’s algorithm [40]
e−iπHf |xi = (−1)f (x) |xi. (25)
Hence, when Hf is known explicitly and size(Hf ) = poly(n), we can efficiently construct and implement the
operator (−1)f (x) using quantum circuits for simulating Hf using only CNOT and RZ gates, without any
necessary ancilla qubits.
with a, cj , djk ∈ R and xj ∈ {0, 1}. Indeed, this is the class of problems (ideally) implementable on current
quantum annealing devices such as, for example, D-WAVE machines, where the qubit interactions are them-
selves quadratic [3,44]. The QUBO class also contains many problems which at first sight are not quadratic,
via polynomial reductions which often require extra variables; indeed, the natural QUBO decision problem
is NP-complete [45]. Note that xj = 1 − xj , so (26) is without loss of generality. Applying our above results
gives the following.
Corollary 5. The QUBO objective function (26) maps to a Hamiltonian given as a quadratic sum of Pauli
Z operators, with size(Hf ) ≤ 1 + n/2 + n2 /2. Explicitly, we have
n
1X 1X
Hf = (a + c + d)I − (cj + dj )Zj + djk Zj Zk , (27)
2 j=1 4
j<k
Pn P P
where we have defined c = 21 j=1 cj , d = 41 j<k djk , and dj = 12 k:k6=j djk with djk = dkj .
Moreover, we can simulate
Hf , i.e., implement the phase operator Up (t) = e−itHf , using at most n many
n
RZ rotation gates and 2 many RZZ gates.
13
The QUBO problem is closely related to the Ising model of interacting spins from physics [46].
Example 2 (Interacting Ising spins). Consider the related classical ISING decision problem of determining
whether the ground state energy (lowest eigenvalue) of an Ising model (degree two) diagonal Hamiltonian
X X
H = a0 I + aj Z j + ajk Zj Zk
j j<k
is at most a given constant. As the number of terms is size(H) = O(n2 ), we can efficiently check the energy
H(x) of each candidate ground state |xi, x ∈ {0, 1}n, so the problem is in NP. On the other hand, from
Theorem 2, we see that the NP-complete problem MAX-2-SAT maps to a degree-two Hamiltonian of this
form, with solution encoded in the ground state energy of −H. Thus, from our results it trivially follows that
ISING is NP-complete. Similar arguments can be used to show NP-completeness with restricted coefficients
values (e.g., antiferromagnetic) or with restricted interaction topologies such as planar graphs [47].
with real coefficients aα ∈ R. (For general linear operators on qubits the same formula holds but with
aα ∈ C, see e.g. [48].) The coefficients are easily shown to satisfy
1
aα = tr(αH), (29)
2n
for each of the 4n Pauli terms α = σ1 σ2 . . . σn , σj ∈ {I, Xj , Yj , Zj }, which are orthonormal with respect to
the Hilbert-Schmidt inner product hα, βi := 21n tr(α† β) that generalizes (16).
for various values t = 1, 2, 4, . . . . Consider such a transformation with fixed t. Labeling the first register
(control qubit) a, the overall unitary may be written as
Recall the notation Λxa (e−iHt ) indicates the unitary e−iHt controlled by the classical function xa . We obtain
e
the Hamiltonian corresponding to this transformation by writing Λxa (e−iHt ) = e−iHt , which gives
e = |1ih1| ⊗ H = xa ⊗ H = 1 I ⊗ H − 1 Za ⊗ H.
H (31)
2 2
Recall that for simplicity we sometimes write a function f in place of its Hamiltonian representation Hf as
we have done here for the function f (x) = xa . Note that the control qubit is assumed precomputed here; its
value may or may not depend on x.
14
More generally, consider Hamiltonian evolution controlled by a Boolean function g ∈ Bk acting on a
k-qubit ancilla register. In this case we seek to affect the unitary transformation on (k + n)-qubit basis states
These results have been summarized in Proposition 1 above. Note that if the Hamiltonian H = Hf represents
e g = Hg ⊗ Hf = Hg∧f .
a Boolean function f , then (33) represents the conjunction of f and g, i.e., we have H
Moreover, for an arbitrary Hamiltonian H, if we can implement the ancilla controlled operator Λxa (e−iHt )
for sufficiently many values of t ∈ R, then it is straightforward to implement a variable-time controlled
Hamiltonian simulation operator Λτ,H , which acts on basis states as
15
derived from a reversible classical circuit for computing f , but we consider it abstractly here. (The query
(25) for Grover’s algorithm is often referred to as a phase query.)
We show that Gf also induces a diagonal representation of Hf , and hence faces the same computational
difficulties for the Boolean case. Observe that the diagonal Hamiltonian
1 1
Hf′ := Gf xa Gf = I − Gf Za Gf = xa + Hf Za (36)
2 2
acts on computational basis states as
using a single ancilla qubit prepared in the state |−i = √12 (|0i − |1i) = H|1i and where H denotes the
Hadamard (single qubit quantum Fourier transform) gate [40], known as phase kickback.
Next consider the controlled-phase-query oracle Λxa ((−1)f ) = Λxa (e−iπHf ) = (−1)f ∧xa derived from
(30). Observe that if we can query Λxa ((−1)f ) then we can implement Gf using a single-bit quantum phase
estimation, which requires two Hadamard gates applied to an ancilla qubit and a single Λxa ((−1)f ) query as
Similarly, two bit queries can simulate Λxa ((−1)f ) using an ancilla qubit |0ib to store f (x) as
(I ⊗ Gf ) RZa (− π2 )RZb (− π2 )RZa Zb ( π2 ) (I ⊗ Gf ) |xa ia |xi|0ib = c′ (−1)f (x)∧xa |xa ia |xi|0ib , (40)
where the constant c′ is an unimportant global phase. (Here the three rotations on the left of (40) are derived
from simulating the Hamiltonian representing the function xa ∧ xb for time π as to implement the operator
(−1)xa ∧xb , and the second application of Gf uncomputes the ancilla qubit.) Hence, we easily see that the
oracles Gf and Λxa (e−iπHf ) = (−1)f (x)∧xa are computationally equivalent, and both are at least as powerful
as the phase oracle (−1)f . The results of this paper may be similarly applied to the study of complexity and
reductions between further classes of oracles.
16
and beyond. Our results give a unified view of existing problem mappings in the literature, such as those
of [6, 8].
There are a variety of enticing applications and extensions of our results, and we briefly outline several
additional directions. We emphasize that Fourier analysis is generally a very rich topic in computer science,
mathematics, and physics, in addition to its many applications in quantum computing. A promising research
direction is to further apply these tools, in particular more advanced ideas from the Fourier analysis of
Boolean functions as applied in classical computer science, to the design and analysis of quantum algorithms.
As mentioned, we leave a detailed analysis of general Hamiltonians acting on qubits or qudits as a topic of
future work. A next step is to further classify unfaithful Hamiltonian representations of Boolean functions,
where n variables are encoded in n′ > n qubits, which in particular is an important paradigm for embedding
problems on physical quantum annealing hardware, and, more generally, is related to the theory of quantum
error correcting codes. Moreover, our results may have useful applications to quantum statistical mechanics,
where many important Hamiltonians are given as linear combination of Pauli operators, such as the Ising
or quantum XY models [47, 52]. Furthermore, exploring connections to quantum complexity theory may
be fruitful, such as Hamiltonian complexity [53–55], or the computational power of restricted classes of
quantum circuits [26,56,57]. Finally, it of interest whether techniques from quantum computing and quantum
information can shed further insight on important open problems in classical computer science [17, 58].
Acknowledgments
We thank Al Aho for support and guidance, and the members of the Quantum AI Lab for providing helpful
comments and suggestions. This work was initiated thanks to the support of the USRA Feynman Quantum
Computing Academy summer internship program and NASA Ames Research Center, and further developed
while at Columbia University. S.H. was additionally supported by NASA Academic Mission Services, Con-
tract No. NNA16BD14C. The views and conclusions contained herein are those of the author and should
not be interpreted as necessarily representing the official policies or endorsements, either expressed or im-
plied, of the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for
Governmental purpose not withstanding any copyright annotation thereon.
References
[1] T. Kadowaki and H. Nishimori, “Quantum annealing in the transverse Ising model,” Phys. Rev. E,
vol. 58, no. 5, p. 5355, 1998.
[2] E. Farhi, J. Goldstone, S. Gutmann, and M. Sipser, “Quantum computation by adiabatic evolution,”
arXiv preprint quant-ph/0001106, 2000.
[3] C. C. McGeoch, “Adiabatic quantum computation and quantum annealing: Theory and practice,”
Synthesis Lectures on Quantum Computing, vol. 5, no. 2, pp. 1–93, 2014.
[4] T. Hogg and D. Portnov, “Quantum optimization,” Information Sciences, vol. 128, no. 3-4, pp. 181–197,
2000.
[5] E. Farhi, J. Goldstone, and S. Gutmann, “A quantum approximate optimization algorithm,” arXiv
preprint arXiv:1411.4028, 2014.
[6] S. Hadfield, Z. Wang, B. O’Gorman, E. G. Rieffel, D. Venturelli, and R. Biswas, “From the quantum
approximate optimization algorithm to a quantum alternating operator ansatz,” Algorithms, vol. 12,
no. 2, p. 34, 2019.
[7] A. Peruzzo, J. McClean, P. Shadbolt, M.-H. Yung, X.-Q. Zhou, P. J. Love, A. Aspuru-Guzik, and J. L.
O’Brien, “A variational eigenvalue solver on a photonic quantum processor,” Nature communications,
vol. 5, 2014.
[8] A. Lucas, “Ising formulations of many NP problems,” Frontiers in Physics, vol. 2, no. 5, pp. 1–15, 2014.
17
[9] G. Ausiello, P. Crescenzi, G. Gambosi, V. Kann, A. Marchetti-Spaccamela, and M. Protasi, Complexity
and approximation: Combinatorial optimization problems and their approximability properties. Springer
Science & Business Media, 2012.
[10] S. Arora and B. Barak, Computational Complexity - A Modern Approach. Cambridge University Press,
2009.
[11] M. A. Nielsen, “Computable functions, quantum measurements, and quantum dynamics,” Physical
Review Letters, vol. 79, no. 15, p. 2915, 1997.
[12] J. Kahn, G. Kalai, and N. Linial, “The influence of variables on Boolean functions,” in Proc. 29th IEEE
Symposium on Foundations of Computer Science, pp. 68–80, IEEE, 1988.
[13] N. Linial, Y. Mansour, and N. Nisan, “Constant depth circuits, Fourier transform, and learnability,”
Journal of the ACM (JACM), vol. 40, no. 3, pp. 607–620, 1993.
[14] R. Beigel, “The polynomial method in circuit complexity,” in Proc. 8th Structure in Complexity Theory
Conference, pp. 82–95, IEEE, 1993.
[15] N. Nisan and M. Szegedy, “On the degree of Boolean functions as real polynomials,” Computational
complexity, vol. 4, no. 4, pp. 301–313, 1994.
[16] P. L. Hammer and S. Rudeanu, Boolean Methods in Operations Research and Related Areas, vol. 7.
Springer Science & Business Media, 2012.
[17] Y. Gu and X.-L. Qi, “Majorana fermions and the sensitivity conjecture,” arXiv preprint
arXiv:1908.06322, 2019.
[18] R. Beals, H. Buhrman, R. Cleve, M. Mosca, and R. De Wolf, “Quantum lower bounds by polynomials,”
Journal of the ACM (JACM), vol. 48, no. 4, pp. 778–797, 2001.
[19] A. Ambainis, “Polynomial degree vs. quantum query complexity,” Journal of Computer and System
Sciences, vol. 72, no. 2, pp. 220–238, 2006.
[20] A. Montanaro and T. J. Osborne, “Quantum Boolean functions,” arXiv preprint arXiv:0810.2435, 2008.
[21] S. Boixo, V. N. Smelyanskiy, and H. Neven, “Fourier analysis of sampling from noisy chaotic quantum
circuits,” arXiv preprint arXiv:1708.01875, 2017.
[22] R. O’Donnell, Analysis of Boolean functions. Cambridge University Press, 2014.
[23] N. Schuch and J. Siewert, “Programmable networks for quantum algorithms,” Physical review letters,
vol. 91, no. 2, p. 027902, 2003.
[24] J. Welch, D. Greenbaum, S. Mostame, and A. Aspuru-Guzik, “Efficient quantum circuits for diagonal
unitaries without ancillas,” New Journal of Physics, vol. 16, no. 3, p. 033040, 2014.
[25] M. Amy, P. Azimzadeh, and M. Mosca, “On the controlled-not complexity of controlled-not–phase
circuits,” Quantum Science and Technology, vol. 4, no. 1, p. 015002, 2018.
[26] M. J. Bremner, A. Montanaro, and D. J. Shepherd, “Achieving quantum supremacy with sparse and
noisy commuting quantum computations,” Quantum, vol. 1, p. 8, 2017.
[27] E. Boros and P. L. Hammer, “Pseudo-Boolean optimization,” Discrete applied mathematics, vol. 123,
no. 1, pp. 155–225, 2002.
[28] A. Barenco, C. H. Bennett, R. Cleve, D. P. DiVincenzo, N. Margolus, P. Shor, T. Sleator, J. A. Smolin,
and H. Weinfurter, “Elementary gates for quantum computation,” Physical review A, vol. 52, no. 5,
p. 3457, 1995.
[29] A. M. Childs, Quantum information processing in continuous time. PhD thesis, Massachusetts Institute
of Technology, 2004.
18
[30] S. Chakraborty, A. Gilyén, and S. Jeffery, “The power of block-encoded matrix powers: improved
regression techniques via faster hamiltonian simulation,” arXiv preprint arXiv:1804.01973, 2018.
[31] S. Hadfield, Z. Wang, E. G. Rieffel, B. O’Gorman, D. Venturelli, and R. Biswas, “Quantum approximate
optimization with hard and soft constraints,” in Proceedings of the Second International Workshop on
Post Moores Era Supercomputing, PMES’17, (New York, NY, USA), p. 15–21, Association for Comput-
ing Machinery, 2017.
[32] M. Soeken and M. Roetteler, “Quantum circuits for functionally controlled not gates,” arXiv preprint
arXiv:2005.12310, 2020.
[33] G. Birkhoff and J. Von Neumann, “The logic of quantum mechanics,” Annals of mathematics, pp. 823–
843, 1936.
[34] R. De Wolf, “A brief introduction to Fourier analysis on the Boolean cube.,” Theory of Computing,
Graduate Surveys, vol. 1, pp. 1–20, 2008.
[35] F. J. MacWilliams and N. J. A. Sloane, The theory of error correcting codes, vol. 16. Elsevier, 1977.
[36] S. Givant and P. Halmos, Introduction to Boolean Algebras. Springer Science & Business Media, 2008.
[37] M. Ohzeki, “Breaking limitation of quantum annealer in solving optimization problems under con-
straints,” Scientific reports, vol. 10, no. 1, pp. 1–12, 2020.
[38] I. Hen and M. S. Sarandy, “Driver Hamiltonians for constrained optimization in quantum annealing,”
Phys. Rev. A, vol. 93, no. 6, p. 062312, 2016.
[39] I. Hen and F. M. Spedalieri, “Quantum annealing for constrained optimization,” Phys. Rev. Appl.,
vol. 5, no. 3, p. 034007, 2016.
[40] M. Nielsen and I. Chuang, Quantum Computation and Quantum Information. Cambridge UK: Cam-
bridge University Press, 2000.
[41] J. Biamonte, “Nonperturbative k-body to two-body commuting conversion Hamiltonians and embedding
problem instances into Ising spins,” Phys. Rev. A, vol. 77, no. 5, p. 052331, 2008.
[42] I. J. Crosson, D. Bacon, and K. R. Brown, “Making classical ground-state spin computing fault-
tolerant,” Phys. Rev. E, vol. 82, no. 3, p. 031106, 2010.
[43] J. D. Whitfield, M. Faccin, and J. Biamonte, “Ground-state spin logic,” EPL (Europhysics Letters),
vol. 99, no. 5, p. 57004, 2012.
[44] Z. Bian, F. Chudak, W. G. Macready, and G. Rose, “The Ising model: teaching an old problem new
tricks,” tech. rep., D-Wave Systems, 2010.
[45] M. R. Garey and D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP–
Completeness. New York, NY, USA: W. H. Freeman & Co., 1979.
[46] H. Nishimori, Statistical physics of spin glasses and information processing: an introduction, vol. 111.
Clarendon Press, 2001.
[47] F. Barahona, “On the computational complexity of ising spin glass models,” Journal of Physics A:
Mathematical and General, vol. 15, no. 10, p. 3241, 1982.
[48] P. Woit, Quantum Theory, Groups and Representations: An Introduction. Springer, 2017.
[49] A. Szabo and N. S. Ostlund, Modern Quantum Chemistry: Introduction to Advanced Electronic Structure
Theory. Dover, 1996.
[50] J. T. Seeley, M. J. Richard, and P. J. Love, “The Bravyi-Kitaev transformation for quantum computation
of electronic structure,” The Journal of chemical physics, vol. 137, no. 22, p. 224109, 2012.
19
[51] G. Verdon, M. Broughton, and J. Biamonte, “A quantum algorithm to train neural networks using
low-depth circuits,” arXiv preprint arXiv:1712.05304, 2017.
[52] E. Lieb, T. Schultz, and D. Mattis, “Two soluble models of an antiferromagnetic chain,” in Condensed
Matter Physics and Exactly Soluble Models, pp. 543–601, Springer, 2004.
[53] J. Kempe, A. Kitaev, and O. Regev, “The complexity of the local Hamiltonian problem,” SIAM J.
Comput., vol. 35, no. 5, pp. 1070–1097, 2006.
[54] S. Gharibian, Y. Huang, Z. Landau, S. W. Shin, et al., “Quantum Hamiltonian complexity,” Foundations
and Trends in Theoretical Computer Science, vol. 10, no. 3, pp. 159–282, 2015.
[55] T. S. Cubitt, A. Montanaro, and S. Piddock, “Universal quantum hamiltonians,” Proceedings of the
National Academy of Sciences, vol. 115, no. 38, pp. 9497–9502, 2018.
[56] E. Knill and R. Laflamme, “Power of one bit of quantum information,” Physical Review Letters, vol. 81,
no. 25, p. 5672, 1998.
[57] S. Bravyi, D. Gosset, and R. König, “Quantum advantage with shallow circuits,” Science, vol. 362,
no. 6412, pp. 308–311, 2018.
[58] Y. Filmus, H. Hatami, S. Heilman, E. Mossel, R. O’Donnell, S. Sachdeva, A. Wan, and K. Wimmer,
“Real analysis in computer science: A collection of open problems,” Preprint available at https://simons.
berkeley. edu/sites/default/files/openprobsmerged.pdf, 2014.
20