Subsystems

class trueq.Subsystems(subsystems=None)

Represents a collection of quantum subsystems. Each subsystem is represented as a sorted tuple of qudit labels, and a particular subsystem can appear only once in the collection.

import trueq as tq

tq.Subsystems([0, [1, 2], 3])
Subsystems(((0,), (3,), (1, 2)))
Parameters:

subsystems (Iterable) – A list of lists of subsystem labels. For convenience, isolated labels are treated as a list of length 1, for example, labels = [0, [1, 2], 3] is equivalent to labels = [[0], [1, 2], [3]].

property subsystems

All the subsystems, sorted first by subsystem size and then lexicographically by the subsystem labels.

import trueq as tq

subsys = tq.Subsystems([0, 2, [1, 2], 1, [0, 1, 2]])
subsys.subsystems
((0,), (1,), (2,), (1, 2), (0, 1, 2))
Type:

tuple

property labels

The sorted union of all system labels in this Subsystems.

import trueq as tq

subsys = tq.Subsystems([0, [0, 1], [0, 1, 2]])
subsys.labels
(0, 1, 2)
Type:

tuple

property n_sys

The number of distinct system labels in this Subsystems.

import trueq as tq

subsys = tq.Subsystems([0, [0, 1], [0, 1, 2]])
subsys.n_sys
3
Type:

int

static from_cycle(cycle, twirl=None)

Returns a new Subsystems containing all the subsystems acted on by the Gates of a given Cycle.

import trueq as tq

cycle = tq.Cycle({0: tq.Gate.h, (2, 3): tq.Gate.cnot})
twirl = tq.Twirl("P", range(4))

tq.Subsystems.from_cycle(cycle, twirl=twirl)
Subsystems(((0,), (1,), (2, 3)))
Parameters:
  • cycle (Cycle) – The cycle to specify the subsystems for.

  • twirl (Twirl) – The Twirl used with this cycle. Setting this will include the non-overlapping labels of the twirl as subsystems in addition to the labels of this cycle.

Return type:

Subsystems

Raises:
  • ValueError – If the twirl is missing subsystems present in the cycle.

  • ValueError – If the subsystems in the twirl partially overlap with those in the cycle.

combinations(k)

Returns a new Subsystems where all combinations of up to k of these subsystems are included.

import trueq as tq

subsys = tq.Subsystems([0, 2, [1, 3]])
subsys.combinations(2)
Subsystems(((0,), (2,), (0, 2), (1, 3), (0, 1, 3), (1, 2, 3)))
Parameters:

k (int) – The maximum number of combinations to include.

Return type:

Subsystems

intersection(labels)

Returns a new Subsystems of labels that are the intersections of this Subsystems with a given labels.

import trueq as tq

subsys = tq.Subsystems([0, [0, 1], [1, 2]])
subsys.intersection([0, 2])
Subsystems(((0,), (2,)))
Parameters:

labels (Iterable) – A label to intersect this Subsystems with.

Return type:

Subsystems

limit_size(size)

Returns a new Subsystems containing all subsystems that have length less than or equal to a given size.

import trueq as tq

subsys = tq.Subsystems([0, [1, 2], 3])
subsys.limit_size(1)
Subsystems(((0,), (3,)))
Parameters:

size (int) – The maximum length subsystems to include.

nearest_neighbour(graph)

Returns a new Subsystems containing all the subsystems as well as pairs of subsystems that are connected by a single edge in a Graph.

import trueq as tq

subsys = tq.Subsystems([0, 1, 2, [3, 4]])
graph = tq.visualization.Graph.linear(5)
subsys.nearest_neighbour(graph)
Subsystems(((0,), (1,), (2,), (0, 1), (1, 2), (3, 4), (2, 3, 4)))
Parameters:

graph (Graph) – The graph that specifies the qudit layout.