(Thanks to Mark Xu for comments on these notes.)

These are some notes on tensor networks, the mapping from boolean circuits to tensor networks, and how #SAT can be written as a tensor network contraction.

Definitions and Notation

What is a tensor?

A rank- tensor is an array of numbers with  integer indices, e.g.  is a rank-3 tensor. The range of each index is called its bond dimension. So for instance the Kronecker delta tensor used in physics is given by

and is a tensor with two indices, each of bond dimension 3. Meanwhile the Levi-Civita symbol

is a tensor with three indices each of dimension 3.

What is a tensor contraction?

A contraction is a specification of dot products to perform between tensors. For instance

says to form the tensor  by contracting  with  along the second index of  and the first index of .

A tensor can also be contracted with itself, forming a trace. For instance

says that we trace over the second and third indices of  to form .

Often times the summation is written just with indices and no  symbol using Einstein summation notation. In this notation, indices are summed over if they appear in an expression exactly twice. This notation is unambiguous because contraction is only defined over pairs of indices.

What is a tensor network?

A tensor network is a specification of which contractions are desired between one or more tensors. They are often drawn diagrammatically in penrose notation as

Here  has three indices, , two of which are free (meaning they are not involved in any contraction) and one of which is linked to an index of , which itself has a further free index .

Representing Boolean Circuits

A boolean circuit with inputs  can be written as a tensor network as follows. For further references see here.

First, each input is mapped from False/True to a vector which is either  or . These vectors can be contracted with tensors representing the various boolean gates. For instance

This has the property that

That is,  implements an OR gate. An AND gate can be similarly constructed:

Note that an AND tensor can also be used to copy a wire, because

Finally, NOT gates are just given by

so that

In this way, we can construct a tensor network which, when contracted against the vectors representing its inputs, results in a vector representing its output.

#SAT

#SAT is the problem of counting the number of instances of a boolean circuit which output True. We can represent this problem in a tensor network as follows:

(1) Map the boolean circuit to a tensor network with input indices  and output index . The result might look like

If we contract some combination of  against the input indices  then the resulting tensor network will equal either  (if the boolean circuit would have produced True with that input) or  (otherwise).

(2) Contract an instance of  against . Because  is orthogonal to , and both have unit norm, the resulting tensor network now produces the scalar 1 if the inputs are set to a combination of  so that  and the scalar 0 otherwise.

(3) Make a copy of this tensor network, with input indices .

(4) Construct a new tensor network which specifies the contraction of the network and its copy, linking each  with the corresponding . This might look as follows:

This network has no free indices and so produces a scalar when contracted. The contraction can be written as a sum over all possible values of the indices , so that scalar equals the number of input instances satisfying the boolean circuit.

New Comment