Notes on Monoids and Automata
Total Page:16
File Type:pdf, Size:1020Kb
Notes on Monoids and Automata Uday S. Reddy November 9, 1994 In this article, I define a semantics for Algol programs with Reynolds’s syntactic control of interference (?; ?) in terms of comonoids in coherent spaces (also called correletation spaces). 1 Background: Monoids 1.1 Definition A monoid (in SET) is a triple M = (M, 1, ·) where • M is a set, • 1 ∈ M is an element called the unit, and • · : M × M → M is a binary operation called multiplication such that the following identities hold: • x · 1= x = 1 · x, for all x ∈ M, and • (x · y) · z = x · (y · z), for all x,y,z ∈ M. Note that the unit is necessarily unique. We often omit the · operator and write x · y as simply xy. The structure is called a semigroup if we don’t insist on the unit being present. It is called a commutative monoid if, in addition, • xy = yx, for all x, y ∈ M. Suppose only some instances of the commutativity equation hold so that the structure is a “partially commutative” monoid. Then, we can define a relation ∼⊆ M × M such that x ∼ y ⇐⇒ xy = yx. Evidently, ∼ is reflexive and symmetric. A zero in a monoid is an element 0 ∈ M such that 0x =0= x0 for all x ∈ M. Note that 0 is necessarily unique. A submonoid of M is a subset M ′ ⊆ M containing 1 and closed under multiplication. If x ∈ M, we use the notation xn for the n-fold product x ··· x (with x0 = 1). x∗ denotes the n ∗ set { x : n ≥ 0 }. Similarly, if S ⊆ M, S denotes the set {x1 ··· xn : x1,...,xn ∈ S }. Note that the S∗ is the least submonoid of M including S. If S∗ = M, we say that S is a set of generators for M. 1.2 Examples The following examples will be of much interest to our discussion: (i) Let Q be a set. The set of partial functions from Q to Q (called transformations of Q) forms a monoid. The identity transformation 1Q is the unit and the composition f; g of transforma- tions is the multiplication. We find it convenient to use postfix notation for transformations. Then, the above operations are defined by q1Q = q (qf)g, if qf is defined q(f; g) = (undefined, otherwise 1 We denote this monoid by [Q → Q]. It has a zero element, viz., the undefined transformation. Any submonoid of [Q → Q] is called a transformation monoid. (ii) More generally, in any category C, the endomorphisms on an object A form a monoid, denoted EndC(A). So, the set of binary relations over Q and the set of total functions from Q to Q form monoids too. (iii) Let Σ be a set (of “symbols”). The set of strings over Σ, denoted Σ∗ is a monoid with concatenation as the multiplication and the empty string ǫ as the unit. It is called the free monoid generated by Σ. Similarly, the set of nonempty strings over Σ (Σ+) is the free semigroup generated by Σ, and the set of finite multisets over Σ is the free commutative monoid generated by Σ. Some more examples of passing interest are as follows: (iv) The set of natural numbers ω forms a monoid with multiplication as the binary operation and the integer 1 as the unit. This is, in fact, a commutative monoid. (v) The set of natural numbers, again, forms a commutative monoid with addition as the binary operation and 0 as the unit. This is isomorphic, in the sense to be made precise below, to the monoid {1}∗ (the free monoid generated by {1}). (vi) The set of n × n matrices forms a monoid under matrix multiplication as the multiplication and the identity matrix as the unit. This is, of course, a special case of the endomorphisms in a category example mentioned above. The following examples give important constructions on monoids: (vii) If M = (M, 1, ·) is a monoid, its dual monoid is (M, 1, ∗) where ∗ is defined by x ∗ y = y · x. Thus, the notion of monoid is a symmetric concept. (viii) Let M be a monoid. For each x ∈ M, there corresponds a right multiplication operator Rx : M → M defined by zRx = zx. The set of right multiplication operators forms a monoid, in fact, a transformation monoid over M. The unit is R1 and the multiplication is Rx · Ry = Rxy. In fact, the right multiplication monoid is isomorphic to the monoid itself. Similarly, the left multiplication operators Lx : M → M are defined by Lx(z) = xz. They have a unit L1 and multiplication Lx · Ly = Lyx. Thus, the left multiplication operators form a monoid that is isomorphic to the dual of M. (ix) Let M be a monoid. An equivalence relation ≡ ⊆ M × M is called a (monoid) congruence relation if x ≡ x′ ∧ y ≡ y′ =⇒ xy ≡ x′y′. A congruence class is a maximal set X ⊆ M such that all the elements of X are equivalent to each other. The congruence class containing an element x is [x] = { y : y ≡ x }. The set of such congruence classes forms a monoid. The unit element is [1] and the multiplication of equivalence classes is defined by: [x] · [y]=[xy]. The fact that ≡ is a congruence relation ensures that multiplication is well-defined (as may be verified). This monoid is called the quotient monoid of M under ≡, denoted M/≡. (x) A pair (Σ, ∼), where Σ is a set and ∼⊆ Σ×Σ a symmetric relation, is called an independence alphabet (and ∼ its independence relation). Consider strings over Σ and the least congruence ≡ such that a ∼ b =⇒ ab ≡ ba. A congruence class [a1 ··· an] consists of all strings which only differ in the relative order of consecutive independent symbols. Such congruence classes are called traces and the quotient monoid Σ∗/≡ is called the free partially commutative monoid generated by Σ. (xi) Let Σ be an alphabet and S ⊆ Σ∗ be a set of strings. S induces an equivalence on strings by x ≈ y ⇐⇒ ∀z,z′. (zxz′ ∈ S ⇐⇒ zyz′ ∈ S). This is, in fact, a congruence relation, called the syntactic congruence or the Myhill congruence of S. Suppose x ≈ x′ and y ≈ y′. Then, zxx′z′ ∈ S ⇐⇒ zyx′z′ ∈ S from the first assumption and zyx′z′ ∈ S ⇐⇒ zyy′z′ ∈ S from the second assumption. Hence, xx′ ≈ yy′. Intuitively, x and y are equivalent if they behave 2 the same way as segments of strings in S. For example, let Σ = {a, b} and S be the regular set ab∗. Under the Myhill congruence of S, b ≈ bn+1 and a2 ≈ an+2 ≈ ban+1. Thus, the congruence classes are [ǫ], [a], [b] and [a2]. [ǫ] is the unit. [a2] is a zero. For the others, multiplication is defined by [a] · [b]=[a] and [b] · [a]=[a2]. The monoid Σ∗/≈ is called the syntactic monoid of S. More generally, a subset of any monoid S ⊆ M induces a syntactic congruence and a syntactic monoid. (xii) If S ⊆ Σ∗ is a set of strings, one can also define a syntactic right congruence on Σ∗ by x ≈r y iff ∀z. (xz ∈ S ⇐⇒ yz ∈ S). This is a right congruence relation in the sense that x ≈r y =⇒ xv ≡ yv for all v ∈ Σ∗. For example, for S = ab∗, the right congruence classes are [ǫ], [a] (containing all abn) and [a2] (containing all bn). Let the set of right congruence classes be Q. Then, each string x ∈ Σ∗ has a corresponding right multiplication operator on Q, defined by [z]Rx = [zx]. The set of right multiplication operators Rx forms a monoid with unit R1 and multiplication Rx · Ry = Rxy. This is in fact a transformation monoid over Q. As will be seen below, such a transformation monoid is nothing but an automaton. 1.3 Definition A monoid homomorphism h : (M, 1, ·) → (M ′, 1′, ·′) is a function h : M → M ′ such that (i) h(1) = 1′, and (ii) h(x · y)= h(x) ·′ h(y) for all x, y ∈ M. A one-one homomorphism is called a monomorphism and an onto homomorphism is called an epimorphism.1 If there is an inverse homomorphism h−1 such that h ◦ h−1 = h−1 ◦ h = id then h is called an isomorphism, and M and M ′ are said to be isomorphic. Whenever h : M → M ′ is a homomorphism, the image of h, defined by Im(h) = { y : ∃x ∈ M. h(x)= u }, is a submonoid of M ′. Dually, the equivalence relation ≡ on M defined by x ≡ y ⇐⇒ h(x)= h(y) is a congruence relation (called the kernel of h). The homomorphism h′ : M/≡ → M ′ given by h′([x]) = h(x), is then a mono. Therefore, M/≡ and Im(h) are isomorphic. If f : Σ → M is a function, it extends to a unique homomorphism h : Σ∗ → M such that h restricted to Σ is f. We can define it explicitly by h(a1 ··· an)= f(a1) ··· f(an). If h is a surjection, M is isomorphic to the quotient monoid Σ∗/≡ where ≡ is the kernel of h. More generally, if M has a set of generators S, to specify a homomorphism h : M → M ′, we only need to specify it on S. 2 Background: Automata 2.4 Definition Let Σ be a set (the alphabet or the instruction set of the automaton). A Σ- automaton is a pair A = (Q, F ) where Q is a set (the state set) and F : Σ → [Q → Q] is a function called the interpretation (mapping instructions to transformations of Q). We also call A an automaton class of type Σ, and denote this fact by writing A = (Q, F )Σ.