Spekkens’s toy theory as a category of processes
Abstract.
We provide two mathematical descriptions of Spekkens’s toy qubit theory, an inductively one in terms of a small set of generators, as well as an explicit closed form description. It is a subcategory MSpek of the category of finite sets, relations and the cartesian product. States of maximal knowledge form a subcategory Spek. This establishes the consistency of the toy theory, which has previously only been constructed for at most four systems. Our model also shows that the theory is closed under both parallel and sequential composition of operations (= symmetric monoidal structure), that it obeys mapstate duality (= compact closure), and that states and effects are in bijective correspondence (= dagger structure). From the perspective of categorical quantum mechanics, this provides an interesting alternative model which enables us to describe many quantum phenomena in a discrete manner, and to which mathematical concepts such as basis structures, and complementarity thereof, still apply. Hence, the framework of categorical quantum mechanics has delivered on its promise to encompass theories other than quantum theory.
2000 Mathematics Subject Classification:
81P10, 18B10, 18D351. Introduction
In 2007 Rob Spekkens proposed a toy theory [20] with the aim of showing that many of the characteristic features of quantum mechanics could result from a restriction on our knowledge of the state of an essentially classical system. The theory describes a simple type of system which mimics many of the features of a quantum qubit. The success of the toy theory in replicating characteristic quantum behaviour is, in one sense, quite puzzling, since the mathematical structures employed by the two theories are quite different. Quantum mechanics represents states of systems by vectors in a Hilbert space, while processes undergone by systems are represented by linear maps. In contrast, the toy theory represents states by subsets and processes by relations. This ‘incomparability’ means that the mathematical origins of the similarities (and differences) between the two theories are not easy to pinpoint.
In this paper we consider the toy theory from a new perspective  by looking at the ‘algebra’ of how the processes of the theory combine. The mathematical structure formed by the composition of processes in any physical theory is a symmetric monoidal category [14], with the objects of the category representing systems, and the morphisms representing processes undergone by these systems  we term this the process category of the theory. Work initiated by Abramsky and Coecke [2], and continued by many other authors [17, 5, 9] has investigated the structure of the process category of quantum mechanics. Mathematical structures of this category have been identified which correspond directly to key physical features of the theory. In principle, any theory whose processes form a category with these mathematical features should exhibit these quantumlike physical features. It will be gratifying then to note that the process category of the toy theory shares many of these features, thus ‘accounting for’ the similarities which this theory has with quantum mechanics.
The main aim of this paper is to characterise the process category of the toy theory. This turns out to be less straightforward than one might have hoped! In the case of quantum mechanics it is straightforward to see that the states of a system correspond exactly with the vectors of the Hilbert space describing that system, and that processes correspond exactly with linear maps; thus we can immediately conclude that the process category of quantum mechanics is Hilb, whose objects are Hilbert spaces and whose morphisms are linear maps. Such a quick and easy statement of the process category for the toy theory is not possible. This is due largely to the way that the valid states and processes of the theory are defined: this is via an inductive procedure where the valid states and transformations for a collection of systems must be known before those for a collection of systems can be deduced.
There is also a certain degree of ambiguity in the way in which the theory was originally stated, and, since the toy theory was never fully constructed (until now), its consistency was not even guaranteed. Another feature which was not addressed in the theory is compositional closure, that is: If we compose two valid processes, either in parallel or sequentially (when types match), do we again obtain a valid process? Obviously, this is a natural operational requirement, and as indicated above, this notion of compositional closure is the operational cornerstone to modelling physical processes in a symmetric monoidal category. In this paper, it is exactly the compositional closure assumption which allows us to formulate the toy theory in terms of no more than a few generators, with clear operational meanings.
The structure of the paper is as follows. We begin with a very brief summary of the toy bit theory, and a discussion of the ambiguities in its definition. We then define a categories Spek and MSpek which we claim is the process category for the toy theory. This is a subcategory of Rel, whose objects are sets and whose morphisms are relations. The next section is devoted to showing the general form of the relations which constitute the morphisms of MSpek. We then go on to argue that these relations are exactly those which describe the processes of the toy theory, thus demonstrating that MSpek is the process category of the toy theory. Finally we note some of the key categorical features of MSpek and link these to the characteristically quantum behaviour exhibited by the toy bit theory.
The category Spek was first proposed by us in [6], and we provide some explicit pointers to useful information therein throughout this text.
2. The toy theory
For full details of Spekkens’s toy bit theory, the reader is referred to the original paper [20]. Here we provide a very brief summary of the key points. There is just one type of elementary system in the theory, which can exist in one of four states. We will denote the set of these four states, the ontic state space by . Alternatively we can depict it graphically as:
(2.1) 
The ontic states are to be distinguished from the epistemic states, which describe the extent of our knowledge about which ontic state the system occupies. For example we might know that the system is either in ontic state 1 or 2. We would depict such an epistemic state in the following fashion:
(2.2) 
The epistemic state is intended to be the analogue of the quantum state. Note that an epistemic state is simply a subset of the ontic state space. Given a composite system of elementary systems, its ontic state space is simply the Cartesian product of the ontic state spaces of the composite systems, . Thus such a system has ontic states.
The key premise of the theory is that our knowledge of the ontic state is restricted in a specific way so that only certain epistemic states are allowed. We refer the reader to the original paper for the full statement of this epistemic restriction, which Spekkens refers to as the knowledge balance principle. It suffices here to say that, given an component system, an epistemic state is a or element subset of the ontic state space, the case being the situation of maximal knowledge and the case being the situation of total ignorance.
For a single system this means that there are six epistemic states of maximal knowledge:
(2.3) 
and one of nonmaximal knowledge:
(2.4) 
A consequence of the knowledge balance principle is that any measurement on a system inevitably results in a probabilistic disturbance of that system’s ontic state. A measurement in the toy theory essentially corresponds to asking which of a collection of subsets of the ontic state space contains the ontic state. An example would be a measurement on a single system corresponding to the question ”is the ontic state in the subset or the subset ?”. If the initial epistemic state of the system was the subset then answering this question would allow us to pin down the ontic state precisely, to 1 if we get the first answer or 3 if we get the second, in violation of the knowledge balance principle. Thus we hypothesise that if, for example, we get the first answer to our question, then the ontic state undergoes a random disturbance, either remaining in state 1 or moving into state 2, with equal probability. The epistemic state following the measurement then would be . The effect of such a probabilistic disturbance on the epistemic state is best modelled by viewing it as a relation on the ontic state space, defined by , , , , where the notation denotes that the element 1 in the domain relates to both the elements 1 and 2 in the codomain, the element 2 in the domain, while the elements 3 and 4 in the domain relate to no elements in the codomain. Below we will omit specification of those elements in the domain that relate to no elements in the codomain. Thus in general the transformations of the theory are described by relations.
In his original paper Spekkens derives the states and transformations allowed in the theory, apparently appealing only to the following three principles:

The epistemic state of any system must satisfy the knowledge balance principle globally i.e. it should be a or element subset of the ontic state space.

When considering a composite system, the ‘marginal’ epistemic state of any subsystem should also satisfy the knowledge balance principle. By the marginal epistemic state we mean the following. Suppose the whole system has components, and we are interested in an component subsystem. The epistemic state of the whole system will be some set of tuples: to get the marginal state on the component system we simply delete the entries from each tuple which correspond to the subsystems which are not of interest to us.

Applying a valid transformation to a valid state should result in a valid state.
The second principle is used, for example, to rule this out as an epistemic state for a twocomponent system:
(2.5) 
The third principle is used extensively. It is invoked to show that the transformations on a single element system constitute permutations on the set of ontic states, since any other function on would lead to some valid epistemic state being transformed into an invalid state.
Another illuminating example of the third principle in action is the elimination of this state as a valid epistemic state:
(2.6) 
This state would be allowed by the first and second principles, but upon making a certain measurement on one of the systems, the resulting measurement disturbance would transform it into this state:
(2.7) 
which clearly fails to satisfy the first principle.
The mode of definition of the theory, via the three principles stated earlier, raises some interesting issues. Firstly, this approach seems to be necessarily iterative. Compare it, for example, to how we would describe the form of valid states in quantum mechanics  in one line we can say that they are the normalised vectors of the system’s state space. Secondly, do these rules actually uniquely define the toy theory? There does seem to be a problem with the third rule. When we use it to rule out the state in diagram 2.6, our argument is that we already know what the valid measurement disturbance transformations on a single elementary system are, and when we apply one of them to this state we obtain a state which clearly violates the knowledge balance principle. However, it is not clear that we could not have made the alternative choice  that this state should be valid, and therefore that the transformation which we had previously thought was valid could no longer be considered as such. It seems that considerations other than the three rules above come into deciding which should be the valid states of the theory, but it is nowhere clearly stated exactly what they are.
The second point touched slightly on our final issue: is the theory as Spekkens presents it consistent? He derives valid states and transformations for systems with up to three elementary components. However, can we be sure that these states and transformations, when combined in more complex situations involving four or more elementary systems, won’t yield a state which clearly violates the knowledge balance principle? Currently there seems to be no such proof of consistency. In fact, in the process of reexpressing the theory in categorical terms, we will develop such a proof.
3. Process categories of quantumlike theories
We briefly review the key structural features of the process categories of quantumlike theories. A physicistfriendly tutorial of the category theoretic preliminaries is in [8]. A survey on the recent applications of these to quantum theory and quantum information is in [4].
Definition 3.1.
A symmetric monoidal category is a category equipped with the following extra structure: a bifunctor ; a unit object ; and four natural isomorphisms, left and right unit: , , associative: and commutative: . Furthermore these objects and natural isomorphisms obey a series of coherence conditions [14].
As argued in [8], the process category of any physical theory is a SMC. The bifunctor is interpreted as adjoining two systems to make a larger compound system. Hilb becomes a SMC with the tensor product as the bifunctor, and as the unit object. Rel is a SMC with the Cartesian product as the bifunctor and the single element set as the unit object.
There is a very useful graphical language for describing SMCs, due to Joyal and Street [12], which we will make extensive use of. It traces back to Penrose’s earlier diagrammatic notation for abstract tensors [16].
In this language we represent a morphism by a box:
(3.1) 
, the composition of morphisms and is depicted as:
(3.2) 
The identity morphism is actually just written as a straight line — this makes sense if you imagine composing it with another morphism. Turning to the symmetric monoidal structure, a morphism is depicted:
(3.3) 
and if and then is depicted as:
(3.4) 
The identity object is not actually depicted in the graphical language. Morphisms and are written as:
(3.5) 
The associativity and left and right unit natural isomorphisms are also implicit in the language. The symmetry natural isomorphism is depicted as:
(3.6) 
In fact the graphical language is more than just a useful tool; it enables one to derive all equational statements that follow from the axioms of a SMC:
Theorem 3.2 ([12, 18]).
Two morphisms in a symmetric monoidal category can be shown to be equal using the axioms of a SMC iff the diagrams corresponding to these morphisms in the graphical language are isomorphic, where by diagram isomorphism we mean that the boxes and wires of the first are in bijective correspondence with the second, preserving the connections between boxes and wires.
The categories described by the graphical language are in fact strict SMCs, that is, those for which , and are equalities. Mac Lane’s Strictification Theorem [14, p.257], which establishes an equivalence of any SMC with a strict one, enables one to apply the diagrammatic notation to any SMC.
We will often refer to morphisms of type as states, since in a process category they represent the preparation of a system in a given state. In Hilb such morphisms are in bijection with the vectors of the Hilbert space ; in Rel they correspond to subsets of the set .
The process categories of quantumlike theories possess a range of additional structures.
Definition 3.3.
A dagger category is a category equipped with a contravariant involutive identityonobjects functor . A dagger symmetric monoidal category (SMC) is a symmetric monoidal category with a dagger functor such that: , , , , and .
Hilb is a SMC with the adjoint playing the role of the dagger functor. Rel is a SMC with relational converse as the dagger functor.
Definition 3.4 ([13]).
In a SMC a compact structure on an object is a tuple
where is a dual object to which may or may not be equal to , and and satisfy the conditions:
(3.7) 
and the dual diagram for . A compact closed category is a SMC in which all have compact structures.
Hilb is a compact closed category, where for each object the Bellstate ket (with a basis for the Hilbert space ) familiar from quantum mechanics provides the morphism , and the corresponding bra acts as . Perhaps unsurprisingly, given this example, Abramsky and Coecke in [2] showed that this structure underlies the capacity of any quantumlike theory to exhibit information processing protocols such as teleportation and entanglement swapping. Furthermore Abramsky has shown [1] that any theory whose process category is compact closed will obey a generalised version of the nocloning theorem.
For the compact structures of interest in this paper is always equal to – see proposition 3.9 below.^{1}^{1}1An analysis of the coherence conditions for these selfdual compact structures is in [19]. Hence, from here on we won’t distinguish these two objects.
This simplifies the graphical language, which can be extended by introducing special elements to represent the morphisms of the compact structure and :
(3.8) 
Equation 3.7 and its dual are then depicted as:
(3.9) 
This extension of the graphical language now renders it completely equivalent to the axioms of a compact closed category; for a detailed discussion we refer to [18].
Theorem 3.5.
Two morphisms in a compact closed category can be shown to be equal using the axioms of compact closure iff the diagrams corresponding to these morphisms in the graphical language are isotopic.
Compact closure is of particular importance to us since in any compact closed category there will be mapstate duality: a bijection between the homsets and (in fact both these will further be in bijection with ):
(3.10) 
and
(3.11) 
That this is a bijection follows from equation 3.9. If we have a morphism with larger composite domain and codomain the number of homsets in bijection increases dramatically. For example the morphisms of the homsets and are in bijection: explicitly the conversion between morphisms from the two sets can be depicted as:
(3.12) 
Clearly manoeuvres like this can convert any ‘input’ line into an ‘output’ line, by using the unit and counit morphisms to ‘bend lines around’.
Definition 3.6.
A diagram equivalence class^{2}^{2}2The terminology is inspired by the fact that the diagrams of all members of a class are essentially the same, only differing in the orientations of their input and output arrows. (DEC) is a set of morphisms in a compact closed category which can be interconverted by composition with the units and counits of the factors of their domains and codomains.
The final structure of interest is the basis structure, which can be seen as the ‘daggervariant’ of Carboni and Walters’s Frobenius algebras [3]. This structure is discussed at length in [5].
Definition 3.7.
In a SMC a basis structure on an object is a commutative isometric dagger Frobenius comonoid . For more details on this definition see section 4 of [5] where basis structures are referred to as ‘observable structures’. We represent the morphisms and graphically as:
(3.13) 
Basis structures are so named because in Hilb they are in bijection with orthonormal bases, via the correspondence:
(3.14) 
where is an orthonormal basis for . This is proved in [10].
Proposition 3.8 (See e.g. [5]).
Two basis structures and induce a third basis structure , with:
(3.15) 
Proposition 3.9 (See e.g. [9]).
Any basis structure induces a selfdual dagger compact structure, with and .
Basis structures are identified in [5] as a key structure underlying a variety of quantumlike features, for example the existence of incompatible observables, and information processing tasks such as the quantum fourier transform.
4. The categories Spek and MSpek
In the section we give the definitions of two key categories. The first definition is a convenient stepping stone to the second:
Definition 4.1.
The category Spek is a subcategory of Rel, defined inductively, as follows:

The objects of Spek are the singleelement set , the four element set , and its fold Cartesian products .

The morphisms of Spek are all those relations generated by composition, Cartesian product and relational converse from the following generating relations:

All permutations of the four element set, represented diagrammatically by:
(4.1) There are 24 such permutations and they form a group, .

A relation defined by:
represented diagrammatically by:
(4.2) 
a relation defined by and represented diagrammatically by:
(4.3) 
the relevant unit, associativity and symmetry natural isomorphisms.

Proposition 4.2.
[6] is a basis structure in FRel and hence also in Spek.
This category turns out to be the process category for the fragment of the toy theory containing only epistemic states of maximal knowledge. In particular, as discussed in detail in [6], the interaction of the basis structure and the permutations of results in three basis structures, analogous to the , the  and the bases of a qubit.
Furthermore, as also discussed in [6]§4, Spek also contains operations which in quantum theory correspond with projection operators, while these are not included in the toy theory. Indeed, compact closure of Spek implies mapstate duality: operations and bipartite states are in bijective correspondence.^{3}^{3}3We see this as an improvement, and in [21] also Spekkens expressed the desire for theories to have this property, as well as having a daggerlike structure, in the sense that states and effects should be in bijective correspondence.
The process category for the full toy theory has a similar definition:
Definition 4.3.
The category MSpek is a subcategory of Rel, with the same objects as Spek. Its morphisms are all those relations generated by composition, Cartesian product and relational converse from the generators of Spek plus an additional generator:
By construction, both Spek and MSpek inherit dagger symmetric monoidal structure from Rel, with Cartesian product being the monoidal product, and relational converse acting as the dagger functor.
Proposition 4.4.
Spek and MSpek are both compact closed.
Proof.
The primary task of the remainder of this paper is to demonstrate that MSpek is indeed the process category of Spekkens’s toy theory.
5. The general form of the morphisms of Spek and MSpek
We first make some preliminary observations.
Definition 5.1.
There is clearly a bijection between the possible compositions of Spek generators, and Spek diagrams. A Spek diagram with inputs and outputs represents a morphism of type : a relation between sets and . The number of relations between two finite sets and is clearly finite itself: it is the power set of . Thus the homset FRel(A,B) is finite. Since we can be sure that the homsets of Spek are finite. On the other hand, there is clearly an infinite number of Spek diagrams which have inputs and inputs  we can add more and more internal loops to the diagrams. Thus many diagrams represent the same morphism. However the morphisms of Spek are, by definition, all those relations resulting from arbitrary compositions of the generating relations, i.e. any relation that corresponds to one of the infinity of Spek diagrams. Hence any proof about the form of the morphisms in Spek is going to have to be a result about the relations corresponding to each possible Spek diagram, even though in general many diagrams correspond to a single morphism.
If we know the relation corresponding to one diagram in one of Spek’s diagram equivalence classes (recall definition 3.6), then it is straightforward to determine the relations corresponding to all of the other diagrams.
Lemma 5.2.
Given a Spek diagram and corresponding relation:
(5.1) 
then the relation corresponding to the following diagram:
(5.2) 
is given by, for all :
(5.3) 
where is the subset of which is related by to .
Every diagram equivalence class in Spek has at least one diagram of type , representing a state, where we make every external line an output. Relations of this type can be viewed as subsets of the set and it will be convenient for us to concentrate on characterising these morphisms. Via lemma 5.2 any results on the general form of states will translate into results on the general form of all morphisms. In what follows we will therefore make no distinction between the inputs and outputs of a Spekdiagram: a diagram with inputs and outputs will simply be referred to as a legged diagram.
Our proof will involve building up Spek diagrams by connecting together the generating morphisms. Here we show what various diagram manipulations mean in concrete terms for the corresponding relations. Henceforth, remembering that we only have to consider states, we will assume that the relation corresponding to any legged diagram is of type .
First we introduce some terminology. The composite of an tuple and an tuple is the tuple from . By the remnant of an tuple we mean the tuple obtained by deleting its component. By the remnant of an tuple (where ) we mean the tuple obtained by deleting the component of its remnant (or equivalently, deleting the component of its remnant).
Example 5.3.
Consider linking two diagrams, the first representing the relation the second representing the relation via a permutation , to form a new diagram as shown:
(5.4) 
The relation corresponding to this diagram is given by
(5.5) 
Or, in less formal language, for every pair of a tuple from and a tuple from obeying the condition , we form composite of the remnant of the tuple from , and the remnant of the tuple from .
Example 5.4.
Given a diagram representing the relation , consider forming a new diagram by linking the and legs of the original diagram via a permutation .
(5.6) 
The relation corresponding to this diagram is given by:
(5.7) 
Or, in less formal language, we take the remnant of every tuple for which .
Example 5.5.
Consider linking two diagrams, the first representing the relation the second representing the relation via a permutation , to form a new diagram as shown:
(5.8) 
The relation corresponding to this diagram is given by:
(5.9) 
Or, in less formal language, we take the remnant of every tuple for which .
5.1. Structure of the construction
It is convenient to single out a particular subgroup of the permutation subgroup. This consists of the four permutations which don’t mix between the sets and : (1)(2)(3)(4) (the identity), (12)(3)(4), (1)(2)(34) and (12)(34). We term these the phased permutations. All other permutations are termed unphased. We single out this subgroup because the relations corresponding to Spek diagrams generated from , , and the four phased permutations have a significantly simpler general form. We term such diagrams phased diagrams. All other diagrams are termed unphased diagrams. A morphism which corresponds to a phased diagram is termed a phased morphism, all other morphisms being unphased morphisms.
It is straightforward to see that any unphased Spek diagram can be viewed as a collection of phased subdiagrams linked together via unphased permutations. We refer to these subdiagrams as zones. Furthermore, note that any permutation in can be written as a product of phased permutations and the unphased permutation (1)(3)(24) (which we denote by ). Since a single phased permutation constitutes a phased zone with two legs, we can in fact view an unphased diagram as a collection of phased zones linked together by the permutation :
(5.10) 
Here represents a phased subdiagram and a square box represents an unphased permutations. Note that such a diagram is not necessarily planar, i.e. it may involve crossing wires. We distinguish between external zones which have external legs (e.g. , and in diagram 5.10), and internal zones all of whose legs are connected to other legs within the diagram (e.g. and ). To the external legs we associate an enumeration, such that legs from the same external zone appear consecutively.
In the first stage of the proof we determine the general form of the relation corresponding to a phased diagram. This stage itself splits into two phases: first we determine the general form of the morphisms of a new category HalfSpek, and then we show how to use this result to prove our main result in Spek. In the second stage we draw on the results of the first to determine the general form of the relation corresponding to any Spek diagram.
5.2. The general form of the morphisms of HalfSpek
We build up to the full theorem via a simplified case. For this we need a new category.
Definition 5.6.
The category HalfSpek is a subcategory of FRel. It is defined inductively, as follows:

The objects of HalfSpek are the singleelement set , the two element set , and its fold Cartesian products .

The morphisms of HalfSpek are all those relations generated by composition, Cartesian product and relational converse from the following generating relations:

All permutations of the two element set. There are 2 such permutations, the identity and the operation which swaps the elements of . Together they form the group .

A relation defined by:

a relation

Proposition 5.7.
[6] is a basis structure in FRel and hence also in HalfSpek.
Remark 5.8.
The existence of this basis structure came as a surprise to the authors. Naively one might think (as many working in the area of categorical quantum mechanics initially did) that on a set in FRel there is a single basis structure with given by for all . The ‘basis vectors’ (or copyable points in the language of [5]) are then the elements of this set. But this is not the case. There are many ‘nonwellpointed’ basis structures such as for which the number of copyable points is less than the number of elements of the set. In related work, Pavlovic has classified all basis structures in FRel and Evans et al. have identified the pairs of complementary basis structures (in the sense of [5]) among these [15, 11].
Next we determine the general form of the relations which constitute the morphisms of HalfSpek, to which the considerations made at the beginning of Section 5 also apply.
We say that an element of has odd parity if it has an odd number of ‘1’ elements, and that it has even parity if it has an even number of ‘1’ elements. We will use to represent a particular parity, odd or even, and will represent the opposite parity. Whether an oddparity tuple has an odd or even number of ‘0’ elements clearly depends on whether itself is odd or even. We could have chosen either 0 or 1 to play the role of labelling the parity; we have chosen 1 since it will turn out to be more convenient later on.
Theorem 5.9.
The relation in HalfSpek corresponding to an legged HalfSpekdiagram is a subset of , consisting of all tuples of a certain parity, which depending on the diagram may either be even or odd: if the product of all the permutations appearing in the diagram is the identity, then parity is even, and if it is , then the parity is odd.
Proof.
We prove this result by induction on the number of generators required to construct the diagram. Remember that we need only consider those diagrams whose corresponding relations are states. There is just one possible base case (), a diagram composed purely of the generator for which : the corresponding state consists of the single 1tuple (0), which is indeed the unique 1tuple of even parity. Now consider a diagram built from generators with a corresponding state consisting all tuples of parity . It is easily seen that composing with either , or respectively yields a diagram whose corresponding state consists of all tuples, all tuples, and all tuples of parity ; and that composing with yields all tuples of parity . Finally consider producing a disconnected diagram by laying the diagram alongside : it is easily seen that the corresponding state consists of tuples of parity . ∎
5.3. The general form of phased morphisms in Spek
We want to apply our results on HalfSpek to the category of real interest, Spek. To do this we first need to digress to discuss some structural features of relations. The category Rel has another symmetric monoidal structure, namely the disjoint union or direct sum, denoted by . Concretely, if we can partition a set into subsets , then we have , and recalling that a relation is a subset of , we can decompose into components of the form , such that . The relations are termed the components of with respect to partitions , . In category theoretic terms, this is biproduct, and there is a distributive law with respect to the Cartesian product:
(5.11) 
for sets and relations . For , , and , and relations , and , we then have:
(5.12) 
For by distributivity we have:
(5.13) 
If for and the only nonempty components are and we call it parallel. Given parallel relations , and with respect to the partition , the relations:
(5.14) 
are all also easily seen to be parallel with respect to the same partition of .
We can use these insights to make a connection between HalfSpek and Spek.
Proposition 5.10.
The generators of the phased morphisms of Spek, i.e. , and the phased permutations on , are all parallel with respect to the following partition of . We conclude that all phased morphisms of Spek are also parallel with respect to this partition. We refer to the two components of a phased Spek morphism as its component and component.
Proposition 5.11.
The components of the generators of the phased morphisms of Spek are simply the generators of HalfSpek with the elements of relabelled according to , . Similarly the components of the generators of the phased morphisms of Spek are simply the generators of HalfSpek with the elements of relabelled according to , .
Proposition 5.12.
A state corresponding to a phased Spek diagram is equal to the union of two states and . and are obtained by the following procedure. Form a HalfSpek diagram by replacing every occurence of and in with and , and replacing every occurence of a permutation with its component, relabelled as a HalfSpek permutation as described in proposition 5.11. Form a second HalfSpek diagram in the obvious analogous fashion using components of permutations. and are the states corresponding to and , once again under the relabelling described in proposition 5.11.
Note that and will appear identical as graphs, both to each other and to , but the labels on some of their permutations will differ.
Theorem 5.13.
A phased morphism in Spek of type is a subset of , consisting of tuples, divided into two classes of equal number:

The first class consists of tuples of 1s and 2s, all of either odd or even parity.

The second class consists of tuples of 3s and 4s, again all of either odd or even parity.
Note that we are adopting the convention that tuples of the first class have odd parity if they have an odd number of 2s, even parity if they have an even number of 2s. Tuples of the first class have odd parity if they have an odd number of 4s, even parity if they have an even number of 4s.
5.4. The general form of arbitrary morphisms in Spek
Recall from section 5.1 that any unphased diagram can be viewed as a collection of phased zones linked together by the permutation , (1)(3)(24). We also enumerated the external legs.
Theorem 5.14.
The relation in Spek corresponding to an legged Spekdiagram with zones, none of which is internal, is a subset of with the following form:

It contains tuples; each entry corresponding to an external leg.

All those entries corresponding to a given zone of the diagram are termed a zone of the tuple (whether we are referring to a zone of a diagram, or zone of a tuple should be clear from the context). Each zone of the tuple has a welldefined type (components either all 1 or 2, or all 3 or 4) and parity (as defined for phased relations).

A block is a subset of such that the zone of all tuples in has the same parity and type. The sequence of types and parities of each zone is called the signature of the block. The tuples of are partitioned into equally sized blocks each with a unique signature.

Each of the blocks has a different type signature  these exhaust all possible type signatures.

The parity signature of a block is the following simple function of its type signature:
(5.15) Here and are Boolean variables representing the parity and type of the zone. We adopt the convention that an odd parity is represented by 0 and an even parity by 1, whilst the type is represented by 0 and the type by 1. The set adj() consists of the zones directly adjacent to the zone. denotes the parity of the type tuples in the relation corresponding to the zone seen as an independent phased diagram (recall theorem 5.13).
Theorem 5.15.
The relation in Spek corresponding to an legged Spekdiagram with zones, of which are external is either:

A subset, of which satisfies conditions (1) and (2) of theorem 5.14 and which is partitioned into blocks. The signatures of these blocks are determined as follows:

Begin with the state corresponding to the diagram obtained by adding an external leg to every internal zone (i.e. we will have blocks, each with zones, exhausting all possible type signatures).

Eliminate all blocks whose type signatures do not satisfy the following constraints, one for each internal zone:
(5.16) where is the label of the internal zone, and labels its adjacent zones.

Finally from each block delete the zones corresponding to internal zones.


or it is equal to the empty set, . This second possibility occurs iff the constraints in equation 5.16 are inconsistent.
A simple counting argument shows that within each block, every tuple with the correct type and parity signature occurs. Theorems 5.14 and 5.15 thus completely characterise the state corresponding to any Spekdiagram. The input data is the shape of the diagram, which determines adj(i), and the ‘intrinsic parities’ of each zone. Futhermore, note from theorem 5.13 that, as we would expect, the general form of phased morphisms is a special case of the form described above, with .
Example 5.16.
We now give an example of theorem 5.14 in action. Consider the following schematicSpekdiagram (circles simply denote zones), which has three zones, all external () and five external legs ():
(5.17) 
where the labels by each zone denote the intrinsic parities of that zone (i.e. the parity of the type12 tuples and the parity of the type34 tuples, recall theorem 5.13). We conclude from theorem 5.14 that the state corresponding to this diagram will consist of 5tuples each with 3 zones, and that these will be partitioned into equally sized blocks. Every combination of types appears exactly once amongst these blocks, and the parity signatures are easily determined from equation 5.15 as follows. First we note, from the intrinsic parities that , and . We then see that equation 5.15 here is essentially three equations:
(5.18) 
From this we can establish the signatures of the eight blocks:
(5.19) 
The first zone will have two elements, the second zone one element and the third zone two elements. Within each block every possible collection of tuples consistent with the signature will appear meaning that each block will consist of four tuples.
Example 5.17.
We go on to give an example of theorem 5.15. Consider the following diagram: it is identical to the diagram in the previous example except that the second zone has been internalised.
(5.20) 
This diagram has two external zones and four external legs ; thus we expect the corresponding state to consist of 4tuples, each with 2 zones, partitioned into blocks. We now determine the signatures of the blocks applying theorem 5.15. According to step (1) we begin with the blocks from the previous example. Step (2) requires that we eliminate all blocks whose types do not satisfy the constraint . This leaves:
(5.21) 
Finally we delete the second zone from each block, leaving:
(5.22) 
The proofs of theorems 5.14 and 5.15 proceed as inductions over the process of building up a diagram by linking together phased zones via the permutation . In the course of this process it is clearly possible for an external zone to become an internal zone, as its last external leg is linked to some other zone  we refer to this as internalising a zone. It turns out that internalisation of a zone complicates the inductive proof. To get around this we do the induction in two stages. In the first stage we build up a diagram identical to the one we are aiming for, except that every zone that should be internal is given a single external leg in the following fashion. Suppose we need to link together two zones via a permutation, and this will result in the internalisation of the left hand zone:
(5.23) 
We instead link the left hand zone to the permutation via a morphism. The morphism becomes part of the original zone, and provides it with an external leg:
(5.24) 
In the second stage we cap off all these extra external legs with the morphism. Since and constitute a basis structure the result is the diagram which we are aiming for:
(5.25) 
5.4.1. Diagrams without internal zones
We now prove theorem 5.14. The proof uses an induction over the process of building up a diagram. This building up can be split into two phases: firstly we connect all of the zones which will appear in the final diagram into a ‘treelike’ structure with no closed loops, secondly we close up any loops necessary to yield the desired diagram. Henceforth we will represent the signature of a tuple with zones as where is the parity of the zone, and is its type. Again, if is a parity, indicates the opposite parity, and likewise if is a type, represents the other type.
Lemma 5.18.
Consider an legged nonphased diagram with zones. Suppose the corresponding state satisfies the conditions in theorem 5.14. Now consider linking the leg of to the leg of an legged phased diagram (with corresponding state ), via , to create an legged diagram with external zones. We will assume that the leg of lies within its external zone. The state corresponding to also satisfies the conditions in theorem 5.14.
Proof.
By the 1remnants of we mean the remnants of those tuples in with a 1 in the position. We define the 2, 3, and 4remnants similarly. By proposition 5.3 the elements of comprise all the possible composites of the remnants of and the remnants of , where . It is clear that the zone structure of the tuples of is inherited by these composites, and that the remnants of constitute an additional zone within the composites  we conventionally consider this to be the zone. Thus the tuples of satisfy condition (2).
Consider a block , with signature , in which for definiteness we assume that (the argument runs entirely analogously if ). The composites of the 1remnants of and the remnants of all have the same signature, , and constitute a block . Likewise the composites of the 2remnants of and the remnants of constitute a block of signature . Thus each ‘parent’ block in gives rise to two ‘progeny’ blocks in . By hypothesis, each block has a unique type signature, thus the progeny blocks derived from different parent blocks are distinct. Thus is partitioned into blocks, thus satisfying condition (3). It is also clear that if all possible type signatures are represented by the blocks of then this is also true for the blocks of , and thus that satisfies condition (1).
Note that consists of tuples, and will have 1remnants and a similar number of 2remnants, all of which will be distinct. Similarly will have remnants and a similar number of 4remnants, again all distinct. Thus, both and will consist of tuples. This holds for all blocks , of which there are . Thus in total consists of tuples, and so satisfies condition (4).
Finally we turn to condition (5). Recall from above that a parent block of signature yields two progeny blocks, of signatures and . Note that those progeny blocks for which the zone and its new adjacent zone have different types exhibit a parity flip on the zone, relative to the parent block, and on the new adjacent zone, relative to its ‘intrinsic parity’. No such flip occurs if the zones have the same type. Note that the term is equal to 0 if and 1 if . If condition (2) holds for then the correct parity signature for the blocks of can be obtained simply by adding the term to the and equations (equation 5.15). Thus we conclude that condition (5) will hold for as well. ∎
Lemma 5.19.
Consider an legged diagram with external zones. Suppose the corresponding state satisfies the conditions in theorem 5.14. Now consider forming a new legged diagram , with corresponding state , by linking the leg of (in the zone of ), to the leg (in the zone), via . also satisfies the conditions in theorem 5.14.
Proof.
By the remnants of a set of tuples we mean the remnants of all those tuples with in the position and in the position. From proposition 5.4, consists of the remnants of . The zone structure of is clearly inherited by these remnants, thus the tuples of satisfy condition (2).
Consider a block with signature . It is straightforward to see that only one quarter of the tuples in this block have remnants which are remnants. All the remnants have the same signature: if and if . Thus each ‘parent’ block in gives rise to one ‘progeny’ block in , with one quarter as many tuples. The type signatures of the progeny blocks are identical to those of the parent blocks; by hypothesis each parent block had a different type signature and so the progeny blocks deriving from different parent blocks are all distinct. Thus is partitioned into blocks, each containing tuples, and so satisfies conditions (1) and (3).
Since the type signatures of progeny and parent blocks are identical, if satisfies condition (4), so will . We now turn to condition (5). Closing a loop between the and zones means that they now become adjacent to each other. In the previous paragraph we saw that a progeny block for which the and zones have different types exhibits a parity flip on both these zones. Using similar reasoning as in the previous lemma we conclude that, if condition (2) holds for , the correct parity signature for the blocks of can be obtained simply by adding the term to the and equations (equation 5.15). Thus we conclude that condition (5) will hold for as well. ∎
We can now prove Theorem 5.14:
Proof.
By induction. The base case is a diagram consisting of a single zone, and it is clear from theorem 5.13 that this satisfies all the conditions. Any other diagram is built up via two inductive steps: linking a new phased zone onto the existing diagram and closing up internal loops within the diagram. Lemmas 5.18 and 5.19 respectively show that if a diagram satisfied the conditions prior to either of these steps, the resulting new diagram will also satisfy the conditions. ∎
5.4.2. Diagrams with internal zones
We now address the issue of internalising zones. Recall that this step involves capping off external legs with the relation. Throughout this section will denote a diagram with no internal zones, and will denote the diagram obtained by internalising some of ’s zones. The corresponding states will be and .
Proposition 5.20.
Suppose we obtain by capping the external leg of with the morphism. From lemma 5.5 we conclude that consists of the 1 and 3remnants of .
Suppose that in going from to we internalised the zone of . From the proposition above we deduce that each block for which will give rise to one progeny block with the same number of tuples as , while all those blocks for which will give rise to no progeny blocks. From this we can conclude that those blocks which do give rise to progeny blocks satisfy a constraint on their type signatures, derived from setting in equation 5.15. Depending on the form of , and whether the number of zones adjacent to the is odd or even, this constraint takes one of four forms:
(5.26) 
(5.27) 
We describe the constraints in (5.26) as type0 constraints, and those in (5.27) as type1 constraints.
Suppose has external legs and external zones. Suppose that in going to we internalise of its zones. Each internalisation gives rise to a corresponding constraint. There are now two possibilities:

Not all of the constraints are consistent. In this case none of the blocks in satisfy all of the constraints, and none of them will give rise to progeny blocks. Thus .

All constraints are consistent, and of these are linearly independent (this essentially means that of the constraints can be derived from the remaining ). Each independent constraint reduces the number of blocks which can give rise to progeny by one half. Thus only of the blocks in give rise to progeny blocks in , and can have at most blocks  this maximum is attained if all of the progeny blocks are distinct.
Lemma 5.21.
The following are equivalent:

The constraints are consistent and there are linearly independent constraints.

The blocks in which can give rise to progeny blocks in are partitioned into sets, each consisting of blocks which all yield identical progeny blocks. Thus in total there are distinct progeny blocks. For brevity we will describe this as fold duplication of progeny blocks.
The proof of this lemma requires a number of preliminary definitions.
Definition 5.22.
The IZset is the set of zones which are internalised in going from to . The noninternalised adjacent zones (nIAZs) of an internalised zone are all the zones adjacent to it which are not themselves members of the IZset. An adjacency closure set (ACS) is a subset of the IZset with the minimal number of elements such that the disjoint union of the nIAZs of each element contains each nIAZ an even number of times.
Example 5.23.
Consider the following seven zone diagram (external legs are suppressed for clarity). The filledin zones are those which we internalise.
(5.28) 
The IZset is . The nIAZs for 1 are for 3 are , for 6 are and for 7 are . Zones 3, 6 and 7 together constitute an ACS. Zone 1 is not part of any ACS.
Definition 5.24.
Given a set of zones in , and a block , the mirror of , is the block with the same type signature as except on the zones in , where the types are opposite.
Proposition 5.25.
Suppose has an ACS . Now, so long as the blocks (i.e. a block and its mirror) both yield progeny blocks in , these progeny blocks will be identical. Conversely, if any two blocks yield identical progeny blocks in , they must be mirrored with respect to some ACS in .
Proof.
For two blocks in to give identical progeny blocks in they must have identical type and parity on every zone which is not internalised. Note from equation 5.15 that two blocks in which are type mirrored on a single zone will otherwise differ only in parities on all the zones adjacent to this zone. Now consider two blocks which are typemirrored on a set of zones : in the case where constitutes an ACS all the parity flips predicted by equation 5.15 cancel one another out on the zones which will still be visible in . ∎
Proposition 5.26.
Suppose has an ACS whose member zones have corresponding constraints which satisfy the following condition: those zones with an odd number of adjacent zones within the IZset have type1 constraints, while those zones with an even number of adjacent zones within the IZset have type0 constraints. Then if a block satisfies the constraints and gives rise to progeny blocks in , so does its mirror. Conversely, if a block and its mirror with respect to some ACS in both give rise to progeny blocks, the constraints corresponding to the zones of must satisfy the condition above.
Proof.
If a constraint contains an even number of terms relating to zones from a set then given a block either (i) both and satisfy the constraint (ii) neither nor satisfy the constraint. Conversely, if both and satisfy a constraint, it must contain an even number of terms relating to zones from . ∎
Proposition 5.27.
Suppose has an ACS whose member zones have corresponding constraints which satisfy the condition in the previous proposition. Then the constraints together form a linearly dependent set. The converse is also true.
Proof.
If is an ACS and the condition on constraints is satisfied then each term appears in the constraints an even number of times altogether. Summing all the constraints together then results in all the terms cancelling out, yielding the single equation 0=0. This is a necessary and sufficient condition for the constraints to be linearly dependent. ∎
We can now prove lemma 5.21.
Proof.
From propositions 5.25 and 5.26 we conclude that for fold duplication to take place the IZset must contain ACSs and that the constraints must satisfy the condition in proposition 5.26. The converse is also clearly true. Every linearly dependent set amongst the constraints corresponding to the internalised zones reduces the total number of linearly independent constraints by one. From proposition 5.27 we conclude that for there to be linearly dependent sets the IZset must contain ACSs and that the constraints must satisfy the condition in proposition 5.26. The converse is also clearly true. Thus we conclude that both statements in the lemma are equivalent to a third statement: the IZset contains ACSs, and the constraints corresponding to the internalised zones satisfy the condition of proposition 5.26. ∎
Corollary 5.28.
Theorem 5.15 follows as a straightforward corollary.
5.5. The general form of the morphisms of MSpek
Theorem 5.29.
All MSpek morphisms of type are subsets of containing or tuples.
Proof.
Any MSpek diagram can be obtained from a Spek diagram simply by capping one or more legs of with the morphism . Suppose we obtain by capping a single external leg of (the , say) with . The state corresponding to consists of the remnants of , the state corresponding to . Suppose has external legs: since is a Spekdiagram consists of tuples. Then, unless some of the remnants of are identical, will also consist of tuples, despite only having external legs. Furthermore it is clear that either all the remnants of are distinct, or is partitioned into pairs, the elements of which yield identical remnants, meaning that the addition of each cap either halves the number of tuples or leaves it unchanged. ∎
6. MSpek is the process category for the toy theory
We know that the epistemic states of the toy theory are subsets of the sets , and that the transformations on these states are relations between these sets. Thus we can see immediately that the toy theory’s process category must be some subcategory of FRel, restricted to the objects . Furthermore we know that it cannot be the full subcategory restricted to these objects, since some subsets of