AA first-order logic for string diagrams
Aleks Kissinger and David Quick {aleks.kissinger,david.quick}@cs.ox.ac.uk Abstract
Equational reasoning with string diagrams provides an intuitive means of proving equationsbetween morphisms in a symmetric monoidal category. This can be extended to proofs of infin-ite families of equations using a simple graphical syntax called !-box notation. While this doesgreatly increase the proving power of string diagrams, previous attempts to go beyond equationalreasoning have been largely ad hoc, owing to the lack of a suitable logical framework for diagram-matic proofs involving !-boxes. In this paper, we extend equational reasoning with !-boxes to afully-fledged first order logic called with conjunction, implication, and universal quantificationover !-boxes. This logic, called !L, is then rich enough to properly formalise an induction principlefor !-boxes. We then build a standard model for !L and give an example proof of a theorem fornon-commutative bialgebras using !L, which is unobtainable by equational reasoning alone.
D.3.1 Formal Definitions and Theory, F.4.1 MathematicalLogic
Keywords and phrases string diagrams, compact closed monoidal categories, abstract tensorsystems, first-order logic
Digital Object Identifier
Many processes come with natural notions of parallel and sequential composition. Insuch cases, it is advantageous to switch from traditional term-based (i.e. one-dimensional)syntax to the two-dimensional syntax of string diagrams. This diagrams, which consist ofboxes (or various other shapes) connected by wires, form a sound and complete languagefor compositions of morphisms in a monoidal category [8]. Recently, the use of stringdiagrams has gained much interest in a wide variety of areas, including categorical quantummechanics [4, 3, 5], computational linguistics [9] and control theory [2, 1].What many of these applications have in common is they make extensive use of equationalreasoning for string diagrams. That is, proofs are constructed by starting with a fixed set ofdiagram equations, e.g. = == = ( ii ) ( iii ) ( iv )( i ) and using those to construct new equations by substitution of sub-diagrams. For example,the following is a derivation making use of the four rules above:= = == ( i ) ( iii ) ( ii ) ( iv ) © Aleks Kissinger and David Quick;licensed under Creative Commons License CC-BYConference title on which this volume is based on.Editors: Billy Editor and Bill Editors; pp. 1–18Leibniz International Proceedings in InformaticsSchloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany a r X i v : . [ m a t h . C T ] M a y First-order logic for string diagrams
However, to prove more powerful theorems, one often needs to pass from statements aboutsingle diagrams to entire families of diagrams and diagram equations. One way to do this,while staying within the realm of string diagrams is to use !-box notation (pronounced‘bang-box notation’), introduced in [6] and formalised in [11]. In this notation, certainsub-diagrams are wrapped in boxes, which mean ‘repeat this sub-diagram any number oftimes’. For example, suppose we considered a family of ‘copy’ operations with 1 input and n outputs. Then, if we had some other map with just a single output, we might ask thatconnecting it to the n -fold ‘copy’ results in n copies. We can represent this family of rulesusing !-box notation as follows:... = ... (cid:32) AA = (1)Whereas the expression on the left is informal, the expression on the right defines a family ofequations without ambiguity. Formally, a !-box rule represents a set of string diagram rulesobtained by instantiating the !-box, which essentially amounts fixing the number of times tocopy each !-box. For example, the instances of the !-box rule above are precisely the ones wemeant to capture with the informal expression: AA = == (cid:26) = , = , , · · · (cid:27) where the ‘blank space’ in the first equation represents the monoidal unit I . We can even usethis more expressive notation to make recursive definitions. For instance, we could recursivelydefine the n -fold copy operation as a tree of binary copy operations: A = A where = (2)Using just equational reasoning, there is no way to get from the equations in (2) to the n -foldcopy equation (1). However, if we introduce an induction principle:= A A = AA = → = AA (Induct)we can split into a base case (zero copies of the !-box) and a step case ( n copies implies n + 1 copies). Taking the base case as given, we can prove the step case using the inductionhypothesis and the rules in (2): = AA A A = i.h. =Unfortunately, this doesn’t quite work. If we interpret → to mean ‘the rule on the left can beused in the proof of the rule on the right’, the step case is vacuous. The rule on the right is already an instance of the rule on the left. This is a bit like saying: ( ∀ n.P n ) → ( ∀ n.P ( n + 1)),which is of course true for any P . . Kissinger and D. Quick 3 The problem is, when we pass to !-box notation, where single diagram rules now representwhole families of rules, our existing reasoning tools do not provide enough control overinstances of rules, and how those instances interact with each other. This problem was solvedfor the specific case of induction in [14] using an operation called fixing , which essentiallyfreezes a !-box so it can’t be instantiated. However, this was introduced more as a stopgap,until a proper logic could be developed, suitable for handling conjunction, implication, andcrucially universal quantification over !-boxes. In this paper, we develop that logic. Withthis new !-logic in hand, we can correct our failed attempt at induction to: (cid:18) = (cid:19) ∧ ∀ A. AA = → = AA → ∀ A. AA = In addition to giving a solid foundation for proofs constructed using !-boxes, a majormotivating factor for the development of a formal logic of !-boxes is its implementation inthe proof assistant Quantomatic [13]. Currently, Quantomatic supports pure equationalreasoning on string diagrams with !-boxes. The implementation of !-logic will allow it tosupport diagrammatic versions of all the usual trappings of a fully-featured proof assistant,such as local assumptions, goal-driven (i.e. backward) reasoning, and of course inductiveproofs.There are two essentially equivalent ways to formalise string diagrams with !-boxes: onecombinatoric (as in the original formulation) and one syntactic, building on the tensor notation for compact closed categories [12]. Here we opt for the latter, as it more conveniently fits intothe presentation of the logic and provides a means of elegantly representing commutative and non-commutative generators. We begin by reviewing compact closed categories, tensornotation, and !-tensors in Section 2. Next, we define the concept of an instantiation, whichwill play a central role in the logic in Section 3. We introduce the syntax of our logic,namely !-formulas , in Section 4 and give the rules of the logic in Section 5. We provide asemantics for !-formulas based on sets of instantiations evaluated in a compact closed category C in Section 6. We conclude by exhibiting a non-trivial proof involving non-commutativebialgebras, which can be done entirely within !L and diagram rewriting. Throughout this paper, we will work with compact closed categories , i.e. symmetric monoidalcategories where every object X has a dual object X ∗ and two morphisms η X : I → X ∗ ⊗ X , (cid:15) X : X ⊗ X ∗ → I satisfying the yanking equations :( (cid:15) X ⊗ X ) ◦ (1 X ⊗ η X ) = 1 X (1 X ∗ ⊗ (cid:15) X ) ◦ ( η X ⊗ X ∗ ) = 1 X ∗ For simplicity, we will focus on strict compact closed categories, where associativity andunitality of ⊗ hold on-the-nose. However, all of the concepts we will use in this paper gothrough virtually unmodified by Mac Lane’s coherence theorem.As string diagrams, we will depict X as a wire directed upwards, and X ∗ as a wiredirected downwards. Thus η X and (cid:15) X can be depicted as half-turns: η X = (cid:15) X =which we typically call ‘cups’ and ‘caps’, respectively. Using this notation, the yankingequations resemble their namesake: First-order logic for string diagrams = =One consequence of the inclusion of cups and caps is that we can now introduce ‘feedbackloops’, allowing us to make sense of arbitrary string diagrams, not just directed acyclic ones.A second consequence is that any map f : X → Y can be equivalently represented as a mapof the form e f : I → X ∗ ⊗ Y just by ‘bending’ the input up to be an output: ff (cid:32) Thus, we will always assume that our generating morphisms can be written in the form φ : I → X ⊗ X ⊗ . . . ⊗ X n for objects X , X , . . . , X n . A morphism whose domain is themonoidal unit is called a point . (cid:73) Definition 1. A compact closed signature Σ consists of a set O := { x, y, . . . } and a set M of pairs ( ψ, w ), where w is a word in { x, x ∗ , y, y ∗ , . . . } . If ψ occurs precisely once in M , it issaid to have fixed arity , otherwise it has variable arity . (cid:73) Definition 2.
For a compact closed category C , a valuation (cid:74) − (cid:75) : Σ → C is a choice ofobject X ∈ ob C for every x ∈ O , and a choice of point (cid:74) ψ (cid:75) : I → X ⊗ X ∗ ⊗ . . . ⊗ X n forevery ( ψ, x x ∗ . . . x n ) ∈ M .When there can be no confusion, we write pairs ( ψ, x x ∗ . . . x n ) also as ψ : X ⊗ X ∗ ⊗ . . . X n .As usual, the free compact closed category Free(Σ) is characterised by the universal propertythat any valuation lifts uniquely to functor (cid:74) − (cid:75) : Free(Σ) → C preserving all of the compactclosed structure. In the next section, we will give a convenient syntactic presentation of thiscategory. From now on, we will assume that Σ only has one object X , so morphisms will be maps from I to monoidal products of X and X ∗ .Suppose that we have two generators in Σ, φ : I → X ⊗ X ⊗ X ∗ ⊗ X ∗ ⊗ X ∗ and ψ : I → X ⊗ X ∗ ⊗ X ∗ . Diagrammatically we will depict these generators as circular nodeswith the edges ordered clockwise around the node. To avoid ambiguity we place a tick onthe node between the last and first edge. We will name free edges so they can be referred towhen manipulating diagrams. Hence the generators in our example (with arbitrarily namededges) are: φ a b c d e (cid:32) φa b cde ψ f g h (cid:32) ψf gh (3)Now, wires connecting these dots indicate the presence of caps: ψ f d e φ c (cid:32) φ cde ψ f (4) . Kissinger and D. Quick 5 To succinctly express these kinds of string diagrams syntactically, we can use tensornotation . Here, we represent generators by writing their names, followed by a list of subscriptsindicating their (named) inputs and outputs: φ ˆ a ˆ b ˇ c ˇ d ˇ e := φa b cde ψ ˆ f ˇ g ˇ h := ψf gh Inputs (i.e. outputs of type X ∗ ) are represented as names with ‘checks’ ˇ a, ˇ b, . . . , whereasoutputs are represented as names with ‘hats’ ˆ a, ˆ b, . . . . We combine generators into a singlediagram by concatenating them, and the process of connecting generators together bycaps—which we call contraction —is indicated by repeating names: ψ ˆ f ˇ a ˇ b φ ˆ a ˆ b ˇ c ˇ d ˇ e := φ cde ψ f (5)If a name occurs once, it is called a free edgename . If it is repeated, it is called a boundedgename . As the name would suggest, bound edgenames have no meaning in their ownright, and can be changed (a.k.a. α -converted) at will. Hence the expressions ψ ˆ f ˇ a ˇ b φ ˆ a ˆ b ˇ c ˇ d ˇ e and φ ˆ g ˆ h ˇ c ˇ d ˇ e ψ ˆ f ˇ g ˇ h both represent (5). Also, since it is the names that indicate inputs/outputs of atensor expression, the order in which we write tensor symbols is irrelevant. So, for example, ψ ˆ f ˇ a ˇ b φ ˆ a ˆ b ˇ c ˇ d ˇ e = φ ˆ a ˆ b ˇ c ˇ d ˇ e ψ ˆ f ˇ a ˇ b .This notation gives a simple presentation of string diagrams, and hence of morphisms inthe free compact closed category over Σ. The only mismatch between tensors and morphismsin the free category is that tensors use names to identify inputs/outputs, whereas categoriesuse positions . Thus, to relate the two concepts, we assume the set of edgenames contains twodisjoint sets { a , a , . . . } and { b , b , . . . } that are totally ordered and (countably) infinite,and introduce the notion of canonically named tensors . (cid:73) Definition 3.
A tensor is canonically named if its free names are a , . . . a m , b , . . . , b n forsome m, n ≥ i -th input is named a i and whose j -th output is named b j . It was shown in [10] (for the traced case) and [12] (forthe compact closed case) that Free(Σ) is equivalent to the category whose morphisms arecanonically-named tensors, with ◦ and ⊗ defined in the obvious way using renaming andcontraction. This gives us an important consequence: (cid:73) Theorem 4.
For any compact closed signature Σ , a valuation (cid:74) − (cid:75) : Σ → C lifts uniquelyto an operation which sends canonically named tensors G over Σ to morphisms (cid:74) G (cid:75) in C . As mentioned in the intro, a string diagram with !-boxes represents a family of stringdiagrams, where the sub-diagram in the !-box has been copied an arbitrary number oftimes. To formalise this, we extend the tensor syntax to include !-boxes. These extendedexpressions are called !-tensors. Fix disjoint, infinite sets E and B of edgenames and boxnames ,respectively. First-order logic for string diagrams (cid:73)
Definition 5.
The set of edgeterms T e is defined inductively as follows: • (cid:15) ∈ T e (empty edgeterm) • ˇ a, ˆ a ∈ T e a ∈ E• h e ] A , [ e i A ∈ T e e ∈ T e , A ∈ B• ef ∈ T e e, f ∈ T e Letting 1 represent the empty !-tensor and 1 ˆ a ˇ b represent an identity edge with inputnamed b and output named a , we can define !-tensor expressions as follows: (cid:73) Definition 6.
The set of all !-tensor expressions T Σ for a signature Σ is defined inductivelyas: • , ˆ a ˇ b ∈ T Σ a, b ∈ E• φ e ∈ T Σ e ∈ T e , φ ∈ Σ • [ G ] A ∈ T Σ G ∈ T Σ , A ∈ B• GH ∈ T Σ G, H ∈ T Σ Subject to the conditions that (F1) ˇ a and ˆ a must occur at most once for each edgename a and (F2) [ . . . ] A must occur at most once for each boxname A , as well as some consistencyconditons for !-boxes.The remaining consistency conditions are easiest to understand in the graphical present-ation of !-tensors. Sub-expressions of the form [ . . . ] A are represented by wrapping a boxaround part of the string diagram: φ ˆ a [ ψ ˇ b ] B := ψφ B a b Edges connecting into or out of a !-box must be annotated with the !-box name and a direction,indicating whether the new edgenames should be produced to the left (anticlockwise) or tothe right (clockwise) when a !-box is expanded. We indicate this direction by drawing an arcover the annotated edges: φ h ˆ a ] B [ ψ ˇ a ] B := B ψφ B vs. φ [ˆ a i B [ ψ ˇ a ] B := B ψφ B We drop the label on the arc when it can be inferred from context. The remaining consistencyconditions say that any edge connecting into or out of a !-box must have an annotation, andthose annotations should respect nesting of !-boxes, as in e.g.: φ ˆ a hh ˇ b ] B ] A [[ φ ˆ b ˇ c ] B ] A := BA φφ BA ac . Kissinger and D. Quick 7 For a fully rigorous account of these conditions, see [12]. However, the above descriptionshould suffice for the purposes of this paper, so we’ll proceed to how !-tensors are instantiated.The primary instantiation operations are expand , which produces a new copy of the contentsof a !-box and kill , which removes the !-box from the diagram: ξ ζ e ← Kill B − φ ψξ ζ e B − Exp B → φξ ψζφ ψ B e These two operations suffice to produce all concrete instances , that is all instances notinvolving any !-boxes, of a !-tensor. If we wish to get all instances of a !-tensor, includingthose with !-boxes, we factorise expand into two additional operations: copy , which makes acopy of the !-box and its contents, and drop , which removes a !-box and leaves its contentsbehind. We can define all four of these operations recursively on !-tensor expressions. Wefirst give the recursive cases where all four operations behave the same:Op B ( GH ) := Op B ( G ) Op B ( H ) Op B ( ef ) := Op B ( e ) Op B ( f )Op B ([ G ] A ) := [Op B ( G )] A Op B ([ e i A ) := [Op B ( e ) i A Op B ( φ e ) := φ Op B ( e ) Op B ( h e ] A ) := h Op B ( e )] A Op B ( x ) := x where A = B and x ∈ { , ˆ a ˇ b , ˇ a, ˆ a, (cid:15) } . The four operations are distinguished on the remainingthree cases:Exp B ([ G ] B ) := [ G ] B fr ( G ) Kill B ([ G ] B ) := 1Exp B ([ e i B ) := [ e i B fr ( e ) Kill B ([ e i B ) := (cid:15) Exp B ( h e ] B ) := fr ( e ) h e ] B Kill B ( h e ] B ) := (cid:15) Copy B ([ G ] B ) := [ G ] B [ fr ( G )] fr ( B ) Drop B ([ G ] B ) := G Copy B ([ e i B ) := [ e i B [ fr ( e ) i fr ( B ) Drop B ([ e i B ) := e Copy B ( h e ] B ) := h fr ( e )] fr ( B ) h e ] B Drop B ( h e ] B ) := e Where fr is a function assigning fresh names to all edges and !-boxes in an expression. Weoccasionally write Exp B, fr and Copy B, fr to explicitly reference the freshness function of a!-box operation. In Section 4, we will define the formulas of !-logic. It only makes sense to combine !-tensorsinto single formulas if their !-boxes are compatible in some sense, so we first provide somebasic notions relating to compatibility. (cid:73)
Definition 7. If F is a set and ≺ is a binary relation on F then the pair ( F, ≺ ) is called a forest if it forms a cycle-free directed graph where each node A has at most one node B s.t First-order logic for string diagrams A ≺ B . A forest can also be seen as a graph made up of disconnected directed trees. Wewrite < for the transitive closure and ≤ for the reflexive and transitive closure of ≺ .Let X ≤ and X ≥ be the downward and upward closure of X ⊆ F , respectively. For asingle element A ∈ F , we write A ≤ for { A } ≤ and A < for A ≤ \ A . (cid:73) Definition 8.
If a subset X ⊆ F is both upward and downward closed (i.e. X = X ≤ = X ≥ )then we say X is a component of ( F, ≺ ). If it contains no proper sub-components, it is calleda connected component .We write F > ⊆ F for the set of maximal elements with respect to ≤ . Note that for A ∈ F > the set A ≤ is always a connected component, and for F finite, all connectedcomponents are of this form. (cid:73) Definition 9.
Two forests
F, F are said to be compatible , written F ↔ F , if the intersection F ∩ F is a (possibly empty) component of both F and F .Equivalently, F, F are compatible if and only if there exist forests X, Y, Z such that F = X ] Y and G = Y ] Z . As a consequence, the union of compatible forests is alwayswell-defined ( F ∪ F := X ] Y ] Z ), and itself a forest. For any !-tensor, we can alwaysassociate a forest of !-boxes: (cid:73) Definition 10.
For a !-tensor G , let (Boxes( G ) , ≺ G ) be the forest of !-boxes in G , where A ≺ G B iff A is a direct descendent of B . That is, A is nested inside of B with no intervening!-boxes.An important concept for !-tensors is that of instantiations . These capture precisely thesequence of operations by which a !-tensor is transformed into some instance of itself. Fora !-tensor G , an instantiation i of G is a sequence of zero or more Exp and Kill operationssuch that i ( G ) doesn’t contain any !-boxes.In fact, we can divorce the notion of instantiation from a particular !-tensor if we noticethat instantiations make sense for any forest. For a forest F , and an element B ∈ F definethe Exp B and Kill B operations as follows:Exp B ( F ) := F ∪ fr ( B < ) Kill B ( F ) := F \ B ≤ where the top elements of fr ( B < ) are added as descendants of the parent of B (if it has one).So, Kill B removes B and all of its children, whereas Exp B behaves just like expanding a!-box, in that it adds a fresh copy of all of the children as siblings:Exp B ABC D E = ABC D C D E Kill B ABC D E = AE We can now define instantiations in a way that only refers to forests: (cid:73)
Definition 11.
For a forest F , an instantiation of F is a composition i of zero or moreoperations Exp B , Kill B such that B is in the domain of each operation and i ( F ) = {} . LetInst( F ) be the set of all instantiations of F .In particular, if F is empty, Inst( F ) only contains the trivial instantiation 1. The set ofinstantiations for a !-tensor G is then just Inst(Boxes( G )). On the other hand, i ( G ) gives usa well-defined !-tensor for any instantiation i ∈ Inst( F ) when F ↔ Boxes( G ). This addedflexibility will be important to the interpretation of !-logic formulas, where instantiationsmay act on many !-tensors simultaneously. . Kissinger and D. Quick 9 In this section, we will introduce the syntax of !-logic. The atomic !-logic formulas arewell-formed equations between !-tensors and generic formulas are built up from the atomicformulas using conjunction, implication, and universal quantification.Well-formed !-tensor equations are pairs of !-tensors with the property that any simultan-eous instantiation of the LHS and RHS produces a valid equation between tensors. That is,the LHS and the RHS of any instance of the equation should have identical free edgenamesfor their inputs and outputs. (cid:73)
Definition 12.
A !-tensor equation G = H is well-formed if G and H have identical inputsand outputs, Boxes( G ) ↔ Boxes( H ), and an input ˇ a (resp. output ˆ a ) occurs in a !-box A in G iff it occurs in the same !-box in H .Note that by ‘ˇ a occurs in A ’ we mean ˇ a occurs as a sub-expression of [ . . . ] A , h . . . ] A or[ . . . i A . The other formulas are built inductively, while maintaining the property that thesub-formulas have compatible !-boxes. To accomplish this, it is most convenient to define theset of !-formulas while simultaneously defining the operation Boxes( X ) for any !-formula X . (cid:73) Definition 13.
The set of !-formulas , F Σ , for a signature Σ is defined inductively as: • G = H ∈ F Σ G, H ∈ T Σ , G = H well-formed • X ∧ Y ∈ F Σ X, Y ∈ F Σ , Boxes( X ) ↔ Boxes( Y ) • X → Y ∈ F Σ X, Y ∈ F Σ , Boxes( X ) ↔ Boxes( Y ) • ∀ A. X ∈ F Σ X ∈ F Σ , A ∈ Boxes( X ) > where Boxes( − ) is defined recursively on !-formulas by: • Boxes( G = H ) := Boxes( G ) ∪ Boxes( H ) • Boxes( X ∧ Y ) := Boxes( X ) ∪ Boxes( Y ) • Boxes( X → Y ) := Boxes( X ) ∪ Boxes( Y ) • Boxes( ∀ A. X ) := Boxes( X ) \ A ≤ Just like one can read formulas in predicate logic as mappings from values of the freevariables to truth values, one should read !-formulas as mappings from instantiations of!-boxes to truth values. Thus, universal quantification over !-boxes states that a particularformula holds for all instantiations involving those !-boxes. We will make this interpretationprecise in Section 6.One important thing to note is that universal quantification over a top-level !-box A should be interpreted as quantifying over the entire connected component A ≤ . In the absenceof nesting, this is the same as quantifying over individual !-boxes. However, in the presenceof nesting, this restriction to only quantifying over entire components seems to be necessaryfor giving a consistent interpretation to !-logic formulas. This boils down to the fact that!-box operations on separate components of Boxes( X ) commute, whereas arbitrary !-boxoperations do not. (cid:73) Remark.
Note that the set F Σ in Definition 13 is defined inductively by relying on asimultaneous recursive definition of Boxes. This is non-circular, since the inductive stepsalways rely on calls to Boxes on strictly smaller formulas. Unsurprisingly, this style ofdefinition is called induction-recursion [7]. In order to talk about instances of !-formulas, we must extend !-box operations from!-tensors to arbitrary formulas. (cid:73)
Definition 14.
For Op B one of the operations Kill B , Exp B, fr , Copy B, fr , Drop B :Op B ( G = H ) := Op B ( G ) = Op B ( H )Op B ( X ∧ Y ) := Op B ( X ) ∧ Op B ( Y )Op B ( X → Y ) := Op B ( X ) → Op B ( Y )Op B ( ∀ A. X ) := ( ∀ A. X B ∈ A ≤ ∀ A. Op B ( X ) B A ≤ (cid:73) Theorem 15. !-box operations preserve the property of being a formula.
Proof.
We prove this using structural induction on !-formulas.If G = H is a formula then G and H have the same free edges in the same !-boxes. HenceOp B ( G ) and Op B ( H ) have the same free edges ( a or fr ( a ) for a free in G = H ) and theseare in the same !-boxes.For the next two cases we have Boxes( X ) and Boxes( Y ) compatible. Op B takes theunique connected component, S , containing B and replaces it with Op B ( S ). This canonly have gained fresh !-box names so Boxes(Op B ( X )) and Boxes(Op B ( Y )) are stillcompatible.If B ∈ A ≤ then the final case is trivial. If B A ≤ then the component A ≤ is not affectedby Op B so is still a component of Op B ( X ). (cid:74) We now define a simple logic over !-formulas, which we call !L. Our presentation is givenin terms of sequents of the form: Γ ‘ Y , where Γ := X , X , . . . , X n is a finite sequence of!-formulas. We will always assume in writing a sequent that all of the formulas involved havecompatible !-boxes. We take the core logical rules to be those from positive intuitionisticlogic with cut: (Id) X ‘ X Γ ‘ Y (Weaken) Γ , X ‘ Y Γ , X, Y, ∆ ‘ Z (Perm) Γ , Y, X, ∆ ‘ Z Γ , X, X ‘ Y (Contr) Γ , X ‘ Y Γ ‘ X ∆ ‘ Y ( ∧ I ) Γ , ∆ ‘ X ∧ Y Γ ‘ X ∧ Y ( ∧ E ) Γ ‘ X Γ ‘ X ∧ Y ( ∧ E ) Γ ‘ Y Γ ‘ X → Y ( → E ) Γ , X ‘ Y Γ , X ‘ Y ( → I ) Γ ‘ X → Y Γ ‘ X ∆ , X ‘ Y (Cut) Γ , ∆ ‘ Y The rules for introducing and eliminating ∀ are also analogous to the usual rules. Let rn : B → B be a bijective renaming function for !-boxes that is identity except on A ≤ , andlet rn ( X ) be the application of that renaming to a formula. Then:Γ ‘ rn ( X ) ( ∀ I ) Γ ‘ ∀ A. X Γ ‘ ∀ A. X ( ∀ E ) Γ ‘ rn ( X )where in the case of ∀ I we also require that rn ( A ≤ ) is disjoint from Boxes(Γ). . Kissinger and D. Quick 11 To these core logical rules, we add rules capturing the fact that = is an equivalencerelation and a congruence: (Refl) Γ ‘ G = G Γ ‘ G = H (Symm) Γ ‘ H = G Γ ‘ G = H Γ ‘ H = K (Trans) Γ ‘ G = K Γ ‘ G = H (Box) Γ ‘ [ G ] A = [ H ] A Γ ‘ G = H (Prod) Γ ‘ F G = F H Γ ‘ G = G (Ins) Γ ‘ Ins A K ( G ) = Ins A K ( G )where Ins A K inserts the expression K into the !-box A ∈ Boxes( G ). The last three rulesallow an equation to be applied to a sub-expression. The first two rules allow us to build thecontext on to the outside of an equation, whereas the third one allows us to add some extracontext within any !-box in an equation. These are precisely the equational reasoning rulesintroduced for !-tensors in [12]. The only difference is we call the ‘weakening’ operation fromthat paper ‘insertion’ to avoid clash with the logical notion.The main utility of universal quantification is to control the application !-box operations.In order to start instantiating a !-box (or one of its children), it must be under a universalquantifier: Γ ‘ ∀ A. X (Kill) Γ ‘ Kill B ( X ) Γ ‘ ∀ A. X (Exp) Γ ‘ Exp B ( X )Γ ‘ ∀ A. X (Drop) Γ ‘ Drop B ( X ) Γ ‘ ∀ A. X (Copy) Γ ‘ Copy B ( X )where B ≤ A ∈ Boxes( X ). These rules, along with ( ∀ E ) play an analogous role to thesubstitution of a universally-quantified variable for an arbitrary term.The final rule of the logic is !-box induction , which allows us to introduce new !-boxes.For a top-level !-box A , we have:Γ ‘ Kill A ( X ) ∆ , X ‘ ∀ B . . . . ∀ B n . Exp A ( X ) (Induct) Γ , ∆ ‘ X where A does not occur free in Γ or ∆ and B to B n are the fresh names of children of A coming from its expansion. In this section, we give a semantic interpretation for !-logic formulas using a compact closedcategory C . For any compact closed category C , a choice of valuation (cid:74) − (cid:75) : Σ → C of thegenerators in Σ will fix a unique morphism (cid:74) G (cid:75) for any concrete (i.e. !-box-free) tensor G .Thus C comes with an interpretation for equality between concrete tensors. From this, wecan build up everything else.For concrete tensors G, H , there is an obvious way to assign a truth value to the formula G = H : (cid:74) G = H (cid:75) := ( T if (cid:74) G (cid:75) = (cid:74) H (cid:75) F otherwise (6)As we first mentioned in Section 4, !-logic formulas should be thought of as mappings frominstantiations to truth values. Equivalently, they can be thought of as sets of instantiations:namely the set of all instantiations for which the formula holds. Applying this interpretationto atomic formulas yields the following definition: (cid:73) Definition 16.
For an atomic !-formula G = H and a valuation (cid:74) − (cid:75) : Σ → C , we let: (cid:74) G = H (cid:75) = (cid:26) i ∈ Inst(Boxes( G = H )) (cid:12)(cid:12)(cid:12)(cid:12) (cid:74) i ( G ) (cid:75) = (cid:74) i ( H ) (cid:75) (cid:27) (7)Concrete tensors are equal if and only if they are equal for the trivial instantiation 1. Wecan interpret truth values as a special case of sets of instantiations: T = { } and F = {} .Then, in the case of concrete tensors, (7) reduces to (6).For a forest F and any i ∈ Inst( F ), and a component S ⊆ F , we write i | S for therestriction of i to only operations involving elements of X (or fresh copies thereof). For a!-formula X , we write i | X for i | Boxes( X ) . Using restrictions of instantiations, we can lift theabove definition from atoms to all formulas. (cid:73) Definition 17.
The interpretation (cid:74) − (cid:75) of a !-logic formula is defined recursively as: (cid:74) X ∧ Y (cid:75) := (cid:26) i ∈ Inst(Boxes( X ∧ Y )) (cid:12)(cid:12)(cid:12)(cid:12) i | X ∈ (cid:74) X (cid:75) ∧ i | Y ∈ (cid:74) Y (cid:75) (cid:27) (cid:74) X → Y (cid:75) := (cid:26) i ∈ Inst(Boxes( X → Y )) (cid:12)(cid:12)(cid:12)(cid:12) i | X ∈ (cid:74) X (cid:75) → i | Y ∈ (cid:74) Y (cid:75) (cid:27) (cid:74) ∀ A. X (cid:75) := (cid:26) i ∈ Inst(Boxes( ∀ A. X )) (cid:12)(cid:12)(cid:12)(cid:12) ∀ j ∈ Inst( A ≤ ) . i ◦ j ∈ (cid:74) X (cid:75) (cid:27) We always interpret sequents as truth values. To do so, we push all of the assumptionsto the right and universally quantify over any free !-boxes: (cid:74) X , . . . , X n ‘ Y (cid:75) := (cid:74) ∀ A . . . ∀ A m . (( X ∧ . . . ∧ X n ) → Y ) (cid:75) where A , . . . A m are the free !-boxes in X , . . . , X n , Y . (cid:73) Theorem 18 (Soundness) . If Γ ‘ X is derivable in !L, then (cid:74) Γ ‘ X (cid:75) is true for anycompact closed category C . Proof.
See Appendix A. (cid:74)
The question of completeness for !L is still open. For the case of atomic !-formulas, thisseems to follow straightforwardly from the fact that string diagrams (or equivalently, tensors)are sound and complete for compact closed categories. So, concrete !-tensor equations aretrue in all models if and only if they are identical tensors. Thus, for the case of general!-tensor equations, the problem reduces to deciding whether two !-tensors with corresponding!-boxes always have identical instances. However, once implication enters the game, we getmany non-trivial formulas that hold in all models. For example, an equation with two !-boxeswithout edges between them always implies another equation obtained by merging those!-boxes:
A B A B = → = C C
In this case, it is always possible to use !-box induction to prove such an implication (andmany others). However, whether the rules in Section 5 suffice to get everything is a topic ofcontinuing research. . Kissinger and D. Quick 13
In this section, we will show how !L can be used to derive highly non-trivial !-box equationsusing a combination of !-box induction and rewriting. Recally that a bialgebra consists of amonoid, a comonoid, and four extra equations governing their interaction. We will extendthe signature of (co)monoids to also allow for n -ary operations, standing for left-associatedtrees of multiplications and comultiplications:...... := ...... :=We then assume the usual (co)monoid laws, along with the definition of a higher-arity tree:Γ M := = , = , = , ∀ A. A = A Γ C := = , = , = , ∀ A. A = A For bialgebras, we start with these equations and add four more:Γ BA := Γ M , Γ C , = , = , = , =Now, we’ll construct a (mostly) formal proof in !L that a tree of multiplications, followedby a tree of comultiplications is equal to a complete bipartite graph of comultiplicationsbefore multiplications. This rule generalises all 4 of the existing bialgebra rules, and can beexpressed very succinctly using !-boxes: =To avoid massive proof trees, we will abbreviate stacks of equational reasoning rules assequences of rewrite steps (marked with (*)’s), suppress ∀ -intro/elim, and write (Assm) toabbreviate using an assumption. The proof from hence forth is purely graphical. (cid:73) Lemma 19. AA = (19) Γ BA ‘ ∀ A. Proof. = ‘ = (Induct)(Assm) (*)Γ BA , Γ BA ‘ =Γ BA ‘ = (*) = = i.h. = (cid:74)(cid:73) Lemma 20. A = (20)Γ BA ‘ A ∀ A. Proof. (Induct)(Assm) (**)Γ BA , Γ BA ‘ Γ BA ‘ == == ‘ (**) == i.h. == = (cid:74)(cid:73) Theorem 21. ∀ A. ∀ B. BA A Γ BA ‘ B = Proof. (Induct) (***)Γ BA , ‘ Γ BA ‘ == = (19) Γ BA ‘ =(***) = = = i.h. = (20) (cid:74) . Kissinger and D. Quick 15 References John C. Baez and Jason Erbele. Categories in control. Technical report, arXiv:1405.6881,2014. F. Bonchi, P. Sobocinski, and F. Zanasi. A categorical semantics of signal flow graphs. In
CONCUR’14: Concurrency Theory. , volume 8704 of
Lecture Notes in Computer Science ,pages 435–450. Springer, 2014. B. Coecke. Quantum picturalism.
Contemporary Physics , 51:59–83, 2009. arXiv:0908.1787. B. Coecke and R. Duncan. Interacting quantum observables. In
Proceedings of the 37thInternational Colloquium on Automata, Languages and Programming (ICALP) , LectureNotes in Computer Science, 2008. B. Coecke, R. Duncan, A. Kissinger, and Q. Wang. Strong complementarity andnon-locality in categorical quantum mechanics. In
Proceedings of the 27th AnnualIEEE Symposium on Logic in Computer Science (LICS) . IEEE Computer Society, 2012.arXiv:1203.4988. Lucas Dixon and Ross Duncan. Extending Graphical Representations for Compact ClosedCategories with Applications to Symbolic Quantum Computation.
AISC/MKM/Cal-culemus , pages 77–92, 2008. Peter Dybjer and Anton Setzer. A finite axiomatization of inductive-recursive definitions. InJean-Yves Girard, editor,
Typed Lambda Calculi and Applications , volume 1581 of
LectureNotes in Computer Science , pages 129–146. Springer Berlin Heidelberg, 1999. Andre Joyal and Ross Street. The geometry of tensor calculus I.
Advances in Mathematics ,88:55–113, 1991. D. Kartsaklis.
Compositional Distributional Semantics with Compact Closed Categoriesand Frobenius Algebras . PhD thesis, University of Oxford, 2014. Aleks Kissinger. Abstract tensor systems as monoidal categories. In C Casadio, B Coecke,M Moortgat, and P Scott, editors,
Categories and Types in Logic, Language, and Physics:Festschrift on the occasion of Jim Lambek’s 90th birthday , volume 8222 of
Lecture Notes inComputer Science . Springer, 2014. arXiv:1308.3586 [math.CT]. Aleks Kissinger, Alex Merry, and Matvey Soloviev. Pattern graph rewrite systems. In
Proceedings of DCM 2012 , volume 143 of
EPTCS , 2012. arXiv:1204.6695 [math.CT]. Aleks Kissinger and David Quick. Tensors, !-graphs, and non-commutative quantum struc-tures (extended version), 2015. arXiv:1503.01348. Aleks Kissinger and Vladimir Zamdzhiev. Quantomatic: A proof assistant for diagrammaticreasoning, 2015. arXiv:1503.01034. Alexander Merry.
Reasoning with !-Graphs . PhD thesis, University of Oxford, 2014.
A Proof of soundness for !L
In this section, we prove Theorem 18, i.e. the soundness of (cid:74) − (cid:75) with respect to !L. To do so,it suffices to show that (cid:74) − (cid:75) respects each of the rules of the logic.For i ∈ Inst( F ) and a formula X such that Boxes( X ) is a component of F , we will write i (cid:15) X as shorthand for i | X ∈ (cid:74) X (cid:75) . Using this notation, we can rewrite the interpretation asfollows: i (cid:15) G = H ⇐⇒ (cid:74) i ( G ) (cid:75) = (cid:74) i ( H ) (cid:75) i ∈ Inst(Boxes( G = H )) i (cid:15) X ∧ Y ⇐⇒ i (cid:15) X ∧ i (cid:15) Y i ∈ Inst(Boxes( X ∧ Y )) i (cid:15) X → Y ⇐⇒ i (cid:15) X → i (cid:15) Y i ∈ Inst(Boxes( X → Y )) i (cid:15) ∀ A.X ⇐⇒ ∀ j ∈ Inst( A ≤ ) . i ◦ j (cid:15) X i ∈ Inst(Boxes( ∀ A.X ))Universal quantification over entire components of Boxes( X ) is well-behaved for thefollowing reason: (cid:73) Lemma 22.
For a forest F , let A, B be elements in disinct connected components of F ,and let Boxes( X ) ↔ F . Then, Op A (Op B ( X )) = Op B (Op A ( X )) for any !-box operations Op A , Op B . Proof.
Since !-box operations recurse down to equations between !-tensors, it suffices toshow that Op A (Op B ( G = H )) = Op B (Op A ( G = H )). Since neither A nor B is a child ofthe other, this is easy to check. The only complication is dealing with the freshness functions fr A , fr B (possibly) associated with the two operations. These necessarily operate on disjointsets of boxnames, so the only overlap might be on edgenames. However, since there is aninfinite supply of fresh edgenames, it is always possible to choose new freshness functions suchthat fr A ◦ fr B = fr B ◦ fr A . Then, it is straightforward to check that Op A, fr A (Op B, fr B ( G = H )) = Op B, fr B (Op A, fr A ( G = H )). (cid:74) A related fact about re-ordering operations in an instantiation is that they can always beput in normal form: (cid:73)
Lemma 23.
Given an instantiation i ∈ Inst( X ) and a top-level !-box A ∈ X > , i can berewritten as i ◦ Kill A ◦ Exp nA where i ∈ INST (Kill A ◦ Exp nA ( X )) . Proof.
We need to check that operations on A can always be commuted to the right, pastother operations. If B is not nested in A , this is true by Lemma 22. Otherwise, B ≤ A and:If Op A = Kill A then killing A will erase any part of the !-formula resulting from Op B , i.e.Kill A ◦ Op B = Kill A .If Op A = Exp A, fr then Exp A, fr ◦ Op B = Op fr ( B ) ◦ Op B ◦ Exp A, fr . In the case thatOp B = Exp B , freshness functions on the RHS need to be chosen to produce identicalnames to the LHS. (cid:74)(cid:73) Notation 24.
We will write KE nA as a shorthand for Kill A ◦ Exp nA . (cid:73) Lemma 25.
For any !-formula X and for B , . . . B n the free, top-level !-boxes in X : ∀ i ∈ Inst(Boxes( X ) . i (cid:15) X ⇐⇒ (cid:74) ∀ B . . . ∀ B n .X (cid:75) = { } = T . Kissinger and D. Quick 17 Proof.
First, assume the LHS, which is equivalent to (cid:74) X (cid:75) = Inst(Boxes X ). For any !-formula Y , if B k ∈ Boxes( Y ) > and (cid:74) Y (cid:75) = Inst(Boxes( Y ), then (cid:74) Y (cid:75) contains all possibleinstantiations of Boxes( Y ). In particular, it contains i ◦ j for any i ∈ Inst(Boxes( ∀ B k .Y ))and j ∈ Inst( B ≤ k ). Thus, (cid:74) ∀ B k .Y (cid:75) = Inst(Boxes( ∀ B k .Y )). Iterating this implication, wehave (cid:74) ∀ B . . . ∀ B n .X (cid:75) = Inst(Boxes( ∀ B . . . ∀ B n .X )) = { } = T .Conversely, assume (cid:74) ∀ B . . . ∀ B n .X (cid:75) = T . Then every instantiation of the form j = i ◦ i ◦ . . . ◦ i n , where the operations in i k only involve !-boxes in B ≤ k is in (cid:74) X (cid:75) . But then,by Lemma 22, we can freely commute !-box operations in distinct components of Boxes( X ).So, in fact, every instantiation i ∈ Inst(Boxes( X )) is equivalent to an instantiation of theform of j . Then, since j ∈ (cid:74) X (cid:75) , so is i . (cid:74)(cid:73) Theorem 26.
For any valuation (cid:74) − (cid:75) : Σ → C , the rules (Id), (Weaken), (Perm), (Contr),( ∧ I ), ( ∧ E ), ( ∧ E ), ( → E ), ( → I ), (Cut), ( ∀ I ), ( ∀ E ), (Refl), (Symm), (Trans), (Box),(Prod), (Ins), (Kill), (Exp), (Drop), (Copy), and (Induct) are sound with respect to (cid:74) − (cid:75) . Proof.
The basic structural rules just reduce to the same rules concerning instantiations. Let K be the conjunction of Γ and K the conjunction of ∆ throughout. By Lemma 25, to checkthat (cid:74) Γ ‘ X (cid:75) is true, it suffices to check that, for all i ∈ Inst(Boxes( K → X )), i (cid:15) K → X .(Ident) Fix i ∈ Inst(Boxes( X )). We need to show i ∈ X → X , but this is equivalent to i (cid:15) X → i (cid:15) X , which is trivially true.(Weaken) Fix i ∈ Inst(Boxes(( K ∧ X ) → Y )) and assume i (cid:15) K → Y . Then, if i (cid:15) K ∧ X ,then i (cid:15) K . So, by assumption, i (cid:15) Y . Thus i ‘ ( K ∧ X ) → Y .(Perm) and (Contr) follow from associativity, commutativity and idempotence of ∧ .( ∧ I ) Fix i ∈ Inst(Boxes(( K ∧ K ) → ( X ∧ Y ))) and assume i (cid:15) K → X and i (cid:15) K → Y .If i (cid:15) K ∧ K , we have i (cid:15) K and hence i (cid:15) X . We also have i (cid:15) K and hence i (cid:15) Y .Thus i (cid:15) X ∧ Y .( ∧ E
1) Fix i ∈ Inst(Boxes( K → X )). Then, there exists i ∈ Inst(Boxes( K → ( X ∧ Y )))that restricts to i . Assume i (cid:15) K → ( X ∧ Y ). If i (cid:15) K then i (cid:15) K and hence i (cid:15) X ∧ Y ,which implies that i (cid:15) X . So, i (cid:15) X .( ∧ E
2) is similar to ( ∧ E → E ) Fix i ∈ Inst(Boxes(( K ∧ X ) → Y )) and assume i (cid:15) K → ( X → Y ). Then, if i (cid:15) K ∧ X then i (cid:15) K . So, i (cid:15) X → Y . But, since it is also the case that i (cid:15) X , i (cid:15) Y .Thus i (cid:15) ( K ∧ X ) → Y .( → I ) is the same as ( → E ) in reverse.(Cut) Fix i ∈ Inst(Boxes( K ∧ K → X )). Then, there exists i ∈ Inst(Boxes( K → X ) ∪ Boxes(( K ∧ X ) → Y )) that restricts to i . Assume i (cid:15) K → X and i (cid:15) ( K ∧ X ) → Y .If i (cid:15) K ∧ K , then i (cid:15) K ∧ K so i (cid:15) K and i (cid:15) K . The former also implies that i (cid:15) X . So, i (cid:15) K ∧ X and hence i (cid:15) Y . Finally, this implies i (cid:15) Y .( ∀ I ) Fix i ∈ Inst(Boxes( K → ∀ A.X )). We need to show that for any j ∈ Inst( A ≤ ), i ◦ j (cid:15) K → X . Assume without loss of generality that any !-box names on operations in i are disjoint from rn ( A ≤ ). This is possible because rn ( A ≤ ) must already be disjoint fromBoxes(Γ) (by side-condition) and it must be disjoint from Boxes( ∀ A.X ) = Boxes( X ) \ A ≤ byinjectivity of rn . The only other !-box names in i are those introduced during instantiation,which can be freely chosen. Let rn ( j ) be the instantiation of rn ( A ≤ ) obtained by renamingoperations according to rn . Then, by assumption of the rule, we have i ◦ rn ( j ) (cid:15) K → rn ( X ).Since rn is identity except on A ≤ , we have rn ( i ◦ j ) (cid:15) rn ( K → X ) and thus i ◦ j (cid:15) K → X .( ∀ E ) Fix i ∈ Inst(Boxes( K → rn ( X ))). Then suppose i (cid:15) K , then i (cid:15) K . Then,by assumption i (cid:15) ∀ A.X . Let i = i | ∀ A.X , then i (cid:15) ∀ A.X , which implies that for all j ∈ Inst( A ≤ ), we have i ◦ j (cid:15) X . Renaming both sides yields rn ( i ◦ j ) (cid:15) rn ( X ), and since rn is identity except on A ≤ , i ◦ rn ( j ) (cid:15) rn ( X ). Now, since we are free to choose j , wechoose it such that ( i ◦ rn ( j )) | rn ( X ) is equivalent to i | rn ( X ) . Then i (cid:15) rn ( X ).The rules (Refl), (Symm), and (Trans) reduce to the properties of equality in C . Thecongruence rules (Box), (Prod), and (Ins) were proven sound in [12], where the only differencehere is the additional (unused) context Γ.(Kill) Fix i ∈ Inst(Boxes( K → Kill B ( X ))). Then if i (cid:15) K , by assumption i (cid:15) ∀ A.X . Since B ≤ A does not occur free in ∀ A.X , i ◦ Kill B (cid:15) ∀ A.X . For i = i | ∀ A.X , choose j ∈ Inst( A ≤ )such that ( i ◦ j ) | X is equivalent to ( i ◦ Kill B ) | X . Then, i ◦ j (cid:15) X , so i ◦ Kill B (cid:15) X , and i (cid:15) Kill B ( X ). (Exp) is similar.(Copy) and (Drop) are is also similar. However, when we choose j ∈ Inst( A ≤ ) suchthat ( i ◦ j ) | X is equivalent to ( i ◦ Copy B ) | X or ( i ◦ Copy B ) | X , we make use of the fact thatinstantiations involving Copy / Drop can always be reduced to a normal form which onlyincludes Exp and Kill. This was proven in [12].Finally, we prove the (Induct) rule. For any top-level !-box A , Lemma 23 says that wecan write any instantiation i equivalently as j ◦ KE nA , where j doesn’t contain A . Thus, wewill show that, for all n , and all instantiations of the form i := j ◦ KE nA , i (cid:15) ( K ∧ K ) → X .We proceed by induction on n .For the base case, i = j ◦ Kill A . If i (cid:15) K , then since K doesn’t contain A , i (cid:15) K implies j (cid:15) K . So, by the first premise j (cid:15) Kill A ( X ). Thus j ◦ Kill A (cid:15) X , as required. For thestep case, assume that for all instantiations of ( K ∧ K ) → X of the form i := j ◦ KE nA , i (cid:15) ( K ∧ K ) → X . We need to show for all i := j ◦ KE n +1 A , i (cid:15) ( K ∧ K ) → X . If i (cid:15) K ∧ K , then i (cid:15) K . Then, since K doesn’t contain A , i (cid:15) K . Combining this withthe induction hypothesis yields i (cid:15) ∀ B . . . ∀ B m . Exp A ( X ). Thus, for any instantiation k ofthe B ≤ , . . . , B ≤ m , i ◦ k (cid:15) Exp A ( X ). So, i ◦ k ◦ Exp A (cid:15) X . i is equivalent to i ◦ k ◦ Exp A forsome i, k , so i (cid:15) X . (cid:74) Soundness of !L with respect to (cid:74) − (cid:75)(cid:75)