scieee AI-readable full text Open interactive document viewer

Topological models of concurrency

Lopes, Rodrigo Marques

Abstract

Concurrency theory is the domain of theoretical computer science that deals with systems of simultane ously executing processes. Concurrent systems can be modeled mathematically in many different ways. It turned out relatively recently that directed algebraic topology can be used as a framework for concurrency theory. This dissertation studies the principal topological models of concurrency, namely partially ordered spaces, d-spaces and precubical sets. These models are used to provide semantics for a class of concur rent programs, called simple concurrent PV-programs. Additionally, we propose and implement several algorithms that calculate the mentioned semantics and address doomed and unreachable states/regions.

Full text

Rodrigo Marques Lopes Topological Models of Concurrency January 2024 UMinho | 2024 Rodrigo Lopes Topological Models of Concurrency Universidade do Minho Escola de Ciências University of Minho School of Sciences Rodrigo Marques Lopes Topological Models of Concurrency Master’s Dissertation Master’s Degree in Mathematics and Computation Dissertation supervised by Thomas Walter Kahl January 2024 Copyright and Terms of Use for Third Party Work This dissertation reports on academic work that can be used by third parties as long as the internationally accepted standards and good practices are respected concerning copyright and related rights. This work can thereafter be used under the terms established in the license below. Readers needing authorization conditions not provided for in the indicated licensing should contact the author through the RepositóriUM of the University of Minho. License granted to users of this work: CC BY-NC-ND https://creativecommons.org/licenses/by-nc-nd/4.0/ i Acknowledgements My academic journey was a gratifying experience, that has changed me for the better, enabled by all the professors I had along the years that made me appreciate and enjoy mathematics, not only in courses but in general with CMAT junior and other initiatives, and they are the reason I have reached this point. This dissertation was educational, challenging and enjoyable, that wouldn’t be possible without my supervisor Thomas Kahl, without his patience, availability, good nature and help. For this I will be forever grateful. To my family, and especially my parents, for always supporting your eccentric son/relative. To my friends for making university a blast, putting up with me, being there for me and overall just making me happy. This dissertation was financed by a research fellowship (23/ECUM/CMAT-UIDB/00013/2020 [Project BI2022-H]) attributed and funded by the Centre of Mathematics, School of Science, University of Minho and the Portuguese Foundation for Science and Technology. ii Statement of Integrity I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledged the Code of Ethical Conduct of the University of Minho. iii Abstract Concurrency theory is the domain of theoretical computer science that deals with systems of simultaneously executing processes. Concurrent systems can be modeled mathematically in many different ways. It turned out relatively recently that directed algebraic topology can be used as a framework for concurrency theory. This dissertation studies the principal topological models of concurrency, namely partially ordered spaces, d-spaces and precubical sets. These models are used to provide semantics for a class of concurrent programs, called simple concurrent PV-programs. Additionally, we propose and implement several algorithms that calculate the mentioned semantics and address doomed and unreachable states/regions. Keywords concurrency, directed algebraic topology, partially ordered space, d-space, precubical set, PV-program iv Resumo A teoria da concorrência é o domínio da ciência da computação teórica que estuda sistemas de processos em execução simultânea. Os sistemas concorrentes podem ser modelados matematicamente de muitas formas diferentes. Descobriu-se, há relativamente pouco tempo, que a topologia algébrica dirigida pode ser usada como uma framework para a teoria da concorrência. Esta dissertação estuda os principais modelos topológicos de concorrência, nomeadamente espaços parcialmente ordenados, d-espaços e conjuntos pré-cúbicos. Estes modelos são usados para dar semântica a uma classe de programas concorrentes, chamados programas PV simples. Adicionalmente, propomos e implementamos vários algoritmos que calculam as semânticas mencionadas e abordam estados/regiões doomed e unreachable . Palavras-chave concorrência, topologia algébrica dirigida, espaço parcialmente ordenado, d-espaço, conjunto pré-cúbico, programa PV v Contents 1 Introduction 2 2 Directed topology 4 2.1 Partially ordered spaces .................................. 4 2.2 D-spaces .......................................... 7 2.3 Precubical sets ....................................... 11 3 Concurrency 23 3.1 PV-programs ........................................ 23 3.2 Graph semantics ...................................... 24 3.3 Precubical semantics .................................... 27 3.4 Euclidean pospace semantics ............................... 28 4 Topology of precubical sets 33 5 Algorithms 43 Appendix 53 1 Examples 2.5. 1. Any topological space Xcan be turned into a d-space by considering the discrete d-structure, where dX consists only of the constant paths in X. Another d-structure every topological space Xcan be equipped with is the chaotic one, where dX has all the paths in X. 2. We will view a pospace Xas a d-space, with d X the set of dipaths −→ I→X. In particular, a Euclidean pospace Xis a d-space, where the d-paths are the componentwise weakly increasing paths. A discrete pospace is a d-space with the discrete d-structure. 3. A d-space not coming from a pospace is the directed circle −→ S1, where the d-paths are the counterclockwise oriented paths: α Morphims Let Xand Ybe d-spaces. A d-map f:X→Yis a continuous map such that ∀α∈d X ,f◦α∈dY . The category of d-spaces, denoted as dTop, has as objects the d-spaces and the arrows are d-maps. Proposition 2.6. Let X and Y be pospaces, and suppose f:X→Y is a monotone continuous map. Then f is d-map. Proof. Let ω∈d X , i.e. ω:−→ I→Xis a monotone continuous map. Then f◦ω:−→ I→X→Yis a monotone continuous map, so f◦ω∈dY . Therefore fis a d-map. Products The Cartesian product X×Yis a d-space, with d(X×Y)the set of paths ω:I→X×Ysuch that prX◦ω∈dX and prY◦ω∈dY . Note that prXand prYare d-maps by definition. 8 Dipaths A directed path or dipath in a d-space Xis a d-map −−−→ [0,a]→X. Proposition 2.7. The concatenation of two dipaths α:−−−→ [0,a]→X and β:−−−→ [0,b]→X with α(a)=β(0) , defined as for dipaths in pospaces, is a dipath. Proof. Let φ∈d−−−−−−→ [0,a+b]. Suppose first that φ(1) ≤a. Consider the d-path ψ∈d−−−→ [0,a]defined by ψ(t)=φ(t). Then (α•β)◦φ=α◦ψ∈dX . Suppose now that φ(0) ≥a. Let ψ∈d−−−→ [0,b]be defined by ψ(t)=φ(t)−a. Then (α•β)◦φ=β◦ψ∈dX . Suppose finally that φ(0) <aand φ(1) >a. Since φis continuous, we may choose a point 0<c<1such that φ(c)=a. Consider the increasing homeomorphism η:I→Igiven by η(t)=       2tc,t≤1 2, (2t−1)(1 −c)+c,t≥1 2, and define σ∈d−−−→ [0,a]and ρ∈−−−→ [0,b]by σ(t)=φ(η(t 2)) =φ(tc) and ρ(t)=φ(η(t+1 2)) −a=φ(t(1 −c)+c)−a. We have (α•β)◦φ◦η(t)=       α•β(φ(2tc)), t≤1 2, α•β(φ((2t−1)(1 −c)+c)), t≥1 2 =       α(φ(2tc)), t≤1 2, β(φ((2t−1)(1 −c)+c)−a), t≥1 2 =       α(σ(2t)), t≤1 2, β(ρ(2t−1)), t≥1 2 =(α◦σ)·(β◦ρ)(t). Thus, (α•β)◦φ◦η=(α◦σ)·(β◦ρ)∈d X . Hence also (α•β)◦φ=(α•β)◦φ◦η◦η−1∈d X . 9 Observation 2.8. Let Xbe a pospace. Then a continuous map α:−−−→ [0,k]→Xis a dipath of pospaces if and only if it is a dipath of d-spaces. Indeed, if αis a dipath of pospaces, it is dipath of d-spaces. If, conversely, αis a dipath of d-spaces, the composite −→ Iβ −→ −−−→ [0,k]α −→ X, where βis defined by β(t)=kt, is a d-map. Hence α◦β∈dX . Thus αis monotone and therefore a dipath of pospaces. Dihomotopy Let Xbe a d-space, and let α,β:−−−→ [0,a]→Xbe two dipaths in Xsuch that α(0) =β(0) and α(a)=β(a). Consider the unit interval Iwith the discrete d-structure. A dihomotopy between α and βis a d-map H:−−−→ [0,a]×I→Xsuch that H(s,0) =α(s)and H(s,1) =β(s)for all s∈[0,a] and H(0,t)=α(0) =β(0) and H(a,t)=α(a)=β(a)for all t∈I. Note that a continuous map H:−−−→ [0,a]×I→Xis a d-map if and only if, for every t∈I, the map Ht:−−−→ [0,a]→X,s7→ H(s,t) is a dipath. We say that αand βare dihomotopic if there exists a dihomotopy between them. Adapting the arguments of the previous section, one shows that dihomotopy is an equivalence relation that is compatible with concatenation and that d-maps preserve dihomotopy. The functor D:Pospace →dTop We denote by Dthe functor that sends a pospace Xto the d-space X, where dX is the set of monotone continuous maps ω:~ I→X, and a monotone continuous map f:X→Yto the d-map f:X→Y, see 2.6. Theorem 2.9. The functor D preserves products and dihomotopy. Proof. Let X,Ybe pospaces. The d-space associated with the pospace X×Yis the product of the d-spaces Xand Y. Indeed, a continuous map ω:I→X×Yis monotone if and only if prX◦ωand prY◦ωare monotone continuous map. Let α,β:−−−→ [0,a]→Xbe dihomotopic dipaths, so there exists a dihomotopy H:−−−→ [0,a]×I→Xbetween αand β. Since the d-space associated with the pospace −−−→ [0,a]×Iis the product of the d-space −−−→ [0,a] and the unit interval with the discrete d-structure, His a dihomotopy between the dipaths αand βin the d-space X. 10 2.3 Precubical sets A precubical set is a family of sets P=(Pn)n≥0with face maps dα i:Pn→Pn−1(n>0,α=0,1,i=1,...,n) satisfying the relations dα i◦dβ j=dβ j−1◦dα i for 1≤i≤j≤nand α,β∈{0,1}, see, e.g., [3]. The elements of Pnare called the n-cubes of P. The elements of degree 0and 1are also called the vertices and edges of P, respectively. Additionally, given x∈Pk, we say that d0 i(x)and d1 i(x)are the back face and front face of xin the ith direction, respectively. An edge xof a precubical set will be considered directed from d0 1(x)to d1 1(x): d0 1(x)xd1 1(x) Hence the vertices and edges of a precubical set form a directed graph. The face relations guarantee that the faces of a cube intersect as expected: x d0 1d0 1(x)=d0 1d0 2(x) d1 1d0 1(x)=d0 1d1 2(x) d1 1d0 2(x)=d0 1d1 1(x) d1 1d1 2(x)=d1 1d1 1(x) d0 1(x) d0 2(x) d1 1(x) d1 2(x) Examples 2.10. 1. Let v,w∈N0,v≤w. The precubical interval v,wis the precubical set defined by v,w0={v,..., w}; v,w1={[i,i+1] |i∈{v,..., w−1}}; v,wj= ;,j>1 with d0 1([i,i+1]) =iand d1 1([i,i+1]) =i+1. 11 vv+1... [v,v+1] [w−1,w] w−1w Note that in the case where v=w,v,v0={v}and v,vj= ; for j≥1. 2. The directed circle is the precubical set −→ S1, where −→ S1 0={v},−→ S1 1={a},−→ S1 i= ; for i≥2, and d0 1(a)=d1 1(a)=v. v a 3. The ordered circle is the precubical set −→ O1, where −→ O1 0={v,w},−→ O1 1={a,b},−→ O1 i= ; for i≥2, d0 1(a)=d0 1(b)=v, and d1 1(a)=d1 1(b)=w. ab v w 4. Lastly, consider the directed torus −→ T, where −→ T0={v},−→ T1={a,b},−→ T2={x},−→ T1 i= ; for i≥3, d0 1(a)=d0 1(b)=d1 1(a)=d1 1(b)=v,d0 1(x)=d1 1(x)=band d0 2(x)=d1 2(x)=a. v x ab Morphisms A morphism f:P→Qbetween a precubical set Pand a precubical set Qis a family (fn:Pn→Qn)n∈N0 of functions such that dα i◦fn=fn−1◦dα i 12 for 1≤i≤nand α∈{0,1}. The category of precubical sets, denoted as Precub, has as objects the precubical sets and the arrows are the morphism between precubical sets. Tensor product Let Pand Qbe two precubical sets. The tensor product P⊗Qis the precubical set defined by (P⊗Q)n=a p+q=n Pp×Qq and, for (x,y)∈Pp×Qq, dα i(x,y)=   (dα i(x), y), 1 ≤i≤p, (x,dα i−p(y)), p+1≤i≤p+q. It is not hard to see that the tensor product of precubical sets is indeed a precubical set [5]. Examples 2.11. 1. In the tensor product 0,2 ⊗ 0,1, we have (0,2 ⊗ 0,1)0={{(0,0),(1,0),(2,0),(0,1),(1,1),(2,1)}; (0,2 ⊗ 0,1)1={{([0,1],0),([1,2],0),([0,1],1),([1,2],1),(0,[0,1]),(1,[0,1]),(2,[0,1])}; (0,2 ⊗ 0,1)2=([0,1],[0,1]),([1,2],[0,1])}. This precubical set can be represented as . (0,0) (0,1) (1,[0,1]) (1,0) (2,0) (1,1) (2,1) ([0,1],[0,1]) ([1,2],[0,1]) (0,[0,1]) ([0,1],0) ([1,2],0) ([1,2],1) (2,[0,1]) ([0,1],1) 2. Consider the directed circle −→ S1and the directed torus −→ Tdefined in 2.10. For −→ S1⊗−→ S1we have (−→ S1⊗−→ S1)0={(v,v)}, (−→ S1⊗−→ S1)1={(a,v),(v,a)}, (−→ S1⊗−→ S1)2={(a,a)}, and we can define a morphism of precubical sets f:−→ S1⊗−→ S1→−→ Tby (v,v)→v(a,v)→a(v,a)→b(a,a)→x Since it is a bijection in each degree, it is an isomorphism −→ S1⊗−→ S1∼ =−→ T. 13 Remark 2.12. The tensor product of precubical sets is associative up to canonical isomorphism and can therefore be iterated. We will be particularly interested in iterated tensor products of the form Nn i=10,li. Dipaths A directed path or dipath of length kin a precubical set Pis a morphism of precubical sets ω:0,k → P. A dipath of length kcorresponds hence to a sequence of kconsecutive edges. The concatenation of two dipaths ω:0,k → Pand ν:0,l → Psuch that ν(0) =ω(k)is the dipath ω.ν:0,k+l → Pgiven by ω.ν(i)=   ω(i), 0 ≤i≤k, ν(i−k), k≤i≤k+l. and ω.ν([i−1,i]) =   ω([i−1,i]), 1 ≤i≤k, ν([i−k−1,i−k]), k<i≤k+l. Example 2.13. Consider the following precubical set P: x2 x1 x6 x4 x8 x7 d0 1(x2) d0 1(x1) d0 2(x2)x5 d1 1(x2) d1 1(x1) d0 2(x1)=d1 2(x2) d1 2(x1)x3 The edges of x3and x4determine the dipath ω1:0,2 → P [0,1] 7→ x3, [1,2] 7→ x4, 0 7→ d0 1(x3), 1 7→ d1 1(x3)=d0 1(x4), 2 7→ d1 1(x4). The edges d0 1(x2),d1 2(x2),d1 1(x1)determine the dipath ω2:0,3 → P 14 [0,1] 7→ d0 1(x2), [1,2] 7→ d1 2(x2), [2,3] 7→ d1 1(x1), 07→ d0 1(d0 1(x2)), 1 7→ d1 1(d0 1(x2)) =d0 1(d1 2(x2)), 27→ d1 1(d1 2(x2)) =d0 1(d1 1(x1)), 3 7→ d1 1(d1 1(x1)). We have ω2(3) =d1 1(d1 1(x1)) =d0 1(x3)=ω1(0), and the concatenation ω2.ω1is the dipath corresponding to the sequence of edges d0 1(x2),d1 2(x2),d1 1(x1),x3,x4. Precubical subsets A precubical subset of a precubical set Pis a graded subset of Pthat is stable under the face maps. For example, the image of a morphism f:P→Qof precubical sets is a precubical subset of Q. One easily checks that union and intersections of precubical subsets are precubical subsets. The n -skeleton of a precubical set Pis the precubical subset P≤ngiven by (P≤n)i=   Pi,i≤n, ;,i>n. Dihomotopy Let Pbe a precubical set. Two paths ω,ν:0,k → Pare said to be elementarily dihomotopic if there exist a∈{1,...,k−1},x∈P2, and r∈{1,2} such that ω([a−1,a]) =d0 r(x), ω([a,a+1]) =d1 3−rx, ν([a−1,a]) =d0 3−r(x), ν([a,a+1]) =d1 rx, and ω([i−1,i]) =ν([i−1,i]) for all i6= a,a+1. x ... ... ω([a−1,a]) ν([a−1,a]) ν([a,a+1]) ω([a,a+1]) 15 Dihomotopy is the equivalence relation generated by elementary dihomotopy. Example 2.14. All dipaths from sto tin the following precubical set are dihomotopic: x2 x4x3 x1 s t ... ... Indeed, they are elementarily dihomotopic or there exists a chain of elementary dihomotopies between them. Geometric realization The geometric realization of a precubical set Pis the quotient space |P| = a n∈N0 Pn×In  ≈ where the sets Pnare given the discrete topology and the equivalence relation is generated by (dα ix,u)≈(x,δα i(u)), x∈Pn+1,u∈In,i∈{1,...,n+1}, α∈{0,1} Here δα i:In→In+1is the continuous map defined by δα i(u1,...,un)=(u1,...,uk−1,α,uk+1,...,un). For n=1, we can visualize the δfunctions as follows: 16 I2 =I 0 1 δ1 1 δ1 2 I= 0 1 ([0,1]) δ0 1 δ0 2 By [6] , |P|is a CW-complex and hence a Hausdorff space (see, e.g., [10, Prop. A.3]). If Pis finite, |P| is compact. It follows from [10, Prop. A.2 (i)] that for every element ξ∈ |P|, there exist unique elements n∈N0,x∈Pn, and u∈Insuch that ξ=[x,u]. The geometric realization |P|is a d-space, with d|P|consisting of paths α:I→ |P|for which there exist integers r>0and p1,..., pr≥0, a partition 0=a0<a1< ··· < ar−1<ar=1, and, for each i∈{1,...,r}, an element xi∈Ppiand an increasing continuous map ωi: [ai−1,ai]→Ipisuch that, for all i∈{1,...,r}and t∈[ai−1,ai],α(t)=[xi,ωi(t)]. By Proposition 2.16 below, d|P|defines a valid dstructure on |P|. The geometric realization is a functor Precub →dTop. Given a morphism of precubical sets f:P→Q, the geometric realization |f|:|P|→|Q|is the d-map given by |f|([x,u]) =[f(x),u]. Examples 2.15. 1. Given P= 0,2 ⊗ 0,1, (0,0) (0,1) (1,0) (2,0) (1,1) (2,1) we first build the set ` n≥0 Pn×[0,1]n, equipped with the discrete topology: {(0,0)} ×I0{(0,1)} ×I0 ...{(2,1)} ×I0 {(0,[0,1])} ×I1{(1,[0,1])} ×I1 ...{([1,2],1)} ×I1 {([0,1],[0,1])} ×I2{([1,2], [0,1])} ×I2 17 Definition 3.2. Given a resource a∈R, we define the consumed capacity of aas the function cκa:Σ∗→Zsuch that cκa(Pa)=1, cκa(Va)= −1, cκa(PR\{a})=0, cκa(VR\{a})=0, cκa(²)=0, and for u,v∈Σ∗ cκa(u;v)=cκa(u)+cκa(v). With this function we can call a process p∈Σ∗valid, if for every resource a∈R, and every prefix uof p 0≤cκa(u)≤κa and cκa(p)=0. Example 3.3. Let us check the validity of the processes in the previous example for given capacities of each resource. Let κa=1and κb=1. For p4=Pa;Va;Pb, we can check that for every prefix 0≤cκa(u)≤1and 0≤cκb(u)≤1: cκa(Pa)=1, cκa(Pa;Va)=0, cκa(Pa;Va;Pb)=0, cκb(Pa)=0, cκb(Pa;Va)=0, cκb(Pa;Va;Pb)=1. So p4verifies the first condition, however cκb(p4)6= 0, therefore it is not a valid process. If we calculate, with the same capacities for every process given in example 3.1, we find that p1is valid, and that p2has cκa(Pa;Pa)=2>κa=1. Therefore p2is a not valid process for κa=1, but if we changed κa=2, then p2is a valid process. Process p3is not valid for any κa, because there is a prefix such that cκa(u)= −1 (u=Pa;Va;Va). Definition 3.4. A simple concurrent PV-program p=p1||...||pnis a sequence of valid processes p1,..., pn. 3.2 Graph semantics Given a simple program p=p1||...||pn, we can construct a labeled directed graph, that will model the states of pand the transitions between them. A PV-labeled directed graph is a tuple G=(V,E,∂−,∂+,l), such that Vand Eare the set of vertices and edges, respectively, ∂−,∂+:E→Vare functions such that given e∈E,∂−(e)is the origin and ∂+(e) 24 is the target, and l:E→Σis a function that associates an element of PRor VRto each edge. Note that (V,E,∂−,∂+)can be seen as the 1-dimensional precubical set Pwhere P0,P1=E,Pi= ; (i>0), ∂−=d0 1and ∂+=d1 1. For a process p=u1;...;un∈Σ∗, the PV-labeled directed graph Gpis defined by the sets V= 0,n0={0,...,n}, E= 0,n1={[0,1],...,[n−1,n]} and for e=[i,i+1] ∈E, ∂−([i,i+1]) =i,∂+([i,i+1]) =i+1, l([i,i+1]) =ui+1. Example 3.5. For p=Pa;Va,GPa;Va=({0,1,2},{[0,1],[1,2]},∂−,∂+,l)is the labeled graph 01 2 PaVa. Definition 3.6. Given ngraphs G1=(V1,E1,∂−,∂+,l),...,Gn=(Vn,En,∂−,∂+,l), we define the tensor product as G1⊗ ··· ⊗Gn=(V1× ·· · ×Vn, n a i=1 V1× ··· ×Vi−1×Ei×Vi+1× ·· · ×Vn,∂−,∂+,l) where for ei=(x1,...,xi−1,e,xi+1,..., xn)∈V1× ··· × Vi−1×Ei×Vi+1× ··· × Vn, we have ∂−(ei)=(x1,..., xi−1,∂−(e), xi+1,..., xn),∂+(ei)=(x1,...,xi−1,∂+(e), xi+1,..., xn)and l(ei)=l(e). Given a simple concurrent PV-program p=p1||...||pn, we define its graph Gpto be the tensor product Gp1⊗ ·· · ⊗Gpn. Example 3.7. Let p1=Pa;Vaand p2=Pb;Vbbe two valid processes. Then the simple program p=Pa;Va||Pb;Vbwill have the following the graph: Gp= (0,0) (1,0) (2,0) (2,1) (2,2) (0,1) (0,2) (1,2) (1,1) PaVa PaVa PaVa Pb Vb Pb Vb Pb Vb 25 Notation 3.8. Given a word u∈Σ∗, the prefix until the ith letter will be denoted as i u, with 0 u=². For example, if u=Pa;Pa;Va;Va, then 0 u=²,1 u=Pa,2 u=Pa;Pa,3 u=Pa;Pa;Va,4 u=Pa;Pa;Va;Va. Definition 3.9. Let p=p1||...||pnbe a simple program and let libe the length of pi. Given a resource a∈R, we define the capacity of a vertex v=(v1,...,vn)of Gpby cvp a=cκa(v1 p1)+ ··· + cκa(vn pn). The pruned graph of pis the subgraph ˇ Gp=(ˇ V,ˇ E,∂−,∂+,l)of Gpwhere ˇ V={v∈V|∀a∈R, 0 ≤cvp a(v)≤κa}, ˇ E={e∈E|∂−(e)∈ˇ V∧∂+(e)∈ˇ V}. The vertices and edges of ˇ Gpare called the states and the transitions of p. The vertices sp=(0,...,0) and tp=(l1,...,ln)are the start and the terminal state of p, respectively. An execution path leading from vto w, i.e., a sequence of edges e1,...,ek∈ˇ Esuch that ∂−(ei+1)=∂+(ei) (i=1,...,k−1), ∂−(e1)=v,∂+(ek)=w. A state v∈ˇ Vis called reachable if there exists an execution path from spto v. A state that is not reachable is called unreachable . A reachable state v6= tpis called a deadlock if there is no transition starting in v. A state vis called doomed if there is no execution path leading from vto tp. Example 3.10. (Swiss flag) Let us prune the Graph Gpwith p=Pa;Pb;Vb;Va||Pb;Pa;Va;Vband κa=κb=1. Then ˇ Gp= (0,0) (1,0) (2,0) (3,0) (4,0) (0,4) (1,4) (2,4) (3,4) (4,4) (0,1) (0,2) (0,3) (0,4) (4,1) (4,2) (4,3) (4,4) (3,1) (1,3) (1,1) (3,3) PaPbVbVa PaPbVbVa Pa Va Pb Pa Va Vb Pb Pa Va Vb Pb Vb Pb Vb Pa Va The state (3,3) is unreachable, and (1,1) is a deadlock. 26 3.3 Precubical semantics Let Pbe a precubical set. The set of vertices of an element x∈Pr(r≥0) will be denoted by V(x). Thus, V(x)=   {x}, r=0, {dk1 i1...dkr irx|1≤is≤s,ks∈{0,1}}, r>0. Given a precubical subset G⊆(Nn i=10,li)≤1, we denote by ä(G)the precubical subset of Nn i=10,li given by ä(G)r={x∈Ãn O i=1 0,li!r |V(x)⊆G0}. Since V(dk ix)⊆V(x), this is indeed a precubical set. Note that ä(G)is the largest precubical subset Qof Nn i=10,lisuch that Q0=G0. In particular, ä¡¡Nn i=10,li¢≤1¢=Nn i=10,li. Let p=p1||...||pnbe a simple concurrent PV-program such that process pihas liinstructions. Then we view ˇ Gpas a precubical subset of (Nn i=10,li)≤1and define the precubical model of pto be the precubical set ä(ˇ Gp). Example 3.11. (Swiss flag) Let p=Pa;Pb;Vb;Va||Pb;Pa;Va;Vb,κb=κa=1. Then the precubical model of pis ä(ˇ Gp)= (0,0) (1,0) (2,0) (3,0) (4,0) (0,4) (1,4) (2,4) (3,4) (4,4) (0,1) (0,2) (0,3) (0,4) (4,1) (4,2) (4,3) (4,4) (3,1) (1,3) (1,1) (3,3) Notation 3.12. Let xbe an element of degree rof Nn i=10,li. Then there exist unique integers 1≤i1< ··· < ir≤nand unique vertices (v1,..., vn),(w1,..., wn)∈(Nn i=10,li)0=Qn i=1{0,...,li} 27 such that wi=   vi+1, i∈{i1,...,ir}, vi,otherwise and x=(v1,..., vi1−1,[vi1,wi1], vi1+1,..., vir−1,[vir,wir], vir+1,..., vn). Note that d0 1...d0 rx=(v1,..., vn)and d1 1...d1 rx=(w1,..., wn). We will write [v1,..., vn] : [w1,..., wn] to denote x. Proposition 3.13. For G⊆(Nn i=10,li)≤1 , ä(G)=[(n O i=1 vi,wi|0≤vi≤wi≤li, n Y i=1 {vi,...,wi}⊆G0). Proof. Write P=[(n O i=1 vi,wi|0≤vi≤wi≤li, n Y i=1 {vi,..., wi}⊆G0). Let x∈Pr. Then there exists 0≤vi≤wi≤li(i=1,...,n)such that Qn i=1{vi,..., wi}⊆G0 and x∈Nn i=1vi,wir. Since ¡Nn i=1vi,wi¢0=Qn i=1{vi,...,wi}, we have V(x)⊆G0. Hence x∈ ä(G)r. Suppose conversely that x∈ ä(G)r. Write x=[v1,..., vn]:[w1,..., wn]. Then V(x)=Qn i=1{vi..., wi}. Moreover, x∈(Nn i=1vi,wi)r.Since V(x)⊆G0, we have x∈Pr. 3.4 Euclidean pospace semantics Let p=p1||...||pnbe a simple concurrent PV-program. For i∈{1,...,n}, let libe the length of process pi. The pospace model of pis the Euclidean pospace ˇ Γp=[(n Y i=1 [vi,wi]|0≤vi≤wi≤li, n Y i=1 {vi,..., wi}⊆ˇ V) where ˇ Vis the set of vertices of the pruned graph ˇ Gp. Example 3.14. Given p=Pa;Va||Pa;Va, we have 28 Gp= (0,0) (0,1) (1,0) (2,0) (1,1) (1,2) (2,2) (2,1) (0,2) Pa Va PaVa Pa Va Pa Va PaVa PaVa We have ˇ V=Vif κa=2and ˇ V=V\ {(1,1)} if κa=1. Hence ˇ Γp=[0,2]2if κa=2and ˇ Γp=[0,2] ×{0,2} ∪{0,2} ×[0,2] if κa=1. κa=1κa=2 (0,0) (1,0) (2,0) (0,1) (0,2) (0,0) (1,0) (2,0) (0,1) (0,2) Remark 3.15. For the pospace semantics it is crucial that we consider simple programs without loops. Using local pospaces, it is, however, possible to extend the semantics to cover more general systems [4]. Lemma 3.16. Let Q be a precubical subset of a finite precubical set P , and let i:Q→P be the inclusion. Then |i|:|Q|→|P| is an inclusion, i.e., a homeomorphism onto its image. Proof. We show first that |i|is injective. Consider x∈Qq,y∈Qr,u∈]0,1[q, and v∈]0,1[rsuch that |i|([x,u]) = |i|([y,v]). Then [x,u]=[y,v]in |P|. Hence x=yand u=v. The result now follows from the fact that |i|:|Q|→|i|(|Q|)is a continuous bijection from a compact to a Hausdorff space. Remark 3.17. By the lemma, we may identify |Q|with the subspace |i|(|Q|)={[x,u]|x∈Qr,u∈Ir(r≥0)} 29 of |P|. Given a family (Qλ)λ∈Λof precubical subsets of P, we have ¯¯¯¯¯[ λ∈Λ Qλ¯¯¯¯¯ ={[x,u]|x∈Ã[ λ∈Λ Qλ!r ,u∈Ir(r≥0)} =[ λ∈Λ {[x,u]|x∈Qλ r,u∈Ir(r≥0)} =[ λ∈Λ |Qλ|. Theorem 3.18. The isomorphism of d-spaces χ: n Y i=1 [0,li]→¯¯¯¯¯ n O i=1 0,li¯¯¯¯¯ given by χ(u1,...,un)=[([v1,v1+1],...,[vn,vn+1]),(u1−v1,...,un−vn)], 0 ≤vi≤ui≤vi+1≤li restricts to an isomorphism of d-spaces ˇ Γp→ |ä(ˇ Gp)| . Proof. By 3.13 we have χ(ˇ Γp)=χÃ[(n Y i=1 [vi,wi]|0≤vi≤wi≤li, n Y i=1 {vi,..., wi}⊆ˇ V)! =[(χ( n Y i=1 [vi,wi])|0≤vi≤wi≤li, n Y i=1 {vi,..., wi}⊆ˇ V) =[(¯¯¯¯¯ n O i=1 vi,wi¯¯¯¯¯ |0≤vi≤wi≤li, n Y i=1 {vi,..., wi}⊆ˇ V) =¯¯¯¯¯[(n O i=1 vi,wi|0≤vi≤wi≤li, n Y i=1 {vi,..., wi}⊆ˇ V)¯¯¯¯¯ = |ä(ˇ Gp)|. As before we want to study the model of the state space and find problematic regions of the system. Definition 3.19. Let p=p1||...||pnbe a simple PV-program, and let libe the number of instructions of pi. An element x∈ˇ Γpis called a deadlock if no dipath is starting in x. An element xis called doomed if there is no dipath in ˇ Γpleading from xto (l1,...,ln). An element is reachable if there exists a dipath (0,...,0) to x. An element that is not reachable is called unreachable . Example 3.20. Consider again the Swiss-flag program p=Pa;Pb;Vb;Va||Pb;Pa;Va;Vb. In ˇ Γpwe have the following doomed and unreachable regions: 30 (0,0) (1,0) (2,0) (3,0) (4,0) (0,1) (0,2) (0,3) (0,4) doomed unreachable So the doomed region of ˇ Γpis [0,1] \ ({0} ×[0,1] ∪[0,1] ×{0}), and the unreachable region is [3,4]2\ ({4} ×[3, 4] ∪[3,4] ×{4}). doomed region unreachable region (0,0) (1,1) (3,3) (4,4) Proposition 3.21. Let x∈ˇ Γp , and let m≥0 , c∈ ä(ˇ Gp)m , and (u1,...,um)∈]0,1[m be the unique elements such that χ(x)=[c,(u1,...,um)] , where χ is the isomorphism ˇ Γp∼ =|ä(ˇ Gp)| . Then 1. x is reachable in ˇ Γp if and only if d0 1...d0 mc is reachable in ˇ Gp ; 2. x is doomed in ˇ Γp if and only if d1 1...d1 mc is doomed in ˇ Gp . Proof. We only prove 1. The proof of 2is analogous. Suppose first that d0 1...d0 mcis reachable in ˇ Gp. Then there exists a dipath ω:0,r→ä(ˇ Gp)from (0,...,0) to d0 1...d0 mc. Then the dipath 31 ν:−−−→ [0,r] ∼ = −→ |0,r| |ω| −−→ |ä(ˇ Gp)|leads from [(0,...,0),()] =[c,(0,...,0)]. Concatenating νwith the dipath ζ:−→ I→ |ä(ˇ Gp)|,ζ(t)=[c,t(u1,...,un)], we obtain a dipath ω:−−−−−−→ [0,r+1] → |ä(ˇ Gp)|from [(0,...,0),()] to χ(x). It follows that the composite α:−−−−−−→ [0,r+1] ω −→ |ä(ˇ Gp)|χ−1 −−→ ˇ Γpis a dipath from (0,...,0) to x. Hence xis reachable in ˇ Γp. Suppose now that there exists a dipath α:−−−→ [0,k]→ˇ Γpfrom (0,...,0) to x. According to [2, 4.22], there exists a sequence (c1,...,cs)of cubes of ä(ˇ Gp)such that c1=(0,...,0),cs=c, and for each 1≤i<s, either ciis an initial face of ci+1or ci+1is a final face of ci. There exists hence a precubical dipath from the initial vertex of cito the initial vertex of ci+1. Concatenating these dipaths, one obtains a dipath from (0,...,0) to d0 1...d0 mc. Thus, d0 1...d0 mcis reachable in ˇ Gp. 32 Chapter 4 Topology of precubical sets As we have seen in Section 2.3, the geometric realization of a precubical set is a d-space. In this chapter, we show that every polyhedron arises as the underlying topological space of the geometric realization of a precubical set. This is joint work with Catarina Faustino and Thomas Kahl. I will only present the proofs I have contributed to this work. The simplicial complex K Let Kbe an abstract simplicial complex with vertices 1,..., N, i.e. a set of subsets of {1,..., N}, called simplexes , such that •∀i∈{1,..., N} {i}∈K; •∀σ,τ⊆{1,..., N}; 6= τ⊆σ∈K⇒τ∈K. Given a simplex σ∈K, we denote by |σ|the geometric simplex in RNwith vertices ei=(0,...,0,1 i ,0,...,0),i∈σ. i.e., their convex hull. Thus, |σ| = {Σi∈σtiei|ti≥0,Σi∈σti=1}. The polyhedron defined by Kis the subset |K| = S σ∈K |σ|of the standard (N−1)-simplex ∆N−1={ΣN i=1tiei|ti≥0,ΣN i=1ti=1} ⊆RN. Remark 4.1. For every element x∈ |K|, there exist a unique simplex σ∈Kand unique numbers ti>0, i∈σsuch that x=P i∈σ tiei. 33 (1 3 2) (1 2 3) (2 3 1) (2 1 3) (3 1 2) (3 2 1) eu1eu2 eu3 1 2(eu1+eu2) 1 3(eu1+eu2+eu3) 1 2(eu1+eu3)1 2(eu2+eu3) Let m=max{i∈{1,...,n}|sα(i)=sα(1)}, and set τ={uα(1),...,uα(m)}. Let φbe the unique order-isomorphism {α(m+1),...,α(n)} →{1,...,n−m}, and define θ∈Sn−mby θ(i)=φ(α(m+i)). Set tθ(i)=(m+i)sα(m+i)+ n X j=m+i+1 sα(j). Then 0≤tθ(n−m)≤ ··· ≤ tθ(1) ≤ n X j=1 sα(j)=1. Hence (t1,..., tn−m)∈∆θ⊆In−m. We set g(x)=[(τ,σ),(t1,...,tn−m)]. Using Lemmas 4.5 and 4.6, one easily checks that g(x)does not depend on the choice of the permutation α. We have thus defined a map g:|K|→|P|. 40 Proof of Theorem 4.9 Since fis a continuous map between compact Hausdorff spaces, it is enough to show that fis bijective. This is done in the next two lemmas, of which we prove the second. Lemma 4.10. f◦g=id|K| . Lemma 4.11. g◦f=id|P| . Proof. Consider an element (τ,σ)∈Pn−m, with τ={v1< ··· < vm}and σ\τ={w1< ··· < wn−m}, and let θ∈Sn−mand (t1,..., tn−m)∈∆θ∩]0,1[n−m. Define {u1< ··· < un}={v1,..., vm,w1,..., wn−m}=σ. Then there exists an α∈Snsuch that τ={uα(1) < ··· < uα(m)}and uα(m+i)=wθ(i)for i=1,...,n−m. Consider the orderisomorphism φ: {1,...,n} \ {α(1),...,α(m)} →{1,...,n−m}. Then uφ−1(i)=wi. Hence uφ−1(θ(i)) =wθ(i)=uα(m+i)and therefore θ(i)=φ(α(m+i)). We have f([(τ,σ),(t1,...,tn−m)] =fτ,σ(t1,..., tn−m) =1−tθ(1) m m X i=1 evi+tθ(1) −tθ(2) m+1( m X i=1 evi+ewθ(1) )+... +tθ(n−m−1) −tθ(n−m) m+n−m−1( m X i=1 evi+ n−m−1 X i=1 ewθ(i)) +tθ(n−m) m+n−m( m X i=1 evi+ n−m X i=1 ewθ(i)). Define numbers s1,..., snas follows: sα(1) = ··· = sα(m)=1−tθ(1) m+tθ(1) −tθ(2) m+1+ ··· + tθ(n−m−1) −tθ(n−m) n−1 +tθ(n−m) n sα(m+1) =tθ(1) −tθ(2) m+1+ ··· + tθ(n−m−1) −tθ(n−m) n−1+tθ(n−m) n . . . sα(m+i)=tθ(i)−tθ(i+1) m+i+ ··· + tθ(n−m−1) −tθ(n−m) n−1+tθ(n−m) n . . . sα(n−1) =tθ(n−m−1) −tθ(n−m) n−1+tθ(n−m) n sα(n)=tθ(n−m) n 41 Since tθ(1) ≥ ··· ≥ tθ(n−m)>0, all si>0. Moreover, n X i=1 si= n X i=1 sα(i) =m1−tθ(1) m+(m+1) tθ(1) −tθ(2) m+1+ ··· + (n−1) tθ(n−m−1) −tθ(n−m) n−1 +ntθ(n−m) n =1. We have f([(τ,σ),(t1,...,tn−m)] =(sα(m)−sα(m+1)) m X i=1 evi+(sα(m+1) −sα(m+2))( m X i=1 evi+ewθ(1) )+... +(sα(m+n−m−1) −sα(m+n−m))( m X i=1 evi+ n−m−1 X i=1 ewθ(i)) +sα(m+n−m)( m X i=1 evi+ n−m X i=1 ewθ(i)) =sα(m) m X i=1 evi+ n−m X i=1 sα(m+i)ewθ(i) =sα(m) m X i=1 euα(i)+ n X i=m+1 sα(i)euα(i) = m X i=1 sα(i)euα(i)+ n X i=m+1 sα(i)euα(i) = n X i=1 sα(i)euα(i) = n X i=1 sieui. Since tθ(1) <1, sα(1) = ··· = sα(m)>sα(m+1) ≥ ··· ≥ sα(n) and therefore m=max{i∈{1,...,n}|sα(i)=sα(1)}. We have tθ(n−m)=nsα(n), and a simple downward induction shows that tθ(i)=(m+i)sα(m+i)+ n X j=m+i+1 sα(j) for all i=1,...,n−m. By definition of g, it follows that g(f([(τ,σ),(t1,...,tn−m)]) =[(τ,σ),(t1,..., tn−m)]. 42 Chapter 5 Algorithms In this chapter, we present algorithms to compute the directed topological models of simple concurrent PV- programs described in Chapter 3. All the algorithms in this chapter are implemented in Python as shown in the appendix. This code is also available on github at https://github.com/Rodrigo-M-L/Topological- Models-of-Concurrency/tree/main. Algorithms in graphs and precubical sets Let p=p1||...||pnbe a simple concurrent PV-program, and let libe the length of pi. Then the set of vertices of Gpis the product V=Qn i=1Vi, where Vi={0,...,li}. With this we can build the full precubical set ä(Gp), and because Gpis the 1-skeleton of ä(Gp)we then have Gp=(V,ä(Gp)1,∂−,∂+). Using the notation introduced in 3.12, we have ä(Gp)k={[v1,...,vn]:[w1,..., wn]| v,w∈V, vr≤wr≤vr+1, n X r=1 wr−vr=k}. 43 In order to compute the elements of ä(Gp)k,we will need the function Tn:Nn 0×Nn 0−→ N0 (v,w)7−→ #{i|wi−vi=1,i=1,...,n} and the Hamming distance Hn:Nn 0×Nn 0−→ N0 (v,w)7−→ #{i|vi6= wi,i=1,...,n}. We have the following algorithm that creates ä(Gp)and Gp: Algorithm 1 Gpand ä(Gp) Require: Vof Gp,p Ensure: ä(Gp)of Gp n←size of p ä(Gp)0←V ä(Gp)i← ;, for 1≤i≤n for v∈Vdo for w∈Vdo i←Tn(v,w) if Hn(v,w)=ithen ä(Gp)i← ä(Gp)i∪{[v]:[w]} end if end for end for Gp=(V,ä(Gp)1,∂−,∂+) ä(Gp)=(ä(Gp)i)i∈{1,...,n} Now we want to prune Gpand ä(Gp), i.e., remove impossible vertices, and at the same time remove the elements of the precubical set that have these vertices. Example 5.1. Given p=Pa;Va||Pa;Va, 44 Gp= (0,0) (0,1) (1,0) (2,0) (1,1) (1,2) (2,2) (2,1) (0,2) cvp a=0 cvp a=1 cvp a=1cvp a=0 cvp a=2 cvp a=1cvp a=0 cvp a=1 cvp a=0 Pa Va PaVa Pa Va Pa Va PaVa PaVa For capacity κa=1, the impossible edge are all that contain the vertex (1,1), i.e., [0,1] : [1,1], [1,0] : [1,1],[1,1] : [2,1],[1,1] : [1,2]. ˇ Gp= (0,0) (0,1) (1,0) (2,0) (1,2) (2,2) (2,1) (0,2) Pa Va PaVa Pa Va PaVa In general, we remove the vertices that exceed at least one of the capacities and all the edges that contain them. Similarly in order to construct ä(ˇ Gp), we remove all elements that contain a forbidden vertex. Algorithm 2 Forbidden vertices Require: Gp=(V,ä(Gp)1,∂−,∂+,l),p=p1||...||pn=(p1,...,pn),(κa)a∈R,R. Ensure: ¯ VSet with vertices that exceed the capacities. n←size of p ¯ V← ; for v∈Vdo v=(v1,..., vn)∈Nn 0 for a∈Rdo if 0≤cvp a(v)≤κathen pass 45 else ¯ V←¯ V∪v end if end for end for Given ¯ Vand ä(Gp), we can create ˇ Gpand its precubical set. Algorithm 3 ˇ Gpand ä(ˇ Gp) Require: Gp=(V,ä(Gp)1,∂−,∂+,l),¯ V,ä(Gp). Ensure: ˇ Gpand ä(ˇ Gp) ˇ V←V\¯ V ˇ E← ä(Gp)1 for i←0,...,ndo ä(ˇ Gp)i← ä(Gp)i for v∈¯ Vdo for x∈ ä(Gp)ido x=[Iv]:[Fv] if Iv≤v≤Fvthen ä(ˇ Gp)i← ä(ˇ Gp)i\ {x} end if end for end for end for ˇ Gp←(ˇ V,ä(ˇ Gp)1,∂−,∂+,l) ä(ˇ Gp)=(ä(ˇ Gp)i)i∈{1,...,n} Finally, the face maps can be calculated by the following algorithm: Algorithm 4 Compute dα ix Require: x=[v1,..., vn]:[w1,...,wn]∈ ä(ˇ Gp)r,i,α. Ensure: dα ix. c1,c2←0 while c16= ido 46 c2←c2+1 if wc2−vc26= 0then c1←c1+1 end if end while if α=0then dα ix←[v1,..., vn]:[w1,..., vc2,..., wn] else dα ix←[v1,..., wc2,..., vn]:[w1,..., wn] end if Algorithms in pospaces Knowing that ˇ Γp=χ−1(|ä(ˇ Gp)|), we will obtain ˇ Γpfrom ä(ˇ Gp)that we constructed in the previous algorithm. In practice, we will once again modify the constructions to facilitate the implementation. Proposition 5.2. ˇ Γp=[(n Y i=1 [vi,wi]|∃r∈{0,...,n} [v1,...,vn]:[w1,..., wn]∈ ä(ˇ Gp)r). Proof. “⊇”: For x=[v1,...,vn]:[w1,..., wn]∈ ä(ˇ Gp)r, we have V(x)=Qn i=1{vi,..., wi}⊆ˇ Vand therefore Qn i=1[vi,wi]⊆ˇ Γp. “⊆”: Suppose that 0≤vi≤wi≤li(i=1,...,n)and Qn i=1{vi,..., wi}⊆ˇ V. Then n Y i=1 [vi,wi]=Ãw1−v1 [ j1=0 [v1+j1,min{v1+j1+1, w1}]!× · ·· × Ãwn−vn [ jn=0 [vn+jn,min{vn+jn+1, wn}]! =[{[v1+j1,min{v1+j1+1, w1}] ×... ×[vn+jn,min{vn+jn+1, wn}]|0≤ji≤wi−vi}]. The result follows because [v1+j1,..., vn+jn]:[min{v1+j1+1, w1},...,min{vn+jn+1,wn}] is an element of ä(ˇ Gp). 47 Algorithm 5 Pospace semantics ˇ Γp Require: ä(ˇ Gp). Ensure: ˇ Γp. n←dimension of P ˇ Γp← ; for i←0,...,ndo for x∈ ä(ˇ Gp)ido x=[v1,..., vn]:[w1,..., wn] ˇ Γp←ˇ Γp∪[v1,w1]× ··· × [vn,wn] end for end for Considering Proposition 5.2, it is also possible to construct ˇ Γpby successively removing the regions of [0,l1]× ··· × [0,ln]corresponding to cubes in ä(Gp) \ ä(ˇ Gp). Algorithm 6 Alternative ˇ Γp Require: ˇ Γpand ¯ V Ensure: ˇ Γpand blocks ˇ Γp. blocksΓp←{Γp} blocks ˇ Γp← ; while ¯ V6= ; do v∈¯ V v=(v1,..., vn) for x∈blocksΓpdo if v∈xthen x=[a1,b1]× ··· × [an,bn] blocksΓp←blocksΓp\ {x} for i←1,...,ndo spli ts ← ; if vi>aithen spli t1←[a1,b1]× ··· × [ai,vi−1] × · ·· × [an,bn] spli ts ←spli ts ∪{spli t1} 48 end if if vi<bithen spli t2←[a1,b1]× ··· × [vi+1,bi]× ··· × [an,bn] spli ts ←spli ts ∪{spli t2} end if for spli t ∈spli ts do if ∃w∈¯ V,w∈spli t then blocksΓp←blocksΓp∪{spli t} else blocks ˇ Γp←blocks ˇ Γp∪{spli t} end if end for end for end if end for ¯ V←¯ V\ {v} end while ˇ Γp←Sx∈blocks ˇ Γpx Doomed and unreachable states In 3.9 we defined deadlocks and doomed and unreachable vertices in ˇ Gp, now we compute them. Let p=p1||...||pnbe a simple concurrent program, and let ˇ Gp=(ˇ V,ˇ E,∂−,∂+,l)be its graph model. Let Dˇ Gp=(Dˇ V,Dˇ E,∂−,∂+)be the largest subgraph of ˇ Gpsuch that no states are doomed. Similarly, let Uˇ Gp=(Uˇ V,Uˇ E,∂−,∂+)be the largest subgraph of ˇ Gpsuch that all states are reachable. The set of doomed and unreachable states are given by (ˇ Gp)0\ (Dˇ Gp)0, and (ˇ Gp)0\ (Uˇ Gp)0respectively. The following algorithm computes the graphs Dˇ Gpand Uˇ Gp. Given a subgraph G=(W,A,∂−,∂+)of ˇ Gp, we write W∂−={∂−(e)|e∈A}and W∂+={∂+(e)|e∈A}. Note that the set of deadlocks of pis (ˇ Gp)0\ ( ˇ V∂−∪{tp}). Algorithm 7 Dˇ Gpand Uˇ Gp Require: ˇ Gp=(ˇ V,ˇ E,∂−,∂+). 49 #-- After executing this use .returnvertices() to observe the␣ ,→output --# #-- constructs the vertices and locks the capacity of each␣ ,→resource. If you change the capacity this needs to be rerun --# #-- creates the full graph with python dictionaries use . ,→returngraph() to observe the output after executing this function␣ ,→--# #now we have enough to create the edges of the graph def CreateGraph(self): self.infograph() self.createvertice() print(self.vertices) edge=[] edges=[] for ed in range(len(self.vertices)): for iin range(len(self.p)): edg=copy.deepcopy(self.vertices[ed]) resource=edg[i] edg[i]=edg[i]+1 if edg[i]<len(self.p[i])+1: #for vertex (i1,i2,...,in), we create k<=n valid␣ ,→connections that for position jwe have [(i1,i2,.,ij,..,in),␣ ,→'__',(i1,i2,.,ij+1,..,in)] edges.append([self.vertices[ed],self. ,→p[i][resource],edg]) else: pass self.edges=edges newedges=dict() #We can now compress the information such that we have a␣ ,→dictionary where dict[vertex]=[valid conections] #with this we will be able to call the connections from the␣ ,→vertices, this will help later to prune the graph for ed in range(len(self.vertices)): newedges[f'{self.vertices[ed]}']=copy.deepcopy([]) for iin range(len(self.edges)): tempedg=copy.deepcopy(self.edges[i]) tempedg1=[tempedg[1],tempedg[2]] if self.vertices[ed]==self.edges[i][0]: 56 #for i(<=k valid connections) vertices that are␣ ,→being pointed by a fixed vertex we get dict[vertice]=[connection_1,. ,→..,connection_i-1,[edge, vertice that is being pointed to]] newedges[f'{self.vertices[ed]}'].append(tempedg1) else: pass #we have enough to build the graph, because for each vertice␣ ,→we know were to point to self.pointers=newedges self.fullPreCubical() #-- creates the full graph with python dictionaries use . ,→returngraph() to observe the output after executing this function␣ ,→--# #-- simple alg for only full graph precubical --# def fullPreCubical(self): dim=len(self.vertices[0]) self.SPC=[] for nin range(dim-1): Pn=dim-n dictPn=dict() for iin range(len(self.vertices)): dictPn[f'{self.vertices[i]}']=[] for jin range(len(self.vertices)): test1=[self.vertices[i][k]!=self.vertices[j][k] for␣ ,→kin range(dim)] test2=[self.vertices[j][k]-self.vertices[i][k]==1␣ ,→for kin range(dim)] if sum(test1)==Pn and sum(test2)==Pn: dictPn[f'{self.vertices[i]}'].append(self. ,→vertices[j]) else: pass self.SPC.append(dictPn) return self.SPC #to add P1 and P0 we can just fullPreCubical.append(self. ,→pointers);fullPreCubical.append(self.vertices) #we dont do this because we want to visualize P2...Pn with␣ ,→this set #-- alg 1 end --# 57 #-- alg 2&3 start --# def singleRemoval(self,init_vertice,ElementOfPn,n=1): global number_Of_Elements_of_Pn_removed if n<len(ElementOfPn): nOfPn=-n+1 n_plus_1_Of_Pn=-n for iin range(len(self.vertices)): test1=[self. ,→vertices[i][j]<=init_vertice[j]<=ElementOfPn[j] for jin␣ ,→range(len(ElementOfPn))] if sum(ElementOfPn)-sum(self.vertices[i])<n+2 and␣ ,→all(test1): original_size=len(self.SPC[n_plus_1_Of_Pn][f'{self. ,→vertices[i]}']) for lin range(len(self.SPC[n_plus_1_Of_Pn][f'{self. ,→vertices[i]}'])): l=l-(original_size-len(self. ,→SPC[n_plus_1_Of_Pn][f'{self.vertices[i]}'])) test2=[ ElementOfPn[j]<=self. ,→SPC[n_plus_1_Of_Pn][f'{self.vertices[i]}'][l][j] for jin␣ ,→range(len(ElementOfPn))] if all(test2): RemoveNext=copy.deepcopy(self. ,→SPC[n_plus_1_Of_Pn][f'{self.vertices[i]}'][l]) if ElementOfPn in self. ,→SPC[nOfPn][f'{init_vertice}']: print(f'We are in {ElementOfPn}(P{n})␣ ,→and remove {ElementOfPn}(P{n})') self.SPC[nOfPn][f'{init_vertice}']. ,→remove(ElementOfPn) ␣ ,→number_Of_Elements_of_Pn_removed=number_Of_Elements_of_Pn_removed+1 else: pass if self.SPC[n_plus_1_Of_Pn][f'{self. ,→vertices[i]}'][l] in self.SPC[n_plus_1_Of_Pn][f'{self.vertices[i]}']: print(f'we are in {init_vertice}: ,→{ElementOfPn}(P{n}) and remove {self.vertices[i]}:{RemoveNext}␣ ,→(P{n+1}) ') self.SPC[n_plus_1_Of_Pn][f'{self. ,→vertices[i]}'].remove(self.SPC[n_plus_1_Of_Pn][f'{self. ,→vertices[i]}'][l]) ␣ ,→number_Of_Elements_of_Pn_removed=number_Of_Elements_of_Pn_removed+1 self.singleRemoval(self. ,→vertices[i],RemoveNext,n+1) 58 else: pass else: pass else: pass if ElementOfPn in self.SPC[nOfPn][f'{init_vertice}']: print(f'we are in {ElementOfPn}(P{n}) and remove␣ ,→{ElementOfPn}(P{n})') self.SPC[nOfPn][f'{init_vertice}'].remove(ElementOfPn) ␣ ,→number_Of_Elements_of_Pn_removed=number_Of_Elements_of_Pn_removed+1 else: pass def ResourceUpdater(self,string): #if P of resource x then +1 to resource utilization x #if V of resource x then -1 to resource utilization x if string[0]=='P': return [string[1],1] elif string[0]=='V': return [string[1],-1] else: print('error') def getdirection(self,vertice1,vertice2): for iin range(len(vertice1)): if vertice2[i]-vertice1[i]!=0: return i else: pass def Cap_vertices(self): self.capproblems=[] vertices=copy.deepcopy(self.vertices) #Here we create a python dictonary that stores the capacity of␣ ,→each resource and we will be able to individually change it, i.e.,␣ ,→cv_a^p(v) self.Resourcetracker=dict() self.Resourcetracker[f'{vertices[0]}']=copy.deepcopy(self.res) for iin range(1,len(vertices)): for kin range(1,len(vertices[i])+1): if vertices[i][-k]-1>=0: verticeteste=copy.deepcopy(vertices[i]) verticeteste[-k]=verticeteste[-k]-1 59 self.Resourcetracker[f'{vertices[i]}']=copy. ,→deepcopy(self.Resourcetracker[f'{verticeteste}']) for lin range(len(self. ,→pointers[f'{verticeteste}'])): if self. ,→pointers[f'{verticeteste}'][l][1]==vertices[i]: resource_info=self.ResourceUpdater(self. ,→pointers[f'{verticeteste}'][l][0]) self. ,→Resourcetracker[f'{vertices[i]}'][resource_info[0]]=self. ,→Resourcetracker[f'{vertices[i]}'][resource_info[0]]+resource_info[1] break else: pass break def KeysToList(self,dictionary): keys=dictionary.keys() ListOfKeys=[list(keys)[i].strip('][').split(', ')for iin␣ ,→range(len(dictionary))] for iin range(len(ListOfKeys)): for jin range(len(ListOfKeys[0])): ListOfKeys[i][j]=int(ListOfKeys[i][j]) return ListOfKeys def PrunedGraph_FP(self,halfpruned=False): #Warning do not run␣ ,→this twice! self.Forbidden_vertices=[] self.Cap_vertices() resources=list(self.cap.keys()) for iin range(len(self.vertices)): test_vertice_cap=[self.Resourcetracker[f'{self. ,→vertices[i]}'][resources[c]]<=self.cap[resources[c]] for cin␣ ,→range(len(self.cap))] #v in \check{V} if all(test_vertice_cap): pass else: self.Forbidden_vertices.append(self.vertices[i]) edges_to_remove=[] for ein range(len(self.pointers[f'{self. ,→vertices[i]}'])): edges_to_remove.append(self.pointers[f'{self. ,→vertices[i]}'][e][1]) del self.pointers[f'{self.vertices[i]}'] for ein range(len(edges_to_remove)): 60 self.singleRemoval(self. ,→vertices[i],edges_to_remove[e]) #This removes edges that point to removed vertices. if not halfpruned: Point_keys=list(self.pointers.keys()) Point_ver=self.KeysToList(self.pointers) keys_removed=0 for iin range(len(Point_keys)): edge_removed=0 i-keys_removed for jin range(len(self.pointers[Point_keys[i]])): j=j-edge_removed if self.pointers[Point_keys[i]][j][1]in Point_ver: pass else: self.singleRemoval(Point_ver[i],self. ,→pointers[Point_keys[i]][j][1]) self.pointers[Point_keys[i]].remove(self. ,→pointers[Point_keys[i]][j]) keys_removed+=1 edge_removed+=1 else: pass print(f'number of elements removed␣ ,→{number_Of_Elements_of_Pn_removed}') #-- alg 2&3 end --# #-- alg 4 start --# def alg4(self,v,w,i,a): #d_i^a([v,w]) c1=0 c2=0 while c1!=i: c2+=1 if w[c1+c2]!=v[c1+c2]: c1+=1 if a==0: w[c2]=v[c2] else: v[c2]=w[c2] return [v,w] #-- alg 4 end --# #-- alg 7 start --# #-- W_delta_plus --# 61 def Delta_plus(self,dictionary): listofvalues=[] Values=list(dictionary.values()) for iin range(len(Values)): for jin range(len(Values[i])): if Values[i][j][1]not in listofvalues: listofvalues.append(Values[i][j][1]) return listofvalues #-- W_delta_minus --# def Delta_minus(self,dictionary): keys=dictionary.keys() ListOfKeys=[list(keys)[i].strip('][').split(', ')for iin␣ ,→range(len(dictionary))] for iin range(len(ListOfKeys)): for jin range(len(ListOfKeys[0])): ListOfKeys[i][j]=int(ListOfKeys[i][j]) for xin ListOfKeys: if len(self.pointers[f'{x}'])==0: ListOfKeys.remove(x) return ListOfKeys def alg7(self): V_delta_plus=self.Delta_plus(self.pointers) V_delta_minus=self.Delta_minus(self.pointers) DV_check=self.KeysToList(self.pointers) for xin V_delta_plus: if xnot in DV_check: DV_check.append(x) UV_check=copy.deepcopy(DV_check) s_p=self.vertices[0] t_p=self.vertices[-1] self.forbidenD=[] self.forbidenU=[] D=[x for xin DV_check if (x!=t_p and xnot in V_delta_minus)] U=[x for xin UV_check if (x!=s_p and xnot in V_delta_plus)] for din D: self.forbidenD.append(d) for uin U: self.forbidenU.append(u) DG=copy.deepcopy(self.pointers) UG=copy.deepcopy(self.pointers) 62 while len(D)!=0: for vertices in D: del DG[f'{vertices}'] V_delta_minus=self.Delta_minus(DG) DV_check=self.KeysToList(DG) D=[x for xin DV_check if (x!=t_p and xnot in␣ ,→V_delta_minus)] for din D: self.forbidenD.append(d) while len(U)!=0: for vertices in U: del UG[f'{vertices}'] V_delta_plus=self.Delta_plus(UG) UV_check=self.KeysToList(UG) U=[x for xin UV_check if (x!=s_p and xnot in␣ ,→V_delta_plus)] for uin U: self.forbidenU.append(u) self.DG=DG self.UG=UG for vin self.Forbidden_vertices: self.forbidenD.append(v) for vin self.Forbidden_vertices: self.forbidenU.append(v) return [DG,UG] #-- alg 7 end --# def returnvertices(self): return self.vertices def returnFvertices(self): return self.Forbidden_vertices def returnDFvertices(self): return self.forbidenD def returnUFvertices(self): return self.forbidenU def returnedges(self): return self.edges 63 def returngraph(self): return self.pointers def returncap(self): return self.cap def returnDG(self): return self.DG def returnDG(self): return self.UG def returnfullPreCubical(self): return self.SPC def GE_info(self,halfpruned=False): self.CreateGraph() self.fullPreCubical() self.PrunedGraph_FP(halfpruned) #appends P0 and P1 to P self.SPC.append(self.pointers) self.SPC.append(self.vertices) return self.SPC [2]: G=SGraph_FP([['Pa','Pb','Vb','Va'],['Pb','Pa','Va','Vb']]) By default the class supposes that every resource has capacity 1, i.e., the resource is a mutex. To change this we have a method “changecap()” where we can define the capacity for each resource. This must be done before creating the graph. [3]: print(f'As stated before this {G.returncap()}is the default capacities␣ ,→for the program p=[["Pa","Pb","Vb","Va"],["Pb","Pa","Va","Vb"]]') print('We can easely change the resources with the .changecap() and we␣ ,→get the updated dictonary') G.changecap('a',2) G.changecap('a',1) As stated before this {'a': 1, 'b': 1} is the default capacities for the␣ ,→program p=[["Pa","Pb","Vb","Va"],["Pb","Pa","Va","Vb"]] We can easely change the resources with the .changecap() and we get the␣ ,→updated dictonary {'a': 2, 'b': 1} {'a': 1, 'b': 1} 64 To create the coordinates of the vertices of the graph, i.e. for this example (0,0),(1,0),...,(4,4), we need a few steps. We start by sourcing from https://docs.python.org/3/library/itertools.html the function “product” that outputs the “cartesian product” with a modification that changes the input function to take a lists of integers inside a list. We convert [‘Pa’,‘Pb’,‘Va’,‘Vb’],[‘Pb’,‘Vb’,‘Pa’,‘Va’] to [[0, 1, 2, 3, 4],[0, 1, 2, 3, 4]] that will be the input to “product()” and we get Vof Gp. [4]: example_list=[] for vin G.product([[0,1,2,3,4],[0,1,2,3,4]]): example_list.append(v) print(example_list) [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3],␣ ,→[1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3],␣ ,→[3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4]] For the convertion we create a simple loop that gives vertices of each sequence [5]: for iin range(len([['Pa','Pb','Vb','Va'],['Pb','Pa','Va','Vb']])): print([k for kin␣ ,→range(len([['Pa','Pb','Vb','Va'],['Pb','Pa','Va','Vb']][i])+1)]) coordinates=[] for iin range(len([['Pa','Pb','Vb','Va'],['Pb','Pa','Va','Vb']])): coordinates.append([k for kin␣ ,→range(len([['Pa','Pb','Vb','Va'],['Pb','Pa','Va','Vb']][i])+1)]) [0, 1, 2, 3, 4] [0, 1, 2, 3, 4] The graph is going to be a dictionary where each key is a initial vertex of an edge and the results are the possible final vertices and the corresponding labels. For example, a given program [‘Pa’,‘Pb’,‘Va’,‘Vb’],[‘Pb’,‘Vb’,‘Pa’,‘Va’] there exists, for instance, the key [1,0] that will represent a initial vertex. The values of this key will be the final vertices [2,0] and [1,1] with the labels ‘Pa’ and ‘Pb’, respectively. The algorithm can be summed up with a simple example, given a vertex [i,j] of [‘Pa’,‘Pb’,‘Va’,‘Vb’],[‘Pb’,‘Vb’,‘Pa’,‘Va’] 65 else: pass if a==False: pass else: ele.append(EP) a=False return ele def inInterval(self,interval1,interval2): if interval2[0]<=interval1[0]<=interval1[1]<=interval2[1]: return True else: return False def inInterval(self,interval1,interval2): if interval2[0]<=interval1[0]<=interval1[1]<=interval2[1]: return True else: return False def geometricrealization(self): # # for nin range(len(self.PrecubicalSet)): Pnkeys=list(self.PrecubicalSet[n].keys()) Pnkeyslist=self.KeysToList(self.PrecubicalSet[n]) elePn=[] for iin range(len(Pnkeys)): elePn=self.createIntervals(Pnkeyslist[i],n,elePn) self.SetInR.append(elePn) for lin range(len(self.SetInR)): if self.SetInR[l] is None or len(self.SetInR[l])==0: self.SetInR[l]=f'P{l}Merged with another Pi' else: pass return self.SetInR #-- alg 5 end --# #-- alg 6 start --# def VerinInter(self,V,I): 72 Lb=I[0] Ub=I[1] n=len(Lb) for vin V: if all([Lb[j]<=v[j]<=Ub[j] for jin range(n)]): return True else: pass return False def Inbounds(self,I_bounded): Lb=I_bounded[0] Ub=I_bounded[1] n=len(Lb) if all([Lb[j]<=Ub[j] for jin range(n)]): return True else: pass return False def alg6(self,V): #li=[len(p_1),...,len(p_n)], V vertices we want␣ ,→to remove li=self.vertices[-1] n=len(li) G_1=[0for iin range(n)] G_2=[li[i] for iin range(n)] set_Gamma=[[G_1,G_2]] setClean_Gamma=[] while len(V)!=0: v=V[0] r=0 for iin range(len(set_Gamma)): x=copy.deepcopy(set_Gamma[i-r]) Lb=x[0] Ub=x[1] if all([Lb[j]<=v[j]<=Ub[j] for jin range(n)]): set_Gamma.remove(x) r+=1 for kin range(n): splits=[] split_1=copy.deepcopy(x) split_2=copy.deepcopy(x) split_1[1][k]=v[k]-1 split_2[0][k]=v[k]+1 if self.Inbounds(split_1): splits.append(split_1) if self.Inbounds(split_2): splits.append(split_2) 73 for split in splits: if self.VerinInter(V,split): set_Gamma.append(split) else: setClean_Gamma.append(split) else: pass V.remove(v) unique_setClean_Gamma =[] for region in setClean_Gamma: if region not in unique_setClean_Gamma: unique_setClean_Gamma.append(region) print(unique_setClean_Gamma) return unique_setClean_Gamma #-- alg 6 end --# def returnvertices(self): return self.vertices def returnprecubicalset(self): return self.PrecubicalSet def returngraph(self): return self.pointers def returnGR(self): return self.SetInR The input for this class is a precubical set [Pn(dictionary),Pn-1(dictionary),…,P3(dictionary),P2(dictionary),P1(graph with labels),P0(list of vertices)] and the output is [n-topological cubes,(n-1)-topological cubes,…,1-topological cubes]. To make it as simple as possible, class “SGraph_FP” comes with a method “GE_info()” that outputs the input for this new class that implements algorithm 5. [14]: %%capture G2=SGraph_FP([['Pa','Pb','Vb','Va'],['Pb','Pa','Va','Vb']]) GR=GeometricRealization(G2.GE_info()) GR.geometricrealization() This method converts the elements of [v1,..., vn]:[w1,..., wn]=x∈ ä(Gp)ito [v1,w1]× ··· × [v1,w2]as a list [[v1,w1],...,[vn,wn]]. [15]: GR.returnGR() 74 [15]: [[[[0, 1], [0, 1]], [[0, 1], [3, 4]], [[3, 4], [0, 1]], [[3, 4], [3,␣ ,→4]]], [[[0, 0], [1, 2]], [[0, 0], [2, 3]], [[1, 2], [0, 0]], [[1, 2], [4, 4]], [[2, 3], [0, 0]], [[2, 3], [4, 4]], [[4, 4], [1, 2]], [[4, 4], [2, 3]]]] One easily sees that the algorithm 6 also follows very closely the theory. [16]: barV=copy.deepcopy(G.returnFvertices()) barV [16]: [[1, 2], [2, 1], [2, 2], [2, 3], [3, 2]] [17]: PrunnedSpace=GR.alg6(barV) [[[0, 0], [0, 4]], [[2, 0], [4, 0]], [[0, 0], [1, 1]], [[3, 0], [4, 1]],␣ ,→[[0, 0], [4, 0]], [[0, 3], [1, 4]], [[3, 3], [4, 4]], [[0, 4], [4, 4]], [[2,␣ ,→4], [4, 4]], [[4, 0], [4, 4]], [[4, 2], [4, 4]]] [18]: import plotgamma li=GR.returnvertices()[-1] plotgamma.overlap(li,PrunnedSpace) 75 76 77 78 χ−1(|ä(Dˇ Gp)|) [19]: DbarV=copy.deepcopy(G.returnDFvertices()) PrunnedSpaceDG=GR.alg6(DbarV) plotgamma.overlap(li,PrunnedSpaceDG) [[[0, 0], [0, 4]], [[0, 0], [4, 0]], [[0, 2], [0, 4]], [[2, 0], [4, 0]],␣ ,→[[0, 3], [1, 4]], [[3, 3], [4, 4]], [[0, 4], [4, 4]], [[2, 4], [4, 4]], [[4,␣ ,→0], [4, 4]], [[3, 0], [4, 1]], [[4, 2], [4, 4]]] 79 80 χ−1(|ä(Uˇ Gp)|) [20]: UbarV=copy.deepcopy(G.returnUFvertices()) PrunnedSpaceUG=GR.alg6(UbarV) plotgamma.overlap(li,PrunnedSpaceUG) [[[4, 0], [4, 4]], [[0, 4], [4, 4]], [[0, 0], [0, 4]], [[0, 0], [0, 2]],␣ ,→[[2, 0], [2, 0]], [[0, 0], [1, 1]], [[0, 0], [2, 0]], [[2, 0], [4, 0]], [[3,␣ ,→0], [4, 1]], [[0, 0], [4, 0]], [[0, 3], [1, 4]], [[0, 4], [2, 4]], [[2, 4], [2,␣ ,→4]], [[4, 0], [4, 2]], [[4, 2], [4, 2]]] 81