Abstract 1 Introduction 2 Symmetric Monoidal Categories as Resource Theories 3 Parametric Iteration 4 Reasoning with Probabilities and Distances 5 Asymptotic Equivalence 6 Conclusions and Future Work References Appendix A Appendix to Section 3 Appendix B A Complete Equational Theory of Boolean Stochastic Maps Appendix C Additional Proofs for Section 4

Parametric Iteration in Resource Theories

Alessandro Di Giorgio ORCID Tallinn University of Technology, Estonia Pawel Sobocinski ORCID Tallinn University of Technology, Estonia Niels Voorneveld ORCID Cybernetica AS, Tartu, Estonia
Abstract

Many algorithms are specified with respect to a fixed but unknown parameter. Examples of this are especially common in cryptography, where protocols often feature a security parameter such as the bit length of a secret key.

Our aim is to capture this phenomenon in a more abstract setting. We focus on resource theories – general calculi of processes with a string diagrammatic syntax – introducing a general parametric iteration construction. By instantiating this construction within the Markov category of probabilistic Boolean circuits and equipping it with a suitable metric, we are able to capture the notion of negligibility via asymptotic equivalence, in a compositional way. This allows us to use diagrammatic reasoning to prove simple cryptographic theorems – for instance, proving that guessing a randomly generated key has negligible success.

Keywords and phrases:
Markov categories, Cryptography, String diagrams, Asymptotic equivalence
Copyright and License:
[Uncaptioned image] © Alessandro Di Giorgio, Pawel Sobocinski, and Niels Voorneveld; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Program semantics
; Theory of computation Logic and verification ; Mathematics of computing Probability and statistics
Funding:
Di Giorgio, Voorneveld and Sobocinski were supported by the European Union under Grant Agreement No. 101087529. Sobocinski was additionally supported by the Estonian Research Council via grants PRG1215 and TEM-TA5 and the Estonian Center of Excellence in Artificial Intelligence (EXAI).
Editors:
Stefano Guerrini and Barbara König

1 Introduction

Cryptographic protocols are designed to resist attacks by adversaries with bounded computational power. A fundamental feature is the use of a security parameter σ, which governs the time complexity of potential attacks. As σ increases, cryptographic schemes become more secure: for example, in public-key encryption, key lengths are chosen in relation to σ to ensure that brute-force attacks require time exponential in σ to succeed. More generally, security is often defined in asymptotic terms, stating that certain probabilities – such as the success rate of an adversary – become negligible as σ grows. This notion of negligibility from cryptography [14] also appears in other computational settings, such as approximation schemes in probabilistic algorithms. In both cases, reasoning about security or approximation guarantees requires a formal understanding of how computations depend on the parameter σ.

Traditionally, the definition of a cryptographic system follows a bottom-up approach: one chooses a model of computation, an algorithm and its notion of complexity, efficiency and security. This usually entails several technicalities that tend to hinder clarity and modularity. In particular, security proofs often become bogged down with low-level details of the computational model, making it difficult to generalise results, compare different cryptographic frameworks, or reason about their composition in a structured way.

This situation motivated the study of the subject at a higher level of abstraction, starting with the work of Canetti on Universal Composable Security [3] and followed by the work of Maurer and Renner on Abstract Cryptography [20, 19]. Motivated by similar intents, Broadbent and Karvonen [2] propose an abstract model of composable security definitions in terms of resource theories, formalised as symmetric monoidal categories.

The resource theoretic approach comes with the visual and intuitive language of string diagrams [13]. Consider the following example:

[Uncaptioned image] (1)

In the diagram above – read from left to right – we think of f and g as processes that transform the resources carried on the wires. The explicit splitting of wires via a copier, indicates that f and g share the second resource. If a resource is unused, as in the diagram on the right hand side, we simply discard it by closing the wire.

In cryptographic terms, we interpret the first input wire in (1) as carrying a message and the second as carrying a key. The processes f and g correspond to encryption and decryption, respectively. The equation postulates the correctness of the protocol: the original message – transformed into a cipher text by f – corresponds to the one decrypted by g. Equations between string diagrams such as these lead to proofs via diagrammatic reasoning, a powerful axiomatic technique that allows compositional reasoning about compound systems.

Our aim in this paper is to capture the notion of parametric algorithms within the abstract framework of resource theories. After a brief introduction to resource theories and their string diagrammatic language in Section 2, in Section 3 we define a notion of iteration bounded by an unspecified parameter, which we call -iteration. Perhaps unexpectedly, we do not study traces (as, e.g., in monoidal streams [9]) but instead define a functorial construction: given a morphism f:SABS, we define τS,(A),(B)k(f):SAkBkS as its k-fold iteration. Below we give a diagrammatic representation of τS,(A),(B)k(f), when k=3.

[Uncaptioned image]=[Uncaptioned image]

Iterated morphism consumes and produces lists of resources of type A and B, respectively. The resource of type S can be thought of as a state carried over by the computation. A similar construction is found in probabilistic programming languages [11, 24], where iteration is usually bounded. Interestingly, useful results can be proved about iteration without instantiating the parameter. To this end, we introduce a technique we dub the diagonal method that allows us to prove useful, general results that add to the arsenal of diagrammatic reasoning about abstract resource theories with parametric iteration.

Parametric iteration is a feature that extends the expressivity of resource theories. Our main application in this paper is motivated by cryptography, and the notion of negligibility in particular. To do this, we work within a probabilistic resource theoretical context. This is the category 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} of Boolean stochastic maps. It is both a Markov category and one that possesses a probabilistic choice structure, which we introduce in Section 4. As a notable property, the probabilistic case structure ensures a unique (up to isomorphism) normal form for probabilistic Boolean functions. This, in turn, allows us to derive a completeness result (Theorem 11). While not essential to the main developments of the paper, it provides an interesting alternative proof to the one found in [21].

Formally, we first move from symmetric monoidal categories to metric-enriched ones, so that morphisms, i.e. processes, are equipped with a notion of distance between them (see e.g. [8, 17]).

We reconcile metric-enrichment with the parameterized iteration construction in Section 5, where we introduce a notion of asymptotic equivalence on morphisms. This captures negligibility – also referred to as indistinguishability – between processes. Intuitively, two processes f and g, potentially involving parametric iterations, are considered indistinguishable if their distance approaches 0 as the parameter σ tends to . In related work [16], such notions of indistinguishability are studied in a bounded linear λ-calculus.

Guided by cryptographic intuitions, we conclude with some examples. Notably, we formally prove that a randomly generated key is unlikely to be any specific key (Lemma 21), and show we can asymptotically approximate fair choice with weighted choice with the iterated von Neumann trick (Lemma 22). We also discuss how we can perform arithmetic over the cyclic groups of sizes 2σ and 2σ1, which is useful for instance in Diffie-Hellman key exchange and Zero knowledge proofs.

The paper presents two theoretical contributions. We define the parametrized iteration construction on symmetric monoidal categories, prove that it forms a category, preserves several categorical structures, and admits an endofuctor τ for parametrized iteration. We moreover define the notion of asymptotic equivalence on the parametrized iteration over a metric-enriched symmetric monoidal category, and show that it defines a congruence and is preserved under the application of τ.

The paper includes appendices containing additional material and omitted proofs.

2 Symmetric Monoidal Categories as Resource Theories

In this section we give a brief introduction to symmetric monoidal categories (SMCs) and their associated graphical calculus [13, 23, 22] in terms of resource theories, following [6].

The basic data consists of objects A,B,C, that we think of as types of resources, and morphisms f:AB, which we think of as transformations that convert a resource of type A into one of type B. Morphisms can be composed sequentially: given f:AB and g:BC, their composite f;g:AC represents performing f followed by g.

The monoidal product lets us express having two resources at once – so AC means having both A and C – and it extends to morphisms too: given f:AB and g:CD, the morphism fg:ACBD describes applying f and g in parallel. There is also a void resource I that acts neutrally under combination: AI=A.

These ideas are captured visually using the graphical calculus of string diagrams. A resource type A is drawn as a wire [Uncaptioned image], and a transformation f:A1AnB1Bm is represented by a box [Uncaptioned image] with n input wires on the left and m output wires on the right. Composition of morphisms is shown by connecting boxes in sequence [Uncaptioned image], while the monoidal product corresponds to placing them side-by-side [Uncaptioned image]. The void resource I corresponds to no wires at all – i.e., the empty diagram.

Resources can also be swapped according to the symmetry χA,B:ABBA, which is represented by a crossing of wires [Uncaptioned image].

Diagrams are subject to the axioms of symmetric monoidal categories (SMCs). However, note that equational reasoning in this setting amounts to deformation of diagrams without changing their topology. For example, naturality of symmetry amounts to sliding a box past a crossing of wires, illustrated as [Uncaptioned image].

In the next section, where we introduce the parametric iteration construction, it will be convenient to explicitly track both the combination of resources via the monoidal product and the void resource. Therefore, following [4], we extend the graphical calculus with operations that introduce [Uncaptioned image] and discard [Uncaptioned image] the void resource, as well as split [Uncaptioned image] and combine [Uncaptioned image] resources. These operations are subject to the expected equations determined by the properties of the monoidal product.

Finally, note that all monoidal categories considered in this paper are taken to be strict, as justified by Mac Lane’s strictification theorem [18].

3 Parametric Iteration

We define a category of parametric iterations over a symmetric monoidal category. We do this by introducing the concept of -iteration, which expresses the idea of iterating an operation a fixed yet unspecified number of times. We do not a priori choose how many times to iterate, the operations are parametrized over this yet to be specified choice of number of iterations.

We define parametric iteration over 𝒞 in two stages. First we define the free iteration construction 𝖥𝖨(𝒞) which adds the relevant objects and operations which will be used to express iteration. We then quotient this category to create the parametric iteration construction PI(𝒞) over 𝒞, giving an interpretation to the added objects and operations.

We define the objects of 𝖥𝖨(𝒞) inductively as follows:

A𝒞A𝖥𝖨(𝒞)A,B𝖥𝖨(𝒞)AB𝖥𝖨(𝒞)A𝖥𝖨(𝒞)A𝖥𝖨(𝒞)

satisfying the equations IA=A=AI, AB=AB, and (AB)C=A(BC). Here A represents a -tuple, that is a tuple of A’s, with the exact number of elements bounded by an external parameter.

Given a tuple of objects 𝐀=(A1,,An), we write 𝐀=A1An, and for each k, 𝐀k=A1kAnk, following notation from [5], where Ak is the k-th power of A with respect to . In particular, 𝐀1=A1An.

Morphisms of 𝖥𝖨(𝒞) are given inductively as follows:

f:AB𝒞f:ABA𝖥𝖨(𝒞)idA:AAf:ABg:BCf;g:ACf:ABg:CDfg:ACBD
A,B𝖥𝖨(𝒞)χA,B:ABBAf:S𝐀1𝐁1SτS,𝐀,𝐁(f):S𝐀𝐁S

satisfying the relevant equations making 𝖥𝖨(𝒞) into a symmetric monoidal category, together with the equations idA=idA, f;g=f;g, χA,B=χA,B, fg=fg. The latter equations make :𝒞𝖥𝖨(𝒞) sending A to A and f to f into a symmetric monoidal functor.

Here τ is the operation which represents -iteration, transforming a list of -tuples 𝐀 into a list of -tuples 𝐁 by going through the elements one by one, carrying over the state S between iterations. We annotate τ by lists telling us exactly how the input and output of f is divided into different tuples. For instance, if f:SA2BS, we could either create τS,(A2),(B)(f):S(A2)BS or τS,(A,A),(B)(f):SAABS, where (A2) is a -tuple of elements of A2, and AA are two -tuples of elements of A.

String diagrammatically, we denote τS,𝐀,𝐁(f) as follows:

[Uncaptioned image][Uncaptioned image]

Here we mark state wires with a , and the -tuples with an interrupted wire. Each non-state wire is part of a different tuple. We may use multiple or no state wires as well.

We give an interpretation of iteration by defining τk as an operation on symmetric monoidal categories describing a constant number of k iterations. Given a symmetric monoidal category 𝒞 , we can inductively define operations push𝐀k:𝐀1𝐀k𝐀(k+1) and pop𝐀k:𝐀(k+1)𝐀1𝐀k which respectively pushes and pops the first element of each tuple of objects in 𝐀(k+1). For instance, if 𝐀=(X,Y), then push𝐀3:XYX2Y2X3Y3 simply swaps the second and third element.

Given a morphism f:S𝐀1𝐁1S in 𝒞, we inductively define τS,𝐀,𝐁k(f):S𝐀k𝐁kS for each k as:

  • τS,𝐀,𝐁0(f)=idS,

  • τS,𝐀,𝐁k+1(f)=(idSpop𝐀k);(fid𝐀k);(id𝐁1τS,𝐀,𝐁k(f));(push𝐁kidS).

[Uncaptioned image][Uncaptioned image]

[Uncaptioned image]:=[Uncaptioned image][Uncaptioned image]:=[Uncaptioned image]

Contrary to τ, the annotations for τk serve a further clarifying role, as they are also necessary for removing ambiguity even in those instances where the type of the produced morphism is known. Without this specification, the input may be wrongly distributed into separate tuples. For instance, a τ3 iteration having A6 as input, could consider this either as two triples of A, or one triple of A2, which lead to different interpretations. In terms of string diagrams, we can keep the convention that each string represents a different tuple, which avoids the need for putting annotations in the string diagrams.

Example 1.

Suppose f:AAB, then τ1,(A,A),(B)2(f) and τ1,(A2),(B)2(f) have the same type but yield two different results, represented respectively as string diagrams as follows:

[Uncaptioned image]=[Uncaptioned image]     [Uncaptioned image]=[Uncaptioned image]

For any k, we define a functor Sk:𝖥𝖨(𝒞)𝒞 inductively as follows, first on objects:

  • Sk(A)=A,

  • Sk(AB)=Sk(A)Sk(B),

  • Sk(A)=(Sk(A))k.

For 𝐀=(A1,,An), then Sk(𝐀)=(Sk(A1),,Sk(An)). Sk is defined on morphisms as:

  • Sk(idA)=idSk(A),

  • Sk(f)=f,

  • Sk(f;g)=Sk(f);Sk(g),

  • Sk(fg)=Sk(f)Sk(g),

  • Sk(χA,B)=χSk(A),Sk(B).

For f:S𝐀1𝐁1S, then Sk(τS,𝐀,𝐁(f))=τS,Sk(𝐀),Sk(𝐁)k(Sk(f)).

Definition 2.

Two morphisms f,g:AB in 𝖥𝖨(𝒞) are -equivalent if for any k, Sk(f)=Sk(g). The parametric iteration category PI(𝒞) of 𝒞 is defined as 𝖥𝖨(𝒞) quotiented over this notion of -equivalence.

We have a symmetric monoidal functor :𝒞PI(𝒞) and for each k a symmetric monoidal functor Sk:PI(𝒞)𝒞. We consider the image of in PI(𝒞) as the constant fragment of PI(𝒞). It holds that Sk is the identity functor on 𝒞 for each k.

Before we continue on and prove results regarding -equivalence, we introduce a powerful proof technique we call the diagonal method. Consider PI(PI(𝒞)), which has two nested parametric iteration constructions, the second we label with . We construct a symmetric monoidal functor M:PI(PI(𝒞))PI(𝒞) that unifies the two iterations, i.e. it satisfies:

  • M(A)=M(A)=(MA),

  • M(τS,𝐀,𝐁(f))=M(τS,𝐀,𝐁(f))=τMS,M𝐀,M𝐁(Mf).

Lemma 3.

There is a functor M:PI(PI(𝒞))PI(𝒞) satisfying the properties above.

Proof.

Let us consider the obvious functor M:𝖥𝖨(PI(𝒞))PI(𝒞). We prove that M preserves -equivalence. Let f and g be -equivalent morphisms in 𝖥𝖨(PI(𝒞)), then for any k, Sk(f)=Sk(g) in PI(C). So for any r, Sr(Sk(f))=Sr(Sk(g)) in 𝒞. Note that the Sk instantiates the , and the Sr the .

Now, for any k, Sk(Mf)=Sk(Sk(f))=Sk(Sk(g))=Sk(Mg), hence Mf=Mg. So M preserves -equivalence and can be factored through PI(PI(𝒞)) creating M.

In practice, this allows us to prove -equivalence between morphisms by instantiating some of the iteration operations but not necessarily all. We can do this as long as we can find a separation into two iteration types, marking a choice of top level -iterations as in a way that type checks. We now have sufficient tools to prove some useful properties.

Lemma 4.

The following equations hold:

[Uncaptioned image]=(3)[Uncaptioned image][Uncaptioned image]=(3)[Uncaptioned image][Uncaptioned image]=(3)[Uncaptioned image][Uncaptioned image]=(3)[Uncaptioned image]

Proof.

Let us prove (3), the other equations are shown in Appendix A. We use the diagonal method, instantiating only the outer iteration operations. We perform induction on those instantiations:

Induction basis:

[Uncaptioned image]=(def)[Uncaptioned image]=(def)[Uncaptioned image]

Induction step:

[Uncaptioned image]=(def)[Uncaptioned image]=(hypo)[Uncaptioned image]=(def)[Uncaptioned image]

Corollary 5.

There is a symmetric monoidal endofunctor on PI(𝒞) given by AA and f:ABτI,(A),(B)(f).

The following property is particularly useful in forthcoming examples:

Lemma 6 (Newton’s cradle).

For any f:SZ,g:Z𝐀1𝐁1Z,h:S𝐀1𝐁1S, if [Uncaptioned image]=(I)[Uncaptioned image] then [Uncaptioned image]=[Uncaptioned image].

Proof.

We use the diagonal method, and choose to instantiate only the top level iterations. We show by induction on k that for each instantiation by k the equation holds.

Induction basis:

[Uncaptioned image]=(def)[Uncaptioned image]=(def)[Uncaptioned image]

Induction step:

[Uncaptioned image]=(def)[Uncaptioned image]=(I)[Uncaptioned image]=(hypo)[Uncaptioned image]=(def)[Uncaptioned image]

Let us look at two examples which occur in PI(𝒞) for any symmetric monoidal category 𝒞.

Example 7.

Consider zipping two -tuples using τI,(A,B),(AB)(idAB):

[Uncaptioned image]     [Uncaptioned image] = [Uncaptioned image]

On the right we see an example instantiation performing three iterations. The zip operations gives one direction of an isomorphism between AB and (AB).

Example 8.

The morphism τA,(A),(A)(idA2):AAAA pushes a new element to the front of a -tuple, and pops the last element from the -tuple to make room.

τA,(A),(A)(idA2)=[Uncaptioned image]τA,(A),(A)k(idA2)=[Uncaptioned image]=[Uncaptioned image]

We can use this to cycle forward and backward through the elements of a -tuple. We take cycleA=τA,(A),(A)(idA2);χA,A and cycle-backA=τAA,(),()(cycleA),

cycleA=[Uncaptioned image]cycle-backA=[Uncaptioned image]

Here we cycle back by cycling forward one less than what is needed to get back to where we started. Concretely, note that Sk(cycleA)=χAk,A, and for any a,b, χAa+1,Ab;χAa+b,A=χAb,Ab+1, so by induction, Sk(cycle-backA)=(χAk,A)k=χA,Ak, so Sk(cycle-backA;cycleA)=χA,Ak;χAk,A=idAk+1. We conclude that:

[Uncaptioned image]=[Uncaptioned image]

4 Reasoning with Probabilities and Distances

To model richer computational behaviors, we consider symmetric monoidal categories with additional properties and structure. In particular, for probabilistic computations, we focus on metric-enriched symmetric monoidal categories and Markov categories [10].

Refer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to captionRefer to caption=(1)Refer to caption
Figure 1: Axioms for Markov categories (top) and probabilistic choice (bottom). Here f:AB, q=1p, c=(1a)b1ab and d=ab.
Definition 9.

A Markov category with probabilistic choice is a symmetric monoidal category equipped with operations !A:AI, A:AAA, p:I𝔹 and ϕA:A𝔹AA, represented in string diagrams, respectively, as

[Uncaptioned image]     [Uncaptioned image]     [Uncaptioned image]     [Uncaptioned image]

where p[0,1], 𝔹 is a designated object and A is any object, and such that the axioms in Figure 1 hold. That is:

  • (A,!A) is a cocommutative comonoid, that is A is associative (1), cocommutative (1) and !A is the unit (1),

  • A and !A are coherent with the monoidal structure,

  • !A is natural (1),

  • 1 and 0 are deterministic ((1) and (1)),

  • ϕA is coherent with the monoidal structure ((1) and (1)),

  • ϕA is natural in A (1),

  • ϕAp–where ϕAp is [Uncaptioned image], often simply [Uncaptioned image]–is a convex algebra, that is, ϕAp is idempotent (1) and satisfies parametric associativity (1) and commutativity (1),

  • ϕ and 1, 0 interact via (1) and (1).

The 𝔹 represents the type of two bit values, 1 and 0. p describes a weighted coin flip, which has a chance of p of producing 1, and a chance of 1p of producing 0. The ϕ represents an if-gate, choosing between two results of the same type using a bit as an argument.

Refer to caption=(2)Refer to captionRefer to caption=(2)Refer to captionRefer to caption=(2)Refer to captionRefer to caption=(2)Refer to caption
Figure 2: Derived laws for Markov categories with probabilistic choice.
Lemma 10.

The laws in Figure 2 hold in any Markov category with probabilistic choice.

Proof.

We give a proof only for (2), the rest can be found in Appendix C.

[Uncaptioned image]=(1)[Uncaptioned image]=(1)[Uncaptioned image]

Our leading example of Markov category with probabilistic choice is 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁, the category of sets and stochastic maps. Objects are sets and morphisms f:AB are functions A𝒟B mapping each aA to a finitely-supported discrete probability distribution over B. We represent a distribution as a function v:A[0,1] with finite support supp(v):={aAv(a)>0} and such that aAv(a)=1, or, alternatively, as a formal sum ipi|ai, where the | notation is used to separate the elements aiA from their associated probability pi[0,1].

We write f(b|a) for f(a)(b), representing the probability that f returns b, given a. For two stochastic maps f:AB,g:BC, their composition is defined by summing over the middle variable, i.e. (f;g)(ca):=bBg(cb)f(ba). Identities idA:AA map each aA to the Dirac distribution at a, i.e. idA(a):=|a.

Given two distributions v𝒟A and u𝒟B, their product vw𝒟(A×B) is given by vu(a,b):=v(a)u(b). This yields a symmetric monoidal structure, with the monoidal product being the cartesian product of sets × on objects and with monoidal unit the singleton set I:={}. For arrows f:AB and g:CD, fg:ACBD is defined as fg(b,d|a,c):=f(b|a)g(d|c), and symmetries χA,B:ABBA as χA,B(a,b):=|b|a.

The comonoid structure is given by A(a):=|a|a and !A(a):=|, while for the probabilistic choice structure we take as choice object the set of Booleans {1,0} and, for any p[0,1], we define p:{}{1,0} as p():=p|1+(1p)|0 and ϕA:A{1,0}AA as ϕA(a,1,b):=|a and ϕA(a,0,b):=|b. Note that ϕAp(a,b)=p|a+(1p)|b.

Throughout the rest of the paper we will work in 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}, the subcategory of 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁 consisting of stochastic maps between sets that are powers of the booleans. The structure of Markov category with probabilistic choice, introduced here, is novel and it offers an alternative presentation of 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} to the one in [21]. In particular:

Theorem 11.

the axioms in Figure 1 are complete for 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}.

The interested reader can find the details in Appendix B.

As an example of diagrammatic reasoning in 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} we look at the one-time-pad protocol on a single bit. We regard 12:I𝔹 as an operation that produces a randomly generated bit, and the xor :𝔹𝔹𝔹, defined below on the left, as an operation that encrypts and decrypts a bit.

[Uncaptioned image] := [Uncaptioned image]     [Uncaptioned image]

The equation on the right expresses the correctness of the protocol: encoding and decoding with the same randomly generated bit gets the same result, and that to an adversary the encrypted message looks completely random. We prove correcteness by equational reasoning:

[Uncaptioned image]

The equations use the fact that is deterministic, associative, idempotent, unitary with respect to 0 and nullary with respect to 12. All of these properties can be proved via the axioms of Markov categories with probabilistic choice. For example the fact that 12 is absorbing for is proved using the laws in Figure 2 as follows:

[Uncaptioned image]

Looking at PI(𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}), the above example can be extended to operations on 𝔹, encrypting and decrypting -tuples of bits. We now show that the parametric iteration construction preserves the structure of Markov categories with probabilistic choice.

Lemma 12.

If 𝒞 is a Markov category with probabilistic choice, then so is PI(𝒞).

Proof.

For 𝔹 we can take 𝔹, and for p we take p. We define discard !A, copy A and case ϕA for PI(𝒞) inductively on objects, with their definition on A being:

[Uncaptioned image] := [Uncaptioned image]   [Uncaptioned image] := [Uncaptioned image]   [Uncaptioned image] := [Uncaptioned image]

The relevant properties can be shown using the diagonal method, with the naturality equations in particular being instances of Newton’s cradle.

4.1 Quantitative Reasoning

The theory developed in the previous section allows for exact reasoning about boolean stochastic maps, enabling us to derive precise equalities between them.

However, in some cases – especially when parametric iteration is involved – we are interested in reasoning about approximate equivalence instead. To do so, we must move to metric-enriched symmetric monoidal categories. We begin by recalling some basic definitions.

Definition 13.

A metric space (A,d) consists of a set A and a distance function d:A×A[0,) such that for all a,b,cA:

d(a,b)=0a=b,d(a,b)=d(b,a),d(a,c)d(a,b)+d(b,c). (2)

A morphism between metric spaces f:(A,dA)(B,dB) is given by a non-expansive function f:AB, that is a function satisfying dB(f(a),f(b))dA(a,b) for all a,bA.

Definition 14.

The category 𝕄 has metric spaces as objects and non-expansive functions as arrows. This is a monoidal category, with defined on objects as the metric space (AB,dAB), where AB is the cartesian product of sets and dAB((a,b),(a,b)):=dA(a,a)+dB(b,b), and on arrows as (fg)(a,c):=(f(a),g(c)), for every f:(A,dA)(B,dB) and g:(C,dC)(D,dD).

Our objects of study in this section are metric enriched monoidal categories, or categories enriched over 𝕄. Unfolding the definition, a metric enriched monoidal category is a category whose homs are metric spaces, such that:

dAC(f;g,f;g)dAB(f,f)+dBC(g,g) (3)

and

dACBD(fg,fg)dAB(f,f)+dCD(g,g). (4)
Lemma 15.

𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁 is a metric enriched symmetric monoidal category.

Proof.

For each set A, we can define a metric 𝗍𝗏A on 𝒟A called the total variation metric (see e.g. [15]). We give two equivalent formulations of 𝗍𝗏A below, for any v,w𝒟A.

𝗍𝗏A(v,w):=asupp(v)supp(w)|v(a)w(a)|2=1asupp(v)supp(w)min(v(a),w(a))

We take as distance between arrows dAB(f,g):=maxaA𝗍𝗏B(f(a),g(a)), for every f,g:AB in 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁. This choice of distance makes 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁 metric enriched (see Example 3.2.7 in [12]).

Just as we approached exact reasoning equationally, we now aim to reason quantitatively in a similar style. To this end, we introduce a proof system that axiomatizes distances between morphisms of metric-enriched Markov categories with probabilistic choice.

f0ff1gfδggδffδggδhfδ+δhfδgδδfδgfδfgδg(fid𝔹g);ϕXδ(fid𝔹g);ϕXfδff;gδf;ggδgf;gδf;gfδffgδfggδgfgδfgfδfgγg(fg);ϕXppδ+(1p)γ(fg);ϕXp (5)

We write fδg to say that f and g, of the same type, are provably at most δ away from each other. Moreover, we say that a proof system is sound if fδg implies d(f,g)δ, and is complete if fd(f,g)g for each pair of morphisms f,g of the same type.

Note that a sound proof system allows one to prove upper bounds to the actual distance between morphisms. As such, certain proofs give better bounds than others, allowing one to improve on a proof of distance by finding different routes. In particular, in order to prove security, one would like to prove that certain distances are below a level of allowed risk ε.

We now show that the proof system above is sound and complete for 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}, equipped with the total variation distance.

This approach varies from the total variation treatment in [17], where the monoidal product combines different cases (disjunctive), whereas in our case the monoidal product combines resources (conjunctive).

Lemma 16.

The proof system in (5) is sound and complete for 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}.

Proof.

See Appendix C.

5 Asymptotic Equivalence

For a metric enriched symmetric monoidal category 𝒞, we can equip PI(𝒞) with a notion of asymptotic equivalence. A nonnegative function f:[0,) approaches zero, written as limkf(k)=0, if for any possible threshold ε(0,) there is some point N after which the function is below ε. Symbolically: ε>0.N>0.kN.f(k)<ε.

From the perspective of cryptography, we consider ε the risk factor we are trying to beat, or the allowable failure rate of our algorithm. Then N>0 is the minimum security parameter to guarantee that the actual probability of failure is below the allowable risk.

The following definition captures indistinguishability between morphisms in PI(𝒞), given that they may be investigated a polynomial number of times by the distinguisher (e.g. adversary), and this distinguisher may choose a polynomial amount of inputs and study each probabilistically generated output.

Definition 17 (Asymptotic Equivalence).

For a metric enriched symmetric monoidal category 𝖢, the asymptotic equivalence relation on morphisms of PI(𝖢) is defined as follows:

fga.limkkad(Sk(f),Sk(g))=0for any f,g:XY in PI(𝖢).
Proposition 18.

is preserved under sequential composition and parallel composition.

Proof.

Suppose ff and gg. Take k, and ε>0, then by assumption on ε/2 there are N and M such that if nN and nM, then respectively nkd(Sn(f),Sn(f))<ε/2 and nkd(Sn(g),Sn(g))<ε/2. Taking K=max(N,M), then for nK we get nkd(Sn(f;g),Sn(f;g))=nkd(Sn(f);Sn(g),Sn(f);Sn(g))nk(d(Sn(f),Sn(f))+d(Sn(g),Sn(g)))=nkd(Sn(f),Sn(f))+nkd(Sn(g),Sn(g))<ε/2+ε/2=ε. The proof for parallel composition is analogous.

We can show that the Newton’s cradle equation from before also holds for asymptotic equivalence. We prove this using a method similar to the diagonal method. As a consequence, asymptotic equivalence is preserved under application of the -iteration operation τ.

Lemma 19 (Newton’s cradle, reprised).

For any f:SZ,g:Z𝐀1𝐁1Z,h:S𝐀1𝐁1S, if   [Uncaptioned image][Uncaptioned image]    then    [Uncaptioned image][Uncaptioned image].

Proof.

Let k, and take S=Sk(S), Z=Sk(Z), 𝐂=Sk(𝐀), 𝐃=Sk(𝐁), fk=Sk(f), gk=Sk(g), and hk=Sk(h). We shall define a[0,1] as:
a:=d([Uncaptioned image],[Uncaptioned image]) and prove that   d([Uncaptioned image],[Uncaptioned image])ka

We prove this, by showing by induction on r that: [Uncaptioned image]ra[Uncaptioned image]

Induction basis:

[Uncaptioned image]=(def)[Uncaptioned image]=(def)[Uncaptioned image]

Induction step:

[Uncaptioned image]=(def)[Uncaptioned image]aa[Uncaptioned image]

ra(hypothesis)ra[Uncaptioned image]=(def)[Uncaptioned image]

together getting an upper bound for the distance of a+ra=(r+1)a, as required.

Taking r=k, we get a distance of ka between the two sides of the equation. Hence, given any b we get
limkkbd([Uncaptioned image],[Uncaptioned image])=limkkb+1d([Uncaptioned image],[Uncaptioned image])=0

5.1 Examples

Asymptotic equivalence is used to reason whether it is possible to increase the security parameter to significantly minimize the risk of two programs being distinguished. This allows us to formally ignore undesirable situations if their probability of occurring is asymptotically insignificant, or in other words: negligible. Our first example shows that a randomly generated key of length σ is unlikely to be any specific key. This has three useful consequences:

  1. 1.

    Two randomly generated keys of length σ are not equal (asymptotically).

  2. 2.

    If an adversary attempts to guess a key before that key is generated (or without any knowledge of the generated key), then this guess is wrong (asymptotically).

  3. 3.

    We can uniformly generate an element of 2σ1 (asymptotically),

We first define all-1:𝔹𝔹 which checks if all elements of 𝔹 are equal to 1. Given an and-gate &:𝔹2𝔹, we define all-1:=(1id𝔹);τ𝔹,(𝔹),()(&).

Lemma 20.

If p<1, then [Uncaptioned image][Uncaptioned image].

Proof.

By induction on k, we can prove that the two diagrams as seen through Sk in the Lemma statement are at most pk apart in the underlying metric-enriched category (to cover an edge-case we use 00=1). Given that p<1, we have that for any a, limkkapk=0. First, observe that by (3) and (3), [Uncaptioned image]=[Uncaptioned image].

For k=0, the required distance 1 is trivially true, i.e. [Uncaptioned image]1[Uncaptioned image].

For k=k+1, we do the following steps.

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]ppk+(1p)0[Uncaptioned image]=[Uncaptioned image]

In other words, no randomly generated key with weighted choice below 1 consists of only ones. Note in particular that this is the case even if the key is used in some other context. We define equality on bits using a negated xor gate (=):𝔹2𝔹. Then equality on -tuples (=):𝔹𝔹𝔹 is done by iterating the equality and checking that all entries are one.

Lemma 21.

[Uncaptioned image][Uncaptioned image].

Proof.

First, we merge the two iterations into one using (3) and (3). Then we can reorder 1/2 and (=) operations in such a way that they still give the same probabilistic stochastic map. Thirdly, we can separate the iteration into two iterations, and apply Lemma 20 to the first iteration. Lastly, merge the two remaining iterations again and note that equality to a random bit gives a random bit (similar to what we observed with xor before).

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image][Uncaptioned image]=[Uncaptioned image]

We consider one final example, the iterated von Neumann’s trick. This is a method for simulating a fair coin flip using a biased coin that lands on heads with probability p(0,1). The method involves flipping the biased coin twice and selecting the first outcome if both flips match; otherwise, the process is repeated. When a form of parametric iteration is available, the trick can be formalised as Example 11 in [24]. Here we give a categorical and diagrammatic representation as the diagram in the lemma.

Lemma 22.

[Uncaptioned image][Uncaptioned image].

Proof.

The equation above states that the process of flipping a bit with probability p a total of k-times converges to a fair coin flip as k increases. We prove this by showing that for a constant number k of iterations, the two diagrams are (2p1)k away if p1/2, and (12p)k away if p1/2. In both cases, the distance approaches zero exponentially.

We shall look at the case in which p1/2, the other case goes similarly. We prove the result by induction on k, as follows. The base case holds since everything is 1 away from everything else, which satisfies the condition. For the inductive step, let k=k+1 and observe that the following holds true, where we take q=2p1 and h=qk the distance from the induction hypothesis. We write n:𝔹𝔹 for the not gate, then:

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]

=[Uncaptioned image]qqk+(1q)0induction hypothesisqqk+(1q)0[Uncaptioned image]=[Uncaptioned image]

6 Conclusions and Future Work

This work is a step towards an algebraic approach to cryptographic proofs completely parametric in security parameters. Such proofs normally entail showing that all protocols have polynomial time complexity with respect to the parameters, and require intricate probabilistic calculations. Binding the parameter helps avoid unsound proof pitfalls, such as accidentally using asymptotic rewriting while performing induction over number of iterations.

In order to incorporate further cryptographic protocols however, we need two further extensions. First, we need to allow for cryptographic primitives, which should be given as families of operations in 𝒞 indexed over the security parameter, with accompanying assumptions regarding distances. This should be possible by extending 𝒞 accordingly, and deriving further equations once one takes the parametric iteration over 𝒞.

The second extension entails dealing with operations like pseudorandom number generators, as e.g. used in stream ciphers. In the current framework, we cannot generate more randomness from less. Concretely, we theoretically cannot have a morphism f:𝔹𝔹𝔹 such that τ(12);fτ(12)12. The solution to this problem is to define a coarser relation, that of contextual equivalence relative to contexts of morphisms which can only investigate a finite amount of data, meaning whose input and output are constant (from 𝒞). Our notion of asymptotic equivalence is (trivially) sound with respect to this notion of contextual equivalence, though further investigation of this relation is for future research.

On the topic of probabilistic computations, we use the fact that all our computations are total, which is reflected in the naturality property of our if-gate operation. Extending to partial probabilistic computations, we should generalize to partial Markov categories with a condition/equality operation. Our if-gate as well as the discard operation will only be natural over all total computations (those not involving conditioning). In order to more accurately model an if-statement as might be used in a programming language, we should either introduce a more structured functorial if operation, or move towards distributive monoidal categories and their associated languages of tape/sheet diagrams [1, 7].

References

  • [1] Filippo Bonchi, Cipriano Junior Cioffo, Alessandro Di Giorgio, and Elena Di Lavore. Tape Diagrams for Monoidal Monads. In Corina Cîrstea and Alexander Knapp, editors, 11th Conference on Algebra and Coalgebra in Computer Science (CALCO 2025), volume 342 of Leibniz International Proceedings in Informatics (LIPIcs), pages 11:1–11:24, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.CALCO.2025.11.
  • [2] Anne Broadbent and Martti Karvonen. Categorical composable cryptography: extended version. Logical Methods in Computer Science, Volume 19, Issue 4, December 2023. doi:10.46298/lmcs-19(4:30)2023.
  • [3] Ran Canetti. Universally composable security: A new paradigm for cryptographic protocols. In Proceedings 42nd IEEE Symposium on Foundations of Computer Science, pages 136–145. IEEE, 2001. doi:10.1109/SFCS.2001.959888.
  • [4] Titouan Carette, Dominic Horsman, and Simon Perdrix. Szx-calculus: Scalable graphical quantum reasoning. In MFCS 2019-44th International Symposium on Mathematical Foundations of Computer Science, volume 138, pages 55–1, 2019.
  • [5] Apiwat Chantawibul and Pawel Sobocinski. Monoidal multiplexing. In B. Fischer and T. Uustalu, editors, Theoretical Aspects of Computing ? ICTAC 2018, volume 11187, pages 116–131. Springer, October 2018. doi:10.1007/978-3-030-02508-3_7.
  • [6] Bob Coecke, Tobias Fritz, and Robert W Spekkens. A mathematical theory of resources. Information and Computation, 250:59–86, 2016. doi:10.1016/J.IC.2016.02.008.
  • [7] Cole Comfort, Antonin Delpeuch, and Jules Hedges. Sheet diagrams for bimonoidal categories. arXiv preprint arXiv:2010.13361, 2020.
  • [8] Ugo Dal Lago, Furio Honsell, Marina Lenisa, and Paolo Pistone. On Quantitative Algebraic Higher-Order Theories. In Amy P. Felty, editor, 7th International Conference on Formal Structures for Computation and Deduction (FSCD 2022), volume 228 of Leibniz International Proceedings in Informatics (LIPIcs), pages 4:1–4:18, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.FSCD.2022.4.
  • [9] Elena Di Lavore, Giovanni de Felice, and Mario Román. Monoidal streams for dataflow programming. In Proceedings of the 37th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS ’22, New York, NY, USA, 2022. Association for Computing Machinery. doi:10.1145/3531130.3533365.
  • [10] Tobias Fritz. A synthetic approach to Markov kernels, conditional independence and theorems on sufficient statistics. Advances in Mathematics, 370:107239, 2020. arXiv:1908.07021.
  • [11] Steven Holtzen, Guy Van den Broeck, and Todd Millstein. Scaling exact inference for discrete probabilistic programs. Proceedings of the ACM on Programming Languages, 4(OOPSLA):1–31, 2020. doi:10.1145/3428208.
  • [12] Nicholas Gauguin Houghton-Larsen. A mathematical framework for causally structured dilations and its relation to quantum self-testing. arXiv preprint arXiv:2103.02302, 2021. arXiv:2103.02302.
  • [13] André Joyal and Ross Street. The geometry of tensor calculus, I. Advances in Mathematics, 88(1):55–112, July 1991. doi:10.1016/0001-8708(91)90003-P.
  • [14] Jonathan Katz and Yehuda Lindell. Introduction to Modern Cryptography, Second Edition. Chapman & Hall/CRC, 2nd edition, 2014.
  • [15] A.N. Kolmogorov and S.V. Fomin. Introductory Real Analysis. Selected Russian publications in the mathematical sciences. Prentice-Hall, 1970. URL: https://books.google.nl/books?id=9l4PAQAAMAAJ.
  • [16] Ugo Dal Lago, Zeinab Galal, and Giulia Giusti. On computational indistinguishability and logical relations. In Programming Languages and Systems: 22nd Asian Symposium, APLAS 2024, Kyoto, Japan, October 22-24, 2024, Proceedings, pages 241–263, Berlin, Heidelberg, 2024. Springer-Verlag. doi:10.1007/978-981-97-8943-6_12.
  • [17] Gabriele Lobbia, Wojciech Różowski, Ralph Sarkis, and Fabio Zanasi. Quantitative Monoidal Algebra: Axiomatising Distance with String Diagrams. In Paweł Gawrychowski, Filip Mazowiecki, and Michał Skrzypczak, editors, 50th International Symposium on Mathematical Foundations of Computer Science (MFCS 2025), volume 345 of Leibniz International Proceedings in Informatics (LIPIcs), pages 68:1–68:21, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.MFCS.2025.68.
  • [18] Saunders Mac Lane. Categories for the Working Mathematician. Springer, 1998.
  • [19] Ueli Maurer. Constructive cryptography–a new paradigm for security definitions and proofs. In Joint Workshop on Theory of Security and Applications, pages 33–56. Springer, 2011. doi:10.1007/978-3-642-27375-9_3.
  • [20] Ueli Maurer and Renato Renner. Abstract cryptography. In Bernard Chazelle, editor, Innovations in Computer Science - ICS 2011, Tsinghua University, Beijing, China, January 7-9, 2011. Proceedings, pages 1–21. Tsinghua University Press, 2011. URL: http://conference.iiis.tsinghua.edu.cn/ICS2011/content/papers/14.html.
  • [21] Robin Piedeleu, Mateo Torres-Ruiz, Alexandra Silva, and Fabio Zanasi. A complete axiomatisation of equivalence for discrete probabilistic programming. In Programming Languages and Systems: 34th European Symposium on Programming, ESOP 2025, Held as Part of the International Joint Conferences on Theory and Practice of Software, ETAPS 2025, Hamilton, ON, Canada, May 3–8, 2025, Proceedings, Part II, pages 202–229, Berlin, Heidelberg, 2025. Springer-Verlag. doi:10.1007/978-3-031-91121-7_9.
  • [22] Robin Piedeleu and Fabio Zanasi. An Introduction to String Diagrams for Computer Scientists. Elements in Applied Category Theory. Cambridge University Press, 2025.
  • [23] P. Selinger. A Survey of Graphical Languages for Monoidal Categories, volume 813 of Lecture Notes in Physics, pages 289–355. Springer, Berlin, Heidelberg, 2010. doi:10.1007/978-3-642-12821-9_4.
  • [24] Mateo Torres-Ruiz, Robin Piedeleu, Alexandra Silva, and Fabio Zanasi. On iteration in discrete probabilistic programming. In 9th International Conference on Formal Structures for Computation and Deduction (FSCD 2024), volume 299 of Leibniz International Proceedings in Informatics (LIPIcs), pages 20:1–20:21. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPIcs.FSCD.2024.20.

Appendix A Appendix to Section 3

Extended proof of Lemma 4.

We prove each property using the diagonalisation method, instantiating the top level iterations by k. We prove the relevant equation by induction on k. The base case is relatively simple. We prove the induction steps below, unfolding once, then using the induction hypothesis, and finishing with an optional refolding.

Induction step for (3):

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]

Induction step for (3):

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]

Induction step for (3) is proved in Section 3.

Induction step for (3):

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]

Appendix B A Complete Equational Theory of Boolean Stochastic Maps

The structure of Markov categories with probabilistic choice, introduced in Section 4, is novel. Thus, it is interesting to study whether the axioms are complete with respect to the category 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}. Here, completeness means that any equality between Boolean stochastic maps in 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} can also be derived syntactically using the axioms listed in Figure 1.

In order to formally state completeness, we introduce the syntactic category 𝖯𝖡𝖢𝗂𝗋𝖼 of probabilistic boolean circuits. This is the symmetric monoidal category of string diagrams freely generated by the single-sorted signature (𝔹,Σ), where Σ:={[Uncaptioned image],[Uncaptioned image],[Uncaptioned image],[Uncaptioned image]} and such that the morphisms are quotiented by the axioms in Figure 1.

Diagrams in 𝖯𝖡𝖢𝗂𝗋𝖼 take semantics in 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} via the interpretation functor : 𝖯𝖡𝖢𝗂𝗋𝖼𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}, defined inductively as follows:

𝔹:={1,0}[Uncaptioned image]:=!{1,0}[Uncaptioned image]:={1,0}[Uncaptioned image]:=ϕ{1,0}[Uncaptioned image]:=p

Then we say that the equational theory of 𝖯𝖡𝖢𝗂𝗋𝖼 is complete for 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} if, for any two diagrams c,d𝖯𝖡𝖢𝗂𝗋𝖼 of the same type, if c=d then their equality can be derived using the axioms in Figure 1. We rephrase Theorem 11.

Theorem 23.

The equational theory of 𝖯𝖡𝖢𝗂𝗋𝖼 is complete for 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0}.

Proof.

The proof shows that each element of 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} has a unique normal form representation as a diagram in 𝖯𝖡𝖢𝗂𝗋𝖼, and each diagram in 𝖯𝖡𝖢𝗂𝗋𝖼 is provably equal to a diagram in normal form.

We first equip each set 𝔹n with a linear order. We then say that a formal sum p1x1++pmxm over 𝔹n is in normal form if all pi>0 and the list x1,,xm forms a sorted list of elements without repetition. As such, a formal sum in normal form is either of the form 1x, or px+(1p)s with p(0,1), and s a formal sum in normal form, containing values x all higher than x according to the chosen order. Importantly, each distribution has a unique normal formal sum representation.

A weighted probabilistic tree over 𝔹n is a diagram I𝔹n inductively defined as:

t,r:=b1bn(tr);ϕ𝔹np

where each bi{0,1}. We represent a normal formal sum as a weighted probabilistic tree, by representing 1(b1,,bn) as b1bn, and p(b1,,bn)+(1p)s as (b1bnt);ϕ𝔹np, where t is the representation of the normal formal sum s. It can be shown that any weighted probabilistic tree over 𝔹n is equal to the tree representation of a normal formal sum. This is done by using axioms (1), (1) and (1) to get rid of zero-probability branches, sorting the order, and re-associating branches, as well as determinism of 1, 0 combined with (1) to combine branches with the same result.

The normal forms of type 𝔹0𝔹n are the tree representations of normal formal sums, which are unique for each distribution. We generalize to arbitrary 𝔹k𝔹n by doing a case distinction on inputs, where a normal form of type 𝔹k+1𝔹n is of the form: (𝔹kid𝔹);(id𝔹kχ𝔹k,𝔹);(f1id𝔹f0);ϕ𝔹n, where f1 and f0 are normal forms of morphisms of type 𝔹k𝔹n. Each morphism f:𝔹k𝔹n of 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} has a unique normal form of this kind, with f:𝔹0𝔹n represented by the tree representation of the normal formal sum for the distribution given by f(), and f:𝔹k+1𝔹n represented by taking f1 and f0 to be the normal form of the functions (b1,,bk)f(b1,,bk,1) and (b1,,bk)f(b1,,bk,0) respectively. This normal form is unique, as this specification is necessitated by the functor.

See below examples of normal forms, with a normal form of a morphism of type 𝔹0𝔹3 on the left in the form of a sorted weighted tree (using lexicographic ordering on 𝔹3), and a normal form of a morphism of type 𝔹3𝔹k with a weighted tree at each t (some liberties were taken regarding the order of swaps and copies).

[Uncaptioned image]     [Uncaptioned image]

We prove that each diagram is equivalent to one in normal form.

  • First we show that the identity diagrams id𝔹n:𝔹n𝔹n can be put in normal form. This can be shown by using the equations (1) and (1) together with monoidal coherence and naturality of ϕ, given in equations (1), (1), and (1).

  • Second, note that each morphism in a freely generated monoidal category can be described as a composition of morphisms of the form (idAsidB), with s a generator, which in our case is of {χ}Σ={χ,,!,p,ϕ}. Then show that f;(idAsidB) can be reduced to a normal form, given that f is in normal form. This is done in three steps:

    1. 1.

      Pull (idAsidB) through each ϕ using naturality (1), both the if-gates used to distinguish between different inputs, as well as the if-gates used in the weighted probabilistic trees, until we get to leaves of the trees.

    2. 2.

      Reduce each (b1bn);(idAsidB) to a weighted probabilistic tree.

    3. 3.

      The result is f, but with different weighted probabilistic trees at each case in its case distinction. Put all those trees into normal form.

Hence we can normalize each f:𝔹k𝔹n by first giving it a specification as composition of (idAsidB) morphisms. Then normalize the identity function on 𝔹k and inductively normalize by composing with each additional layer.

Lemma 24.

𝖯𝖡𝖢𝗂𝗋𝖼 is a metric enriched symmetric monoidal category.

Proof of Lemma 24.

We take as distance between arrows

d𝔹n𝔹m(c,d):=d{1,0}n{1,0}m(c,d)

for every c,d:𝔹n𝔹m in 𝖯𝖡𝖢𝗂𝗋𝖼.

First, we verify that d𝔹n𝔹m is indeed a distance – that is, it satisfies the conditions in (2). Most properties are straightforward to check; the only non-trivial one is d𝔹n𝔹m(c,d)=0c=d, which we prove below:

d𝔹n𝔹m(c,d)=0 d{1,0}n{1,0}m(c,d)=0 (Definition of d𝔹n𝔹m)
c=d (Lemma 15)
c=d (Theorem 11)

To conclude that 𝖯𝖡𝖢𝗂𝗋𝖼 is metric enriched, we need to verify also that ; and are non-expansive, that is (3) and (4). We prove (3) below, the proof for the other is analogous.

d𝔹n𝔹m(c;d,c;d) =d{1,0}n{1,0}m(c;d,c;d) (Definition of d𝔹n𝔹m)
=d{1,0}n{1,0}m(c;d,c;d) ( is a functor)
d{1,0}n{1,0}l(c,c)+d{1,0}l{1,0}m(d,d) ((3))
=d𝔹n𝔹l(c,c)+d𝔹l𝔹m(d,d) (Definition of d𝔹n𝔹m)

Appendix C Additional Proofs for Section 4

Proof of Lemma 10.

(2) is proven by using (1) and (1).

Now to prove (2): [Uncaptioned image]

First we apply axiom (1), (1), and (1) to each of the incoming wires, and combining those with monoidal coherence (1). Then we pull the main morphism through the ϕ-gate using naturality. As a third step, we use determinism of 1 and 0, as well as (1) and (2). Lastly, we use naturality of the discard operation to get the right result.

[Uncaptioned image]

Lastly, proving (2): [Uncaptioned image]

For simplicity, we define: [Uncaptioned image], and swap the first two wires of (2). We then prove as follows, starting with the equations (1), (1), and (1), then use (1), and finally simplifying using equations (1) and (2):

[Uncaptioned image]

Extended proof of Lemma 12.

We define copy, discard and if-gate on objects as done in Section 4. We then show that in 𝒞, τ1,(A),(A,A)k(A)=Ak, τ1,(A),()k(!A)=!Ak, and

[Uncaptioned image]=[Uncaptioned image]

Consequently, by induction on A in PI(𝒞), we then reason that with the chosen definition, Sk(A)=Sk(A), Sk(!A)=!Sk(A), and Sk(ϕA)=ϕSk(A). This allows us to lift the equations for Markov categories and probabilistic choice to PI(𝒞) via Sk.

We prove the relevant property for ϕ stated above by induction on k. The induction basis is simple. The induction step goes as follows:

[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]=[Uncaptioned image]

Using the above property, we can show by induction on objects A that Sk(ϕA)=ϕSk(A). This allows us to prove the relevant equations by lifting them from 𝒞.

Proof of Lemma 16.

For soundness we proceed by induction on the rules in (5). Observe that the laws which do not involve the probabilistic choice are trivially verified from the fact that 𝖥𝗂𝗇𝖲𝗍𝗈𝖼𝗁{1,0} is metric-enriched.

For the top rightmost rule, given maps c,c:{1,0}n{1,0}m and d,d:{1,0}l{1,0}m such that cδc and dδd, by inductive hypothesis we have that d{1,0}n{1,0}m(c,c)δ and d{1,0}l{1,0}m(d,d)δ. Now let h=(cid𝔹d);ϕ{1,0}m and h=(cid𝔹d);ϕ{1,0}m and observe that for any a{1,0}n,b{1,0}l, we have the following cases:

h(a,0,b)=(c!{1,0}l)(a,b)=c(a)h(a,0,b)=(c!{1,0}l)(a,b)=c(a)h(a,1,b)=(!{1,0}nd)(a,b)=d(b)h(a,1,b)=(!{1,0}nd)(a,b)=d(b)

Thus, d{1,0}m(h(a,0,b),h(a,0,b))=d{1,0}m(c(a),c(a))δ and d{1,0}m(h(a,1,b),h(a,1,b)) =d{1,0}m(d(b),d(b))δ.

To conclude we have that

d{1,0}n+1+l{1,0}m(h,h) =max(a,i,b){1,0}n+i+l𝗍𝗏{1,0}m(h(a,i,b),h(a,i,b))
max(a,i,b){1,0}n+i+lδ=δ.

For the bottom rightmost rule, given maps c,c:{1,0}n{1,0}m and d,d:{1,0}l{1,0}m such that cδc and dδd, by inductive hypothesis: d{1,0}n{1,0}m(c,c)δ and d{1,0}l{1,0}m(d,d)γ. Now let h=(cd);ϕ{1,0}mp and h=(cd);ϕ{1,0}mp and observe that for any a{1,0}n,b{1,0}l, we have that

h(a,b)=pc(a)+(1p)d(b)h(a,b)=pc(a)+(1p)d(b)

and thus,

d{1,0}n+l{1,0}m(h,h)=max(a,b){1,0}n+l𝗍𝗏{1,0}m(h(a,b),h(a,b))
= max(a,b){1,0}n+lx|h(a,b)(x)h(a,b)(x)|2
= max(a,b){1,0}n+lx|p(c(a)(x)c(a)(x))+(1p)(d(b)(x)d(b)(x))|2
pmaxa{1,0}nx|c(a)(x)c(a)(x)|2+(1p)maxb{1,0}lx|d(b)(x)d(b)(x)|2
= pd{1,0}n{1,0}m(c,c)+(1p)d{1,0}l{1,0}m(d,d)pδ+(1p)γ.

For completeness, we rely on the normal form Theorem 11 and use the rules from (5). For morphisms f,g:nm in normal form, we prove fd(f,g)g by induction on n and m.

  • Base case: n=m=0, then both morphisms are idI. So f0g and d(f,g)=0.

  • Suppose n=0 and m=m+1. Then f=(1f10f0);ϕp and g=(1g10g0);ϕq. Now, d(f,g)=min(p,q)d(f1,g1)+min(1p,1q)d(f0,g0)+(1min(p,q)min(1p,1q)), since d(ifi,igi)=d(fi,gi), and d(ifi,1igi1)=1.

    Assume w.l.o.g. that pq, so min(p,q)=p and min(1p,1q)=1q, and d(f,g)=pd(f1,g1)+(1q)d(f0,g0)+(qp). Define k=qp1p. We can then prove that f=(0f00f0);(1f1ϕk);ϕp using (1), (2), and g=(1g10g0);(1g1ϕk);ϕp using the same rules and (1). By induction hypothesis, 1f1d(f1,g1)1g1 and 0f0d(f0,g0)0g0, and trivially 0f011g1. Applying the second quantitative ϕ-rule twice, we get that fαg for: α=pd(f1,g1)+(1p)(k1+(1k)d(f0,g0))=pd(f1,g1)+(pq)+(1q)d(f0,g0).

  • Suppose n=k+1. Then f=(𝔹kid𝔹);(id𝔹kχ𝔹,𝔹k);(f1id𝔹f0);ϕ𝔹m and g=(𝔹kid𝔹);(id𝔹kχ𝔹,𝔹k);(g1id𝔹g0);ϕ𝔹m. Note that

    d(f,g) =max(x,i){1,0}n(d(f(x,i),g(x,i)))=max(x,i){1,0}n(d(fi(x),gi(x)))
    =max(maxx{1,0}k(d(f1(x),g1(x))),maxx{1,0}k(d(f0(x),g0(x))))
    =max(d(f1,g1),d(f0,g0)).

    By induction hypothesis, f1d(f1,g1)g1 and f0d(f0,g0)g0. So since d(fi,gi)d(f,g) as proven above, f1d(f,g)g1 and f0d(f,g)g0. Applying the first quantitative ϕ-rule, we get: (f1id𝔹f0);ϕ𝔹kd(f,g)(g1id𝔹g0);ϕ𝔹k, so with compositionality, fd(f,g)g as required.