THEORY OF COMPUTATION Chapter 7 Regular Languages (Automata as - - PowerPoint PPT Presentation

theory of computation chapter 7 regular languages
SMART_READER_LITE
LIVE PREVIEW

THEORY OF COMPUTATION Chapter 7 Regular Languages (Automata as - - PowerPoint PPT Presentation

THEORY OF COMPUTATION (Automata as Algebras) THEORY OF COMPUTATION Chapter 7 Regular Languages (Automata as Algebras) A. Daneshgar (Slides prepared by Z. Ghafouri) Department of Mathematical Sciences Sharif University of Technology 2020,


slide-1
SLIDE 1

THEORY OF COMPUTATION (Automata as Algebras)

THEORY OF COMPUTATION Chapter7 Regular Languages (Automata as Algebras)

  • A. Daneshgar

(Slides prepared by Z. Ghafouri)

Department of Mathematical Sciences Sharif University of Technology

2020, March, 1st (1998, Esfand, 10)

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-2
SLIDE 2

THEORY OF COMPUTATION (Automata as Algebras)

An algebra

Definition: An algebra is a pair A = (A, O) where A is a set and O is a set of operations on A.

◮ An n−ary operation τ on A is a function that takes n

elements of A and returns a single element of A; i.e. τ : A × . . . × A

  • n

→ A,

◮ A 0−ary operation (nullary operation) is simply an element of

A, or a constant,

◮ A 1−ary operation (unary operation) is simply a function from

A to A,

◮ A 2−ary operation (binary operation) is simply a function

from A × A to A.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-3
SLIDE 3

THEORY OF COMPUTATION (Automata as Algebras)

A pre-automaton

Definition: A pre-automaton A =

  • Q, q0 ∈ Q, {τi : Q → Q}i∈Σ
  • with input symbols Σ of n elements, is an algebra with one nullary

and n unary operations on a set of states A.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-4
SLIDE 4

THEORY OF COMPUTATION (Automata as Algebras)

Homomorphisms

A =

  • Q, q0 ∈ Q, {τi : Q → Q}i∈Σ
  • B =
  • Q′, q0′ ∈ Q′, {τi ′ : Q′ → Q′}i∈Σ
  • A

B x y σ(x) σ(y) σ : Q → Q′ τi τ ′

i

∀i τ ′

i ◦ σ = σ ◦ τi

σ(q0) = q′

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-5
SLIDE 5

THEORY OF COMPUTATION (Automata as Algebras)

Isomorphisms

Definition: Two algebras A =

  • Q, q0 ∈ Q, {τi : Q → Q}i∈Σ
  • and

B =

  • Q′, q0′ ∈ Q′, {τi ′ : Q′ → Q′}i∈Σ
  • are said to be isomorphic if there exists a bijective homomorphism

σ : A → B such that its inverse, σ−1 : B → A, is also a bijective homomorphism.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-6
SLIDE 6

THEORY OF COMPUTATION (Automata as Algebras)

Subalgebras

◮ Let A = (A, O) be an algebra and let τ ∈ O be an n−ary operation

  • f A. A subset B of A is τ− closed if a0, . . . , an−1 ∈ B imply

τ(a0, . . . , an−1) ∈ B.

◮ B is a closed subset of A if B is τ− closed for each operation τ of

A.

◮ A subalgebra of the algebra A = (A, O) is an algebra B = (B, OB),

where B ⊆ A is a closed subset of A and OB = {τ|Bn : τ ∈ O is an n−ary operation}. In other words, a subalgebra is a subset of an algebra which is closed under all its operations and carrying the induced operations.

◮ A reduced algebra is an algebra whose only subalgebras are the

empty set and itself.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-7
SLIDE 7

THEORY OF COMPUTATION (Automata as Algebras)

Reduced pre-automata

A reduced pre-automaton A =

  • Q, q0 ∈ Q, {τi : Q → Q}i∈Σ
  • is a pre-automaton which is reduced as an algebra. Note that this

is equivalent to the condition that each state of Q is reachable from the initial state q0.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-8
SLIDE 8

THEORY OF COMPUTATION (Automata as Algebras)

Equivalence relations

◮ An equivalence relation on X is a binary relation ∼ on X such

that

◮ ∀x ∈ X (x ∼ x) (reflexivity), ◮ ∀x, y ∈ X (x ∼ y → y ∼ x) (simmetry), ◮ ∀x, y, z ∈ X (x ∼ y ∧ y ∼ z → x ∼ z) (transitivity).

◮ The equivalence class of an element x in X with respect to

the equivalence relation ∼ , denoted by [x]∼, is the set of all elements of X which are equivalent to x, i.e. [x]∼ = {y ∈ X | x ∼ y}.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-9
SLIDE 9

THEORY OF COMPUTATION (Automata as Algebras)

◮ Every two equivalence classes [x]∼ and [y]∼ are either equal

  • r disjoint, so the set of equivalence classes is a partition of X.

◮ The set of all equivalence classes of X by ∼, denoted by

X/ ∼, is called the quotient set of X.

◮ For any partition P of a set X, the relation ∼ on X defined by

x ∼ y if and only if x and y belong to the same element of P, is an equivalence relation on X.

Hence, talking about equivalence relations on a set is essentially the same as talking about partitions of a set: An equivalence relation determines a partition (in which the subsets are the equivalence classes), and a partition determines an equivalence relation (in which being equivalent means belonging to the same subset).

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-10
SLIDE 10

THEORY OF COMPUTATION (Automata as Algebras)

Equivalence coming from an onto-map

Any onto-map σ : A onto − → B gives rise to an equivalence relation on A according to which a1 ∼σ a2 ⇔ σ(a1) = σ(a1). Hence, the collection of all σ−inverse images of the elements of B forms a partition of A.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-11
SLIDE 11

THEORY OF COMPUTATION (Automata as Algebras)

Congruence relations

Definition: Let A = (A, O) be an algebra. A congruence relation is an equivalence relation on A which is compatible with the algebra

  • perations. In the case of a pre-automaton where each operation is

either nullary or unary, it means that for every x and y in A and each unary operation τi: [x] = [y] ⇔ [τi(x)] = [τi(y)].

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-12
SLIDE 12

THEORY OF COMPUTATION (Automata as Algebras)

The quotient pre-automaton

Definition: Let A =

  • Q, q0 ∈ Q, {τi : Q → Q}i∈Σ
  • be a

pre-automaton and ∼ be a congruence relation on A. The quotient pre-automaton of A by ∼ is A/ ∼=

  • Q/ ∼, [q0], {˜

τi : Q/ ∼ → Q/ ∼}i∈I

  • where ˜

τi([x]) = [τi(x)].

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-13
SLIDE 13

THEORY OF COMPUTATION (Automata as Algebras)

The canonical homomorphism

Consider the map σ : A → A/ ∼ defined as σ(x) = [x]; then σ is called the natural or the canonical map. Obviously σ is a homomorphism, or equivalently: x τi(x) σ(x) = [x] [τi(x)] = ˜ τi([x])

def ˜ τi

σ τi σ ˜ τi In other words σ(τi(x)) = [τi(x)] = ˜ τi(σ(x)). and σ(q0) = [q0].

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-14
SLIDE 14

THEORY OF COMPUTATION (Automata as Algebras)

Let A =

  • Q, q0 ∈ Q, {τi : Q → Q}i∈Σ
  • and

B =

  • Q′, q0′ ∈ Q′, {τi ′ : Q′ → Q′}i∈Σ
  • be two pre-automata and σ : A → B be an onto homomorphism.

Since σ maps A onto B, the collection of all σ−inverse images of the elements of B forms a partiotion of A. Let ∼σ be the equivalence relation corresponding to this partition. Since σ is a homomorphism, ∼σ is a congruence relation on A: [x]∼σ = [y]∼σ ⇔ σ(x) = σ(y) ⇔ τi ′(σ(x)) = τi ′(σ(y)) ⇔ σ(τi(x)) = σ(τi(y)) ⇔ [τi(x)]∼σ = [τi(y)]∼σ ⇔ ˜ τi([x]∼σ) = ˜ τi([x]∼σ).

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-15
SLIDE 15

THEORY OF COMPUTATION (Automata as Algebras)

Hence, having an onto homomorphism σ : A → B, one can make the quotient pre-automaton A by ∼σ A/∼σ =

  • Q/∼σ, [q0], {˜

τi : Q/∼σ → Q/∼σ}i∈Σ

  • where ˜

τi([x]) = [τi(x)]. Question: A B A/∼σ σ

  • nto hom

canonical hom ?

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-16
SLIDE 16

THEORY OF COMPUTATION (Automata as Algebras)

Consider the bijective map ˜ σ : A/∼σ − → B [x] → σ(x) [q0] → σ(q0) = q0′ Then ˜ σ is a homomorphism: [x] [τi(x)] σ(x) σ(τi(x)) = τi ′(σ(x))

σ : hom

˜ σ ˜ τi ˜ σ τi ′ Consequently,

A/∼σ ≃ B.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-17
SLIDE 17

THEORY OF COMPUTATION (Automata as Algebras)

Without loss of genelarity, assume that all pre-automata are defined on {0, 1}. So a pre-automaton is an algebra of type (0,1,1).

Consider the following fixed pre-automaton: Ur =

  • {0, 1}∗, λ ∈ {0, 1}∗, {ri : {0, 1}∗ → {0, 1}∗}i=0,1
  • where ri(w1 . . . wn) = w1 . . . wni.

Claim: For any reduced pre-automaton B =

  • P, p0 ∈ P, {τi : P → P}i=0,1
  • there exists an onto homomorphism σB : Ur
  • nto

− → B such that σB(w) = B(w). In other words σB(w1 . . . wn) = τwn ◦ . . . ◦ τw2 ◦ τw1(p0).

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-18
SLIDE 18

THEORY OF COMPUTATION (Automata as Algebras)

Sketch of Proof. B : a reduced pre-automaton ⇒ σB : an onto-map and w wi B(w) σB(wi) = τi(B(w))

def σB, B(w)

σB ri σB τi Hence, σB is a homomorphism. Therefore,

Ur/∼σB ≃ B.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-19
SLIDE 19

THEORY OF COMPUTATION (Automata as Algebras)

Example

The following two pre-automata are isomorphic:

q0

start

q2 q1

1 1 0, 1

{λ}

start

S {10n}

1 1 0, 1

where S = {0, 1}∗ \ ({λ} ∪ {10n | n ∈ N}).

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-20
SLIDE 20

THEORY OF COMPUTATION (Automata as Algebras)

Ur B λ 10n S q0 q1 q2 σB σB σB

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-21
SLIDE 21

THEORY OF COMPUTATION (Automata as Algebras)

The minimal automaton

Let L ⊆ {0, 1}∗ be a language. We are trying to construct a minimal pre-automaton ML to accept L. We will be needing some ingredients as follows:

◮ Definition: For a language L ⊆ {0, 1}∗ and any x ∈ {0, 1}∗,

define: x\L = {u ∈ {0, 1}∗ | xu ∈ L}. From this definition, it follows that for every x, y ∈ {0, 1}∗: x\(y\L) = {u ∈ {0, 1}∗ | xu ∈ y\L} = {u ∈ {0, 1}∗ | yxu ∈ L} = (yx)\L.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-22
SLIDE 22

THEORY OF COMPUTATION (Automata as Algebras)

◮ Definition: For a language L ⊆ {0, 1}∗, define a relation ∼ on

{0, 1}∗ as follows: for x, y ∈ {0, 1}∗, x ∼ y ⇔ x\L = y\L ⇔ {u ∈ {0, 1}∗ | xu ∈ L} = {u ∈ {0, 1}∗ | yu ∈ L}. In other words, x ∼ y if and only if for any u ∈ {0, 1}∗, xu and yu are either both in L or both are not in L.

◮ Note: The relation ∼ is indeed an equivalence relation; It is

easy to see that the relation ∼ is reflexive, symmetric, and transitive, because the equality relation has these properties.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-23
SLIDE 23

THEORY OF COMPUTATION (Automata as Algebras)

Now we are ready to construct the minimal pre-automaton accepting L. Claim: For a language L ⊆ {0, 1}∗, ML = (Q , q0 , τ0 , τ1) is the minimal pre-automaton w.r.t. right concatenation accepting L, where

  • 1. Q = {x\L | x ∈ {0, 1}∗},
  • 2. q0 = λ\L,
  • 3. τi(x\L) = i\(x\L) = (xi)\L,

i = 0, 1.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-24
SLIDE 24

THEORY OF COMPUTATION (Automata as Algebras)

Example

L = {1 0n | n ∈ N} λ\L = L 1\L = {0n | n ∈ N} = Z 1 0j\L = Z j ∈ N 0\L = ∅ 0u\L = ∅ u ∈ {0, 1}∗ 11u\L = ∅ u ∈ {0, 1}∗ 101u\L = ∅ u ∈ {0, 1}∗ . . .

L

start

∅ Z

1 1 0, 1

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-25
SLIDE 25

THEORY OF COMPUTATION (Automata as Algebras)

Relations Equivalence Relations Congruence Relations

∅ {(x, x) | x ∈ {0, 1}∗} {0, 1}∗ × {0, 1}∗

∼L ≃L

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-26
SLIDE 26

THEORY OF COMPUTATION (Automata as Algebras)

◮ A language L ⊆ {0, 1}∗ determines an equivalence relation ∼L

  • n {0, 1}∗ in a usual way, i.e. for x, y ∈ {0, 1}∗

x ∼L y ⇔ x, y ∈ L ∨ x, y ∈ Lc.

◮ Now we define a congruence relation ≃L on {0, 1}∗ as follows:

for x, y ∈ {0, 1}∗, x ≃L y ⇔ x\L = y\L.

◮ Claim: ≃L is the greatest congruence relation less than ∼L.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-27
SLIDE 27

THEORY OF COMPUTATION (Automata as Algebras)

Claim1: The relation ≃L is a congruence relation on Ur.

  • Proof. It is easy to see that ≃L is an equivalence relation on

{0, 1}∗, so it suffices to show that ≃L is compatible with ri, for i=0,1: x ≃L y ⇔ x\L = y\L ⇔ ∀u ∈ {0, 1}∗ (xu, yu ∈ L ∨ xu, yu ∈ L) ⇔ ∀u ∈ {0, 1}∗ ∀i ∈ {0, 1} (xiu, yiu ∈ L ∨ xiu, yiu ∈ L) ⇔ xi\L = yi\L ⇔ xi ≃L yi ⇔ ri(x) ≃L ri(y).

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-28
SLIDE 28

THEORY OF COMPUTATION (Automata as Algebras)

Claim2: ≃L ⊆ ∼L. Proof. x ≃L y ⇒ x\L = y\L ⇒ ∀u ∈ {0, 1}∗ (xu, yu ∈ L ∨ xu, yu ∈ L) ⇒ for λ ∈ {0, 1}∗ (xλ, yλ ∈ L ∨ xλ, yλ ∈ L) ⇒ x, y ∈ L ∨ x, y ∈ L ⇒ x, y ∈ L ∨ x, y ∈ Lc ⇒ x ∼L y.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-29
SLIDE 29

THEORY OF COMPUTATION (Automata as Algebras)

...

Claim3: For any congruence relation ρ on {0, 1}∗, ρ ⊆ ∼L = ⇒ ρ ⊆ ≃L . Proof. (x, y) ∈ ρ ⇒ ∀i ∈ {0, 1} (ri(x), ri(y)) ∈ ρ ⇒ ∀i ∈ {0, 1} (xi, yi) ∈ ρ ⇒ ∀u ∈ {0, 1}∗ (xu, yu) ∈ ρ ⇒ ∀u ∈ {0, 1}∗ xu ∼L yu ⇒ ∀u ∈ {0, 1}∗ (xu, yu ∈ L ∨ xu, yu ∈ Lc) ⇒ ∀u ∈ {0, 1}∗ (xu, yu ∈ L ∨ xu, yu ∈ L) ⇒ x\L = y\L ⇒ x ≃L y.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-30
SLIDE 30

THEORY OF COMPUTATION (Automata as Algebras)

Now we can form the quotient pre-automaton Ur/≃L and show that Ur/≃L ≃ ML. Therefore, it follows from the construction of Ur/≃L that ML is the minimal pre-automaton w.r.t. right concatenation accepting L. In order to show this isomorphism, consider the map σ : Ur → M by σ([x]≃L) = M(x) = x\L for any x ∈ {0, 1}∗.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-31
SLIDE 31

THEORY OF COMPUTATION (Automata as Algebras)

◮ σ is a well-defined map:

  • 1. For any x = x1 . . . xn:

M(x) = M(x1 . . . xn) = τxn ◦ . . . ◦ τx2 ◦ τx1(λ\L) = τxn ◦ . . . ◦ τx2(x1\L) = τxn ◦ . . . ◦ τx3(x1x2\L) . . . = x1 . . . xn\L = x\L.

  • 2. For any x, y ∈ {0, 1}∗:

[x]≃L = [y]≃L ⇔ x ≃L y ⇔ x\L = y\L.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-32
SLIDE 32

THEORY OF COMPUTATION (Automata as Algebras)

◮ σ is a homomorphism:

[x]≃L [ri(x)]≃L = [xi]≃L x\L xi\L σ ˜ ri σ τi τi ◦ σ = σ ◦ ˜ ri.

◮ Obviously, σ is a bijective map.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-33
SLIDE 33

THEORY OF COMPUTATION (Automata as Algebras)

In a similar way, we can treat L w.r.t. left concatenation as follows: Definition: For a language L ⊆ {0, 1}∗ and any x ∈ {0, 1}∗, define: L\x = {u ∈ {0, 1}∗ | ux ∈ L}. It follows from the definition that for every x, y ∈ {0, 1}∗: (L\x)\y = {u ∈ {0, 1}∗ | uy ∈ L\x} = {u ∈ {0, 1}∗ | uyx ∈ L} = L\(yx).

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-34
SLIDE 34

THEORY OF COMPUTATION (Automata as Algebras)

Hence, for a language L ⊆ {0, 1}∗ the minimal pre-automaton w.r.t. left concatenation accepting L is NL = (Q , q0 , τ0 , τ1) , where

  • 1. QL = {L\x | x ∈ {0, 1}∗},
  • 2. q0 = L\λ,
  • 3. τi(L\x) = (L\x)\i = L\(ix).

i = 0, 1.

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)

slide-35
SLIDE 35

THEORY OF COMPUTATION (Automata as Algebras)

Example

L = {1 0n | n ∈ N} L\λ = L L\0 = L L\0j = L j ∈ N L\1 = {λ} L\1 0j = {λ} j ∈ N L\u = ∅ u = λ, u = 0j, 1 0j j ∈ N

L

start

∅ {λ}

1 0, 1 0, 1

THEORY OF COMPUTATION (Automata as Algebras), A. Daneshgar , (Slides prepared by Z. Ghafouri)