aa r X i v : . [ c s . F L ] F e b Learning Pomset Automata ⋆ Gerco van Heerdt ( B ), Tobias Kapp´e ,Jurriaan Rot , and Alexandra Silva University College London, London, UK [email protected] Cornell University, Ithaca NY, USA Radboud University, Nijmegen, The Netherlands
Abstract.
We extend the L ⋆ algorithm to learn bimonoids recognisingpomset languages. We then identify a class of pomset automata thataccepts precisely the class of pomset languages recognised by bimonoidsand show how to convert between bimonoids and automata. Automata learning algorithms are useful in automated inference of models, whichis needed for verification of hardware and software systems. In active learning,the algorithm interacts with a system through tests and observations to producea model of the system’s behaviour. One of the first active learning algorithmsproposed was L ⋆ , due to Dana Angluin [2], which infers a minimal deterministicautomaton for a target regular language. L ⋆ has been used in a range of verifica-tion tasks, including learning error traces in a program [5]. For more advancedverification tasks, richer automata types are needed and L ⋆ has been extendedto e.g. input-output [1], register [19], and weighted automata [15]. None of theexisting extensions can be used in analysis of concurrent programs.Partially ordered multisets (pomsets) [13,12] are basic structures used inthe modeling and semantics of concurrent programs. Pomsets generalise words,allowing to capture both the sequential and the parallel structure of a trace in aconcurrent program. Automata accepting pomset languages are therefore usefulto study the operational semantics of concurrent programs—see, for instance,work on concurrent Kleene algebra [16,25,20,23].In this paper, we propose an active learning algorithm for a class of pomsetautomata. The approach is algebraic: we consider languages of pomsets recog-nised by bimonoids [27] (which we shall refer to as pomset recognisers). This canbe thought of as a generalisation of the classical approach to language theory ofusing monoids as word acceptors: bimonoids have an extra operation that mod-els parallel composition in addition to sequential. The two operations give riseto a complex branching structure that makes the learning process non-trivial. ⋆ This work was partially supported by the ERC Starting Grant ProFoundNet(679127) and the EPSRC Standard Grant CLeVer (EP/S028641/1). The authorsthank Matteo Sammartino for useful discussions. Van Heerdt et al.
The key observation is that pomset recognisers are tree automata whose alge-braic structure satisfies additional equations. We extend tree automata learningalgorithms [7,8,30] to pomset recognisers. The main challenge is to ensure thatintermediate hypotheses in the algorithm are valid pomset recognisers, which isessential in practical scenarios where the learning process might not run to thevery end, returning an approximation of the system under learning. This requiresequations of bimonoids to be correctly propagated and preserved in the core datastructure of the algorithm—the observation table. The proof of termination, inanalogy to L ⋆ , relies on the existence of a canonical pomset recogniser of a lan-guage, which is based on its syntactic bimonoid. The steps of the algorithmprovide hypotheses that get closer in size to the canonical recogniser.Finally, we bridge the learning algorithm to pomset automata [20,21] byproviding two constructions that enable us to seamlessly move between pomsetrecognisers and pomset automata. Note that although bimonoids provide a usefulformalism to denote pomset languages, which is amenable to the design of thelearning algorithm, they enforce a redundancy that is not present in pomsetautomata: whereas a pomset automaton processes a pomset from left to right insequence, one letter per branch at a time, a bimonoid needs to be able to takethe pomset represented as a binary tree in any way and process it bottom-up.This requirement of different decompositions leading to the same result makesbimonoids in general much larger than pomset automata and hence the latterare, in general, a more efficient representation of a pomset language.The rest of the paper is organised as follows. We conclude this introductorysection with a review of relevant related work. Section 2 contains the basic defi-nitions on pomsets and pomset recognisers. The learning algorithm for pomsetrecognisers appears in Section 3, including proofs to ensure termination and in-variant preservation. Section 4 presents constructions to translate between (aclass of) pomset automata and pomset recognisers. We conclude with discussionof further work in Section 5. Omitted proofs appear in Appendices A and B. Related Work.
There is a rich literature on adaptations and extensions of L ⋆ from deterministic automata to various kinds of models, see, e.g., [33,17] for anoverview. To the best of our knowledge, this paper is the first to provide anactive learning algorithm for pomset languages recognised by finite bimonoids.Our algorithm learns an algebraic recogniser. Urbat and Schr¨oder [32] pro-vide a very general learning approach for languages recognised by algebras formonads [4,31], based on a reduction to categorical automata, for which theypresent an L ⋆ -type algorithm. Their reduction gives rise to an infinite alphabetin general, so tailored work is needed for deriving algorithms and finite represen-tations. This can be done for instance for monoids, recognising regular languages,but it is not clear how this could extend to pomset recognisers. We present adirect learning algorithm for bimonoids, which does not rely on any encoding.Our concrete learning algorithm for bimonoids is closely related to learn-ing approaches for bottom-up tree automata [7,8,30]: pomset languages can beviewed as tree languages satisfying certain equations. Incorporating these equa- earning Pomset Automata 3 tions turned out to be a non-trivial task, which requires additional checks on theobservation table during execution of the algorithm.Conversion between recognisers and automata for a pomset language was firstexplored by Lodaya and Weil [27,26]. Their results relate the expressive power ofthese formalisms to sr-expressions . As a result, converting between recognisersand automata using their construction uses an sr-expression as an intermediaterepresentation, increasing the resulting state space. Our construction, however,converts recognisers directly to pomset automata, which keeps the state spacerelatively small. Moreover, Lodaya and Weil work focus on pomset languagesof bounded width , i.e., with an upper bound on the number of parallel events.In contrast, our conversions work for all recognisable pomset languages (and asuitable class of pomset automata), including those of unbounded width.´Esik and N´emeth [9] considered automata and recognisers for biposets , i.e.,sp-pomsets without commutativity of parallel composition. They equate lan-guages recognised by bisemigroups (bimonoids without commutativity or units)with those accepted by parenthesizing automata . Our equivalence is similar instructure, but relates a subclass of pomset automata to bimonoids instead. Theresults in this paper can easily be adapted to learn representations of biposetlanguages using bisemigroups, and convert those to parenthesizing automata. Throughout this paper we fix a finite alphabet Σ and assume (cid:3) Σ . Whendefining sets parameterised by a set X , say S ( X ), we may use S to refer to S ( Σ ).We recall pomsets [12,13], a generalisation of words that model concurrenttraces. A labelled poset over X is a tuple u = h S u , ≤ u , λ u i , where S u is a finite set(the carrier of u ), ≤ u is a partial order on S u (the order of u ), and λ u : S u → X is a function (the labelling of u ). Pomsets are labelled posets up to isomorphism. Definition 1 (Pomsets).
Let u , v be labelled posets over X . An embedding of u in v is an injection h : S u → S v such that λ v ◦ h = λ u and s ≤ u s ′ if andonly if h ( s ) ≤ v h ( s ′ ) . An isomorphism is a bijective embedding whose inverse isalso an embedding. We say u is isomorphic to v , denoted u ∼ = v , if there existsan isomorphism between u and v . A pomset over X is an isomorphism class oflabelled posets over X , i.e., [ v ] = { u : u ∼ = v } . When u = [ u ] and v = [ v ] arepomsets, u is a subpomset of v when there exists an embedding of u in v . When two pomsets are in scope, we tacitly assume that they are representedby labelled posets with disjoint carriers. We write 1 for the empty pomset. When a ∈ X , we write a for the pomset represented by the labelled poset whose soleelement is labelled by a . Pomsets can be composed in sequence and in parallel: Definition 2 (Pomset composition).
Let u = [ u ] and v = [ v ] be pomsetsover X . We write u k v for the parallel composition of u and v , which is thepomset over X represented by the labelled poset u k v = h S u ∪ S v , ≤ u ∪ ≤ v , λ u ∪ λ v i Van Heerdt et al.
Similarly, we write u · v for the sequential composition of u and v , that is, thepomset represented by the labelled poset u · v = h S u ∪ S v , ≤ u ∪ ≤ v ∪ S u × S v , λ u ∪ λ v i We may elide the dot for sequential composition, for instance writing ab for a · b . The pomsets we use can be built using sequential and parallel composition.
Definition 3 (Series-parallel pomsets).
The set of series-parallel pomsets(sp-pomsets) over X , denoted SP ( X ) , is the smallest set such that ∈ SP ( X ) and a ∈ SP ( X ) for every a ∈ X , closed under parallel and sequential composition. Concurrent systems admit executions of operations that are not only orderedin sequence but also allow parallel branches. An algebraic structure consistingof both a sequential and a parallel composition operation, with a shared unit, iscalled a bimonoid . Formally, its definition is as follows.
Definition 4 (Bimonoid). A bimonoid is a tuple h M, ⊙ , ȅ , i where – M is a set called the carrier of the bimonoid, – ⊙ is a binary associative operation on M , – ȅ is a binary associative and commutative operation on M , and – 1 ∈ M is a unit for both ⊙ (on both sides) and ȅ .Bimonoid homomorphisms are defined in the usual way. Given a set X , the free bimonoid [12] over X is h SP ( X ) , · , k , i . The factthat it is free means that for every function f : X → M for a given bimonoid h M, ⊙ , ȅ , M i there exists a unique bimonoid homomorphism f ♯ : SP ( X ) → M such that the restriction of f ♯ to X is f .Just as monoids can recognise words, bimonoids can recognise pomsets [27].A bimonoid together with the witnesses of recognition is a pomset recogniser . Definition 5 (Pomset recogniser). A pomset recogniser is a tuple R = h M, ⊙ , ȅ , , i, F i where h M, ⊙ , ȅ , i is a bimonoid, i : Σ → M , and F ⊆ M .The language recognised by R is given by L R = { u ∈ SP : i ♯ ( u ) ∈ F } ⊆ SP . Example 6.
Suppose a program consists of a loop, where each iteration runsactions a and b in parallel. We can describe the behaviour of this program by L = { a k b } ∗ = { , a k b , ( a k b ) · ( a k b ) , . . . } We can describe this language using a pomset recogniser, as follows. Let M = { q a , q b , q , q ⊥ , } , and let ⊙ and ȅ be the operations on M given by q ⊙ q ′ = q q ′ = q ′ q = q q = q ′ = q q ⊥ otherwise q ȅ q ′ = q q ′ = q ′ q = q { q, q ′ } = { q a , q b } q ⊥ otherwise earning Pomset Automata 5 A straightforward proof verifies that h M, ⊙ , ȅ , i is a bimonoid.We set i ( a ) = q a , i ( b ) = q b , and F = { , q } . Now, for n > i ♯ (( a k b ) · · · ( a k b ) | {z } n times ) = ( i ( a ) k i ( b )) ⊙ · · · ⊙ ( i ( a ) k i ( b )) | {z } n times = q ⊙ · · · ⊙ q | {z } n times = q No other pomsets are mapped to q ; hence, h M, ⊙ , ȅ , , i, F i accepts L . Example 7.
Suppose a program solves a problem recursively, such that the re-cursive calls are performed in parallel. In that case, the program would eitherperform the base action b , or some preprocessing action a followed by runningtwo copies of itself in parallel. This behaviour can be described by the smallestpomset language L satisfying the following inference rules: b ∈ L u, v ∈ L a · ( u k v ) ∈ L This language can be described by a pomset recogniser. Let our carrier setbe M = { q a , q b , q , q ⊥ , } , and let ⊙ and ȅ be the operations on M given by q ⊙ q ′ = q q ′ = q ′ q = q b q = q a , q ′ = q q ⊥ otherwise q ȅ q ′ = q q ′ = q ′ q = q q = q ′ = q b q ⊥ otherwise h M, ⊙ , ȅ , i is a bimonoid, F = { q b } , and i : Σ → M is given by setting i ( a ) = q a and i ( b ) = q b . One can then show that h M, ⊙ , ȅ , , i, F i accepts L . Pomset contexts are used to describe the behaviour of individual elements ina pomset recogniser. Formally, the set of pomset contexts over a set X is givenby PC ( X ) = SP ( X ∪ { (cid:3) } ). Here the element (cid:3) acts as a placeholder, wherea pomset can be plugged in: given a context c ∈ PC ( X ) and t ∈ SP ( X ), let c [ t ] ∈ SP ( X ) be obtained by substituting t for (cid:3) in c . In this section we present our algorithm to learn pomset recognisers from anoracle ( the teacher ) that answers membership and equivalence queries . A mem-bership query consists of a pomset, to which the teacher replies whether thatpomset is in the language; an equivalence query consists of a hypothesis pom-set recogniser, to which the teacher replies yes if it is correct or no with acounterexample—a pomset incorrectly classified by the hypothesis—if it is not.A pomset recogniser is essentially a tree automaton, with the additional con-straint that its algebraic structure satisfies the bimonoid axioms. Our algorithmis therefore relatively close to tree automata learning—in particular Drewes andH¨ogberg [7,8]—but there are several key differences: we optimise the algorithmby taking advantage of the bimonoid axioms, and at the same time need to ensurethat the hypotheses generated by the learning process satisfy those axioms. Van Heerdt et al.
We fix a target language
L ⊆ SP throughout this section. As in the original L ⋆ algorithm, the state of the learner throughout a run of the algorithm is given bya data structure called the observation table , which collects information about L .The table contains rows indexed by pomsets, representing the state reached bythe correct pomset recogniser after reading that pomset; and columns indexedby pomset contexts, used to approximately indentify the behaviour of each state.To represent the additional rows needed to approximate the pomset recogniserstructure, we use the following definition. Given U ⊆ SP , we define U + = Σ ∪ { u · v : u, v ∈ U } ∪ { u k v : u, v ∈ U } ⊆ SP . Definition 8 (Observation table). An observation table is a pair h S, E i , with S ⊆ SP subpomset-closed and E ⊆ PC such that ∈ S and (cid:3) ∈ E . These setsinduce the function row h S,E i : S ∪ S + → E : row h S,E i ( s )( e ) = 1 ⇐⇒ e [ s ] ∈ L . We often write row instead of row h S,E i when S and E are clear from the context. We depict observation tables, or more precisely row , as two separate tableswith rows in S and S + \ S respectively, see for instance Example 9 below.The goal of the learner is to extract a hypothesis pomset recogniser from therows in the table. More specifically, the carrier of the underlying bimonoid of thehypothesis will be given by the rows indexed by pomsets in S . The structure onthe rows is obtained by transferring the structure of the row labels onto the rows(e.g., row ( s ) ⊙ row ( t ) = row ( s · t )), but this is not well-defined unless the tablesatisfies closedness , consistency , and associativity . Closedness and consistencyare standard in L ⋆ , whereas associativity is a new property specific to bimonoidlearning. We discuss each of these properties next, also including compatibility ,a property that is used to show minimality of hypotheses.The first potential issue is a closedness defect: this is the case when a com-posed row, indexed by an element of S + , is not indexed by a pomset in S . Example 9 (Table not closed).
Recall L = { a k b } ∗ from Example 6, and suppose S = { , a , b } and E = { (cid:3) , a k (cid:3) , (cid:3) k b } . The induced table is E (cid:3) a k (cid:3) (cid:3) k b S a b E (cid:3) a k (cid:3) (cid:3) k b S + \ S aa ab ba bb a k a a k b b k b M = { row (1) , row ( a ) , row ( b ) } , but the com-position row ( a ) ⊙ row ( a ) cannot be defined since row ( aa ) M . The absence of the issue described above is captured with closedness . earning Pomset Automata 7 Definition 10 (Closed table).
An observation table h S, E i is closed if for all t ∈ S + there exists s ∈ S such that row ( s ) = row ( t ) . Another issue that may occur is that the same row being represented bydifferent index pomsets leads to an inconsistent definition of the structure. Theabsence of this issue is referred to as consistency . Definition 11 (Consistent table).
An observation table h S, E i is consistent if for all s , s ∈ S such that row ( s ) = row ( s ) we have for all t ∈ S that row ( s · t ) = row ( s · t ) row ( t · s ) = row ( t · s ) row ( s k t ) = row ( s k t ) . Whenever closedness and consistency hold, one can define sequential and par-allel composition operations on the rows of the table. However, these operationsare not guaranteed to be associative, as we show with the following example.
Example 12 (Table not associative).
Consider L = { a u : u ∈ { b } ∗ } over Σ = { a , b } , and suppose S = { , a , b } and E = { (cid:3) , (cid:3) a } . The induced table is: (cid:3) (cid:3) a a b (cid:3) (cid:3) aaa ab ba bb a k a a k b b k b This table does not lead to an associative sequential operation on rows:( row ( a ) ⊙ row ( b )) ⊙ row ( a ) = row ( ab ) ⊙ row ( a ) = row ( a ) ⊙ row ( a ) = row ( aa ) = row ( ab ) = row ( a ) ⊙ row ( b ) = row ( a ) ⊙ row ( ba ) = row ( a ) ⊙ ( row ( b ) ⊙ row ( a )) . To prevent this issue we enforce the following additional property:
Definition 13 (Associative table).
Let ♥ ∈ {· , k} . An observation table h S, E i is ♥ -associative if for all s , s , s , s l , s r ∈ S with row ( s l ) = row ( s ♥ s ) and row ( s r ) = row ( s ♥ s ) we have row ( s l ♥ s ) = row ( s ♥ s r ) . An observationtable is associative if it is both · -associative and k -associative. The table from Example 12 is not · -associative: we have row ( a ) = row ( ab )and row ( b ) = row ( ba ) but row ( aa ) = row ( ab ).Putting the above definitions of closedness, consistency and associativity oftables together, we have the following result for constructing a hypothesis. Lemma 14 (Hypothesis).
A closed, consistent and associative table h S, E i induces a hypothesis pomset recogniser H = h H, ⊙ H , ȅ H , H , i H , F H i where H = { row ( s ) : s ∈ S } row ( s ) ⊙ H row ( s ) = row ( s · s ) row ( s ) ȅ H row ( s ) = row ( s k s ) H = row (1) i H ( a ) = row ( a ) F H = { row ( s ) : s ∈ S, row ( s )( (cid:3) ) = 1 } . Van Heerdt et al.
Proof.
The operations ⊙ H and ȅ H are well-defined by closedness and consis-tency, and H is well-defined because 1 ∈ S by the observation table definition.Commutativity of ȅ H follows from commutativity of k , and similarly that H is a unit for both operations follows from 1 being a unit. Associativity followsby associativity of the table (it does not follow from · and k being associative:given elements s , s , s ∈ S , s · s · s is not necessarily present in S ∪ S + ). ⊓⊔ Since a hypothesis is constructed from an observation table h S, E i thatrecords for given s ∈ S and e ∈ E whether e [ s ] is accepted by the languageor not, one would expect that the hypothesis classifies those pomsets T h S,E i = { e [ s ] : s ∈ S, e ∈ E } correctly. This is not necessarily the case, as we show in the following example. Example 15.
Consider the language L from Example 7, and let S = { , b } and E = { (cid:3) , a ( (cid:3) k b ) } . The induced table is (cid:3) a ( (cid:3) k b )1 0 0 b (cid:3) a ( (cid:3) k b ) a bb b k b row ( a ) ⊙ ( row ( b ) ȅ row ( b )))( (cid:3) ) = ( row ( a ) ⊙ row ( b k b ))( (cid:3) )= ( row ( a ) ⊙ row (1))( (cid:3) ) = row ( a )( (cid:3) ) = 0 = 1and thus recognises a language that differs from L on a · ( b k b ) ∈ T h S,E i .We thus have the following definition, parametric in a subset of T h S,E i . Definition 16 (Compatible hypothesis).
A closed, consistent, and associa-tive observation table h S, E i induces a hypothesis H that is X -compatible withits table, for X ⊆ SP , if for x ∈ X we have x ∈ L H ⇐⇒ x ∈ L . We say that thehypothesis is compatible with its table if it is T h S,E i -compatible with its table. Ensuring hypotheses are compatible with their table will not be a crucial stepin proving termination, but plays a key role in ensuring minimality (Section 3.4).This was originally shown by van Heerdt [14] for Mealy machines.
We are now ready to introduce our learning algorithm, Algorithm 1. The mainalgorithm initialises the table to h{ } , { (cid:3) }i and starts by augmenting the tableto make sure it is closed and associative. We give an example below. earning Pomset Automata 91 S = { } , E = { (cid:3) } repeat repeat while h S, E i is not closed or not associative5 if h S, E i is not closed6 find t ∈ S + such that row ( t ) = row ( s ) for all s ∈ S S = S ∪ { t } for ♥ ∈ {· , k} if h S, E i is not ♥ -associative10 find s , s , s , s l , s r ∈ S and e ∈ E such that row ( s l ) = row ( s ♥ s ), row ( s r ) = row ( s ♥ s ), and row ( s l ♥ s )( e ) = row ( s ♥ s r )( e )11 let b be the result of a membership query on s ♥ s ♥ s if row ( s l ♥ s )( e ) = b E = E ∪ { e [ (cid:3) ♥ s ] } else E = E ∪ { e [ s ♥ (cid:3) ] }
16 construct the hypothesis H for h S, E i if H is not compatible with its table18 find s ∈ S and e ∈ E such that e [ s ] ∈ L H ⇐⇒ e [ s ]
6∈ L E = E ∪ { HandleCounterexample ( S, E, e [ s ] , (cid:3) ) } until H is compatible with its table21 if the teacher replies no to H , with a counterexample z E = E ∪ { HandleCounterexample ( S, E, z, (cid:3) ) } until the teacher replies yes return H HandleCounterexample ( S, E, z, c )1 if z ∈ S ∪ S + s ∈ S be such that row ( s ) = row ( z )3 if c [ s ] ∈ L ⇐⇒ c [ z ] ∈ L return s else return c u , u ∈ SP and ♥ ∈ {· , k} be such that u ♥ u = z u = HandleCounterexample ( S, E, u , c [ (cid:3) ♥ u ])9 if u S return u u = HandleCounterexample ( S, E, u , c [ u ♥ (cid:3) ])12 if u S return u return HandleCounterexample ( S, E, u ♥ u , c ) Algorithm 1: The pomset recogniser learning algorithm.
Example 17 (Fixing closedness and associativity).
Consider the table from Ex-ample 9, where row ( aa )
6∈ { row (1) , row ( a ) , row ( b ) } witnesses a closedness defect.To fix this, the algorithm would add aa to the set S , which means row ( aa ) willbecome part of the carrier of the hypothesis.Now consider the table from Example 12. Here we found an associativitydefect witnessed by row ( a ) = row ( ab ) and row ( b ) = row ( ba ) but row ( aa ) = row ( ab ). More specifically, row ( aa )( (cid:3) ) = row ( ab )( (cid:3) ). Thus, s = s = s l = a , s = s r = b , s l = a , and e = (cid:3) . A membership query on aba shows aba
6∈ L ,so b = 0. We have row ( aa )( (cid:3) ) = 0, and therefore the algorithm would add thecontext (cid:3) [ a · (cid:3) ] = a · (cid:3) to E .Note that the algorithm does not explicitly check for consistency; this is be-cause we actually ensure a stronger property—sharpness [3]—as an invariant(Lemma 25). This property ensures every row indexed by a pomset in S is in-dexed by exactly one pomset in S (implying consistency): Definition 18 (Sharp table).
An observation table h S, E i is sharp if for all s , s ∈ S such that row ( s ) = row ( s ) we have s = s . The idea of maintaining sharpness is due to Maler and Pnueli [28].Once the table is closed and associative, we construct the hypothesis andcheck if it is compatible with its table. If this is not the case, a witness for in-compatibility is a counterexample by definition, so
HandleCounterexample is invoked to extract an extension of E , and we return to checking closednessand associativity. Once we obtain a hypothesis that is compatible with its table,we submit it to the teacher to check for equivalence with the target language.If the teacher provides a counterexample, we again process this and return tochecking closedness and associativity. Once we have a compatible hypothesis forwhich there is no counterexample, we return this correct pomset recogniser.The procedure HandleCounterexample , adapted from [7,8], is providedwith an observation table h S, E i a pomset z , and a context c and finds a sin-gle context to add to E . The main invariant is that c [ z ] is a counterexample.Recursive calls replace subpomsets from S + with elements of S in this counterex-ample while maintaining the invariant. There are two types of return values: if c is a suitable context, c is returned; otherwise the return value is an elementof S that is to replace z . The context c is suitable if z ∈ S + and adding c to E would distinguish row ( s ) from row ( z ), where s ∈ S is such that currently row ( s ) = row ( z ). Because S is non-empty and subpomset-closed, if z S ∪ S + it can be decomposed into z = u ♥ u for non-empty u , u ∈ SP and ♥ ∈ {· , k} .We then recurse into u and u to replace them with elements of S and replace z with u ♥ u ∈ S + in a final recursive call. If c = (cid:3) , the return value cannot bein S , as we will show in Lemma 25 that these elements are not counterexamples. Example 19 (Processing a counterexample).
Consider L = { a , aa , a k a } , andlet S = { , a } and E = { (cid:3) } . This induces a closed, sharp, and associative table (cid:3) a (cid:3) aa a k a earning Pomset Automata 11 Suppose an equivalence query on its pomset recogniser, which rejects only theempty pomset, gives counterexample z = a k a k aa . We may decompose z as ( (cid:3) k aa )[ a k a ], where a k a ∈ S + \ S . Because row ( a k a ) = row ( a ),( (cid:3) k aa )[ a ] = a k aa , and a k aa ∈ L ⇐⇒ z ∈ L , we update z = a k aa andrepeat the process. Now we decompose z = ( a k (cid:3) )[ aa ]. Since row ( aa ) = row ( a ),( a k (cid:3) )[ a ] = a k a , and a k a ∈ L ⇐⇒ z
6∈ L , we finish by adding a k (cid:3) to E . Our termination argument is based on a comparison of the current observationtable with the infinite table h SP , PC i . We first show that the latter induces a hy-pothesis, called the canonical pomset recogniser for the language. Its underlyingbimonoid is isomorphic to the syntactic bimonoid [27] for the language. Lemma 20. h SP , PC i is a closed, consistent, and associative observation table. Definition 21 (Canonical pomset recogniser).
The canonical pomset re-cogniser for L is the the hypothesis for the observation table h SP , PC i . We denotethis hypothesis by h M L , ⊙ L , ȅ L , L , i L , F L i . The comparison of the current table with h SP , PC i is in terms of the numberof distinct rows they hold. In the following lemma we show that the number ofthe former is bounded by the number of the latter. Lemma 22. If M L is finite, any observation table h S, E i satisfies |{ row ( s ) : s ∈ S }| ≤ | M L | . Proof.
Note that M L = { row h SP , PC i ( s ) : s ∈ S } . Given s , s ∈ S such that row h S,E i ( s ) = row h S,E i ( s ) we have row h SP , PC i ( s ) = row h SP , PC i ( s ). This implies |{ row ( s ) : s ∈ S }| ≤ | M L | . ⊓⊔ An important fact will be that none of the pomsets in S can form a coun-terexample for the hypothesis of a table h S, E i . In order to show this we will firstshow that the hypothesis is always reachable , a concept we define for arbitrarypomset recognisers below. Definition 23 (Reachability).
A pomset recogniser R = h M, ⊙ , ȅ , , i, F i is reachable if for all m ∈ M there exists u ∈ SP such that i ♯ ( u ) = m . Our reachability lemma relies on the fact that S is subpomset-closed. Lemma 24 (Hypothesis reachability).
Given a closed, consistent, and as-sociative observation table h S, E i , the hypothesis it induces is reachable. In par-ticular, i H♯ ( s ) = row ( s ) for any s ∈ S . From the above it follows that we always have compatibility with respect tothe set of row indices, as we show next.
Lemma 25.
The hypothesis of any closed, consistent, and associative observa-tion table h S, E i is S -compatible. Before turning to our termination proof, we show that some simple propertieshold throughout a run of the algorithm.
Lemma 26 (Invariant).
Throughout execution of Algorithm 1, we have that h S, E i is a sharp observation table.Proof. Subpomset-closedness holds throughout each run since { } is subpomset-closed and adding a single element of S + to S preserves the property.For sharpness, first note that the initial table is sharp as it only has one row.Sharpness of h S, E i can only be violated when adding elements to S . But theonly place where this happens is on line 7, and there the new row is unequal toall previous rows, which means sharpness is preserved. ⊓⊔ The preceding results allow us to prove our termination theorem.
Theorem 27 (Termination). If M L is finite, then Algorithm 1 terminates.Proof. First, we observe that fixing a closedness defect by adding a row (line 7)can only happen finitely many times, since, by Lemma 22, the size of { row ( s ) : s ∈ S } is bounded by M L .This means that it suffices to show the following two points:1. Each iteration of any of the loops starting on lines 2–4 either fixes a closed-ness defect by adding a row, or adapts E so that h S, E i ends up not beingclosed at the end of loop body. In the second case, a closedness defect willbe fixed in the following iteration of the inner while loop.2. The calls to HandleCounterexample terminate.Combined, these show that the algorithm terminates. For the first point, wetreat each of the cases: – If the table is not closed, we directly find a new row that is taken from the S + -part of the table and added to the S -part of the table. – Consider the failure of ♥ -associativity, for ♥ ∈ {· , k} , and let s , s , s , s l , s r ∈ S and e ∈ E be such that row ( s l ) = row ( s ♥ s ), row ( s r ) = row ( s ♥ s ), and row ( s l ♥ s )( e ) = row ( s ♥ s r )( e ). Suppose row ( s l ♥ s )( e ) = b , with b be theresult of a membership query on s ♥ s ♥ s . Then e [ (cid:3) ♥ s ] distinguishes thepreviously equal rows row ( s ♥ s ) and row ( s l ), so adding it to E creates aclosedness defect. The fact that row ( s ♥ s ) cannot remain equal to anotherrow than row ( s l ) is a result of the sharpness invariant.Alternatively, row ( s l ♥ s )( e ) = b means row ( s ♥ s r )( e ) = b , for otherwisewe would contradict row ( s l ♥ s )( e ) = row ( s ♥ s r )( e ). For similar reasonsthe context e [ s ♥ (cid:3) ] in this case distinguishes the previously equal rows row ( s ♥ s ) and row ( s r ), creating a closedness defect. – A compatibility defect results in the identification of a counterexample, thehandling of which we discuss next. earning Pomset Automata 13 – Whenever a counterexample is identified, we eventually find a context c , s ∈ S , and t ∈ S + \ S such that row ( t ) = row ( s ) and c [ t ] ∈ L ⇐⇒ c [ s ]
6∈ L .Thus, adding c to E creates a closedness defect.Termination of HandleCounterexample follows: the first two recursivecalls in the procedure replace z with strict subpomsets of z , whereas the last onereplaces z with an element of S + , so no further recursion will happen. ⊓⊔ Query Complexity.
We determine upper bounds on the membership and equiva-lence query numbers of a run of the algorithm in terms of the size of the canonicalpomset recogniser n = | M L | , the size of the alphabet k = | Σ | , and the maximumnumber of operations (from {· , k} , used to compose alphabet symbols) m foundin a counterexample. We note that since the number of distinct rows indexed by S is bounded by n and the table remains sharp throughout any run, the finalsize of S is at most n . Thus, the final size of S + is in O ( n + k ). Given theinitialisation of S with a single element, the number of closedness defects fixedthroughout a run is at most n −
1. This means that the total number of asso-ciativity defects fixed and counterexamples handled (including those resultingfrom compatibility defects) together is n −
1. We can already conclude that thenumber of equivalence queries posed is bounded by n . Moreover, we know thatthe final table will have at most n columns, and therefore the total number ofcells in that table will be in O ( n + kn ).The number of membership queries posed during a run of the algorithm isgiven by the number of cells in the table plus the number of queries neededduring the processing of counterexamples. Consider the counterexample z thatcontains the maximum number of operations among those encountered duringa run. The first two recursive calls of HandleCounterexample break downone operation, whereas the third is used to execute a base case making twomembership queries and does not lead to any further recursion. The numberof membership queries made starting from a given counterexample is thus in O ( m ). This means the total number of membership queries during the processingof counterexamples is in O ( mn ), from which we conclude that the number ofmembership queries posed during a run is in O ( n + mn + kn ). In this section we will show that all hypotheses submitted by the algorithm tothe teacher are minimal. We first need to define what minimality means. As isthe case for DFAs, it is the combination of an absence of unreachable states andof every state exhibiting its own distinct behaviour.
Definition 28 (Minimality).
A pomset recogniser R = h M, ⊙ , ȅ , , i, F i is minimal if it is reachable and for all u, v ∈ SP with i ♯ ( u ) = i ♯ ( v ) there exists c ∈ PC such that c [ u ] ∈ L R ⇐⇒ c [ v ]
6∈ L R . Before proving the main result of this section, we need the following:
Lemma 29.
For all pomset recognisers h M, ⊙ , ȅ , , i, F i and u, v ∈ SP suchthat i ♯ ( u ) = i ♯ ( v ) we have for any c ∈ PC that i ♯ ( c [ u ]) = i ♯ ( c [ v ]) . The minimality theorem below relies on table compatibility, which allows usto distinguish the behaviour of states based on the contents of their rows. Notethat the algorithm only submits a hypothesis in an equivalence query if thathypothesis is compatible with its table.
Theorem 30 (Minimality of hypotheses).
A closed, consistent, and as-sociative observation h S, E i induces a minimal hypothesis if the hypothesis iscompatible with its table.Proof. We obtain the hypothesis from Lemma 14. Since S is subpomset-closed,we have by Lemma 24 that the hypothesis is reachable. Moreover, for every s ∈ S we have i H ♯ ( s ) = row ( s ). Consider u , u ∈ SP such that i H♯ ( u ) = i H ♯ ( u ).Then there exist s , s ∈ S such that row ( s ) = i H ♯ ( u ) and row ( s ) = i H ♯ ( u ),and we have row ( s ) = row ( s ). Let e ∈ E be such that row ( s )( e ) = row ( s )( e ).We have i H♯ ( e [ u ]) ∈ F H ⇐⇒ i H♯ ( e [ s ]) ∈ F H (Lemma 29) ⇐⇒ e [ s ] ∈ L H ⇐⇒ row ( s )( e ) = 1 ⇐⇒ row ( s )( e ) = 0 ⇐⇒ e [ s ]
6∈ L H ⇐⇒ i H♯ ( e [ s ]) F H ⇐⇒ i H♯ ( e [ u ]) F H . (Lemma 29) ⊓⊔ As a corollary, we find that the canonical pomset recogniser is minimal.
Proposition 31.
The canonical pomset recogniser is minimal.
Bimonoids are a useful representation of pomset languages because sequentialand parallel composition are on an equal footing; in the case of the learning al-gorithm of the previous section, this helps us treat both operations similarly. Onthe other hand, the behaviour of a program is usually thought of as a series ofactions, some of which involve launching two or more threads that later combine.Here, sequential actions form the basic unit of computation, while fork/join pat-terns of threads are specified separately.
Pomset automata [21] encode this moreasymmetric model: they can be thought of as non-deterministic finite automatawith an additional transition type that brokers forking and joining threads.In this section, we show how to convert a pomset recogniser to a certaintype of pomset automaton, where acceptance of a pomset is guided by its struc-ture; conversely, we show that each of the pomset automata in this class can earning Pomset Automata 15 be represented by a pomset recogniser. Together with the previous section, thisestablishes that the languages of pomset automata in this class are learnable.If S is a set, we write M ( S ) for the set of finite multisets over S . A finitemultiset over S is written φ = {| s , . . . , s n |} . Definition 32 (Pomset automata). A pomset automaton (PA) is a tuple A = h Q, I, F, δ, γ i where – Q is a set of states , with I, F ⊆ Q the initial and accepting states , and – δ : Q × Σ → Q the sequential transition function , and – γ : Q × M ( Q ) → Q the parallel transition function .Lastly, for every q ∈ Q there are finitely many φ ∈ M ( Q ) such that γ ( q, φ ) = ∅ . A finite PA can be represented graphically: every state is drawn as a vertex,with accepting states doubly circled and initial states pointed out by an arrow,while δ -transitions are represented by labelled edges, and γ -transitions are drawnas a multi-ended edge. For instance, in Figure 1a, we have drawn a PA with states q through q with q accepting, and q ∈ δ ( q , a ) (among other δ -transitions),while the multi-ended edge represents that q ∈ γ ( q , {| q , q |} ), i.e., q can launchthreads starting in q and q , which, upon termination, resume in q . q q q q q q a bc a (a) A simple PA. q q q q ba (b) A non-saturated PA. Fig. 1: Some pomset automata.The sequential transition function is interpreted as in non-deterministic finiteautomata: if q ′ ∈ δ ( q, a ), then a machine in state q may transition to state q ′ afterperforming the action a . The intuition to the parallel transition function is thatif q ′ ∈ γ ( q, {| r , . . . , r n |} ), then a machine in state q may launch threads startingin states r through r n , and when each of those has terminated succesfully,may proceed in state q ′ . Note how the representation of starting states in a γ -transition allows for the possibility of launching multiple instances of the samethread, and disregards their order—i.e., γ ( q, {| r , . . . , r n |} ) = γ ( q, {| r n , . . . , r |} ).This intuition is made precise through the notion of a run . Definition 33 (Run relation).
The run relation of a PA A = h Q, I, F, δ, γ i ,denoted → A , is defined as the the smallest subset of Q × SP × Q satisfying q −→ A q q ′ ∈ δ ( q, a ) q a −→ A q ′ ∀ ≤ i ≤ n. r i u i −→ A r ′ i ∈ Fq ′ ∈ γ ( q, {| r , . . . , r n |} ) q u k···k u n −−−−−−→ A q ′ q u −→ A q ′′ q ′′ v −→ A q ′ q u · v −−→ A q ′ The language accepted by A is L A = { u ∈ SP : ∃ q ∈ I, q ′ ∈ F. q u −→ A q ′ } .Example 34. If A is the PA from Figure 1a, we can see that q b −→ A q and q c −→ A q as a result of the second rule; by the third rule, we find that q b k c −−→ A q .Since q a −→ q and q a −→ A q (again by the second rule), we can conclude q a · ( b k c ) · a −−−−−→ A q by repeated application of the last rule. The language acceptedby this PA is the singleton set { a · ( b k c ) · a } .In general, finite pomset automata can accept a very wide range of pomsetlanguages, including all context free (pomset) languages [22]. The intuition be-hind this is that the mechanism of forking and joining encoded in γ can be usedto simulate a call stack. For example, the automaton in Figure 1b accepts thestrictly context-free language (of words) { a n · b n : n ∈ N } . It follows that PAscan represent strictly more pomset languages than pomset recognisers. To tamethe expressive power of PAs at least slightly, we propose the following. Definition 35 (Saturation).
We say that A = h Q, I, F, δ, γ i is saturated whenfor all u, v ∈ SP with u, v = 1 , both of the following are true:(i) If q u · v −−→ A q ′ , then there exists a q ′′ ∈ Q with q u −→ A q ′′ and q ′′ v −→ A q ′ .(ii) If q u k v −−→ A q ′ , then there exist r, s ∈ Q and r ′ , s ′ ∈ F such that r u −→ A r ′ s v −→ A s ′ q ′ ∈ γ ( q, {| r, s |} ) Example 36.
Returning to Figure 1, we see that the PA in Figure 1a is saturated,while Figure 1b is not, as a result of the run q a · a · b · b −−−−→ A q , which does not admitan intermediate state q such that q a · a −−→ A q and q b · b −−→ A q .We now have everything in place to convert the encoding of a language givenby a pomset recogniser to a pomset automaton. The idea is to represent everyelement q of the bimonoid by a state which accepts exactly the language ofpomsets mapped to q ; the transition structure is derived from the operations. Lemma 37.
Let R = h M, ⊙ , ȅ , , i, F i be a pomset recogniser. We constructthe pomset automaton A = h M, F, { } , δ, γ i (note: we use F as the set of initialstates) where δ : M × Σ → M and γ : M × M ( M ) → M are given by δ ( q, a ) = { q ′ : i ( a ) ⊙ q ′ = q } γ ( q, φ ) = { q ′ : ( r ȅ r ′ ) ⊙ q ′ = q, φ = {| r, r ′ |}} Then A is saturated, and L A = L R .Example 38. Let h M, ⊙ , ȅ , , i, F i be the pomset recogniser from Example 7.The pomset automaton that arises from the construction above is partially de-picted in Figure 2; we have not drawn the state q ⊥ and its incoming transitions,or forks into , to avoid clutter. In this PA, we see that, since q a ⊙ q = q b and i ( a ) = q a , we have q ∈ δ ( q b , a ). Furthermore, since ( q b ȅ q b ) ⊙ = q ⊙ = q ,we also have ∈ γ ( q , {| q b , q b |} ). Finally, q b is initial, since F = { q b } . earning Pomset Automata 17 q b q q a ba a Fig. 2: Part of the PA obtained from the pomset recogniser from Example 7,using the construction from Lemma 37. The state q ⊥ (which does not contributeto the language of the automaton) and forks into the state are not pictured.We have thus shown that the language of any pomset recogniser can beaccepted by a finite and saturated PA. In turn, this shows that our algorithmcan, in principle, be adapted to work with a teacher that takes a (saturated) PAinstead of a pomset recogniser as hypothesis, by simply converting the hypothesispomset recogniser to an equivalent PA before sending it over.Conversely, we can show that the transition relations of a saturated PA carrythe algebraic structure of a bimonoid, and use that to show that a languagerecognised by a saturated PA is also recognised by a bimonoid. This shows thatour characterisation is “tight”, i.e., languages recognised by saturated PAs areprecisely those recognised by bimonoids, and hence learnable. Lemma 39.
Let A = h Q, I, F, δ, γ i be a saturated pomset automaton. We canconstruct a pomset recogniser R = h M, ⊙ , ȅ , , i, F ′ i , where M = { u −→ A : u ∈ SP } u −→ A ⊙ v −→ A = u · v −−→ A u −→ A ȅ v −→ A = u k v −−→ A i ( a ) = a −→ A F ′ = { u −→ A ∈ M : ∃ q ∈ I, q ′ ∈ F. q u −→ A q ′ } Now ⊙ and ȅ are well-defined, and R is a pomset recogniser such that L R = L A . If A is finite, then so is R , since each of the elements of M is a relation on Q , and there are finitely many relations on a finite set.In general, the PA obtained from a pomset recogniser may admit runs wherethe same fork transition is nested repeatedly. Recognisable pomset languagesof bounded width may be recognised by a pomset recogniser that is depth-nilpotent [27], which can be converted into a fork-acyclic PA by way of ansr-expression [27,21]. However, this detour via sr-expressions is not necessary:one can adapt Lemma 37 to produce a fork-acyclic PA, when given a depth-nilpotent pomset recogniser. The details are discussed in Appendix C.We conclude this section by remarking that the minimal pomset recogniser fora bounded-width language is necessarily depth-nilpotent [27]; since our algorithmproduces a minimal pomset recogniser, this means that we can also produce afork-acyclic PA after learning a bounded-width recognisable pomset language.
To learn DFAs, there are several alternatives to the observation table data struc-ture that reduce the space complexity of the algorithm. Most notable is the clas-sification tree [24], which distinguishes individual pairs of words (which for us would be pomsets) at every node rather than filling an entire row for each ofthem. The TTT algorithm [18] further builds on this and achieves optimal spacecomplexity. Given that we developed the first learning algorithm for pomset lan-guages, we opted for the simplicity of the observation table—optimisations suchas those analogous to the aforementioned work are left to future research.We would like to extend our algorithm to learn recognisers based on arbitraryalgebraic theories. One challenge is to ensure that the equations of the theoryhold for hypotheses, by generalising our definition of associativity (Definition 13).Our algorithm can also be specialised to learn languages recognised by com-mutative monoids. These languages of multisets can alternatively be representedas semi-linear sets [29] or described using Presburger arithmetic [11]. While notall languages described this way are recognisable (for instance, the set of multi-sets over Σ = { a , b } with as many a ’s as b ’s [27]), it would be interesting to beable to learn at least the fragment representable by commutative monoids, andapply that to one of the domains where semi-linear sets are used.Our algorithm is limited to learning languages of series-parallel pomsets;there exist pomsets which are not series-parallel, each of which must contain an“N-shape” [12,13,34]. Since N-shapes appear in pomsets that describe messagepassing between threads, we would like to be able to learn such languages aswell. We do not see an obvious way to extend our algorithm to include thesepomsets, but perhaps recent techniques from [10] can provide a solution.Every hypothesis of our algorithm can be converted to a pomset automaton.The final pomset recogniser for a bounded-width language is minimal, and hencedepth-nilpotent [27], which means that it can be converted to a fork-acyclic PA.In future work, we would like to guarantee that the same holds for intermediatehypotheses when learning a bounded-width language.Running two threads in parallel may be implemented by running some initialsection of those threads in parallel, followed by running the remainder of thosethreads in parallel. This interleaving is represented by the exchange law [12,13].One can specialise pomset recognisers to include this interleaving to obtain recog-nisers of pomset languages closed under subsumption [27], i.e., such that if apomset u is recognised, then so are all of the “more sequential” versions of u .We would like to adapt our algorithm to learn these types of recognisers, andexploit the extra structure provided by the exchange law to optimise further.We have shown that recognisable pomset languages correspond to saturatedregular pomset languages (Lemmas 37 and 39). One question that remains iswhether there is an algorithm that can learn all or at least a larger class ofregular pomset languages. Given that pomset automata can accept context-freelanguages (Figure 1b), we wonder if a suitable notion of context-free grammarsfor pomset languages could be identified. Clark [6] showed that there existsa subclass of context-free languages that can be learned via an adaptation of L ⋆ . Arguably, this adaptation learns recognisers with a monoidal structure andreverses this structure to obtain a grammar. An extension of this work to pomsetlanguages might lead to a learning algorithm that learns more PAs. earning Pomset Automata 19 References
1. Aarts, F., Vaandrager, F.W.: Learning I/O automata. In: CONCUR. pp. 71–85(2010). https://doi.org/10.1007/978-3-642-15375-4 62. Angluin, D.: Learning regular sets from queries and counterexamples. Inf. Comput. (2), 87–106 (1987). https://doi.org/10.1016/0890-5401(87)90052-63. Barlocco, S., Kupke, C.: Angluin learning via logic. In: LFCS. LNCS, vol. 10703,pp. 72–90. Springer (2018). https://doi.org/10.1007/978-3-319-72056-2 54. Bojanczyk, M.: Recognisable languages over monads. In: DLT. pp. 1–13 (2015).https://doi.org/10.1007/978-3-319-21500-6 15. Chapman, M., Chockler, H., Kesseli, P., Kroening, D., Strichman, O.,Tautschnig, M.: Learning the language of error. In: ATVA. pp. 114–130 (2015).https://doi.org/10.1007/978-3-319-24953-7 96. Clark, A.: Distributional learning of some context-free languageswith a minimally adequate teacher. In: ICGI. pp. 24–37 (2010).https://doi.org/10.1007/978-3-642-15488-1 47. Drewes, F., H¨ogberg, J.: Learning a regular tree language from a teacher. In: DLT.pp. 279–291 (2003). https://doi.org/10.1007/3-540-45007-6 228. Drewes, F., H¨ogberg, J.: Query learning of regular tree languages:How to avoid dead states. Theory Comput. Syst. , 163–185 (2007).https://doi.org/10.1007/s00224-005-1233-39. ´Esik, Z., N´emeth, Z.L.: Higher dimensional automata. J. Autom. Lang. Comb. (1), 3–29 (2004). https://doi.org/10.25596/jalc-2004-00310. Fahrenberg, U., Johansen, C., Struth, G., Thapa, R.B.: Generating posets beyond N . In: RAMiCS. pp. 82–99 (2020). https://doi.org/10.1007/978-3-030-43520-2 611. Ginsburg, S., Spanier, E.H.: Bounded ALGOL-like languages. Trans. Am. Math.Soc. (2), 333–368 (1964). https://doi.org/10.2307/199406712. Gischer, J.L.: The equational theory of pomsets. Theor. Comput. Sci. , 199–224(1988). https://doi.org/10.1016/0304-3975(88)90124-713. Grabowski, J.: On partial languages. Fundam. Inform. , 130–153 (2019). https://doi.org/10.1016/j.jlamp.2018.12.00123. Kapp´e, T., Brunet, P., Silva, A., Zanasi, F.: Concurrent Kleene al-gebra: Free model and completeness. In: ESOP. pp. 856–882 (2018).https://doi.org/10.1007/978-3-319-89884-1 3024. Kearns, M.J., Vazirani, U.V.: An Introduction to Computational Learning Theory.MIT press (1994)25. Laurence, M.R., Struth, G.: Completeness theorems for bi-Kleene alge-bras and series-parallel rational pomset languages. In: Proc. Relationaland Algebraic Methods in Computer Science (RAMiCS). pp. 65–82 (2014).https://doi.org/10.1007/978-3-319-06251-8 526. Lodaya, K., Weil, P.: A Kleene iteration for parallelism. In: FSTTCS. pp. 355–366(1998). https://doi.org/10.1007/978-3-540-49382-2 3327. Lodaya, K., Weil, P.: Series-parallel languages and the bounded-width property. Theoretical Computer Science (1), 347–380 (2000).https://doi.org/10.1016/S0304-3975(00)00031-128. Maler, O., Pnueli, A.: On the learnability of infinitary regular sets. Inf. Comput. , 316–326 (1995). https://doi.org/10.1006/inco.1995.107029. Parikh, R.: On context-free languages. J. ACM (4), 570–581 (1966).https://doi.org/10.1145/321356.32136430. Sakakibara, Y.: Learning context-free grammars from structural datain polynomial time. Theor. Comput. Sci. (2-3), 223–242 (1990).https://doi.org/10.1016/0304-3975(90)90017-C31. Urbat, H., Ad´amek, J., Chen, L., Milius, S.: Eilenberg theorems for free. In: MFCS.pp. 43:1–43:15 (2017). https://doi.org/10.4230/LIPIcs.MFCS.2017.4332. Urbat, H., Schr¨oder, L.: Automata learning: An algebraic approach. In: LICS. pp.900–914 (2020). https://doi.org/10.1145/3373718.339477533. Vaandrager, F.W.: Model learning. Commun. ACM (2), 86–95 (2017).https://doi.org/10.1145/296760634. Valdes, J., Tarjan, R.E., Lawler, E.L.: The recognition of series parallel digraphs.SIAM J. Comput. (2), 298–313 (1982). https://doi.org/10.1137/0211023 Open Access
This chapter is licensed under the terms of the Creative CommonsAttribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/),which permits use, sharing, adaptation, distribution and reproduction in any mediumor format, as long as you give appropriate credit to the original author(s) and thesource, provide a link to the Creative Commons license and indicate if changes weremade.The images or other third party material in this chapter are included in the chapter’sCreative Commons license, unless indicated otherwise in a credit line to the material. Ifmaterial is not included in the chapter’s Creative Commons license and your intendeduse is not permitted by statutory regulation or exceeds the permitted use, you will needto obtain permission directly from the copyright holder.earning Pomset Automata 21
A Omitted Proofs about the Algorithm
Lemma 20. h SP , PC i is a closed, consistent, and associative observation table.Proof. Closedness holds trivially, and associativity follows from consistency. Itremains to show that consistency holds. For ♥ ∈ {· , k} we have for all s , s , t ∈ SP such that row ( s ) = row ( s ) and e ∈ PC that row ( s ♥ t )( e ) = 1 ⇐⇒ e [ s ♥ t ] ∈ L⇐⇒ e [ (cid:3) ♥ t ][ s ] ∈ L⇐⇒ row ( s )( e [ (cid:3) ♥ t ]) = 1 ⇐⇒ row ( s )( e [ (cid:3) ♥ t ]) = 1 ⇐⇒ e [ (cid:3) ♥ t ][ s ] ∈ L⇐⇒ e [ s ♥ t ] ∈ L⇐⇒ row ( s ♥ t )( e ) = 1and symmetrically we can show that row ( t ♥ s )( e ) = 1 ⇐⇒ row ( t ♥ s )( e ) = 1 . ⊓⊔ Lemma 24 (Hypothesis reachability).
Given a closed, consistent, and as-sociative observation table h S, E i , the hypothesis it induces is reachable. In par-ticular, i H♯ ( s ) = row ( s ) for any s ∈ S .Proof. By induction on the pomsets in S , using subpomset-closedness. We have i H ♯ (1) = H = row (1) ∀ a ∈ Σ. i
H ♯ ( a ) = i H ( a ) = row ( a ) . Now assume for the inductive case that s , s ∈ S are such that i H♯ ( s ) = row ( s )and i H ♯ ( s ) = row ( s ). Then i H ♯ ( s · s ) = i H ♯ ( s ) ⊙ H i H ♯ ( s ) = row ( s ) ⊙ H row ( s ) = row ( s · s )and similarly i H ♯ ( s k s ) = row ( s k s ). ⊓⊔ Lemma 25.
The hypothesis of any closed, consistent, and associative observa-tion table h S, E i is S -compatible.Proof. For all s ∈ S , we have s ∈ L H ⇐⇒ i H ♯ ( s ) ∈ F H ⇐⇒ row ( s ) ∈ F H (Lemma 24) ⇐⇒ row ( s )( (cid:3) ) = 1 ⇐⇒ s ∈ L . ⊓⊔ Lemma 29.
For all pomset recognisers h M, ⊙ , ȅ , , i, F i and u, v ∈ SP suchthat i ♯ ( u ) = i ♯ ( v ) we have for any c ∈ PC that i ♯ ( c [ u ]) = i ♯ ( c [ v ]) . Proof.
Proof by induction on the elements of PC . For any a ∈ Σ trivially have i ♯ ( a ) = i ♯ ( a ), and similarly i ♯ (1) = i ♯ (1). Furthermore, i ♯ ( (cid:3) [ u ]) = i ♯ ( u ) = i ♯ ( v ) = i ♯ ( (cid:3) [ v ]) . Now let c , c ∈ PC satisfy i ♯ ( c [ u ]) = i ♯ ( c [ v ]) and i ♯ ( c [ u ]) = i ♯ ( c [ v ]). Then i ♯ (( c · c )[ u ]) = i ♯ ( c [ u ] · c [ u ])= i ♯ ( c [ u ]) ⊙ i ♯ ( c [ u ])= i ♯ ( c [ v ]) ⊙ i ♯ ( c [ v ])= i ♯ ( c [ v ] · c [ v ])= i ♯ (( c · c )[ v ])and similarly i ♯ (( c k c )[ u ]) = i ♯ (( c k c )[ v ]). ⊓⊔ Proposition 31.
The canonical pomset recogniser is minimal.Proof.
From Lemma 25 we know that the pomset recogniser accepts L , so byTheorem 30 it is minimal. B Omitted proofs about saturated pomset automata
Lemma 37.
Let R = h M, ⊙ , ȅ , , i, F i be a pomset recogniser. We constructthe pomset automaton A = h M, F, { } , δ, γ i (note: the set F consists of initialstates) where δ : M × Σ → M and γ : M × M ( M ) → M are given by δ ( q, a ) = { q ′ : f ( a ) ⊙ q ′ = q } γ ( q, φ ) = { q ′ : ( r ȅ r ′ ) ⊙ q ′ = q, φ = {| r, r ′ |}} Then A is saturated, and L A = L R .Proof. Our proof relies on the following property of A : Claim. q u −→ A q ′ if and only if i ♯ ( u ) ⊙ q ′ = q . Proof.
For the direction from left to right, we proceed by induction on → A . Inthe base, there are two cases. On the one hand, suppose q u −→ A q ′ is a trivial run,i.e., u = 1 and q = q ′ . We then calculate i ♯ ( u ) ⊙ q ′ = ⊙ q ′ = q ′ = q . On theother hand, suppose q u −→ A q ′ is a δ -run, which is to say that u = a for some a ∈ Σ with q ′ ∈ δ ( q, a ). It then follows that, i ♯ ( u ) ⊙ q ′ = i ( a ) ⊙ q ′ = q .For the inductive step, there are again two cases to consider. – Suppose that q u −→ A q ′ is a composite run, i.e., that u = v · w and q ′′ ∈ M such that q v −→ A q ′′ and q ′′ w −→ A q ′ . By induction, we have i ♯ ( v ) ⊙ q ′′ = q and i ♯ ( w ) ⊙ q ′ = q ′′ . In total, we find that i ♯ ( u ) ⊙ q ′ = ( i ♯ ( v ) ⊙ i ♯ ( w )) ⊙ q ′ = i ♯ ( v ) ⊙ ( i ♯ ( w ) ⊙ q ′ ) = i ♯ ( v ) ⊙ q ′′ = q earning Pomset Automata 23 – Suppose q u −→ q ′ because u = v k w and there exist r, r ′ ∈ M such that q ′ ∈ γ ( q, {| r, r ′ |} ) as well as r v −→ A and r ′ w −→ A . Then by induction weknow that i ♯ ( v ) = i ♯ ( v ) ⊙ = r and i ♯ ( w ) = i ♯ ( w ) ⊙ = r ′ . Furthermore,since q ′ ∈ γ ( q, {| r, r ′ |} ) we know that ( r ȅ r ′ ) ⊙ q ′ = q . In total, we find that i ♯ ( u ) ⊙ q ′ = ( i ♯ ( v ) ȅ i ♯ ( w )) ⊙ q ′ = ( r ȅ r ′ ) ⊙ q ′ = q For the other direction, we proceed by induction on the structure of u . In thebase, there are two cases. On the one hand, if u = 1, then q −→ A q = q ′ immedi-ately. On the other hand, if u = a for some a ∈ Σ , then i ( a ) ⊙ q ′ = i ♯ ( u ) ⊙ q ′ = q ,and hence q ′ ∈ δ ( q, a ). Therefore, q a −→ A q ′ .For the inductive step, there are two cases to consider. – Suppose that u = v · w for v, w = 1. Let q ′′ = i ♯ ( w ) ⊙ q ′ . We then find byinduction that q ′′ w −→ A q ′ . Furthermore, note that i ♯ ( v ) ⊙ q ′′ = i ♯ ( v ) ⊙ ( i ♯ ( w ) ⊙ q ′ ) = ( i ♯ ( v ) ⊙ i ♯ ( w )) ⊙ q ′ = i ♯ ( u ) ⊙ q ′ = q . Hence, we find by induction that q v −→ A q ′′ . Putting this together, it follows that q u −→ A q ′ . – If u = v k w for v, w = 1, then choose r = i ♯ ( v ) and r ′ = i ♯ ( w ), and note that i ♯ ( v ) ⊙ = r and i ♯ ( w ) ⊙ = r ′ . Hence, we find by induction that r v −→ A and r ′ w −→ A . Since also ( r ȅ r ′ ) ⊙ q ′ = ( i ♯ ( v ) ȅ i ♯ ( w )) ⊙ q ′ = i ♯ ( u ) ⊙ q ′ = q ,it follows that q ′ ∈ γ ( q, {| r, r ′ |} ). In total, q u −→ A q ′ . ⊓⊔ Continuing the proof of Lemma 37, to see that A is saturated, let u, v ∈ SP with u, v = 1. First, suppose q u · v −−→ A q ′ . By the above property, i ♯ ( u · v ) ⊙ q ′ = q . Ifwe now choose q ′′ = i ♯ ( v ) ⊙ q ′ ∈ M , we find that i ♯ ( u ) ⊙ q ′′ = i ♯ ( u ) ⊙ i ♯ ( v ) ⊙ q ′ = i ♯ ( u · v ) ⊙ q ′ . By the same property we find that q u −→ A q ′′ and q ′′ v −→ A q ′ .Next, suppose that q u k v −−→ A q ′ . By the property above, we have ( i ♯ ( u ) ȅ i ♯ ( v )) ⊙ q ′ = q . If we choose r = i ♯ ( u ) and s = i ♯ ( v ) as well as r ′ = s ′ = , then i ♯ ( u ) ⊙ r ′ = r and i ♯ ( v ) ⊙ s ′ = s , and thus r u −→ A r ′ and s v −→ A s ′ again by thesame property. Furthermore, since ( r ȅ s ) ⊙ q ′ = q , we have q ′ ∈ γ ( q, {| r, s |} ).Note that A is finite. To see that A accepts L R , note that u ∈ L R preciselywhen i ♯ ( u ) ∈ F , which holds if and only if there exists a q ∈ F with i ♯ ( u ) = q ,which, by the above, is equivalent to q u −→ for some q ∈ F , i.e., u ∈ L A . ⊓⊔ Lemma 39.
Let A = h Q, I, F, δ, γ i be a saturated pomset automaton. We canconstruct a pomset recogniser R = h M, ⊙ , ȅ , , i, F ′ i , where M = { u −→ A : u ∈ SP } u −→ A ⊙ v −→ A = u · v −−→ A u −→ A ȅ v −→ A = u k v −−→ A i ( a ) = a −→ A F ′ = { u −→ A ∈ M : ∃ q ∈ I, q ′ ∈ F. q u −→ A q ′ } Now ⊙ and ȅ are well-defined, and R is a pomset recogniser such that L R = L A .Proof. Without loss of generality, we can assume that for u ∈ SP , we have u −→ A = −→ A if and only if u = 1: the implication from right to left is obvious, andthe converse can be guaranteed (while preserving saturation of A as well as itslanguage) by adding a non-initial and non-accepting state without transitions. Let u, u ′ , v, v ′ ∈ SP such that u −→ A = u ′ −→ A and v −→ A = v ′ −→ A . To prove thatthe operations are well-defined, we should show u · v −−→ A = u ′ · v ′ −−−→ A and u k v −−→ A = u ′ k v ′ −−−→ A . For the former equality, we consider two cases. – If u = 1, then u ′ −→ A = u −→ A = −→ A , and thus u ′ = 1. In that case u · v −−→ A ′ = v −→ A ′ = v ′ −→ A ′ = u ′ · v ′ −−−→ A ′ A similar derivation applies if any of the other pomsets are empty. – If u, u ′ , v, v ′ = 1, suppose q u · v −−→ A q ′ . Because A is saturated, we find a q ′′ ∈ Q such that q u −→ A q ′′ and q ′′ v −→ A q ′ . Since u −→ A = u ′ −→ A and v −→ A = v ′ −→ A , itfollows that q u ′ −→ A q ′′ and q ′′ v ′ −→ A q ′ , and hence q u ′ · v ′ −−−→ A q ′ . This showsthat u · v −−→ A is contained in u ′ · v ′ −−−→ A ; the converse can be shown symmetrically.Next, we show that u k v −−→ A = u ′ k v ′ −−−→ A ; again, we have two cases to consider. – If u = 1, then u ′ −→ A = u −→ A = −→ A , and thus u ′ = 1 by the above. Thus, u k v −−→ A ′ = v −→ A ′ = v ′ −→ A ′ = u ′ k v ′ −−−→ A ′ A similar derivation applies if any of the other pomsets are empty. – If u, u ′ , v, v ′ = 1, suppose that q u k v −−→ A q ′ . In that case, since A is saturated,we find r, s ∈ Q and r ′ , s ′ ∈ F such that r u −→ A r ′ and s v −→ A s ′ , and q ′ ∈ γ ( q, {| r, s |} ). Since u −→ A = u ′ −→ A and v −→ A = v ′ −→ A , it then follows that r u ′ −→ A r ′ and s v ′ −→ s ′ , and thus q u ′ k v ′ −−−→ q ′ . This shows that u k v −−→ A iscontained in u ′ k v ′ −−−→ ; the converse inclusion follows by a similar argument.The bimonoid laws can now be proved straightforwardly; for instance, ȅ is as-sociative because for u, v, w ∈ SP we have u −→ A ȅ ( v −→ A ȅ w −→ A ) = u k ( v k w ) −−−−−→ A = ( u k v ) k w −−−−−→ A = ( u −→ A ȅ v −→ A ) ȅ w −→ A Associativity of ⊙ and the fact that −→ A is a unit can be shown similarly. Thismakes R a proper pomset recogniser.It should be clear that for u ∈ SP we have i ♯ ( u ) = u −→ A . From this, it followsthat u ∈ L A if and only if there exist q ∈ I and q ′ ∈ F such that q u −→ A q ′ , whichholds precisely when i ♯ ( u ) = u −→ A ∈ F ′ , and thus u ∈ L R . ⊓⊔ C Translation to fork-acyclic pomset automata
Bimonoids recognisers can, in general, encode pomset languages of unboundedwidth , i.e., without an upper bound on the antichains in the pomsets, and evenpomset languages of unbounded depth , with a complex mutual nesting structurebetween sequential and parallel composition. By Lemma 37, even these can beaccepted by a pomset automaton. Typical programs, however, have a limitednumber of parallel threads, and tend not to launch threads recursively. To furtherrestrict PAs so as to exclude this kind of behaviour, we can use the notion offork-acyclicity [27]; for pomset automata, this comes down to the following [21]: earning Pomset Automata 25
Definition 40 (Fork-acyclicity).
Let A = h Q, I, F, δ, γ i be a PA. We definethe support relation of A , denoted (cid:22) A , as the smallest preorder on Q satisfying a ∈ Σ q ′ ∈ δ ( q, a ) q ′ (cid:22) A q φ ∈ M ( Q ) q ′ ∈ γ ( q, φ ) q ′ (cid:22) A q γ ( q, {| r, . . . |} ) r (cid:22) A q We say that A is fork-acyclic if for all q, r ∈ Q and φ ∈ M ( Q ) with r ∈ φ and γ ( q, φ ) = ∅ it holds that q A r .Example 41. Recall the PAs drawn in Figure 1. If A is the PA in Figure 1a,then A is fork-acyclic; after all, the only fork is given by q ∈ γ ( q , {| q , q |} ), andwe have that q , q ≺ A q —in other words, the runs starting at q or q do notdepend on q . On the other hand, if A is the PA in Figure 1b, then A is notfork-acyclic, since γ ( q , {| q , q |} ) = ∅ but q (cid:22) A q , since q ∈ δ ( q , a ).Intuitively, if q and q ′ are states such that q ′ (cid:22) A q , then the pomsets thatcan be read starting in q somehow depend on those that can be read from q ′ . Apomset automaton is fork-acyclic if it can only fork into states whose languagedoes not depend on the point of origin for the fork. For example, the PA inFigure 1a is fork-acyclic, because q and q cannot reach (or fork into) q , whilethe PA in Figure 1b is not, because γ ( q , {| q , q |} ) = ∅ while q (cid:22) A q .The corresponding restriction on pomset recognisers is depth-nilpotency [27],which we adapt for our purposes as follows. Definition 42 (Depth-nilpotency).
Let R = h M, ⊙ , ȅ , , i, F i be a pomsetrecogniser. We define ≺ R as the smallest transitive relation on M satisfying thefollowing rule for all s, u, v, w, t, x, y ∈ M : s = u ⊙ ( v ȅ ( w ⊙ t ⊙ x )) ⊙ y v ȅ ( w ⊙ t ⊙ x ) = w ⊙ t ⊙ xs ≺ R t We say that R is depth-nilpotent if the following hold:(i) there exists an N ∈ N such that every ≺ R -chain is of length at most N , thatis, for all q , . . . , q n ∈ M with q ≺ R · · · ≺ R q n , it holds that n ≤ N .(ii) there exists a ∈ M \ F such that s k = for all s ∈ M .(iii) if s, t ∈ M and s ȅ t = t , then either s = or t = .(iv) for all u ∈ SP , we have i ♯ ( u ) = if and only if u = 1 .When R is depth-nilpotent, we write D R ( s ) for the length of the longest ≺ R -chain starting at s ∈ M , i.e., the maximal n such that there exist s = s , . . . , s n ∈ M with s ≺ R · · · ≺ R s n .Example 43. The pomset recogniser R defined in Example 6 is depth-nilpotent;indeed, the maximal ≺ R -chain is given by q ⊥ ≺ R q ≺ R q a , q b ≺ R .On the other hand, if R is as in Example 7, then R is not depth-nilpotent,because q b = q a ⊙ ( q b ȅ q b ), and hence q b ≺ R q b . q b q q a b a Fig. 3: Part of the PA obtained from the pomset recogniser from Example 6,using the construction from Lemma 44. Once more, the state q ⊥ and transitionsinto are not pictured.One can combine existing results to show that a language recognised by adepth-nilpotent pomset recogniser can also be accepted by a fork-acyclic PA:by [27, Theorem 3.9], every such language is series-rational, and by [21, Theo-rem 7.16], every series-rational language is recognised by a fork-acyclic PA. How-ever, this detour is not necessary: we can convert a depth-nilpotent bimonoid toa fork-acyclic automaton directly, by adapting the construction from Lemma 37. Lemma 44.
Let R = h M, ⊙ , ȅ , , i, F i be a depth-nilpotent pomset recogniser.Let A = h M, F, { } , δ, γ i be the PA constructed from R just like in Lemma 37,except that we define the parallel transition function γ : : M × M ( M ) → M by γ ( q, φ ) = { q ′ : ( r ȅ s ) ⊙ q ′ = q, φ = {| r, s |} , D R ( r ) < D R ( q ) , D R ( s ) < D R ( q ) } Now A is fork-acyclic, and L A = L R .Example 45. Let h M, ⊙ , ȅ , , i, F i be the pomset recogniser from Example 6.The pomset automaton that arises from the construction above is partially de-picted in Figure 3. Here, we have that q and are initial states, since theyboth appear in F . Furthermore, ∈ δ ( q b ) because i ( b ) ⊙ = q b , and q ∈ γ ( q , {| q a , q b |} ) because ( q a ȅ q b ) ⊙ q = q ⊙ q = q . However, γ ( q b , {| q b , |} )despite ( q b ȅ ) ⊙ = q b , because D R ( q b ) is not strictly larger than D R ( q b ). Proof (of Lemma 44).
Our proof rests on the following two properties of A . Claim. If i ♯ ( u ) ⊙ q ′ = q and q = , then q u −→ A q ′ . Proof.
We proceed by induction on u . In the base, we have two cases. On theone hand, if u = 1, then i ♯ ( u ) = , and so the claim holds immediately. On theother hand, if u = a for some a ∈ Σ , then q ′ ∈ δ ( q, a ), whence q u −→ A q ′ again.For the inductive step, there are two cases. – If u = v · w with v, w = 1, then choose q ′′ = i ♯ ( w ) ⊙ q ′ . Now q ′′ = , otherwise q = i ♯ ( v ) ⊙ q ′′ = . By induction, we then find that q ′′ w −→ A q ′ , as well as q v −→ A q ′′ . In total, we have q u −→ A q ′ . earning Pomset Automata 27 – If u = v k w with v, w = 1, then choose r = i ♯ ( v ) and s = i ♯ ( w ). Now r, s = , otherwise q = i ♯ ( u ) ⊙ q = ( i ♯ ( v ) ȅ i ♯ ( w )) ⊙ q ′ = . Furthermore, r, s = , otherwise v = 1 or w = 1. Together, this means that r ȅ s = r and r ȅ s = s , by depth-nilpotency of M . Since i ♯ ( v ) ⊙ = r and i ♯ ( w ) ⊙ = s , wefind by induction that r v −→ A and s w −→ A . Since q = ( r ȅ s ) ⊙ q ′ , it followsthat q ≺ R r, s , and hence D R ( r ) < D R ( q ) as well as D R ( s ) < D R ( q ). Wethen know that q ′ ∈ γ ( q, {| r, s |} ), and thus q u −→ A q ′ . ⊓⊔ Claim. If q (cid:22) A q ′ , then D R ( q ′ ) ≤ D R ( q ). Proof.
It suffices to validate the claim for the pairs that generate (cid:22) A . – If q ′ (cid:22) A q because q ′ ∈ δ ( q, a ) for some a ∈ Σ , then i ♯ ( a ) ⊙ q ′ = q . Nowsuppose that q ′ ≺ R q ′′ for some q ′′ ∈ M ; we then obtain u, v, w, x, y ∈ M such that q ′ = u ⊙ ( v ȅ ( w ⊙ q ′′ ⊙ x )) ⊙ y , and v ȅ ( w ⊙ q ′′ ⊙ x ) = w ⊙ q ′′ ⊙ x .Clearly, q = i ♯ ( a ) · q ′ = i ♯ ( a ) ⊙ u ⊙ ( v ȅ ( w ⊙ q ′′ ⊙ x )) ⊙ y , and hence q ≺ R q ′′ .It follows that every chain starting at q ′ can be turned into one starting at q , hence D R ( q ′ ) ≤ D R ( q ). – If q ′ (cid:22) A q because q ′ ∈ γ ( q, {| r, s |} ) for some r, s ∈ M , then a similar argu-ment to the previous case shows that D R ( q ′ ) ≤ D R ( q ). – If q ′ (cid:22) A q because γ ( q, {| q ′ , r |} ) = ∅ for some r ∈ M , then D R ( q ′ ) < D R ( q )by definition of γ . ⊓⊔ We return to the proof of Lemma 44. If u ∈ L A , then there exists a q ∈ F with q u −→ A . By the same argument as in Lemma 37, i ♯ ( u ) ⊙ = q —after all,the transitions of the new automaton are also transitions of the old automaton.Hence i ♯ ( u ) ∈ F , meaning u ∈ L R . Conversely, if u ∈ L R , then i ♯ ( u ) = bydepth-nilpotency, and by the first claim above we have q u −→ A , meaning u ∈ L A .For fork-acyclicity, let q, r, s ∈ M be such that γ ( q, {| r, s |} ) = ∅ . In that case, D R ( r ) < D R ( q ) by definition; thus q (cid:22) A r cannot hold, because that wouldimply D R ( r ) ≤ D R ( r ) by the second claim above. ⊓⊔⊓⊔