0% found this document useful (0 votes)
23 views52 pages

Week4 Chapter2 Automata

Chapter 2 of the document focuses on Automata Theory as a method for mathematical modeling, covering basic terms, finite automata, and the equivalence of deterministic and nondeterministic automata. It emphasizes the importance of automata theory in computer science, particularly in programming languages and compilers. The chapter includes various sections detailing definitions, operations on languages, and practical examples to illustrate the concepts discussed.

Uploaded by

Khoa Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views52 pages

Week4 Chapter2 Automata

Chapter 2 of the document focuses on Automata Theory as a method for mathematical modeling, covering basic terms, finite automata, and the equivalence of deterministic and nondeterministic automata. It emphasizes the importance of automata theory in computer science, particularly in programming languages and compilers. The chapter includes various sections detailing definitions, operations on languages, and practical examples to illustrate the concepts discussed.

Uploaded by

Khoa Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

MATHEMATICAL MODELING

METHODS And APPLICATIONS


MATHEMATICAL MODELING

Chapter 2: AUTOMATA THEORY

© Man VM. Nguyen(†) and Khuong An Nguyen(‡)

(†) Faculty of Science - Mahidol University

(‡) Faculty of Computer Science & Engineering - HCMC University of Technology


Contents

Chapter 2 AUTOMATA THEORY-


For Mathematical Modeling 1

2.1 PART A. BASIC TERMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4


2.2 Determining a language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4 PART B. FINITE AUTOMATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.5 Finite Automata- Basic Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.6 PART C: Equivalence of DFA and NFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.7 Determine regular expression given automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
2.8 Reviewed Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
List of Figures

2.1 A automaton for the process of an X-ray machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5


2.2 NFA with total 4 states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.3 Symbolic representation of automata based on (primitive) regular expressions . . . . . . . . . . . . . . . . . . . . . 57
2.4 Automaton for L (r1 r2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
2.5 Construct an NFA with 3 states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
2.6 Equivalence of two small automata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.7 The output DFA from the above input NFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
2.8 NFA-to-DFA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
2.9 A simple GTG, language 𝐿 and its regular expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
2.10 A simple NFA and its regular expression? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
2.11 Reduce node of a complete GTG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
2.12 A complete GTG with 4 nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
2.13 Reduced GTG with 3 and 2 nodes, with output of regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 102

MATHEMATICAL MODELING
Methods and Applications
Chapter 2

AUTOMATA THEORY-

For Mathematical Modeling


2

AUTOMATA THEORY from Mathematical Modeling View


We study the following topics in this chapter.

A. BASIC TERMS

Motivation and Key concepts

Determining a language - Regular Expressions

B. AUTOMATA

Finite Automata, see Section 2.4

Finite Automata- Basic Problems, in Section 2.5

B. C. Equivalence of DFA and NFA

Equivalence of DFA and NFA (Nondeterministic automata)

Determine a regular expression given an automaton, in Section 2.7.

Knowledge blocks include automata theory, formal languages and grammars;

bringing the theoretical foundation of computer science (CS).

MATHEMATICAL MODELING
Methods and Applications
3

COURTESY:

Some material of chapter 1 (Logic Theory) and 2 (Automat Theory) are borrowed from texts

1. REF. 1: MICHAEL HUTH and MARK RYAN. LOGIC IN COMPUTER SCIENCE - Modelling

and Reasoning about Systems, Chapter 1,2,4 [2nd ed., Cambridge University Press 2004]

2. REF. 2: MICHAEL HUTH and MARK RYAN. Solutions Manual - LOGIC IN COMPUTER

SCIENCE [2nd ed., Cambridge University Press 2004]

3. REF. 3: Peter Linz. An Introduction to Formal Languages and Automata,

6th Ed., Jones & Bartlett Learning (2017)

4. REF. 4: Mordechai Ben-Ari. Mathematical Logic for Computer Science,

Chapter 15 Third Edition, Springer-Verlag (2012).

MATHEMATICAL MODELING
Methods and Applications
2.1. PART A. BASIC TERMS 4

2.1 Overview - Motivation - Key concepts

1. Computer science a very diverse (with many important topics), but in spite of this diversity,

there are some common underlying principles. To study these basic principles, we construct

abstract models of computers and computation.

2. Why study automata theory? Automata theory provides such abstract model, its ideas

have some important applications, both software (programming languages, and compilers

...), midleware (operating systems) to hardware (digital design).

3. An automaton 1 : a construct that possesses all the features of a digital computer, or any

process. It accepts input, produces output, may have some storage, and can make decisions

in transforming the input into the output, see Figure 2.1, in which we use notations below.

○ with label: describe states of a process/agent


→: transitions from a state to another one
1 single automaton, plural automata

MATHEMATICAL MODELING
Methods and Applications
2.1. PART A. BASIC TERMS 5

□: action of an agent (or multiple agents)

Figure 2.1: A automaton for the process of an X-ray machine

Chapter’s aims: We will study various automata, mostly

abstract and mathematical concepts, to see how they are related to

(formal) languages and grammars.

MATHEMATICAL MODELING
Methods and Applications
2.1. PART A. BASIC TERMS 6

From Alphabets to Languages- KEY TERMINOLOGIES

We need basic definitions and their relations.

1. An alphabet Σ is a finite and non-empty set of symbols (or characters).

For example: Σ = {𝑎, 𝑏, 𝑐}, the binary Σ = {0, 1},

The set of all lower-case letters: Σ = {𝑎, 𝑏, 𝑐, . . . , 𝑧} ... And other sets.

Σ consists of almost all available characters (lowercase and capital letters, numbers, sym-
bols and special characters as space or Greek characters 𝛼, 𝛽...).

2. A string (word) 𝑢 over Σ is a finite sequence of symbols from the alphabet Σ.

A empty string is denoted by 𝜀 (with no symbols at all).

The length of a string 𝑢, denoted by |𝑢|, is the number of characters. Obviously

|𝜀| = 0, empty string has length of 0, and 𝜀𝑢 = 𝑢𝜀 = 𝑢.

If 𝑢 = 𝑢1 𝑢2 · · · 𝑢𝑛 , clearly |𝑢| = 𝑛. Let Σ* be the set of all strings over Σ.

String concatenation is map from Σ* × Σ* to Σ* , with (𝑢, 𝑣) ↦→ 𝑢.𝑣 = 𝑢𝑣 =: 𝑤.

MATHEMATICAL MODELING
Methods and Applications
2.1. PART A. BASIC TERMS 7

The substrings 𝑢 and 𝑣 are said to be a prefix and a suffix of 𝑤.

3. A language 𝐿 over Σ is a sub-set of Σ* .

Denote ∅ the empty language. Σ* itself is called the universal language.

Question: How about {𝜀}, {0, 00, 001}, are they languages over Σ = {0, 1} ?

4. A formal language : an abstraction of the general characteristics of programming lan-

guages.

A formal language consists of

(i) a set of symbols and

(ii) formation rules by which these symbols are combined into entities called sentences.

5. Operations on languages:

Because languages are sets, hence set operators as the union, intersection, difference ...

of two languages are immediately defined.


⋃︀
Union of languages 𝐿1 , 𝐿2 is set-like union 𝐿1 𝐿2 .

MATHEMATICAL MODELING
Methods and Applications
2.1. PART A. BASIC TERMS 8

Product (or multiplication) 𝐿1 𝐿2 = {𝑢 𝑣| 𝑢 ∈ 𝐿1 , 𝑣 ∈ 𝐿2 }.

This is based on concatenation of languages 𝐿1 , 𝐿2

Power 𝐿0 = {𝜀}, 𝐿𝑖 = 𝐿𝑖−1 𝐿, if power 𝑖 ≥ 1.

Iteration (star operation) 𝐿* is a special union of powers



⋃︁ ⋃︁
* 𝑖
𝐿 = 𝐿 = {𝜀} 𝐿+
𝑖=0
⋃︀∞
where 𝐿+ = 𝑖=1 𝐿𝑖 is named proper iteration.
The union, product and iteration are called regular operations.

The complement 𝐿 = Σ* ∖ 𝐿 of a language 𝐿 [is defined with respect to Σ* ].

The reverse of a language is the set of all string reversals, that is,

𝐿𝑅 = {𝑤𝑅 : 𝑤 ∈ 𝐿.}

♦ EXAMPLE 2.1.

Let Σ = {𝑎, 𝑏, 𝑐}, 𝐿1 = {𝑎𝑏, 𝑎𝑎, 𝑏}, 𝐿2 = {𝑏, 𝑐𝑎, 𝑏𝑎𝑐}

a) 𝐿1 ∪ 𝐿2 =? 𝐿1 ∪ 𝐿2 = {𝑎𝑏, 𝑎𝑎, 𝑏, 𝑐𝑎, 𝑏𝑎𝑐},


MATHEMATICAL MODELING
Methods and Applications
2.1. PART A. BASIC TERMS 9

b) 𝐿1 ∩ 𝐿2 =? 𝐿1 ∖ 𝐿2 =?
c) 𝐿1 𝐿2 =? 𝐿1𝐿2 = {𝑎𝑏𝑏, 𝑎𝑎𝑏, 𝑏𝑏, 𝑎𝑏𝑐𝑎, 𝑎𝑎𝑐𝑎, 𝑏𝑐𝑎, 𝑎𝑏𝑏𝑎𝑐, 𝑎𝑎𝑏𝑎𝑐, 𝑏𝑏𝑎𝑐},
d) 𝐿2 𝐿1 =? Now newly define 𝐿 = {𝑎𝑏, 𝑎𝑎, 𝑏, 𝑐𝑎, 𝑏𝑎𝑐}, find 𝐿2 =?

PRACTICE 2.1.

1. Prove by induction that: If 𝑢 and 𝑣 are strings, then the length of their concatenation is the

sum of the individual lengths, that is |𝑢.𝑣| = |𝑢| + |𝑣|.

2. Let alphabet Σ = {𝑎, 𝑏, 𝑐}.

i) Write at least 10 elements of Σ* .

Is 𝐿 = {𝑎, 𝑎𝑎, 𝑎𝑎𝑏} a finite language over Σ?

ii) Is 𝐿3 = {𝜀, 𝑎𝑏, 𝑎𝑎𝑏𝑏, 𝑎𝑎𝑎𝑏𝑏𝑏, 𝑎𝑎𝑎𝑎𝑏𝑏𝑏𝑏, . . .} a language? finite?

iii) Is 𝐿4 = {𝑎𝑛 𝑏𝑛 : 𝑛 = 0, 1, 2, . . .} also a language over Σ? Is it 𝐿3?


Is the string 𝑢 = 𝑎𝑏𝑏 in 𝐿4 ? How about 𝑣 = 𝑎𝑎𝑎𝑎𝑎𝑏𝑏𝑏𝑏𝑏?

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 10

PRACTICE 2.2.

Let Σ = {𝑎, 𝑏, 𝑐}. Give at least 5 strings for each of the following languages

𝐿1: all strings with exactly one ’𝑎’.


𝐿2: all strings of even length.
𝐿3: all strings which the number of appearances of ’𝑏’ is divisible by 3.
𝐿4: all strings ending with ’𝑎’.

𝐿5: all non-empty strings not ending with ’𝑎’.

𝐿6: all strings including at least one ’𝑎’ and


whose the first appearance of ’𝑎’ is not followed by a ’𝑐’.

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 11

2.2 Determining a language

A language can be specified in several ways:

a) Enumeration (listing) of its words, for example: 𝐿1 = {𝜀, 0, 1}.

b) Using a property, such that all words of the language have this property but other words

have not.

c) Using its grammar, [defined yet?] for example:

𝐿(𝐺) = {𝑎𝑛𝑏𝑛| 𝑛 ≥ 1} defined by a grammar 𝐺 = (𝑉, 𝑇, 𝑃, 𝑆), as defined explicitly next.

♦ EXAMPLE 2.2 (Using a property).

Fix Σ = {𝑎, 𝑏}, then 𝐿4 = {𝑎𝑛 𝑏𝑛 : 𝑛 = 0, 1, 2, . . .} is a language

(it is in fact 𝐿3 = {𝜀, 𝑎𝑏, 𝑎𝑎𝑏𝑏, 𝑎𝑎𝑎𝑏𝑏𝑏, . . .} in PRACTICE 2.1 above by enumeration).

Also using property on string length gives 𝐿6 = {𝑢 ∈ Σ* | 𝑛𝑎 (𝑢) = 𝑛𝑏 (𝑢)}, where 𝑛𝑐 (𝑢)

denotes the number of letter ’c’ in word 𝑢. Is 𝐿4 ⊂ 𝐿6 ? ■

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 12

Definition 2.1 (Grammar of a language)


A grammar is defined as a quadruple 𝐺 = (𝑉, 𝑇, 𝑃, 𝑆) where

𝑉 is a finite set of objects called variables,

𝑇 is a finite set of objects called terminal symbols, 𝑇 ∩ 𝑉 = ∅,

𝑃 is a finite set of productions (production rules), and

𝑆 ∈ 𝑉 is a special symbol called the start variable.

We will assume that all production rules are of the form

𝑥 → 𝑦, 𝑥 ∈ (𝑉 ∪ 𝑇 )+ and 𝑦 ∈ (𝑉 ∪ 𝑇 )*.

If string 𝑤 consists of 𝑥, say 𝑤 = 𝑎𝑥𝑏, string 𝑧 consists of 𝑦 , say 𝑧 = 𝑎𝑦𝑏, and 𝑥 → 𝑦 ,

then we define direct derivation, written as 𝑤 ⇒ 𝑧.

We say that string 𝑤 derives string 𝑧 (or that 𝑧 is derived from 𝑤).

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 13

If there is a finite derivation sequence 𝑤1 ⇒ 𝑤2 ⇒ · · · ⇒ 𝑤𝑛 [unspecified steps]


* *
then we reduce it as 𝑤1 ⇒ 𝑤𝑛 . Relation ⇒ is called a derivation.

ELUCIDATION

1. Briefly, the production rules of grammar 𝐺 specify how the grammar transforms one string

into another, and they define a language associated with the grammar.

2. Successive strings are generally derived by applying such productions of the grammar 𝐺 in

arbitrary order, and as often as desired.

3. Derivation are based on productions.

Definition 2.2 (Language generated by a grammar)


A grammar 𝐺 = (𝑉, 𝑇, 𝑃, 𝑆) can normally generate many strings.

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 14

The language 𝐿 = 𝐿(𝐺) defined or generated by the grammar 𝐺 is


*
𝐿 = 𝐿(𝐺) = {𝑤 ∈ 𝑇 * : 𝑆 ⇒ 𝑤} (2.1)

(the set of all such terminal strings). We obtain the derivation


*
[𝑆 ⇒ 𝑤] ≡ [𝑆 ⇒ 𝑤1 ⇒ 𝑤2 ⇒ · · · ⇒ 𝑤𝑛 ⇒ 𝑤],
* a
in which strings 𝑆 and 𝑤𝑖 are called sentential forms of the derivation ⇒.
a
Sentential forms are strings that contain both variables and terminals.

♦ EXAMPLE 2.3.

Let define grammar 𝐺 = (𝑉, 𝑇, 𝑃, 𝑆) where

𝑉 = {𝑆} [only one variable],


𝑇 = {𝑎, 𝑏} [terminal symbols], and
𝑃 = {𝑆 → 𝑎𝑆𝑏, 𝑆 → 𝑎𝑏, 𝑆 → 𝜀} with three production rules.

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 15

*
We see 𝑆 ⇒ 𝑎𝑆𝑏 ⇒ 𝑎𝑎𝑆𝑏𝑏 = 𝑎2 𝑆𝑏2 ⇒ 𝑎2 𝑏2 ... then 𝑆 ⇒ 𝑎𝑎𝑏𝑏 = 𝑎2 𝑏2 .

Also 𝑎2 𝑆𝑏2 ⇒ 𝑎3 𝑏3 ... and hence


*
recursively we get the following derivation 𝑆 ⇒ 𝑎𝑛 𝑏𝑛 , i.e.

𝑆 ⇒ 𝑎𝑆𝑏 ⇒ 𝑎2𝑆𝑏2 ⇒ . . . ⇒ 𝑎𝑛𝑆𝑏𝑛.

Therefore the language defined by 𝐺 is


*
𝐿(𝐺) = {𝑤 ∈ 𝑇 * : 𝑆 ⇒ 𝑤} = {𝑎𝑛 𝑏𝑛| 𝑛 ≥ 1} ■

♦ EXAMPLE 2.4.

Consider a language 𝐿 = {𝑎𝑛 𝑏𝑛+1 | 𝑛 ≥ 0}. Find a grammar that generates 𝐿.


Should the grammar 𝐺 = (𝑉, 𝑇, 𝑃, 𝑆) be defined as before?

No, we need to modify it to generate an extra 𝑏 in 𝐿.

Explicitly we extend a new ‘stronger variable’ 𝑆 to incorporate 𝑏 to the sentences of 𝐿, hence

if redefine 𝑉 = {𝑆, 𝑀 }, 𝑇 = {𝑎, 𝑏} then 𝑀 replaces the old 𝑆 ’s role,

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 16

and so the set of productions becomes 𝑃 = {𝑆 → 𝑀 𝑏, 𝑀 → 𝑎𝑀 𝑏, 𝑀 → 𝜀}.


*
Can you derive specific sentences to convince yourself, like 𝑎𝑏2 ∈ 𝐿 by checking [𝑆 ⇒ 𝑎𝑏2 ]?

Or 𝑆 ⇒ 𝑀 𝑏 ⇒ 𝑎𝑀 𝑏𝑏 ⇒ 𝑎𝑎𝑀 𝑏𝑏𝑏? ■

Is a language generated by a certain grammar 𝐺?

Often it is not so easy to find a grammar for a language described in an informal way, or to

give an intuitive characterization of the language defined by a grammar. To show mathemati-

cally that a given language 𝐿 is indeed generated by a certain grammar 𝐺, we must be able

to show

(a) that every word 𝑤 ∈ 𝐿 can be derived from the start variable 𝑆 using 𝐺 and

(b) that every string so derived is in 𝐿.

a
Theorem (REF. 3, p 17): Not all languages can be generated by grammars.
a
Antal Iványi. Algorithms of Informatics, AnTonCom Budapest (2010).

MATHEMATICAL MODELING
Methods and Applications
2.2. Determining a language 17

HW: Readers should try the following.

PRACTICE 2.3. Denote 𝑛𝑐 (𝑢) the number of letter ’c’ in any word 𝑢.

Take now Σ = {𝑎, 𝑏}, and consider a language

𝐿6 = {𝑢 ∈ Σ*| 𝑛𝑎(𝑢) = 𝑛𝑏(𝑢)}.

Prove that the grammar 𝐺 = (𝑉, 𝑇, 𝑃, 𝑆) with 𝑇 = Σ, 𝑉 = {𝑆, 𝑀 }, and productions

𝑃 = {𝑆 → 𝜀, 𝑆 → 𝑎𝑆𝑏, 𝑀 → 𝑏𝑆𝑎, 𝑆 → 𝑆𝑆} generates the language 𝐿.

Hint: check both 𝐿(𝐺) ⊆ 𝐿 and 𝐿 ⊆ 𝐿(𝐺).

PRACTICE 2.4.

Solve examples in page 4.12, and Exercises in page 13, 14 of REF 1 .

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 18

2.3 Regular Expressions

Definition 2.3
Regular expressions over some given alphabet Σ involve a combination of ♣
(︀)︀
♦ strings of symbols from Σ, parentheses , and

♦ the operators + (union), · (product or concatenation), and * (transitive closure).

A regular expression over the alphabet Σ is ‘recursively’ determined by 3 conditions

1. ∅, 𝜀 and 𝑎 ∈ Σ are all regular expressions, called primitive regular expressions.

2. If 𝑟 and 𝑠 are regular expressions, so are (𝑟), 𝑟 + 𝑠, 𝑟 · 𝑠, and 𝑟 * .

3. A string is a regular expression if and only if it can be derived from the

primitive regular expressions by a finite number of applications of the rules in (2). ■

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 19

♦ EXAMPLE 2.5. On the alphabet Σ = {𝑎, 𝑏, 𝑐}

the string (𝑎 + 𝑏 · 𝑐)* · (𝑐 + ∅) is a regular expression, explain?

But (𝑎 + 𝑏 +) is not a regular expression, since there is no way it can be constructed from

the primitive regular expressions.

In fact, regular expressions can be used to describe some simple languages.

♦ EXAMPLE 2.6. On the alphabet Σ = {𝑎, 𝑏}

The regular expression (𝑎 + 𝑏)* represents all the strings, written 𝐿

𝑎*(𝑏𝑎*)* represent the same language 𝐿


(𝑎 + 𝑏)*𝑎𝑎𝑏 represent all strings ending with 𝑎𝑎𝑏? or 𝐿 · 𝑎𝑎𝑏

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 20

Languages associated with regular expressions

Definition 2.4 (Kleene)


Language 𝐿 ⊆ Σ* is regular if and only if there exists a regular expression over Σ

representing language 𝐿.

Knowledge box 1. Regular Expressions denote languages in the following ways.

♦ Consider a regular expression (string) 𝑟 ∈ Σ* = {∅, 𝜀, 𝑎, 𝑏, . . .}.

The language 𝐿(𝑟) ⊂ Σ* associated with expression 𝑟 is defined by the following rules.

1. ∅ is a regular expression, representing the empty language,

2. 𝜀 is a regular expression, representing language {𝜀},

3. For every 𝑎 ∈ Σ, 𝑎 is a regular expression, representing the language {𝑎}.

What if 𝑟 = 𝑎 · 𝑏 = 𝑎𝑏, then the language 𝐿(𝑟) =?

♦ Consider regular expressions 𝑟 and 𝑠, representing languages 𝑋 = 𝐿(𝑟), 𝑌 = 𝐿(𝑠) re-

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 21

spectively. Then (𝑟+𝑠), (𝑟·𝑠), 𝑟 * are regular expressions, (so they) respectively representing

𝑌 , 𝑋 𝑌 , and 𝑋 *. Explicitly,
⋃︀
languages 𝑋
⋃︀
4. 𝐿(𝑟 + 𝑠) ≡ 𝐿(𝑟) + 𝐿(𝑠) = 𝑋 𝑌

5. 𝐿(𝑟 · 𝑠) ≡ 𝐿(𝑟) 𝐿(𝑠) = 𝑋 𝑌

6. 𝐿((𝑟)) ≡ 𝐿(𝑟) = 𝑋
)︀*
7. 𝐿(𝑟 * ) ≡ 𝐿(𝑟) = 𝑋 *.
(︀

♦ EXAMPLE 2.7. On the alphabet Σ = {𝑎, 𝑏}


)︀*
Take 𝑟 = 𝑎, 𝐿(𝑟 * ) ≡ 𝐿(𝑎)
(︀
= {𝜀, 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, . . .}.
Take 𝑟 = 𝑎* ·𝑏, it give the language, 𝐿(𝑟) = 𝐿(𝑎* ·𝑏) = 𝐿(𝑎* )𝐿(𝑏) = {𝑏, 𝑎𝑏, 𝑎2 𝑏, 𝑎3 𝑏, . . . , 𝑎𝑎, 𝑎𝑎𝑎, . . .}.

The language 𝐿(𝑎* · (𝑎 + 𝑏)) = 𝐿(𝑎* ) 𝐿(𝑎 + 𝑏) = ...? = {𝑎, 𝑎𝑎, 𝑎𝑎𝑎, . . . , 𝑏, 𝑎𝑏, 𝑎𝑎𝑏, . . .}

𝑟 = (𝑎 + 𝑏)* represents all the (regular) strings of of 𝑎’s and 𝑏’s, any order.
)︀*
So language 𝐿(𝑟) = 𝐿(𝑎 + 𝑏) = Σ* ?
(︀

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 22

We also employ the following properties, applied for regular expressions 𝑥, 𝑟 and 𝑠.

(𝑥 + 𝑟) + 𝑠 ≡ 𝑥 + (𝑟 + 𝑠);

(𝑥𝑟)𝑠 ≡ 𝑥(𝑟𝑠)

(𝑥 + 𝑟)* ≡ (𝑥* + 𝑟)* ≡ (𝑥 + 𝑟*)* ≡ (𝑥* + 𝑟*)*

(𝑥 + 𝑟)* ≡ (𝑥*𝑟*)*

(𝑟*)* ≡ 𝑟*

𝑥*𝑥 ≡ 𝑥𝑥*;

𝑥𝑥* + 𝜀 ≡ 𝑥*

PRACTICE 2.5. On the alphabet Σ = {𝑎, 𝑏},

I) 𝑠 = (𝑎𝑎)* (𝑏𝑏)* 𝑏 represents all the (regular) strings of language 𝐿(𝑠) =?

II) Is 𝐸 = (𝑎 + 𝑏)* (𝑎 + 𝑏𝑏) regular? Find the language 𝐿(𝐸) =?

Hint: 𝐿(𝑎 + 𝑏𝑏) consists of word ending by 𝑎 or a double 𝑏. ■

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 23

PROBLEM 2.1.

On the alphabet Σ = {𝑎, 𝑏, 𝑐}, give at least 5 words for each language represented by the

following regular expressions.

a) 𝐸1 = 𝑎* + 𝑏* ,

b) Elucidate why 𝑎* 𝑏 = {𝑏, 𝑎𝑏, 𝑎2 𝑏, 𝑎3 𝑏, . . . , 𝑎𝑎𝑎 . . . 𝑎𝑏}?

Then find the language of 𝐸2 = 𝑎* 𝑏 + 𝑏* 𝑎.

c) 𝐸 = b(ca + ac) (aa) + 𝑎* · (𝑎 + 𝑏) = r + 𝑠 =⇒ 𝐿𝐸 =?

Hint for c): You will prove firstly 𝐿2 = 𝐿(𝑠) = 𝐿(𝑎* · (𝑎 + 𝑏)) = {𝑎𝑛+1 , 𝑎𝑚 𝑏 | 𝑛, 𝑚 ≥ 0}.

Next find 𝐿0 = 𝐿(𝑏(𝑐𝑎 + 𝑎𝑐)) = 𝐿(𝑏𝑐𝑎) ∪ 𝐿(𝑏𝑎𝑐),

then finally get 𝐿1 = 𝐿(𝑟) = 𝐿0 {𝑎𝑎} = 𝐿(𝑟). ■

MATHEMATICAL MODELING
Methods and Applications
2.3. Regular Expressions 24

PROBLEM 2.2.

Simplify each of the following regular expressions

1. 𝐸1 = 𝜀 + 𝑎𝑏 + 𝑎𝑏𝑎𝑏(𝑎𝑏)* ,

2. 𝐸2 = 𝑎𝑎(𝑏* + 𝑎) + 𝑎(𝑎𝑏* + 𝑎𝑎),

3. 𝐸3 = 𝑎(𝑎 + 𝑏)* + 𝑎𝑎(𝑎 + 𝑏)* + 𝑎𝑎𝑎(𝑎 + 𝑏)* .

MATHEMATICAL MODELING
Methods and Applications
PART B. AUTOMATA

AIM of studying Automata: toward a representation of a process or system.

[[GoogleMap]]
2.4. PART B. FINITE AUTOMATA 26

2.4 Finite Automata

An automaton (a machine) can be represented by a graph in which

the vertices give the initial states and one or several final/accepting states, and the edges

means transitions or events.

Definition 2.5 (Finite automaton (FA))


A finite automaton 𝑀 is a 5-tuples (𝑄, Σ, 𝑞, 𝛿, 𝐹 ) or (𝑄, Σ, 𝐼, 𝛿, 𝐹 ) where ♣

1. 𝑄 is a finite set, called the states,

2. Σ is a finite set, called alphabet,

3. 𝑞 ∈ 𝑄 is the initial or start state,

4. 𝛿 : 𝑄 × Σ → 𝑄 is the transition function,

5. 𝐹 ⊆ 𝑄 is the set of accepting states of the automaton.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 27

Definition 2.6 (Accepted string and Language of a machine (finite automaton))


𝑤
A string 𝑤 = 𝑎1 𝑎2 · · · 𝑎𝑛 ∈ Σ* is accepted by an automaton 𝑀 if symbolically 𝑞 ⇝ 𝑞𝑤 ∈

𝐹 , meaning applying 𝑤 on 𝑞 gives a final (accept) state 𝑞𝑤 in 𝐹 .


If 𝐴 is the set of all strings 𝑤 that machine 𝑀 accepts, we say that

𝐴 is the language of machine 𝑀 and write 𝐿(𝑀 ) = 𝐴 = {𝑤 : |𝑀 accepts string 𝑤}.


We say that machine 𝑀 recognizes (or accepts) the language 𝐴.

♦ EXAMPLE 2.8.
(︀ )︀
This state diagram shows the two-state finite automaton 𝑀 = {𝑞1 , 𝑞2 }, {0, 1}, 𝑞1 , 𝛿, {𝑞2 } ,
where 𝐹 = {𝑞2 } (unique accepting state), the transition function 𝛿 is given by table below,

that is 𝛿(𝑞1 , 0) = 𝑞1 , 𝛿(𝑞1 , 1) = 𝑞2 and so on. Final states are drawn with a double circle.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 28

A finite automaton with two states

0 1

𝑞1 𝑞 1 𝑞2
𝑞2 𝑞 1 𝑞2

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 29

Let string 𝑟 = 1101 ∈ 𝐴, will 𝑀 accept it?

We apply 𝑟 = 1101 ∈ 𝐴 on the start state 𝑞1 , letter by letter to find out.

Use 𝑟 = 1101 ∈ 𝐴 we finally get state 𝑞2 ∈ 𝐹 (accepting states).

The string 𝑟 is accepted because 𝑞2 is an accept state.

But string 𝑠 = 110 leaves 𝑀 in state 𝑞1 , so it is rejected. You would see that

𝑀 accepts all strings that end in a 1. Thus the language of 𝑀 , 𝐿(𝑀 ) = {𝑤| 𝑤 ends in a 1 }.

Moreover the regular expression

𝑟 = 1101 ∈ 1*(0 + 1),

expresses the complete information of 𝑀 . Abstractly, if we would replace letter

𝑎 = 1, 𝑏 = 0 on the machine 𝑀 then we get the same conclusion, for 𝑟 = 𝑎𝑎𝑏𝑎 ∈ 𝑎*(𝑏 + 𝑎).

♦ EXAMPLE 2.9 (Finite automaton to a regular expression ).

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 30

𝑏
𝑎, 𝑏
𝑞0 𝑞1

Regular expression is 𝑟 = 𝑏* (𝑎 + 𝑏)? But what is the transition function 𝛿 ?

PROBLEM 2.3.

I) Let Σ = {𝑎, 𝑏}. Which of the strings

1) 𝑎3 𝑏,

2) 𝑎𝑏𝑎2 𝑏,

3) 𝑎4 𝑏2 𝑎𝑏3 𝑎,

4) 𝑎4 𝑏𝑎4 ,

5) 𝑎𝑏4 𝑎9 𝑏,

are accepted by the following finite automaton?

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 31

𝑎 𝑏
𝑏
𝑞0 𝑞1 𝑎 𝑞2
𝑏
𝑎
II) Do Exercises on page 4.2x, for 𝑥 = 4, 5, 6 of REF. 1.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 32

2.4.1 Nondeterministic finite automata

Definition 2.7 (Nondeterministic finite automaton (NFA))


A non-deterministic finite automaton 𝑀 is represented by a 5-tuples (𝑄, Σ, 𝑞0 , 𝛿, 𝐹 ) or

(𝑄, Σ, 𝐼, 𝛿, 𝐹 ) where ♣

1. 𝑄 a finite, nonempty set of states,

2. Σ is the input alphabet,

3. 𝑞0 is an initial state, [𝑞0 can be extended to 𝐼 ⊂ 𝑄, the set of initial states],

4. 𝛿 : 𝑄 × (Σ ∪ {𝜀}) → 2𝑄 is a transition function,

5. 𝐹 ⊆ 𝑄 is the set of final/accepting states of the automaton.

In Item 4, generally the 𝛿 can be extended to 𝐸 , a set of many transition functions.

ELUCIDATION

Nondeterminism/ Nondeterministic property means a choice of moves for automaton 𝑀 .

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 33

Rather than prescribing a unique move in each situation, we allow a set of possible moves.

Formally, we achieve this by defining the transition function 𝛿 so that Range(𝛿) ⊂ 𝑄

or Range(𝛿) ∈ 2𝑄 [its range is a set of possible states in 𝑄].

An NFA is a directed, labeled graph, named the transition graph 𝑇 (𝑀 ) = (𝑉, 𝐸) of automaton 𝑀 ,

whose node set 𝑉 ≡ 𝑄 and 𝐸 = {(𝑝, 𝑎, 𝑞)}, consisting of transitions - directed edges [la-

beled with letter 𝑎 ∈ Σ] - from (state) node 𝑝 to node 𝑞 :


𝑎
𝑝 −→ 𝑞.

Among nodes some are initial and some final states.

Initial states are marked by a small arrow entering the corresponding vertex,

while the final states are marked with double circles [as 𝑞4 in the next figure].

A sequence (𝑞𝑖 , 𝑎𝑖+1 , 𝑞𝑖+1 ), where 𝑞𝑖 ∈ 𝑄 for 𝑖 = 0, 1, . . . , 𝑛 − 1 of edges of graph 𝑇 (𝑀 )

is a walk 𝑤 in 𝑇 (𝑀 ) with the label 𝑎1 , 𝑎2 , . . . , 𝑎𝑛 .


𝑤
We write 𝑤 = 𝑎1 , 𝑎2 , . . . , 𝑎𝑛 or shortly 𝑞0 −→ 𝑞𝑛 .

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 34

♦ EXAMPLE 2.10. Fix 𝑄 = {𝑞1, 𝑞2, 𝑞3, 𝑞4} and Σ = {0, 1, 𝜀}.

An nfa with 4 states and 1 accepting state.

Figure 2.2: NFA with total 4 states

* Transition function 𝛿 gives the Range(𝛿) ∈ 2𝑄 :

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 35

If, as in Figure 2.2, the current state is 𝑞1 , select actions 𝑤 = 1 0 1

then the symbol 𝑎 = 1 is read, and 𝛿(𝑞1 , 𝑎) = {𝑞1 , 𝑞2 },

hence either 𝑞1 or 𝑞2 could be the next state of the NFA.

* The transition graph 𝑇 (𝑀 ) of 𝑀 has edges (𝑞1 , 𝑞1 ) and (𝑞1 , 𝑞2 ) with label 𝑎 = 1.

* In Figure 2.2, string of actions 𝑤 = 1 0 1 acts on 𝑞1 and returns 𝑞4 .

The states in a walk are not necessary distinct. ■

Definition 2.8 (Extended transition function in NFA)


For an NFA, the extended transition function 𝛿 * is defined

so that 𝛿 * (𝑞𝑖 , 𝑤) contains 𝑞𝑗 if and only if

there is a walk in the transition graph from 𝑞𝑖 to 𝑞𝑗 labeled 𝑤.

This holds for all 𝑞𝑖 , 𝑞𝑗 ∈ 𝑄, and 𝑤 ∈ Σ* .

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 36

We need two more concepts for the next definition (language accepted by NFA).

Productive walk: A walk


𝑤
𝑤 = 𝑎1, 𝑎2, . . . , 𝑎𝑛 ≡ 𝑞0 −→ 𝑞𝑛

is productive if its start-vertex is an initial state

and its end-vertex is a final state, i.e. 𝑞0 ∈ 𝐼 and 𝑞𝑛 ∈ 𝐹 .

Word and language accepted by an NFA 𝑀 or its transition graph 𝑇 (𝑀 ):

We say that

an NFA 𝑇 (𝑀 ) accepts or recognizes a word 𝑤 = 𝑎1 , 𝑎2 , . . . , 𝑎𝑛 [or 𝑤 accepted by 𝑇 (𝑀 )]

if this word is the label of a productive walk (that is, there is some sequence of possible

moves that will put the machine in a final state 𝑞𝑛 at the end of the string.)

The set of words accepted by an NFA is called the language accepted by this NFA.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 37

Definition 2.9 (Language accepted by NFA)


The language being accepted by an NFA 𝑀 = (𝑄, Σ, 𝐼, 𝛿, 𝐹 ) is determined by

𝐿(𝑀 ) = {𝑤 ∈ Σ* : 𝛿 *(𝑞, 𝑤) ∩ 𝐹 ̸= ∅, ∃𝑞 ∈ 𝐼}. (2.2)

It is the language consists of all strings 𝑤 = 𝑎1 , 𝑎2 , . . . , 𝑎𝑛 labeling of a productive walk.

𝑤
Explicitly this means for each string 𝑤 ∈ 𝐿(𝑀 ) there is a walk labeled 𝑞 −→ 𝑝 from an

initial vertex 𝑞 ∈ 𝐼 of the transition graph to some final vertex 𝑝 ∈ 𝐹 .

So instead of using

𝐿(𝑀 ) = {𝑤 ∈ Σ* : 𝛿 *(𝑞, 𝑤) ∩ 𝐹 ̸= ∅, ∃𝑞 ∈ 𝐼},

we also use the equivalent


𝑤
𝐿(𝑀 ) = {𝑤 ∈ Σ* : ∃𝑞 ∈ 𝐼, ∃𝑝 ∈ 𝐹, and there exists the path 𝑞 −→ 𝑝}. (2.3)

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 38

Knowledge box 2 (Regular Expressions denote Regular Languages).

The language accepted by an NFA so is defined by the extended transition 𝛿 * (𝑞, 𝑤) [Def.

2.8].

A language 𝐿 is regular if there exists a regular expression generating 𝐿 [Def. 2.4

(Kleene)].

Let 𝑟 be a regular expression. Then there exists some nondeterministic finite automaton

(NFA) that accepts the language 𝐿(𝑟). Consequently, 𝐿(𝑟) is a regular language.

We discuss more on the equivalence connection between regular languages and regular

expressions later in Section 2.7, including two smaller problems

1. Regular Expressions define regular languages: how construct an NFA 𝑀 from a given reg-

ular expression 𝑟 , so that 𝑀 accepts 𝐿(𝑟).

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 39

2. Regular Languages give regular expressions: from a regular language 𝐿, find a regular

expression that generates 𝐿.

PROBLEM 2.4.

(I) Consider the set of strings on Σ = {𝑎, 𝑏} in which every 𝑎𝑎 is followed immediately by 𝑏.

For example 𝑎𝑎𝑏, 𝑎𝑎𝑏𝑎, 𝑎𝑎𝑏𝑎𝑎𝑏𝑏𝑎𝑎𝑏 are in the language, but 𝑎𝑎𝑎𝑏 and 𝑎𝑎𝑏𝑎𝑎 are not.

Construct an accepting NFA.

(II) Give regular expression for the following finite automaton

𝑎 𝑏
𝑏
𝑞0 𝑞1 𝑎 𝑞2
𝑏
𝑎

PROBLEM 2.5. Do Exercise on page 4.3y, for 𝑦 = 1, 2, 3 of REF. 1.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 40

2.4.2 Deterministic finite automata

Definition 2.10 (Deterministic finite automaton (DFA))


A deterministic finite automaton or DFA 𝑀 is defined by a 5-tuples

𝑀 = (𝑄, Σ, 𝑞0, 𝛿, 𝐹 )

with

1. 𝑄 a finite, nonempty set of states,

2. Σ is the input alphabet,

3. 𝑞0 ∈ 𝑄 is the initial state,

4. 𝛿 : 𝑄 × Σ → 𝑄 is a transition function,

5. 𝐹 ⊆ 𝑄 is the set of final/accepting states of the automaton, |𝐹 | ≥ 1.

ELUCIDATION
MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 41

A DFA fulfills that |𝐼| = 1 and moreover

|𝛿(𝑞, 𝑎)| ≤ 1, ∀𝑞 ∈ 𝑄, ∀𝑎 ∈ Σ

in Defi. 2.7.

For letter 𝑎 ∈ Σ, if |𝛿(𝑞, 𝑎)| = 1

then 𝛿(𝑞, 𝑎) = 𝑝, an edge in the transition graph 𝑇 (𝑀 ).

The fact |𝛿(𝑞, 𝑎)| = 0 says 𝛿(𝑞, 𝑎) = ∅ (nonfinal trap state in the DFA):

this represents an impossible move for the automaton and, therefore,

means nonacceptance of the letter 𝑎, and nonacceptance of any string 𝑟 holding 𝑎.

Given a walk 𝑟 = 𝑎𝑏𝑐 . . . 𝑠 (series of accepted arrows/ letters/ actions), and a state 𝑞 ,

the automaton 𝑀 starts with the transition function, called an application 𝛿(𝑞, 𝑎) = 𝑝.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 42

𝑎 𝑏 𝑠
𝑞 −→ 𝑝 −→ · · · −→ 𝑝𝑛

The input mechanism then advances one position to the right, as a result

each move consumes one input symbol of 𝑟 .

The transition graph 𝑇 (𝑀 ) of finite automaton 𝑀 has an edge (𝑞, 𝑝) with label 𝑎...

When the end letter 𝑠 of the string 𝑟 = 𝑎 𝑏 𝑐 . . . 𝑠 is reached,

the string is accepted if the automaton is in state 𝑝𝑛 ∈ 𝐹 (one of its final states):
𝑎 𝑏 s
𝑞 −→ 𝑝 −→ · · · −→ pn.

Otherwise the string is rejected. ♦

♦ EXAMPLE 2.11.

The figure shows the transition graph 𝑇 (𝑀 ) of a DFA = 𝑀 = (𝑄, Σ, 𝑞0 , 𝛿, 𝐹 ) with 𝐹 = {𝑞1 }.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 43

A DFA with two states and only one accepting state

i/ Determine the transition 𝛿 .

ii/ Check 𝑀 recognizes the set 𝐴 of strings which contain an odd number of 𝑎, that is

𝐿(𝑀 ) = 𝐴.

iii/ Determine a new machine 𝑀𝐵 accepts the set 𝐵 of strings which contain an even number

of 𝑎, that is 𝐵 = 𝐿(𝑀𝐵 ).

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 44

HINT: Obviously 𝑄 = {𝑞0 , 𝑞1 }, the alphabet Σ = {𝑎, 𝑏}, and the set 𝐹 = {𝑞1 } of accepting

states.

i/ The transition 𝛿 fulfills 𝛿(𝑞0 , 𝑎) = 𝑞1 , 𝛿(𝑞0 , 𝑏) = 𝑞0 . . . and given in table

a b

→ 𝑞0 𝑞1 𝑞0
𝑞1 𝑞0 𝑞1

ii/: Need to write the pattern of strings 𝑟 ∈ 𝐴 which contain an odd number of 𝑎, as

𝑟 = 𝑏*𝑎𝑛𝑏*, 𝑛 = 2𝑘 + 1?

Then check the equality 𝛿(𝑞0 , 𝑟) = 𝑞1 ∈ 𝐹 if and only if 𝑟 has the above pattern only.

iii/: Perhaps we redefine the new defining string

𝑠 = 𝑏*𝑎𝑚𝑏*, 𝑚 = 2𝑘 =⇒ 𝐵 = 𝐿(𝑀𝐵 )

where 𝑀𝐵 = (𝑄, Σ, 𝑞1 , 𝛿, 𝐹 ), 𝐹 = {𝑞0 }? ■

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 45

Proposition 2.1
Transition graphs provide convenient ways for working with FA. ♠

Precisely, given a DFA 𝑀 = (𝑄, Σ, 𝑞0 , 𝛿, 𝐹 ), let its transition graph be 𝑇 (𝑀 ).

For all 𝑞𝑖 , 𝑞𝑗 ∈ 𝑄, and 𝑤 ∈ Σ+ , then the extended transition

𝛿 *(𝑞𝑖, 𝑤) = 𝑞𝑗 if and only if there is a walk with label 𝑤 (in 𝑇 (𝑀 )) from 𝑞𝑖 to 𝑞𝑗 .

♦ EXAMPLE 2.12. Set alphabet Σ = {0, 1}

Give a DFA that accepts all words that contain a number of 0 multiple of 3.

Give an execution of this automaton on word w= 1101010.

Any other way to define DFA?

GUIDANCE for solving.

Define the states 𝑄, the transition 𝛿 and set 𝐹 of accepting states properly.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 46

i) Call DFA 𝑀 = (𝑄, Σ, 𝑞0 , 𝛿, 𝐹 ) with 𝑄 = {𝑞0 , 𝑞1 }, and 𝐹 = {𝑞1 }?.

Then define a transition 𝛿 such that 𝛿(𝑞𝑜 , 𝑤) ∈ 𝐹 for any word 𝑤 satisfying that 𝑛0 (𝑤) mod 3 = 0

[word 𝑤 contains a number of 0 multiple of 3].

1 1
0
𝑞0 𝑞1
0

ii) Here 𝑤 = 1101010 fulfills 𝑛0 (𝑤) mod 3 = 0, and 𝛿(𝑞𝑜 , 𝑤) = 𝑞1 ∈ 𝐹 .

iii) What if we redefine states 𝑄 = {𝑞0 , 𝑞1 , 𝑞2 }, and 𝐹 = {𝑞1 , 𝑞2 }? Can we redraw the graph

as

1 1 1
0 0
𝑞0 𝑞1 𝑞2
0 0

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 47

PROBLEM 2.6. Do Exercise on page 4.37, REF.1.

MATHEMATICAL MODELING
Methods and Applications
2.4. PART B. FINITE AUTOMATA 48

WHAT NEXT?

We next study four basic problems in Finite Automata theory:

1. Construction of a DFA and NFA from a given language 𝐿, or a given regular expression 𝐸 ,

Section 2.5.1 and 2.5.2.

2. Equivalence of automata: Build a DFA from a given NFA, see Section 2.6.1;

Why? For an NFA, for a single input given to a single state, the machine can go to more

than one state. So, for an NFA, it is hard to decide for a string to be accepted by the NFA or

not. This type of problem will not arise for DFA.

3. Minimization of a DFA, given in Section 2.6.2; Why? To save storage in computer.

4. Inverse of Problem 1: Determining a regular expression given an automaton (NFA- DFA),

studied in Section 2.7.

Problems 1 and 4 show a mutual relationship between languages and automata.

MATHEMATICAL MODELING
Methods and Applications

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy