NAE3SAT is an NP-complete Boolean satisfiability (SAT) problem that has clauses of three literals each and requires that for every clause the literals are not all equal to each other; i.e., all configurations are valid except {$-1, -1, -1$} and {$+1, +1, +1$} (for spin-valued variables, or {$0,0,0$} and {$1, 1, 1$} for binary-valued variables).
SAT Terminology:
The SAT problem problem is to decide whether the literals in its clauses can be assigned values that satisfy all the clauses. In CNF, the SAT is satisfied only if all its clauses are satisfied.
-
Literal is a Boolean variable such as
$x$ and its negation,$\bar x$ . -
Clause is a disjunction of literals such as
$x_0 \vee x_1$ . -
conjunctive normal form (CNF) conjoins clauses by the AND operator; i.e.,
(clause 1)
$\wedge$ (clause 2)$\wedge$ (clause 3).
NAE3SAT problems are known to transition from the satisfiable to the unsatisfiable
regime at a clause-to-variable ratio
This example explores solving this satisfiability problem with two different generations of D-Wave quantum computers:
- A Pegasus-topology Advantage system.
- An experimental prototype of a Zephyr-topology quantum processing unit (QPU) for the Advantage2 next-generation system currently under development.
You can run this example in the Leap IDE.
Alternatively, install requirements locally (ideally, in a virtual environment):
pip install -r requirements.txt
To run the example:
python nae3sat_example.pyThe code saves the resulting graphics under a plots folder.
The code reformulates NAE3SAT instances as Ising problems, embeds these onto the QPU graphs, and analyzes the solution quality obtained from both QPUs.
NAE3SAT problems can be mapped to the
Ising model by
anti-ferromagnetically coupling the variables of a clause. For example, a clause
for variables {$s_0$,
The table below shows the energy for all configurations of the variables. The valid not-all-equal configurations have a lower energy than the all-equal ones. Therefore, the NAE3SAT clause is solved when minimizing the Hamiltonian objective.
| -1 | -1 | -1 | 3 |
| 1 | -1 | -1 | -1 |
| 1 | 1 | -1 | -1 |
| -1 | 1 | -1 | -1 |
| -1 | 1 | 1 | -1 |
| 1 | 1 | 1 | 3 |
| 1 | -1 | 1 | -1 |
| -1 | -1 | 1 | -1 |
Negated variables are represented by a
spin-reverse transform
of such variables. For example, a clause with
A NAE3SAT problem is generated by adding all its clauses together; for example:
The minimization of this objective solves the NAE3SAT problem.
For more information on reformulating SAT problems in Ising format, see the system documentation.
Both the Pegasus and Zephyr graphs natively support triangles, enabling the embedding of three-variable clauses without chains. Nevertheless, large NAE3SAT problems typically include interactions between variables that are not natively connected and do require chains.
The graphic below shows the distribution of chain lengths for a
The Zephyr topology of the Advantage2 prototype has a greater connectivity than the Pegasus topology of Advantage. This enables more-compact embedding (minor embeddings with shorter chains) of problems in the Advantage2 prototype, which in turn improves the performance of the QPU on embedded problems.
The graphic below shows the solution quality of 100 samples from a
The distribution of samples obtained by the Advantage2 prototype tends to have lower energy than that of the Advantage QPU. Lower energies mean better solutions.
Note: The data displayed in the graphics above was generated for a particular execution of this code example; results will slightly vary from run to run. If you wish to experiment further to get more consistent results, you can increase the number of samples or the number of calls (keep in mind these runs will consume your solver access time at the standard rate).
Released under the Apache License 2.0. See LICENSE file.

