On Stochastic Rewriting and Combinatorics via Rule-Algebraic Methods
PP. Bahr (Ed.): 11th International Workshop onComputing with Terms and Graphs (TERMGRAPH 2020)EPTCS 334, 2021, pp. 11–28, doi:10.4204/EPTCS.334.2 © N. BehrThis work is licensed under theCreative Commons Attribution License.
On Stochastic Rewriting and Combinatoricsvia Rule-Algebraic Methods *Nicolas Behr
Universit´e de Paris, CNRS, IRIFF-75006, Paris, France [email protected]
Building upon the rule-algebraic stochastic mechanics framework, we present new results on therelationship of stochastic rewriting systems described in terms of continuous-time Markov chains,their embedded discrete-time Markov chains and certain types of generating function expressions incombinatorics. We introduce a number of generating function techniques that permit a novel formof static analysis for rewriting systems based upon marginalizing distributions over the states of therewriting systems via pattern-counting observables.
An important aspect of the standard theory of continuous-time Markov chains (CTMCs) [23] concernsthe well-known fact that the CTMC semantics may be equivalently described via a pair of discrete-timeMarkov chains (DTMCs), where the so-called embedded DTMC encodes the probabilities for each of thepossible transitions, and with the second DTMC encoding the jump-times for the transitions. This featurepermits to design algorithms for simulating
CTMCs, for instance in the form of Gillespie’s stochasticsimulation algorithms for chemical reaction systems [20], but in particular also in several variations forthe simulation of stochastic rewriting systems, such as via the
KaSim simulation engine of the Kappaplatform [13]. The main contribution of the present paper consists in uncovering a hitherto unknownintimate relationship between three types of moment generating functions that are constructable from thedata that specifies a stochastic rewriting system, and for a chosen set of pattern count observables : thoseof the CTMC itself, those of the embedded DTMC, and those of the (weighted) combinatorial speciesgenerated by the rewriting rules.
The methodology developed in the present paper relies heavily upon the mathematical formalism intro-duced in [2, 3, 9, 4, 7, 10], yet due to space restrictions, we will only provide some notations and essentialdefinitions here, inviting the interested readers to consult loc. cit. for the full technical details.
Throughout this paper, we will consider categorical rewriting theories over categories that satisfy thefollowing sets of properties (with DPO- and SqPO-semantics to be introduced below) : * The author would like to thank Paul-Andr´e Melli`es and Noam Zeilberger for fruitful discussions and valuable feedback. We invite the readers to consult [6] or [7] for compact accounts of the relevant technical definitions of M -adhesive cate-gories, pullbacks, pushouts, pushout complements, final pullback complements and their respective properties. On Stochastic Rewriting and Combinatorics
Assumption 1 (cf. [7], As. 1) . C ≡ ( C , M ) is a finitary M -adhesive category with M -initial object, M -effective unions and epi- M -factorization. In the setting of Sesqui-Pushout (SqPO) rewriting , weassume in addition that all final pullback complements (FPCs) along composable pairs of M -morphismsexist, and that M -morphisms are stable under FPCs. Definition 1 ([21, 18]) . Conditions over objects X ∈ obj ( C ) are defined recursively: true X is a condition;for any M -morphism ( X (cid:44) → Y ) and for any condition c Y over Y , ∃ ( X (cid:44) → Y , c Y ) is a condition; ¬ c X and c ( ) X ∧ c ( ) X are conditions if c X , c ( ) X , c ( ) X are conditions. Satisfaction of a condition c X by a M -morphism ( a : X (cid:44) → Z ) , denoted a (cid:15) c X , is also defined recursively: a satisfies true X ; a satisfies ∃ ( X (cid:44) → Y , c Y ) ifthere exists a M -morphism ( b : Y (cid:44) → Z ) such that b (cid:15) c Y and a = b ◦ ( Y ← (cid:45) X ) ; a (cid:15) ¬ c X if not a (cid:15) c X ,and a (cid:15) c ( ) X ∧ c ( ) X if a (cid:15) c ( ) X and a (cid:15) c ( ) X . Two conditions c X and c (cid:48) X are defined to be equivalent , denoted c X ≡ c (cid:48) X , if a (cid:15) c X ⇔ a (cid:15) c (cid:48) X for all M -morphisms ( a : X (cid:44) → Y ) . By standard convention, ∃ ( a ) ≡ ∃ ( a , true ) and ∀ ( a , c Y ) ≡ ¬∃ ( a , ¬ c Y ) . We denote the class of all conditions over objects of C by cond ( C ) .Throughout this work, we will be exclusively interested in the following notion of rewriting rules : Definition 2.
Let
Lin ( C ) ∼ denote the set of equivalence classes of M -linear rules Lin ( C ) [6], Lin ( C ) ∼ : = { R = ( r = ( O o ←− K i −→ I ) , c I ) | o , i ∈ M , c I ∈ cond ( C ) } (cid:30) ∼ , (1)where R ∼ R (cid:48) iff there exist isomorphisms ( ω : O → O (cid:48) ) , ( κ : K → K (cid:48) ) and ( ι : I → I (cid:48) ) such that ω ◦ o = o (cid:48) ◦ κ and ι ◦ i = i (cid:48) ◦ κ , and if in addition c I ≡ c (cid:48) I (i.e. if ∀ ( m : I (cid:44) → X ) ∈ M : m (cid:15) c I ⇔ m (cid:15) c (cid:48) I ).The two key definitions of rewriting theory for the formulation of rule algebras (cf. Section 2.2) arethe definition of the action of rules on objects and of the sequential composition of rules . Definition 3 (Direct derivations; cf. [7], Def. 3) . Let r = ( O ← (cid:45) K (cid:44) → I ) ∈ Lin ( C ) and c I ∈ cond ( C ) beconcrete representatives of some equivalence class R = [( r , c I )] ∼ ∈ Lin ( C ) ∼ , and let X , Y ∈ obj ( C ) beobjects. Then a type T direct derivation is defined as a commutative diagram such as below right, whereall morphism are in M (and with the left representation a shorthand notation) O IY X m ∗ mr T : = O K IY K X m ∗ k ( B ) ( A ) m . (2)with the following pieces of information required relative to the type:1. T = DPO : given ( m : I (cid:44) → X ) ∈ M , m is a DPO-admissible match of R into X , denoted m ∈ M DPO R ( X ) , if m (cid:15) c I and ( A ) is constructable as a pushout complement , in which case ( B ) is con-structed as a pushout .2. T = SqPO : given ( m : I (cid:44) → X ) ∈ M , m is a SqPO-admissible match of R into X , denoted m ∈ M SqPO R ( X ) , if m (cid:15) c I , in which case ( A ) is constructed as a final pullback complement and ( B ) as a pushout .3. T = DPO † : given just the “plain rule” r and ( m ∗ : O (cid:44) → Y ) ∈ M , m ∗ is a DPO † -admissible matchof r into X , denoted m ∈ M DPO † r ( Y ) , if ( B ) is constructable as a pushout complement , in which case ( B ) is constructed as a pushout . Note that while
Lin ( C ) is typically a proper class (i.e. of M -linear rules with conditions), we make the tacit assumption herethat Lin ( C ) ∼ forms a set. We opt throughout this paper for a “right-to-left” convention for rules and their compositions that isnon-standard w.r.t. the standard graph rewriting literature, yet which is preferable in the setting of rule-algebraic computations.This is due to rules r giving rise to linear operators ρ ( δ ( r )) (Definition 7) which by standard mathematical convention left-compose, whence our notational convention is ultimately motivated by the representation property stated in Theorem 1. . Behr T ∈ { DPO , SqPO } , we will sometimes employ the notation R m ( X ) for the object Y . Definition 4.
For rewriting of type T ∈ { DPO , SqPO } , X ∈ obj ( C ) ∼ = and a set of rules R = { R j } nj = ,we recursively define a family of reachability relations {⇒ ( i ) } i ≥ on obj ( C ) × ∼ = as X ⇒ ( ) Y iff ∃ R ∈ R , m ∈ M T R ( X ) : Y ∼ = R m ( X ) ∀ n ≥ X ⇒ ( i + ) Y iff ∃ Z ∈ obj ( C ) ∼ = , R ∈ R , m ∈ M T R ( Z ) : Y ∼ = R m ( Z ) ∧ X ⇒ ( i ) Z . (3) Definition 5 (Rule compositions; cf. [7], Def. 4) . Let R , R ∈ Lin ( C ) ∼ be two equivalence classesof rules with conditions, and let r j ∈ Lin ( C ) and c I j be representatives of R j (for j = , T ∈{ DPO , SqPO } , a span µ = ( I ← (cid:45) M (cid:44) → O ) of M -morphisms is a T -admissible match of R into R ,denoted µ ∈ M T R ( R ) , if the diagram below is constructable (with N constructed by taking pushout) O I M O I O N I r T PO DP O † r (4)and if c I (cid:54) ˙ ≡ false . Here, the condition c I is computed as (cf. [7] for the definitions of Shift and
Trans ) c I : = Shift ( I (cid:44) → I , c I ) ∧ Trans ( N (cid:40) I , Shift ( I (cid:44) → N , c I )) . (5)In this case, we define the type T composition of R with R along µ , denoted R µ (cid:47) T R , as R µ (cid:47) T R : = [( O (cid:40) I ; c I )] ∼ , (6)where ( O (cid:40) I ) : = ( O (cid:40) N ) ◦ ( N (cid:40) I ) (with ◦ the span composition operation). Referring yet again to [6, 7] for the full technical details, suffice it here to quote the essential definitions:
Definition 6 ( Rule algebras ; [7], Def. 5) . Let T ∈ { DPO , SqPO } be the rewriting type, and let C be acategory satisfying the relevant variant of Assumption 1. Let R C be an R -vector space, defined via abijection δ : Lin ( C ) ∼ ∼ = −→ basis ( R C ) from the set of equivalence classes of linear rules with conditions tothe set of basis vectors of R C . Let (cid:63) T denote the type T rule algebra product , a binary operation definedvia its action on basis elements δ ( R ) , δ ( R ) ∈ R C (for R , R ∈ Lin ( C ) ∼ ) as δ ( R ) (cid:63) T δ ( R ) : = ∑ µ ∈ M T R ( R ) δ ( R µ (cid:47) T R ) . (7)We refer to R T C : = ( R C , (cid:63) T ) as the T -type rule algebra over C . Definition 7 (Representations; [7], Def. 6) . Let ˆ C be defined as the R -vector space whose set of basisvectors is isomorphic to the set of iso-classes of objects of C via a bijection | . (cid:105) : obj ( C ) ∼ = → basis ( ˆ C ) .Then the T -type canonical representation of the T -type rule algebra over C , denoted ρ T C , is defined asthe morphism ρ T C : R T C → End R ( ˆ C ) specified via ∀ R ∈ Lin ( C ) ∼ , X ∈ obj ( C ) ∼ = : ρ T C ( δ ( R )) | X (cid:105) : = ∑ m ∈ M T R ( X ) | R m ( X ) (cid:105) . (8)The salient part of the rule-algebra framework in view of computational techniques is the followingresult on the interaction of the rule algebra product and the notion of representations: Theorem 1 ([7], Thm. 3) . ρ T C is an algebra homomorphism , i.e. (for ρ ≡ ρ T C ) ( i ) ρ ( δ ( R ∅ )) = Id End ( ˆ C ) ( ii ) ρ ( δ ( R )) ρ ( δ ( R )) = ρ ( δ ( R ) (cid:63) T δ ( R )) . (9)4 On Stochastic Rewriting and Combinatorics
For either DPO- or SqPO-type rewriting semantics over a category C satisfying Assumption 1 a stochas-tic rewriting system (SRS) is specified via providing the following pieces of data:1. An input state , i.e. a probability distribution indexed by isomorphism classes of objects of C : | Ψ (cid:105) = ∑ X ∈ obj ( C ) ∼ = p X ( ) | X (cid:105) (10)2. A set of transitions { ( κ j , R j ) } nj = , whence a set of (finitely many) pairs of base rates κ j ∈ R > and linear rules with conditions R j ∈ Lin ( C ) , with R j = ( r j , c I j ) . Example 1.
Consider the case where C = FinSet (the finitary restriction of the category of sets and setfunctions), with an input state a “pure state” | Ψ (cid:105) = | ∅ (cid:105) (i.e. a probability distribution with probabilityone for the state associated to the empty set), and with a transition set given by { ( κ + , R + ) , ( κ − , R − ) } ,where R + : = ( • ← ∅ → ∅ , c + ) and R − : = ( ∅ ← ∅ → • , c − ) . If c + = c − = true , we reproduce preciselya classical birth-death process (with initial state the state with no “particles”). However, we may as wellchoose non-trivial conditions, for example c ( )+ = ∃ ( ∅ (cid:44) → • • • ) , in which case we would obtain a systemin which once the number of vertices falls below 3 vertices, the “death” transition will with probability 1eventually delete all remaining vertices.Back to the general stochastic mechanics framework, we assemble from the input data the definitionof a CTMC as follows (with ρ ≡ ρ T C , T ∈ { DPO , SqPO } and ˆ O T as in (14) of Section 3.1 below): ddt | Ψ ( t ) (cid:105) = H | Ψ ( t ) (cid:105) , | Ψ ( ) (cid:105) = | Ψ (cid:105) H : = ˆ H + H O , ˆ H = ρ ( h ) , H O = − ˆ O T ( h ) , h = n ∑ j = κ j ρ ( δ ( R j )) . (11)Compared to the traditional CTMC literature [23], note that ˆ H is a linear operator with off-diagonal non-negative entries only, while H O is a diagonal linear operator with non-positive entries. In order todemonstrate that H indeed qualifies as a so-called infinitesimal stochastic operator (also referred to asconservative stable Q -matrix), note that by virtue of the jump-closure property (cf. (14) in Section 3.1), (cid:104)| H = (cid:104)| ( ˆ H + H O ) = (cid:104)| ( ρ ( h ) − O ( h )) = R . (12)In other words, the above equation expresses that each row of H sums to zero, which together withthe (non-) negativity of the off- and on-diagonal entries confirms that H is a valid infinitesimal CTMCgenerator. Unlike in the setting of chemical reaction systems or, equivalently, of rewriting systems over vertex-onlygraphs, where certain combinatorial techniques exist to directly compute the full solution for | Ψ ( t ) (cid:105) (cf.e.g. [4]), as it stands the definition of a CTMC for a stochastic rewriting system provided in (11) doesnot lend itself easily in its own right for practical computations. Intuitively, for a stochastic rewritingsystem such as the one we will study in detail in Section 5 evolving over planar rooted binary trees(PRBTs), the set of isomorphism classes reachable even in a very small number of transitions and givena “pure” input state | Ψ (cid:105) = | X (cid:105) (for some iso-class X ) can be of an enormous size and complexity. For . Behr ≈ isomorphism classes of PRBTs reachable in just 100 iterationsof the R´emy generator studied in Section 5. Since CTMC theory describes the time-evolution of theprobability distribution | Ψ ( t ) (cid:105) over all states reachable by the transitions from the input state, it is inpractice very often entirely infeasible to aim for a direct calculation of | Ψ ( t ) (cid:105) itself.The remedy for the aforementioned conceptual problem is the introduction of the concept of patterncount observables . Referring to [7] for the precise derivation, depending on the rewriting semantics T ∈ { DPO , SqPO } utilized, let us introduce the following definitions:ˆ O P , q ; c P : = ρ DPO C (cid:16) δ (cid:16) P q ←− Q q −→ P , c P (cid:17)(cid:17) , ˆ O P ; c P : = ρ SqPO C (cid:16) δ (cid:16) P id ←− P id −→ P , c P (cid:17)(cid:17) (13)To better understand the meaning of the above definitions, it is important to note the so-called jump-closure properties of DPO- and SqPO-types, respectively (cf. [7, Thm. 4]): ∀ R = ( O o ←− K i −→ I , c I ) ∈ Lin ( C ) : (cid:104)| ρ T C ( δ ( R )) = (cid:104)| ˆ O T ( δ ( R )) ˆ O DPO ( δ ( R )) : = ˆ O I , i ; c I , ˆ O SqPO ( δ ( R )) : = ˆ O I ; c I . (14)In other words, ˆ O I , i ; c I and ˆ O I ; c I permit to count the number of matches of the rule R = ( O o ←− K i −→ I , c I ) in DPO- and SqPO-semantics, respectively. More explicitly, we find that (cid:104)| ˆ O I , k ; c I | X (cid:105) = | M DPO ( I i ←− K i −→ I , c I ) ( X ) | = | M DPO ( O o ←− K i −→ I , c I ) ( X ) |(cid:104)| ˆ O I ; c I | X (cid:105) = | M SqPO ( I id ←− I id −→ I , c I ) ( X ) | = | M SqPO ( O o ←− K i −→ I , c I ) ( X ) | . (15) Example 2.
The simplest type of observables encountered in practice are the “plain” pattern-countingobservables ˆ O P = ˆ O P , id P ; true = ˆ O P ; true , with typical examples including ˆ O • (counting vertices ), ˆ O • • (counting pairs of vertices ) and ˆ O •−• (counting (undirected) edges ). In contrast, for example in DPOrewriting the variant ˆ O • , ∅ (cid:44) →• ; true effectively counts vertices that are not linked to any other vertices via in-cident edges, whence by (15) in particular ˆ O • , ∅ (cid:44) →• ; true (cid:54) = ˆ O • ; true , while in both DPO- and SqPO-rewriting,ˆ O • • , • • (cid:44) →• • ; ¬∃ ( • • (cid:44) →•−• ) = ˆ O • • ; ¬∃ ( • • (cid:44) →•−• ) yields a linear operator that in effect counts pairs of vertices not linked by an edge. As advocated in [3, 10, 2, 4, 7], observables are a crucial concept in rule-algebraic rewriting theory, sinceit will often be the case that one considers distributions over isomorphism classes of objects in the givencategory, which due to the typically enormous number of such classes cannot be computed explicitly, orwould even be insensible to compute. Instead, choosing a set of pattern-counting observables permitsto extract partial information from the distributions, which may then provide important insights on thebehavior of the rewriting system.
Definition 8.
Given a stochastic rewriting system as defined in (11), and for a finite set of observables { ˆ O , . . . ˆ O m } , the exponential moment-generating function (EMGF) M ( t ; ω ) is defined as M ( t ; ω ) : = (cid:104)| e ω · ˆ O | Ψ ( t ) (cid:105) . (16)Here, we employed the shorthand notation ω · ˆ O : = ∑ mj = ω j ˆ O j , with ω , . . . , ω m formal variables . Here, = is the equality of linear operators, whereby two linear operators are equal if they agree in every matrix entry. On Stochastic Rewriting and Combinatorics
The interpretation of M ( t ; ω ) is that it serves as a form of bookkeeping device for all (joint) momentsof the chosen observables, in the sense that one may expand (16) into a formal power series of the form M ( t ; ω ) = ∑ k ≥ ω k k ! (cid:104)| ˆ O k | Ψ ( t ) (cid:105) , x k ≡ x k · · · x k m m . (17)As a caveat, one should note that it depends strongly on the chosen rewriting system whether or notthe formula for M ( t ; ω ) is mathematically well-posed, in the sense that all moments exist and are finite.Since currently no general theory for providing conditions on the rewriting system that ensure these prop-erties, one must resort in practice to either simulation data or to other empirical methods in order to (atleast approximately) verify the well-posedness. Setting these technical issues aside, the main motivationfor studying exponential moment-generating functions is the fact that if indeed all moments exist and arefinite, there exists a Legendre transform from M ( t ; ω ) to the probability-generating function P ( t ; x ) (i.e.a change of variables ω j → ln x j for j = , . . . , m ): P ( t ; x ) : = M ( t ; ln x ) . (18) Lemma 1.
The formal power series P ( t ; x ) is the ordinary probability-generating function for the countsn , . . . , n m of the observables ˆ O , . . . , ˆ O m , which entails that with n j ( X ) : = (cid:104)| ˆ O j | X (cid:105) (for j = , . . . , m),P ( t ; x ) = ∑ n ≥ x n p n ( t ) , p n ( t ) : = Pr ( { X ∈ obj ( C ) ∼ = | n ( X ) = n } | at time t ) . (19) Proof.
Starting from the definition of M ( t ; ω ) and (18), P ( t ; x ) = M ( t ; ln x ) = (cid:104)| x ˆ O | Ψ ( t ) (cid:105) = ∑ X ∈ obj ( C ) ∼ = p X ( t ) (cid:104)| x ˆ O | X (cid:105) = ∑ X ∈ obj ( C ) ∼ = p X ( t ) x n ( X ) (cid:104) | X (cid:105) . (20)Since by definition (cid:104) | X (cid:105) = R , this is almost of the form in (19), except that the summation is not overthe values of observable counts, but instead over the possible states (i.e. isomorphism classes of objects).However, as is a well-known technique in the combinatorics literature [19], since | Ψ ( t ) (cid:105) is a probabilitydistribution over a countable space of states (i.e. of isomorphism classes of objects of C ), the remainingargument is a simple re-partition of the probability distribution of the form ∑ X ∈ obj ( C ) ∼ = p X ( t ) x n ( X ) = ∑ n ≥ (cid:0) = : p n ( t ) (cid:122) (cid:125)(cid:124) (cid:123) ∑ X ∈ obj ( C ) ∼ = n ( X )= n p X ( t ) (cid:1) x n . (21)To summarize this part of the general framework, let us emphasize that the passage from exponentialmoment-generating functions to probability-generating functions in principle permits to extract somevery detailed information from stochastic rewriting systems, with some worked examples of this kindto be found in [10, 2, 4, 7]. Modulo the question of how to practically compute either the exponentialmoment- or the probability-generating functions, we have thus obtained a method to project the typicallyextremely large state-spaces to the more tractable subspaces in which the state-space is partitioned intosubspaces determined by the values of the counts of a given set of pattern observables. . Behr The concept of exponential moment-generating functions (EMGFs) for stochastic rewriting systemsopens the possibility for a form of static analysis technique that aims at computing the time-dependentEMGF from an evolution equation , based upon the following key result:
Theorem 2 ([4], Thm. 3.24) . For a CTMC such as in (11) , an EMGF M ( t ; ω ) as defined in (16) satisfiesthe formal evolution equation ∂∂ t M ( t ; ω ) = ∑ q ≥ q ! (cid:104)| (cid:16) ad ◦ q ω · ˆ O ( ˆ H ) (cid:17) e ω · ˆ O | Ψ ( t ) (cid:105) , (22) where the adjoint action ad is recursively defined for any two endomorphisms A , B ∈ End ( ˆ C ) asad ◦ A ( B ) : = A , ∀ q > ad ◦ ( q + ) A ( B ) = [ A , ad ◦ qA ( B )] . (23) Here, [ A , B ] : = AB − BA is referred to in the mathematics literature as the commutator of A and B.
As it stands, the formal evolution equation in (22) is not of any computational value, since a priori itis not possible to evaluate concretely the infinite series of coefficients. However, there exists a criterionwhose satisfaction permits to proceed further:
Definition 9 ([4], Def. 4.1) . A set of observables ˆ O , . . . , ˆ O m (for finite m ) is polynomially jump-closed with respect to a CTMC as in (11) if the following conditions hold true: ( PJC ) ∀ q ∈ Z > : ∃ N ( n ) ∈ Z m ≥ , γ q ( ω , k ) ∈ R : (cid:104)| ad ◦ q ω · ˆ O ( ˆ H ) = N ( q ) ∑ k = γ k ( ω , k ) (cid:104)| ˆ O k . (24)Polynomial jump-closure has the benefit of permitting to transform the formal evolution equationof (22) into a computationally much more accessible evolution equation on formal power series, a processreferred to in [4] as combinatorial conversion : Theorem 3 ([4], Thm. 4.2) . Let ˆ O , . . . , ˆ O m be a (finite) set of pattern observables that is polynomiallyjump-closed with respect to a CTMC as in (11) . Then the EMGF M ( t ; ω ) satisfies the evolution equation ∂∂ t M ( t ; ω ) = D ( ω , ∂ ω ) M ( t ; ω ) , D ( ω , ∂ ω ) : = (cid:16) (cid:104)| e ad ω · ˆ O ( H ) (cid:17)(cid:12)(cid:12)(cid:12) ˆ O (cid:55)→ ∂ω (25)Referring to [4, 7] for a number of applications of the above theorem, suffice it here for brevity tomention that the theorem in favorable cases permits to establish a direct contact between techniquesintroduced in applied research fields such as network, physical and social sciences on the one hand, andrewriting-theoretic methods on the other hand. We envision that the rich theory of analytical combinatorics [19] with its numerous computational meth-ods for reasoning about pattern counts in combinatorial structures and in particular about their asymptoticbehavior in the limit of large structure sizes could harbor an enormous potential also for reasoning aboutstochastic rewriting systems. For instance, certain aspects of combinatorial theory parallel surprisinglyclosely the notions of M -adhesive categories, concretely the various operations that permit to obtain8 On Stochastic Rewriting and Combinatorics valid specifications of combinatorial species from simpler species, which strikingly resemble the opera-tions listed in the work of Ehrig [17] for generating M -adhesive categories from M -adhesive categories(e.g. the operations of sum, product, functor and comma categories). Yet to date, this clear correspon-dence is not straightforward to exploit, in part since many combinatorial specifications of graph-likestructures require in effect the theory of M -adhesive categories combined with structural constraints inorder to encode them rewriting-theoretically, but more importantly since generating-function techniquesare not in the least common-place in rewriting theory. As a modest first step towards a rewriting-basedvariant of combinatorial theories, we introduce here a notion of multi-variate generating functions thatpermits to much more clearly compare the combinatorial theory with rewriting theory. In Section 5, wewill moreover present a complete worked example in order to illustrate this new viewpoint.Consider a rewriting system over some suitable category C that consists of a finite set of rules withconditions R , . . . , R n ∈ Lin ( C ) . For some choice of parameters γ , . . . , γ n ∈ R , define a linear operatorˆ G : = n ∑ j = γ j ρ ( δ ( R j )) . (26)The readers will immediately notice that ˆ G has a natural interpretation as a linear operator that encodes“application of the rules R , . . . , R n in all possible ways, and weighted by the parameters γ , . . . , γ n ”. Inclose analogy to the definition of exponential moment-generating functions (EMGFs) in the previoussection, if we in addition choose a (finite) set of pattern observables ˆ O , . . . , ˆ O m , we may define what isconventionally also referred to as an EMGF (albeit this time not for moments of a probability distribution,but of an arbitrary distribution): G ( λ ; ω ) : = (cid:104)| e ω · ˆ O e λ ˆ G | X (cid:105) (27)Here, we chose an “initial state” | X (cid:105) ∈ ˆ C , yet we could have in principle equally well chosen somearbitrary “initial distribution” | Φ ( ) (cid:105) (possibly subject to suitable summability conditions). Equippedwith the insights from the previous section, it is straightforward to develop the analogue of the formalEMGF evolution equation for G ( λ ; ω ) : ∂∂λ G ( λ ; ω ) = (cid:104)| (cid:16) e ad ω · ˆ O ˆ G (cid:17) e ω · ˆ O e λ ˆ G | X (cid:105) (28)Applying the version of the jump-closure theorem appropriate for the chosen rewriting semantics (DPOor SqPO), the above formal evolution equation may be converted into a proper evolution equation onformal power series if the following modified version of polynomial jump-closure holds: ( PJC (cid:48) ) ∀ q ∈ Z ≥ : ∃ N ( n ) ∈ Z m ≥ , γ q ( ω , k ) ∈ R : (cid:104)| ad ◦ q ω · ˆ O ( ˆ G ) = N ( q ) ∑ k = γ k ( ω , k ) (cid:104)| ˆ O k (29)If a given set of observables satisfies ( PJC (cid:48) ) , the formal evolution equation (24) for the EMGF G ( λ ; ω ) may be refined into ∂∂λ G ( λ ; ω ) = G ( ω , ∂ ω ) G ( λ ; ω ) , G ( ω , ∂ ω ) = (cid:16) (cid:104)| e ad ω · ˆ O ( ˆ G ) (cid:17)(cid:12)(cid:12)(cid:12) ˆ O (cid:55)→ ∂ω . (30) In modern standard approaches to combinatorics such as described in the seminal book [19], the centraltechnical tool consists in the theory of combinatorial species . According to the work of A. Joyal [22], . Behr F -structure) consists in providing afunctor F : B → B , where B : = FinSet ∗ denotes the groupoid of finite sets and bijections B = FinSet ∗ .The functoriality of F entails in particular that if F [ A ] is an F -structure for a given set of “labels” A , andif f : A → B is an isomorphism of finite sets (i.e. a morphism of B ), then one obtains a morphism of F -structures F [ f ] : F [ A ] → F [ B ] that is also an isomorphism (since functors preserve isomorphisms). Onthe other hand, two finite sets A and B can only be isomorphic if they have the same number of elements, | A | = | B | , thus we recover the more intuitive interpretation of F -structures as “structures induced by F and invariant under relabeling”. We posit that in situations where the combinatorial species is of a certain“graph-like nature” (to be specified in further details momentarily), it may be advantageous to considerinstead of classical species theory an alternative approach that is based upon category-theoretical struc-ture of the combinatorial structures other than the defining species structure. More precisely, in the casewhere the species at hand is either giving rise to an (finitary) M -adhesive category [14], or wheneverthe structure arises as the restriction of such a category via imposing constraints in the sense of [21](see also [6] for further details), one may utilize rule-algebraic techniques to analyze these combinatorialstructures. While we postpone a detailed analysis of precisely which prerequisites are necessary for acombinatorial species defined in terms of a species functor to also possess the structure of (a restriction ofan) M -adhesive category to future work, in this paper we follow the pragmatic approach of introducingthe computational theory of rule-algebra based formal moment evolution equations, and then illustratethis approach with the application example of studying the species of planar rooted binary trees (PRBTs) .In order to give an interpretation to G ( λ ; ω ) within the theory of combinatorics, consider first thespecial case of setting all formal parameters ω , . . . , ω m to zero: G ( λ ; 0 ) = ∑ n ≥ λ n n ! (cid:104)| ˆ G n | X (cid:105) ≡ ∑ n ≥ λ n n ! g n (31)Since ˆ G n | X (cid:105) is nothing but a distribution over all outcomes of applying n rewriting steps with rulesfrom the given rule-set in all possible ways, and with weights given by the parameters γ , . . . , γ n , onemay recognize G ( λ ; 0 ) as the exponential generating function (EGF) of some weighted combinatorialspecies [11, 12]. To expose this feature more clearly, let {⇒ ( i ) } i > denote the reachability relation on obj ( C ) × ∼ = as introduced in (26) (with respect to the initial configuration X ∈ obj ( C ) ∼ = and the rule-set { R j } nh = used to define ˆ G ). Then one may view ˆ G as the generator of a (countable) set of structures S ˆ G , S ˆ G : = ∪ n > S ( n ) ˆ G , S ( n ) ˆ G : = (cid:40) { X } if n = { X ∈ obj ( C ) ∼ = | X ⇒ ( n ) X } if n > . (32)Since we assume X to be a finite object (in the sense of a finite number of M -subobjects), clearly eachof the sets S ( n ) ˆ G is of finite cardinality. In addition, the coefficients g n = (cid:104)| ˆ G n | X (cid:105) are evidently of finitevalue as well, which in summary permits the following repartition of the formal power series G ( λ ; 0 ) : G ( λ ; 0 ) = ∑ n ≥ λ n n ! ∑ X ∈ S ( n ) ˆ G g n ( X ) , g n ( X ) : = (cid:104) X | ˆ G n | X (cid:105) (33)Consequently, the configurations X ∈ S ( n ) ˆ G may be seen as the combinatorial structures contained in the n -th generation, with g n ( X ) the weight of a configuration X in the n -th generation. Recall that a groupoid is a category in which all morphisms are isomorphism; consequently, given an arbitrary category C (such as e.g. FinSet , the category of finite sets and total functions), one may obtain a groupoid C ∗ called the core of C viarestricting the morphisms of C to isomorphisms. On Stochastic Rewriting and Combinatorics
For generic values of ω , G ( λ ; ω ) evaluates as follows: G ( λ ; ω ) = ∑ n ≥ λ n n ! (cid:104)| e ω · ˆ O ˆ G n | X (cid:105) = ∑ n ≥ λ n n ! ∑ X ∈ S ( n ) ˆ G g n ( X ) e ω · N ( X ) , N i ( X ) : = (cid:104)| ˆ O i | X (cid:105) . (34) Given a linear operator ˆ G for which all of the parameters γ , . . . , γ n ∈ R are positive, and with initial state | X (cid:105) for some X ∈ obj ( C ) ∼ = , one may construct from this data a CTMC according to (11): H = ˆ H + H O , ˆ H : = ρ ( G ) = ˆ G , H O : = − ˆ O ( G ) , G : = n ∑ j = γ j δ ( R j ) (35)This raises an interesting question: what is the precise interpretation of the formal power series G ( λ ; ω ) in this particular setting? Recall first from (31) that the coefficients g n : = (cid:104)| ˆ G n | X (cid:105) are finite real numbers(by assumption of finiteness of X and of the rule-set defining ˆ G ), and due to the additional assumption γ , . . . , γ n of ˆ G made here, they are in fact positive real numbers. We may conclude in summary that g : = g n ∈ R > for all n ≥
0. Evidently, we also find that g n ( X ) ∈ R > for all n ≥ X ∈ S ( n ) ˆ G ,which leads to the following result: Lemma 2.
With notations as above, let the integral transformation ˆ I be implicitly defined via its action ˆ I ( s n ) : = g − n on the integration variable s, and let ˆ d denote the umbral transformation of ˆ G, defined via ˆ d n : = ˆ I (( s ˆ G ) n ) (for n ∈ Z ≥ ). Then the τ -dependent distribution | Φ ( τ ) (cid:105) : = e τ ˆ d | X (cid:105) = ∑ n ≥ τ n n ! ˆ d n | X (cid:105) (36) encodes a family of distributions | Φ n (cid:105) : = ˆ d n | X (cid:105) , where | Φ n (cid:105) is the result of the n-th step of the embed-ded discrete-time Markov chain (DTMC) of the CT MC ( H , | X (cid:105) ) . In particular, | Φ n (cid:105) is a probabilitydistribution , with coefficients p n ( X ) : = (cid:104) X | ˆ d n | X (cid:105) the probability of reaching state | X (cid:105) from the initialstate | X (cid:105) in n steps. The readers uncomfortable with the idea of employing some integral transformation in order to definethe DTMC generator ˆ d might alternatively prefer a more direct definition of ˆ d in the following form:ˆ d : = ˆ G · (cid:0) ˆ O ( G ) (cid:1) − ∗ , (cid:0) ˆ O ( G ) (cid:1) − ∗ | X (cid:105) : = (cid:40) G | X (cid:105) = R (cid:104)| ( ˆ O ( G ) | X (cid:105) | X (cid:105) otherwise. (37)Note that the order of ˆ G and (cid:0) ˆ O ( G ) (cid:1) − ∗ in the above formula is not exchangeable, and that we had todefine the formal inverse (cid:0) ˆ O ( G ) (cid:1) − ∗ of ˆ O ( G ) such that it evaluates to 1 (rather than the division by 0) for | X (cid:105) with ˆ G | X (cid:105) = R . However, from a purely computational viewpoint, the formulation of Lemma 2 isin practice more suitable in order to derive data about embedded DTMCs via evolution equations.In full analogy to the arguments for the rewriting-based CTMCs, one may introduce exponentialmoment-generating functions for the embedded DTMCs: D ( τ ; ω ) : = (cid:104)| e ω · O e τ ˆ d | X (cid:105) (38) This notation is motivated by the operational theory of umbral calculus presented in [5]. . Behr ( PJC (cid:48) ) of (29) with respect to ˆ G (and thus byextension also for ˆ d ). Assuming once again the existence and finiteness of all moments, the variabletransformations ω i → ln x i then induce the following evolution equation: ∂∂τ P ( τ ; x ) = ˆ d ( x , ∂ x ) P ( τ ; x ) , P ( τ ; x ) : = (cid:104)| x ˆ O e τ ˆ d | X (cid:105) , ˆ d ( x , ∂ x ) : = (cid:16) e ad ln x · ˆ O ( ˆ d ) (cid:17)(cid:12)(cid:12)(cid:12) ˆ O → ∂∂ x (39)As we will demonstrate in the next section, for suitable choices of ˆ G and observables, the above typeof evolution equation permits to statically analyze an induced DTMC that evolves not on the originalstate space ˆ C , but instead on a state space indexed by the vectors N ( X ) of pattern counts (with N i ( X ) : = (cid:104)| ˆ O i | X (cid:105) ). The interest in such types of observable-based marginalization of the probability distributionof the embedded DTMC is that typically the evolution over the full state space ˆ C would be entirelyinfeasible to interpret (or even to compute), reiterating that for instance in the case of the tree-basedexample presented in the next section, the reachable state space even after just 100 applications of ˆ G contains already more than 10 states. Trees in all their sorts and varieties are amongst some of the best-studied combinatorial structures, yethave not been considered in any detail from the viewpoint of graph rewriting theory. For the presentillustration, let us consider planar rooted binary trees (PRBTs) and disjoint unions thereof, which willbe referred to as planar rooted binary forests (PRBFs). We will encode PRBTs as typed directed graphs that satisfy certain structural constraints. Concretely, let prePRBF (the “host category” for planar rootedbinary forests) be the adhesive category of directed multigraphs typed over the type-graph T PRBF , prePRBF : = FinGraph / T PRBF , T PRBF : = RL I (40)In close analogy to the fashion in which the data type of Kappa site-graphs [13] may be encoded asrecently described in [7], PRBFs may be defined as objects of prePRBF that satisfy the structural con-straint c PRBF that is defined in terms of negative and positive constraints over the initial object ∅ (i.e. the“empty object”) as follows: c PRBF : = c ( − ) PRBF ∧ c (+) PRBF , c ( − ) PRBF : = (cid:94) N ∈ N PRBF (cid:54) ∃ ( ∅ (cid:44) → N ) N PRBF : = (cid:26) IL , II , IR , LL , R R (cid:27) ∪ (cid:91) T , T (cid:48) ∈{ I , L , R } (cid:110) T T , T T , T T (cid:111) c (+) PRBF : = ∀ (cid:0) ∅ (cid:44) → L , ∃ (cid:0) L (cid:44) → L R (cid:1)(cid:1) (cid:94) ∀ (cid:0) ∅ (cid:44) → R , ∃ (cid:0) R (cid:44) → L R (cid:1)(cid:1) (cid:94) (cid:94) T ∈{ L , R } ∀ ∅ (cid:44) → T , (cid:95) T (cid:48) ∈{ I , L , R } ∃ (cid:18) T (cid:44) → TT (cid:19) (41)Following yet again the tradition of the Kappa framework [13] (see also [16]), let us introduce the set P PRBF of PRBF patterns and the set S PRBF of states (with the latter coinciding of course with the set of2 On Stochastic Rewriting and Combinatorics
PRBFs), with the natural hierarchy S PRBF ⊂ P PRBF ⊂ obj ( prePRBF ) ∼ = : P PRBF : = { X ∈ obj ( prePRBF ) ∼ = | X (cid:15) c ( − ) PRBF } , S PRBF : = { X ∈ P PRBF | X (cid:15) c (+) PRBF } (42)The importance of this distinction between patterns and states is that in general one may define rules over patterns , while states will be the types of structures over which we will study CTMC, DTMC orcombinatorial constructions. It is well-known [16] that by virtue of the properties of negative applicationconditions, for every M -morphism P (cid:48) (cid:44) → P where P is a pattern, P (cid:48) is a pattern as well.We may finally define planar rooted binary trees as elements of S PRBF that are in addition connectedgraphs . If we let T n denote the set of PRBTs with ( n + ) leaves, we thus find for example T : = (cid:110) I (cid:111) , T : = (cid:26) L RI (cid:27) , T : = (cid:40) L RL RI , L RL RI (cid:41) , . . . (43)From hereon, we will simplify our graphical notations via omitting the vertices when drawing PRBTs,the direction of edges and also the I , L and R labels where possible, since the type of the edges may beinferred from the chosen “standard orientation” for the PRBT depictions: ≡ I , ≡ L ≡ R (44)For illustration of the computational framework put forward in the present paper, we will constructand analyze PRBTs via the so-called R´emy uniform generator [24], starting from the root-only PRBT | ∈ T . The generator may be encoded in the present formalism as follows (where we let ρ : = ρ SqPO prePRBF ):ˆ G : = ˆ G L + ˆ G R , ˆ G L : = ∗∗ : = ∑ T ∈{ I , L , R } ρ (cid:18) δ (cid:18) L RT ← (cid:45) (cid:44) → T , Shift (cid:16) ∅ (cid:44) → T , c PRBF (cid:17)(cid:19)(cid:19) ˆ G R : = ∗ ∗ : = ∑ T ∈{ I , L , R } ρ (cid:18) δ (cid:18) L RT ← (cid:45) (cid:44) → T , Shift (cid:16) ∅ (cid:44) → T , c PRBF (cid:17)(cid:19)(cid:19) (45)Here, in the specification of the rewriting rules, we have highlighted the vertices that are preservedby the rules (as black vertices in the compressed notation, and in blue in the explicit notation for betterreadability). The application conditions for the rules are simply suitable shifts of the structural constraints c PRBT to the input interfaces of the rules; this is because while one would a priori also need to consider acontribution to the application conditions that ensures satisfaction of c PRBT after application of the rules(i.e. technically applying
Trans to the
Shift of c PRBT from ∅ to the output interfaces), one may computethat the resulting conditions are subsumed by the ones explicitly mentioned in (45).As a first consistency check, we verify that ˆ G is a uniform generator , in the sense thatˆ G | | (cid:105) = ∑ t ∈ T | t (cid:105) , ∀ t ∈ T : ˆ G | t (cid:105) = ∑ t (cid:48) ∈ T (cid:12)(cid:12) t (cid:48) (cid:11) , . . . , ∀ t ∈ T n : ˆ G | t (cid:105) = ∑ t (cid:48) ∈ T n + ( n + ) ! (cid:12)(cid:12) t (cid:48) (cid:11) . (46)In other words, starting from an arbitrary tree t ∈ T n in “generation” n , applying ˆ G yields a uniformdistribution over all trees in “generation” n +
1, all with weight ( n + ) !. Note that our choice of SqPO-type rewriting was taken purely for technical convenience, i.e. in order to take advantage ofthe slightly simpler structure of SqPO-type observables (cf. (13)) and SqPO-type jump-closure (cf. (14)). . Behr commutators that occur in the variousforms of evolution equations. We will focus here on the simplest form of SqPO-type pattern countingobservables, namely those of the form ˆ O P : = ˆ O P ; true (cf. (13)). Since we will be exclusively interested inevaluating the action of ˆ G and of the observables on PRBTs states, our computations may be simplifiedto constraint-preserving semantics in the sense of [21]. Under this simplified semantics, the applicationconditions in the rules of ˆ G are equivalent to true , whence in computing SqPO-type rule compositionsfor the commutators, the problem simplifies drastically to the following one: a partial overlap betweenthe input or output of a rule in ˆ G with an output or input of another rule ˆ R with application condition true is an admissible match if and only if it is an admissible match of the “plain rules”, and if in addition thegluing N of the interfaces as in (4) satisfies the pattern constraints (i.e. if N (cid:15) c ( − ) PRBF ).Let us begin with the simplest non-trivial polynomial jump-closed set of observables for ˆ G , whichconsists just of the observable ˆ O E that “counts” edges in the trees regardless of their type:ˆ O E : = ∗ : = ∑ T ∈{ I , L , R } ρ (cid:16) δ (cid:16) T ← (cid:45) T (cid:44) → T , true (cid:17)(cid:17) (47)According to SqPO-type jump-closure and under constraint-preserving semantics (i.e. when acting onPRBTs), we may verify that the set { ˆ O E } is indeed polynomially jump-closed with respect to ˆ G : ( i ) [ ˆ O E , ˆ G ] = G , ( ii ) (cid:104)| ˆ G = (cid:104)| ˆ O E . (48)In order to gain some intuitions for the computation technique for commutators, we present below somedetails on ( i ) , where . . . denote contributions that drop out of the commutator due to sequential indepen-dence, and where we have highlighted the rules of ˆ G in orange to show the structure of the individualrule compositions: [ ˆ O E , ˆ G ] = (cid:34) + + , ∗∗ + ∗ ∗ (cid:35) = ∗∗ + ∗∗ + ∗ ∗ + ∗ ∗ + . . . − . . . = G . (49)This result is sufficient to perform our first moment-EGF computation: G ( λ ; ε ) : = (cid:104)| e ε ˆ O E e λ ˆ G | | (cid:105) ∂∂λ G ( λ ; ε ) = (cid:104)| (cid:16) e ad ε ˆ OE ( ˆ G (cid:17) e ε ˆ O E e λ ˆ G | | (cid:105) = ∑ q ≥ q ! (cid:104)| (cid:16) ad ◦ q ε ˆ O E ( ˆ G ) (cid:17) e ε ˆ O E e λ ˆ G | | (cid:105) ( via (28) )= (cid:0) ∑ q ≥ ( ε ) q q ! (cid:1) (cid:104)| ˆ Ge ε ˆ O E e λ ˆ G | | (cid:105) = e ε (cid:104)| ˆ O E e ε ˆ O E e λ ˆ G | | (cid:105) ( via (48) ) (50)We have thus derived an evolution equation that is solvable e.g. via semi-linear normal-ordering [4]: (cid:40) ∂∂λ G ( λ ; ε ) = e ε ∂∂ε G ( λ ; ε ) G ( ε ) = (cid:104)| e ε ˆ O E | | (cid:105) = e ε ⇒ G ( λ ; ε ) = √ e − ε − λ = ∑ n ≥ λ n n ! (cid:16) ( n ) ! n ! e ε ( n + ) (cid:17) . (51)Unsurprisingly, the final result for G ( λ ; ε ) expresses that all PRBTs in “generation” n have the sameoverall number of edges (i.e. 2 n + g n : = (cid:104)| ˆ G n | | (cid:105) for small values of n that g n = ( n ) ! / n !, which is obtained alternatively via specializing G ( λ ; ε ) to ε = G ( λ ) : = G ( λ ; 0 ) = ∑ n ≥ λ n ! g n ).4 On Stochastic Rewriting and Combinatorics
The true test of utility of the rule-algebraic methods is of course whether or not it is possible tocompute evolution equations for more intricate observables, since in the case of ˆ O E it would have beenpossible to derive the evolution equations and the moment EGF via heuristics. To this end, it will proveuseful to introduce some auxiliary results to facilitate dealing with nested commutator equations. Lemma 3.
For arbitrary ˆ R = ρ ( δ ( R )) and { ˆ O , . . . , ˆ O m } a set of observables, nested actions of theobservables on ˆ R are multi-linear and symmetric in the following sense (for any permutation σ ∈ S m ):ad ω ˆ O (cid:16) ad ω ˆ O (cid:16) . . . (cid:16) ad ω m ˆ O m ( ˆ R ) (cid:17) . . . (cid:17)(cid:17) = ( ω · · · ω m ) ad ˆ O σ ( ) (cid:16) ad ˆ O σ ( ) (cid:16) . . . (cid:16) ad ˆ O σ ( m ) ( ˆ R ) (cid:17) . . . (cid:17)(cid:17) . (52) Thus in particular ( i ) e ad ω O [ ˆ O , ˆ R ] = [ ˆ O , e ad ω O ( ˆ R )] , ( ii ) e ad ω O (cid:16) e ad ω O ( ˆ R ) (cid:17) = e ad ω O (cid:16) e ad ω O ( ˆ R ) (cid:17) . (53)As a case study, we will now present a body of results on a set of observables that is non-triviallypolynomially jump-closed with respect to ˆ G . We will represent by convention an observable ˆ O P simplyby the pattern P (motivated by the fact that the rule underlying ˆ O P is an identity rule):ˆ O P : = ∗ ≡ ∑ T ∈{ I , L , R } T , ˆ O P : = ∗ ≡ ∑ T ∈{ I , L , R } T , ˆ O P : = ∗ ≡ ∑ T ∈{ I , L , R } T (54)We will need a considerable number of commutator equations, which could in principle ultimately beperformed automatically via our tool ReSMT [8], but which were computed manually here. For thesake of illustration, we present the computation of [ ˆ O P , ˆ G ] in some detail below (where . . . denotecontributions that cancel from the commutator due to sequential independence): [ ˆ O P , ˆ G ] = (cid:34) T , ∗∗ + ∗ ∗ (cid:35) = ∗∗ + ∗∗ + ∗ L + ∗ R + ∗ ∗ + ∗ ∗ + ∗ R + ∗ L + . . . − ∗ L − ∗ L − ∗ R − ∗ ∗ − ∗ R − ∗ L − . . . = ˆ G (55)While ˆ O P has thus a similarly simple closure property under commutators with ˆ G as was the case withˆ O E , the observables ˆ O P and ˆ O P in contrast present an interesting form of higher-order commutator- https://gitlab.com/nicolasbehr/ReSMT (GitHub), https://nicolasbehr.gitlab.io/ReSMT (documentation) . Behr [ ˆ O P , ˆ G ] = ∗∗ + ∗ L + ∗ L − ∗ L − ∗ L ˆ R P (cid:48) : = ∗ L [ ˆ O P , ˆ G ] = ∗ L + ∗ L + ∗∗ + ∗ L − ∗ L − ∗ L − ∗ L − ˆ R P (cid:48) [ ˆ O P , [ ˆ O P , ˆ G ]] = [ ˆ O P , ˆ G ] , [ ˆ O P , [ ˆ O P , ˆ G ]] = [ ˆ O P , ˆ G ] + ˆ R P [ ˆ O P , [ ˆ O P , ˆ G ]] = [ ˆ O P , ˆ G ] + R P (cid:48) , [ ˆ O P , ˆ R P (cid:48) ] = , [ ˆ O P , ˆ R P (cid:48) ] = − ˆ R P (cid:48) (cid:104)| [ ˆ O P , ˆ G ] = (cid:104)| ( O P − O P ) , (cid:104)| [ ˆ O P , ˆ G ] = (cid:104)| ( O P − O P ) , (cid:104)| ˆ R P (cid:48) = (cid:104)| ˆ O P (56)Summarizing all commutator results thus far, we may conclude that the observables { ˆ O E , ˆ O P , ˆ O P , ˆ O P } are polynomially jump-closed with respect to ˆ G , with the closure involving up to triple commutators. Wemay then formulate the following moment-EGF evolution equation (with ω : = ( ε , γ , µ , ν ) ): G ( λ ; ω ) : = (cid:104)| e ω · ˆ O e λ ˆ G | | (cid:105) , ω · ˆ O : = ε ˆ O E + γ ˆ O P + µ ˆ O P + ν ˆ O P (57a) ∂∂λ G ( λ ; ω ) = (cid:104)| (cid:16) e ad ω · ˆ O ( ˆ G ) (cid:17) e ω · ˆ O e λ ˆ G | | (cid:105) ( ∗ ) = (cid:104)| (cid:16) e ad ν ˆ OP (cid:16) e ad µ ˆ OP (cid:16) e ad ε ˆ OE + γ ˆ OP ( ˆ G ) (cid:17)(cid:17)(cid:17) e ω · ˆ O e λ ˆ G | | (cid:105) (57b) = e ε + γ (cid:104)| (cid:16) e ad ν ˆ OP (cid:16) e ad µ ˆ OP ( ˆ G ) (cid:17)(cid:17) e ω · ˆ O e λ ˆ G | | (cid:105) (57c) = e ε + γ (cid:104)| (cid:16) e ad ν ˆ OP (cid:0) ˆ G + ( e µ − )[ ˆ O P , ˆ G ] (cid:1)(cid:17) e ω · ˆ O e λ ˆ G | | (cid:105) (57d) = e ε + γ (cid:104)| (cid:0) ˆ G + ( e µ − )[ ˆ O P , ˆ G ]+ e µ ( e ν − )[ ˆ O P , ˆ G ] + ( e ν − )( e µ − e − ν ) ˆ R P (cid:48) (cid:1) e ω · ˆ O e λ ˆ G | | (cid:105) (57e) = e ε + γ (cid:104)| (cid:0) O E + ( e µ − ) ˆ O P + ( e µ + ν − e µ + ) ˆ O P +( e µ + e − ν − e µ + ν − ) ˆ O P (cid:1) e ω · ˆ O e λ ˆ G | | (cid:105) (57f) = e ε + γ (cid:104)| (cid:0) ∂∂ε + ( e µ − ) ∂∂γ + ( e µ + ν − e µ + ) ∂∂ µ +( e µ + e − ν − e µ + ν − ) ∂∂ν (cid:1) e ω · ˆ O e λ ˆ G | | (cid:105) (57g)Here, in the step marked ( ∗ ) , we took advantage of the commutativity of the adjoint action of observablesaccording to Lemma 3, and each of the subsequent lines amounts to evaluating the highlighted adjointactions utilizing the formulas for the commutators, with the last step resulting from applying SqPO-typejump-closure in the sense of (3).Granted that the derivation of the evolution equation for G ( λ ; ω ) is somewhat involved, one mayextract from it a very interesting insight via a transformation of variables ω i → ln x i (which entails that ∂∂ω i → x i ∂∂ x i ), and collecting coefficients for the operators ˆ n i : = x i ∂∂ x i : ∂∂λ G ( λ ; ln x ) = ˆ D G ( λ ; ln x ) ˆ D = x ε x ν ( n ε − n γ + n µ − ˆ n ν ) + x ε x ν x µ ( n γ − n µ + n ν ) + x ε x ν x µ ( n µ − n ν ) + x ε ˆ n ν (58)6 On Stochastic Rewriting and Combinatorics P I count P I c oun t n =3 P I count P I c oun t n =4 P I count P I c oun t n =5 P I count P I c oun t n =10 P I count P I c oun t n =50 P I count P I c oun t n =100 Figure 1: Probability distribution of pattern counts of pattern P P d n | | (cid:105) for n = , , , , , n i sum up to 2 ˆ n E , which iswhy ˆ d : = ˆ D ( n E ) − ∗ qualifies as the generator of a DTMC in the sense of (39). We have thus succeededin statically extracting information from the combinatorial species of PRBTs on the joint pattern countdistribution of patterns P P
3, with some illustrative examples plotted in Figure 1.
Modern rewriting theory in the framework of M -adhesive categories and with conditions on objects andrewriting rules [21, 18, 14] in either DPO- [17] or SqPO-semantics [15] provides a powerful frameworkcapable of encoding many types of rewriting systems over graph-like structures of practical interest.However, in the theory of Markov chains [23] and in particular in the theory of enumerative combina-torics [19], even though graph-like structures and their manipulations play a prominent role, it is rarelyif ever the case that such situations are analyzed via rewriting-theoretical methods. While the tradi-tional focus of rewriting theory had been predominantly upon analyzing traces of rewriting systems andtheir causal properties, the aforementioned fields instead require a form of reasoning that may be in-tuitively described as requiring the analysis of all possible rewriting traces of a given system, albeittypically under a certain form of projection induced via only tracking the behavior of observables alongthe traces. Over the course of a long-term research project aimed at identifying the precise conceptual andmathematical prerequisites to implement such a type of reasoning, we have developed the rule algebra framework [3, 9, 10, 2], which we recently were able to extend to the setting of compositional rewrit-ing theories over M -adhesive categories for rules with conditions in both DPO- and SqPO-semantics . Behr embedded discrete-time Markov chains (eDTMCs) that are associated to each rewriting-based CTMC (Section 4.2). Both constructions are strongly moti-vated from the methodology advocated in our earlier work [4, 7] of focussing the analysis of CTMCsupon exponential moment-generating functions (EMGFs) for ensembles of pattern-counting observables.We demonstrate here that analogous formulations yield valuable insights also in the combinatorics andeDTMC settings, with a worked example in the setting of the rewriting of planar rooted binary trees(PRBTs) provided in Section 5 illustrating the potential of these novel methods. While we certainly donot claim that our rewriting- and rule-algebra-based methods would necessarily result in entirely unex-pected results on PRBTs (which in this particular case are in fact likely to be derivable along the linesof the work of Rowland [25] that is based upon the combinatorial inclusion-exclusion principle), themain motivations for the rule-algebraic approach are its universality , its agnosticism and its potential for automation of the requisite computations: we may (at least formally) specify the various notions of gen-erating functions for any rewriting system that satisfies the requirements of the rule algebra framework,we do not need to employ any sophisticated combinatorics arguments to perform the computations, andultimately all rule-algebraic computations may be performed automatically via implementations such asour (as of yet experimental) ReSMT framework [8]. Conversely, the ultimate motivation of the presentwork consisted in opening the rich algorithmic toolkit of enumerative and analytic combinatorics [19]for application to analyzing stochastic rewriting systems, with the goal of developing novel static analy-sis techniques in particular in the settings of biochemical [13] and organo-chemical [1] graph rewriting.Crucially, the standard combinatorics intuition as described in the seminal book [19, Ch. III.1.2] “[. . . ]the eventual goal of multivariate enumeration is the quantification of properties present with high reg-ularity in large random structures.” has to be reconsidered in the aforementioned chemical rewritingsettings, since repeated applications of rewriting rules will not necessarily always result in increasinglylarge graphical structures. However, no part of the rule-algebraic specification of evolution-equationswas even remotely based on any asymptotic arguments, which is why we believe this novel viewpointwill ultimately constitute a valuable addition to the computational toolkit in the applied sciences andpotentially even in combinatorics itself.
References [1] J.L. Andersen, C. Flamm, D. Merkle & P.F. Stadler (2016):
A Software Package for Chemically InspiredGraph Transformation . In:
Graph Transformation (ICGT 2016) , LNCS,
Sesqui-Pushout Rewriting: Concurrency, Associativity and Rule Algebra Framework . In:
Proceedings of GCM 2019 , EPTCS
Stochastic mechanics of graph rewriting . In:
Proceedings of LICS’16 , ACM Press, doi:10.1145/2933575.2934537.[4] N. Behr, V. Danos & I. Garnier (2020):
Combinatorial Conversion and Moment Bisimulation for StochasticRewriting Systems . LMCS
16, Issue 3. Available at https://lmcs.episciences.org/6628 . On Stochastic Rewriting and Combinatorics [5] N. Behr, G. Dattoli, G´erard H.E. Duchamp, S. Licciardi & K.A. Penson (2019):
Operational Methods in theStudy of Sobolev-Jacobi Polynomials . Mathematics
Compositionality of Rewriting Rules with Conditions . arXiv:1904.09322 .[7] N. Behr & J. Krivine (2020): Rewriting theory for the life sciences: A unifying framework for CTMC seman-tics . In:
Graph Transformation (ICGT 2020) , LNCS
Efficient Computation of Graph Overlaps for RuleComposition: Theory and Z3 Prototyping . In :
Proceedings of GCM 2020 , EPTCS
Rule Algebras for Adhesive Categories . In:
Proceedings of CSL 2018 , LIPIcs
Rule Algebras for Adhesive Categories (extended journal version) . LMCS
Volume 16, Issue 3. Available at https://lmcs.episciences.org/6615 .[11] F. Bergeron, G. Labelle & P. Leroux (1997):
Combinatorial Species and Tree-like Structures . Encyclopediaof Mathematics and its Applications, doi:10.1017/CBO9781107325913.[12] F. Bergeron, G. Labelle & P. Leroux (2013):
Introduction to the Theory of Species of Structures . Available at http://bergeron.math.uqam.ca/wp-content/uploads/2013/11/book.pdf .[13] P. Boutillier, M. Maasha, X. Li, H.F. Medina-Abarca, J. Krivine, J. Feret, I. Cristescu, A.G .Forbes &W. Fontana (2018):
The Kappa platform for rule-based modeling . Bioinformatics
Finitary M -adhesive categories . MSCS
Sesqui-Pushout Rewriting . In:
Graph Transforma-tions (ICGT 2006) , LNCS
Transformation and Refinement of Rigid Structures . In:
GraphTransformation (ICGT 2014) , LNCS
Fundamentals of Algebraic Graph Transformation . Monographs in Theoretical Computer Science. An EATCS Series , doi:10.1007/3-540-31188-2.[18] H. Ehrig, U. Golas, A. Habel, L. Lambers & F. Orejas (2014): M -adhesive transformation systemswith nested application conditions. Part 1: parallelism, concurrency and amalgamation . MSCS
Analytic Combinatorics . Cambridge University Press,doi:10.1017/cbo9780511801655.[20] D.T. Gillespie (1977):
Exact stochastic simulation of coupled chemical reactions . The Journal of PhysicalChemistry
Correctness of high-level transformation systems relative to nestedconditions . MSCS
Une th´eorie combinatoire des s´eries formelles . Advances in Mathematics
Markov Chains . Cambridge Series in Statistical and Probabilistic Mathematics, Cam-bridge University Press.[24] J.-L. R´emy (1985):
Un proc´ed´e it´eratif de d´enombrement d’arbres binaires et son application `a leurg´en´eration al´eatoire . RAIRO. Informatique th´eorique