{'fraction_non_alphanumeric': 0.04011666581384639, 'fraction_numerical': 0.004144706544542803, 'mean_word_length': 4.577625570776256, 'pattern_counts': {'":': 1, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The Safari of Update Structures: Visiting the Lens and Quantum Enclosures

We build upon our recently introduced concept of an update structure to show that they are a generalisation of very-well-behaved lenses, that is, there is a bijection between a strict subset of update structures and vwb lenses in cartesian categories. We then begin to investigate the zoo of possible update structures. We show that update structures survive decoherence and are sufficiently general to capture quantum observables, pinpointing the additional assumptions required to make the two coincide. In doing so, we shift the focus from dagger-special commutative Frobenius algebras to interacting (co)magma (co)module pairs, showing that the algebraic properties of the (co)multiplication arise from the module-comodule interaction, rather than direct assumptions about the magma comagma pair. Thus this work is of foundational interest as update structures form a strictly more general class of algebraic objects, the taming of which promises to illuminate novel relationships between separately studied mathematical structures.


Introduction
Modelling meaning updating within natural language processing is an ongoing foundational problem. Inspired by an operational interpretation, we recently introduced the concept of an update structure [10] as a candidate for modelling meaning updating in monoidal categories, with the intention of possible applications within DisCoCat [3,7,5].
At its core, an update structure is a "weak" module-comodule pair, that is a pair of an action and coaction on a magma-comagma, without the stricter underlying assumption of a monoid-comonoid pair 1 . An update structure also comes with two extra axioms which capture clear operational notions constraining how the magma and comagma should interact.
Particular cases of module-comodule pairs have been considered elsewhere; they make an appearance in both categorical quantum mechanics where they have been shown to capture quantum observables and measurements [6,11] and in work on lenses [2,9] in relation to the view-update problem. In this paper we offer a unifying perspective of these two fields from the vantage point of update structures. To this end, the purpose of the remainder of this article is twofold: to pinpoint precisely when lenses and update structures coincide and to demonstrate that update structures are sufficient to capture quantum observables and measurements. For the former, we demonstrate that update structures are more general than vwb lenses, capturing both demolition and non-demolition viewing (Get) processes and with regards to the latter, we demonstrate both that the application of decoherence to any update structure will produce a new update structure on classical objects and that to characterise quantum observables it is sufficient to look at how the weak module-comodule interact without underlying assumptions on the magmacomagma. This is contrary to the usual approach where one typically begins with a module-comodule over a †-Frobenius structure as their underlying assumptions. Thus the focus is shifted from demands on both how the module and comodule interact and the algebraic structure of the (co)magma, to demands placed purely on the module-comodule interaction. This places quantum observables and vwb lenses within a zoo of update structures with many other exotic enclosures left to explore, an example of which we give in the last section.
We finish this introduction by recalling several definitions from [10].
Definition 1 ((Strong) Update Structure). An update structure (↑, , ∼, ) in a monoidal category C consists of: • An object S, which we refer to as a system • An object p, which we refer to as a property, which has: Which satisfy the following equations: making ↑ a magma module and a comagma module. Additionally we require: These four equations are operationally well-chosen with the intent of capturing what it means to be an "update". The PutPut rule says updating twice ought to be the same as performing some operation on the properties and then updating once with the new combined property. GetGet is the converse of this; retrieving a property twice should be the same as retrieving once and then performing some operation (e.g. copying) on the retrieved data. PutGet captures the notion that updating and then retrieving ought to be the same as copying, then updating with one of the copies. Finally GetPut is the notion that looking and then putting back ought to leave the system invariant.
In some circumstances, GetPut is quite a strong demand. For instance quantum measurements do not satisfy this law, as measurement and reinsertion of classical data disturbs the system via decoherence. Thus we also defined a strictly weaker notion.
Definition 2 (Weak Update Structure). A weak update structure (↑, , ∼, ) satisfies all the axioms of an update structure apart from GetPut which we replace with the strictly weaker repeat-update axiom: Proposition 1.
[10] Any strong update structure is a weak update structure.
For a weak update structure measurement is allowed to disturb the system. The Put is however "static": updating twice with copies of a property is the same as updating once with that property. We give a separate operational axiom to capture when the occurrence of an update can be ignored.

Definition 3 (Ignorable). Put is ignorable if
Get is ignorable if it has the same property but flipped vertically.
Since we introduced the weakening of strong update structures to cope with interactions which disturb or collapse systems in the way that for example quantum measurements do, it is appropriate that those weak updates that are truly ignorable are strong. Proposition 2. Any weak update structure with an ignorable Put is a strong update structure: Proof. By the ignorable Put, PutGet, the repeat-update axiom, and another use of the ignorable Put.
To finish this section, it is worth pointing out that the PutPut and GetGet laws place quite strong constraints on the (co)associativity of the (co)magma. One can deduce the following from PutPut and GetGet: While the definition of an update structure allows for a (co)magma which is not (co)associative, in this case the put/get would have to be noisy. More concretely it cannot be faithful (see definition 12).

Relation to Very-Well-Behaved Lenses
In this section we relate update structures to very-well-behaved lenses. Indeed, to those familiar with lenses, our choice of language "Get" and "Put" may raise suspicions that the two are related. We now make the connection precise.
Definition 4 (Very-Well-Behaved Lens). In a category C with finite products, a lens [9] is a tuple (S,V, g : S → V, p : S × V → S), where S and V are objects of C. A lens is further very-well-behaved (vwb) if it satisfies the following: Proposition 3. Vwb lenses (S,V, g, p) in a category C with finite products are in bijection with update structures that have ignorable gets, ∼:= π 2 , and := δ V . Under this bijection, the very-wellbehavedness laws are equivalent to their update structure counterparts.
Proof. Given in Appendix A.1.
Thus update structures generalise lenses; every vwb lens is an update structure but not the converse. Perhaps the most import distinction is that update structures allow for the possibility that Get affects the system. When a lens is viewed as an update structure, its Get operation does not modify the system S; it duplicates it using the duplication map that comes with the finite product structure, and returns it unmodified alongside the computed V .
In the more general setting of a monoidal category one does not have this additional structure. In general, there will be no such duplication map (for instance we cannot copy quantum data) and as such it is important to require that the Get also returns a system of type S. Thus Proposition 3 serves as a bridge between vwb lenses and update structures in monoidal settings: where S and V in the monoidal category are comonoid objects, and and ↑ are comonoid homomorphisms, one obtains a close analogue of vwb lenses.
This vantage point of lenses qua update structures appears to be an interesting new point in the space of lens-like structures: it generalizes the usual cartesian lenses without being as general as optics [13]. We remark an interesting similarity with Abou-Saleh et al.'s monadic lenses [1]: they also generalize lenses to a setting that is not quite cartesian monoidal, and in doing so come up with strikingly similar laws. Specifically, their MPutGet and MGetPut laws are exact analogues to our PutGet and GetPut, that would be drawn identically if string diagrams could be drawn in the monadic case. They also mention another approach to monadic lenses that requires an analogue of our GetGet law.
A final distinguishing point between lenses and update structures appears relative to composition. Notions of lenses all have the important property of composability: one can compose lenses to build accessors for a big data type in terms of accessors for its subcomponents. In this paper we however do not investigate composition of update structures, and it appears there might be different sensible such notions 2 , requiring different additional structure on the (co)magmas and operations.

Interacting Module-Comodule Pairs
Given a (co)magma (co)module pair, there are many possible PutGet rules one could impose and in this section we will study a handful of these possibilities, elucidating the restrictions each choice places on the rest of the structure, in particular the magma-comagma pair.
In the presence of PutPut and GetGet, PutGet A leads to: 1. with the GetPut rule, S S ⊗ p, which in many categories, for instance FHilb, FRel and FSet, means S or p have to in some way be trivial. In FHilb p = I, and in FRel and FSet, either p = I, p = ∅ or S = ∅.
2. If the (co)magma has a (co)unit then the identity separates.
Proof. Given in Appendix A.2.
Thus an update satisfying PutGet A would imply a very exotic magma-comagma: they cannot have the GetPut rule in finite dimensions and even dropping this rule, they cannot have a (co)unit.

Quantum Measurements As Weak Update Structures
Having confirmed that update structures generalise lenses, we now show that they generalise quantum measurements and their precursors -projector valued spectra. By generalising the process given in [6] for building quantum measurements from projector valued spectra, we find that decoherence generates weak update structures from strong update structures. Projector valued spectra in FHilb are characterised by the following graphical conditions. Definition 6 (Projector-Valued Spectrum). [6] The pair of morphisms (↑, ) in FHilb is a projectorvalued spectrum if is a commutative †-special Frobenius algebra and ↑ satisfies: These equations are paraphrased by asking that ↑ be p-idempotent, p-self-adjoint, and p-complete respectively. A projector valued spectrum carries only the data of a single interacting module ↑ and magma , however the † can be used to construct a full update structure. Definition 7 (Dagger Update Structure). (↑, ) is a †-update structure if (↑, ↑ † , , ) is an update structure.
For a tuple (↑, ↑ † , , ) built from a projector valued spectrum to be an update structure it must satisfy the PutGet and GetPut axioms. Proposition 10. Every projector-valued spectrum (↑, ) is a †-update structure.
Proof. By p-idempotency, (↑, ↑ † , , ) is immediately a (co)magma module pair. The GetPut axiom holds, any projector valued spectrum is isometric with inverse equal to the adjoint.
Finally the PutGet axiom holds.
Quantum measurements are built from projector valued spectra in FHilb via embedding into CPM(FHilb) [14] and subsequent application of the decoherence morphism [6,4].
We can consequently show that any quantum measurement is itself an update structure. First of all, for any †-compact category C the functor F from C to CPM(C) which takes f : A → B to f ⊗ f * : A ⊗ A * → B ⊗ B * , maps any update structure in C to an update structure in CPM(C). Secondly, we will show that for any such update structure with commutative †-special Frobenius, decoherence generates a new weak update structure, which can furthermore be considered a weak update structure on classical objects in Split(CPM(C)) -the Karoubi envelope of CPM(C). Definition 8 (Karoubi Envelope). The Karoubi envelope Split(C) of a category C has as objects the pairs (A, π) where A ∈ Ob(C) and π : A → A is an idempotent. The morphisms f : (A, π) → (B, σ ) are the morphisms f : As studied in refs [8,15,12], the object (F(p), ) represents a classical version of the object p, on which the only states and transformations permitted are those which are unaffected by decoherence f • = f = • f . Applying decoherence to an update structure then produces a new update structure for which the property read off is guaranteed to be classical.
Proposition 11. Given any weak update structure (↑, , , ) in a †-compact category C on system S, and property p with a commutative †-special Frobenius algebra, composition with the decoherence map * , , generates a weak update structure on F(S) and F(p) which also appears as a weak update structure in Split(CPM(C)) on system (F(S), id F(S) ) and property (F(p), ).
The GetPut axiom on a †-update structure is isometricity, it naturally fails because decoherence disturbs a quantum system. Via a GetPut restriction as introduced in [10] any such weak update structure on a fully quantum system (F(S), id F(S) ) can be used to construct a strong update structure on a measured, partially decohered, system (S, ↑ • ).
On top of being update structures, projector valued spectra carry some additional conditions, their Puts are commutative, ignorable, and in Appendix A.9 we confirm they are faithful.

Definition 9 (Faithful). A †-update structure is faithful if
Conversely, the above conditions are enough to characterise projector valued spectra. Proof. Since we have already demonstrated the "⇒" direction we only need to consider "⇐". The results of section 3 imply that the magma of a faithful, commutative, ignorable †-update is a commutative †special Frobenius algebra. The unit is the effect which makes ↑ ignorable, so ↑ is p-complete. The PutPut axiom is p-idempotency, and finally since ↑ is p-complete, the putget axiom implies that ↑ is p-self-adjoint.

A New Example: Morphisms as Properties
We now give a new example of a strong update structure based on the "pair of pants" monoid [11]. †-Compact categories come equipped with an evaluation morphism ε : S * ⊗ S ⊗ S → S and a composition morphism σ : S * ⊗ S ⊗ S * ⊗ S → S * ⊗ S which satisfy PutPut. The evaluation takes as inputs a morphism and a state, and produces an output by applying the morphism to the state. We can use ε and σ as ↑ and ∼ respectively, along with the dagger to construct an update structure for which systems are states, and properties are morphisms waiting to be applied to those states. Proof. PutPut and GetGet can be confirmed graphically, but also follow by definition of composition σ as the adjunct to ε • (ε ⊗ I) in any symmetric closed monoidal category. PutGet is quick to verify as is GetPut This update structure is ignorable and faithful, its magma and co-magma are Frobenius, and special, but non-commutative.

Conclusion
In this article we have furthered our development of update structures. We originally introduced update structures with operational inspiration and we have now shown that very-well-behaved lenses, quantum observables and measurements and a slight alteration on the pair-of-pants monoid all live within the zoo of update structures. This offers a unifying perspective of two fields and elevates update structures to algebraic objects that deserve further investigation. This work opens several lines of investigation. We have not discussed composition of update structures in this article, but there seems to be multiple interesting such notions. Each such notion would impose additional structure in order to be well-defined. Exploring these alternatives would provide further insight into those structures and contribute to a more featureful unification.
We also endeavour to expand the zoo of update structures with more exotic beasts. Perhaps such structures could allow for updates which behave neither quantumly nor classically and further the search for post-quantum phenomena.
A further goal would be to formally justify the axioms of update structures. Currently they are operationally well-chosen but it is not clear how necessary and sufficient they are, or whether other choices could lead to related and interesting structures. We touched upon this when we investigated alternative PutGet rules, but the full ramifications of these choices are not currently understood.

A.1 Proof of Proposition 3
Proof. Recalling that categories with finite products are cartesian monoidal, we rewrite the lens laws in the following suggestive graphical form.
The bijection identifies p and ↑. is δ V , the copy on V , and ∼ is π 2 . g and follow the obvious type-matching strategy.
We verify one injection as follows: And the other (making use of the ignorability of in the penultimate step): From the substitutions on ∼ and , it immediately follows that the PutPut and GetPut laws are equivalent for both update structures and vwb lenses. Regarding PutGet, we have that PutGet for lenses implies PutGet for the corresponding update structure, and PutGet for an update structure implies PutGet for the corresponding lens: It is worth noting that this correspondence makes use of the 'left-delete' magma ∼= π 2 which is not a monoid.

A.2 Proof of Proposition 4
Proof.
1. In the presence of the GetPut law we immediately have that S S ⊗ p. In FHilb this requires p = I and in FRel and FSet either p = I, p = ∅ or S = ∅. Thus the update is rendered essentially trivial. Proof. Starting with the left-hand side and applying PutGet B twice followed by GetGet and PutGet B in reverse recovers the right-hand side.

A.4 Proof of Proposition 6
Proof. Starting with the left-hand side and applying PutGet C twice followed PutPut and PutGet C in reverse recovers the right-hand side.

A.5 Proof of Proposition 7
Proof. Consider • ↑ •(↑ ⊗ id p ) and apply the following laws: • PutGet B followed by PutPut, for the left-hand side • PutPut followed by PutGet B, for the centre and similarly GetGet implies the proposition for Get.

A.7 Proof of Proposition 9
Proof. Again the proposition for Put follows immediately from the PutPut axiom.
and similarly for Get.

A.8 Proof of Proposition 11
The decoherence map is an idempotent magma & co-magma homomorphism in CPM(C). We prove that any idempotent magma & co-magma homomorphism m in a category D defines a transformation from a strong update structure (↑, , ∼, ) in D on objects S and p to a weak update structure in Split(D) on system (S, id S ) and property (p, m).
As such (↑ , , ∼ , ) is a weak update structure, furthermore each morphism is easily checked to be a morphism on the appropriate objects in Split(D).
So far we have come across two uses of this proposition, one in defining updates of correlated properties [10], and another here in defining updates of classical properties.

A.9 Proof that Projector Valued Spectra are Faithful
We define f mni j and g mni j by Now since ↑ • (id ⊗ |i ) ≡ P i are orthogonal projectors it follows that δ jk ∑ j g mni j ↑ k = (24) and so for all m,n,i,k f mnik = g mnik i.e. f = g.