Tensor networks and their contraction #
A tensor network over a commutative semiring R and an alphabet U is a multigraph whose
edges carry values in U, with a tensor at each vertex v: a value N.tensor v x ∈ R for each
assignment x : E → U of values to the edges, which depends only on the values on the edges at
v. Its contraction sums, over all assignments, the product of the tensors:
Z(N) = ∑ x : E → U, ∏ v, N.tensor v x.
A Boolean tensor network has U = Bool, one bit per edge. The usual presentation gives the
tensor at v as a function F_v of the bits on the ordered list δ(v) of edges at v, with
Z = ∑ x ∏ v F_v (x|δ(v)). Here the tensor is a function of the whole assignment, constrained to
read only the edges at v (TensorNetwork.tensor_congr); the ordered presentation, with
explicit tables, is Cslib.Circuits.Frontier.ExplicitTensorNetwork, and
Cslib.Circuits.Frontier.TensorNetwork.contraction_toExplicit shows that the two contractions
agree. Parallel edges are distinct elements of E and so give distinct ports.
A tensor network is the weighted form of a constraint network
(Cslib.Circuits.Frontier.Network) on a fixed input: the two share the multigraph and the
locality condition, and a constraint becomes its 0–1 indicator tensor, whose contraction
counts the satisfying assignments
(Cslib.Circuits.Frontier.Network.contraction_toTensorNetwork).
Subdivision (TensorNetwork.subdivide). Splitting every edge e into two edges joined at a
new vertex that carries the equality tensor [y₁ = y₂] preserves the contraction
(TensorNetwork.contraction_subdivide): each assignment of the old network extends in exactly one
way to an assignment of the new one with nonzero weight. The subdivided network is bipartite
(TensorNetwork.isBipartite_subdivide), with the old vertices on one side and the new ones on the
other, and it keeps the degree bound of a loopless network (TensorNetwork.maxDegreeLE_subdivide).
It has twice as many edges and one new vertex per old edge.
Main definitions #
Cslib.Circuits.Frontier.Multigraph.IsBipartite: the vertices split into two sides and every edge joins the two sides.Cslib.Circuits.Frontier.TensorNetwork: a tensor network.Cslib.Circuits.Frontier.TensorNetwork.contraction: its contractionZ.Cslib.Circuits.Frontier.TensorNetwork.subdivide: subdivision of every edge by an equality tensor.
Main results #
Cslib.Circuits.Frontier.Multigraph.isBipartite_iff: a multigraph is bipartite iff it has no loops and its underlying simple graph is bipartite (SimpleGraph.IsBipartite).Cslib.Circuits.Frontier.TensorNetwork.contraction_subdivide: subdivision preserves the contraction.Cslib.Circuits.Frontier.TensorNetwork.isBipartite_subdivide: a subdivided network is bipartite.Cslib.Circuits.Frontier.TensorNetwork.maxDegreeLE_subdivide: subdividing a loopless network of maximum degree at mostd ≥ 2gives maximum degree at mostd.
References #
- OpenAI, The Exponential Time Hypothesis is False, Appendix D.1 (p. 53) and the subdivision step of Appendix D.2 (p. 54).
Bipartite multigraphs #
A multigraph is bipartite when its vertices split into two sides, side v = true and
side v = false, and every edge joins the two sides. A bipartite multigraph has no loops
(Multigraph.IsBipartite.loopless).
A bipartite multigraph has no loops.
A multigraph is bipartite exactly when it has no loops and its underlying simple graph is
bipartite in the sense of Mathlib (SimpleGraph.IsBipartite, a 2-colouring).
Tensor networks #
A tensor network over the commutative semiring R with alphabet U: a multigraph on the
vertices V and edges E, whose edges carry values in U, and at each vertex a tensor, a value
in R for each assignment of values to the edges, that sees only the values on the edges at that
vertex. A Boolean tensor network has U = Bool.
- src : E → V
- tgt : E → V
- tensor : V → (E → U) → R
The tensor at a vertex: its value on an assignment of values to the edges.
- tensor_congr (v : V) (x y : E → U) : (∀ (e : E), self.src e = v ∨ self.tgt e = v → x e = y e) → self.tensor v x = self.tensor v y
Tensors are local: the tensor at
vsees only the values on the edges incident tov.
The contraction of a tensor network: the sum over all assignments of values to the edges of the product of the tensors at all vertices.
Subdivision by equality tensors #
The subdivision of a tensor network by equality tensors. Each edge e becomes a new vertex
Sum.inr e and two edges: Sum.inl e, from the source of e, and Sum.inr e, from its target,
both ending at Sum.inr e. The new vertex carries the equality tensor, one when its two edges
carry the same value and zero otherwise. An old vertex reads the value of e on the half of e
at its end.
The tensor at an old vertex of the subdivision.
The equality tensor at a new vertex of the subdivision.
Subdivision is bipartite. Every edge of the subdivision joins an old vertex to a new one.
Subdivision preserves the contraction. An assignment of the subdivision has nonzero weight only when the two halves of every edge carry the same value, and such assignments are exactly the assignments of the original network.
The edges at an old vertex of the subdivision are the halves of its old edges at it.
The edges at a new vertex of the subdivision are the two halves of its edge.
Subdivision keeps the degree bound. In a loopless network, the edges at a vertex are those with it as source and those with it as target, and they are the halves at its old vertex in the subdivision; a new vertex has degree two.