Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 69

Formal Language and

Automata Theory
Subject Code
• Finite Automata (FA) 3151605
• Regular Expression (RE)
• Languages
• Grammars

1
Formal Language and Automata Theory
(3151605)
Rationale:

The importance to study the Formal Language and Automata Theory


(Theory of Computation) is to better understand the development
of formal mathematical models of computation that reflect the
real-world of computer.

To achieve deep understanding about the mathematical properties


of computer hardware and software.

The course should in addition clarify the practical view towards the
applications of these ideas in engineering.
2
ASSESSMENT GUIDELINES
Theory Marks (100)
1) End Semester Examination: 70 Marks (Conducted by The University)
2) Progressive Assessment: 30 Marks
Mid Semester Examination: 20 Marks
Class Tests: 05 Marks
Attendance: 05 Marks

Practical Marks (50)


3) End Semester Examination: 30 Marks (Conducted by the external examiner)
4) Progressive Assessment: 20 Marks
Progressive Performance: 10 Marks
Assignment and Internal Viva: 10 Marks

3
WHAT IS FA?
 Finite Automata(FA) is the simplest machine to recognize patterns.
A+C+D*T–F*X/V–Y

A+C+D*T–F*X/T–Y

A Finite Automata consists of the following:


Q : Finite set of states.
Σ : set of Input Symbols.
q : Initial state.
F : set of Final States.
δ : Transition Function.

Formal specification of machine is { Q, Σ, q, F, δ }.

4
Example: Finite Automata

δ Input
State

• is defined as

1 1 0

𝑞0 0
𝑞1 0
𝑞2
1

5
Finite Automata
• A finite automaton, or finite state machine is a 5-tuple where
• is finite set of states;
• is finite alphabet of input symbols;
• (initial state);
• (the set of accepting states);
• is a function from (the transition function).
• For any element of and any symbol , we interpret as the state to
which the FA moves, if it is in state and receives the input .

6
Applications of FA
• Lexical analysis phase of a compiler.
• Design of digital circuit.
• String matching.
• Communication Protocol for information exchange.

7
WHAT IS DFA and NFA?
Deterministic Finite Automata (DFA)
Verify for below strings:

1010001010
11010100
11211011
01010011111
010101010111000
DFA with Σ = {0, 1} accepts all strings ending with 0.
11
00

Non-deterministic Finite Automata (NFA)

8
FA Examples
• The strings ending with 10.

0 1

𝐴 1
𝐵 𝐶
1

9
Nondeterministic Finite Automata (NFA)
• A nondeterministic finite automaton is a 5-tuple where and are
nonempty finite sets, , and

is the set of states, is the alphabet, is the initial state and is the
set of accepting states.

10
Exercise:
Design a DFA with ∑ = {0, 1} accepts the only input 101

Design a FA with ∑ = {0, 1} accepts those string which starts with 1 and
ends with 0.

Design FA with ∑ = {0, 1} accepts


the set of all strings with three
consecutive 0's.

11
Regular Expression

12
Regular expression
• A regular expression is a sequence of characters that define
a pattern.
• Notational shorthand's
1. One or more occurrences:
2. Zero or more occurrences:
3. Alphabets:

13
Regular expression
L = Zero or More Occurrences of a = a*

*
𝜖
a
aa
aaa Infinite …..
aaaa
aaaaa…..

14
Regular expression

+
L = One or More Occurrences of a = a+

a
aa
aaa Infinite …..
aaaa
aaaaa…..

15
Regular expression examples
1. 0 or 1
𝑺𝒕𝒓𝒊𝒏𝒈𝒔 :𝟎 ,𝟏𝑹 . 𝑬 .=𝟎∨𝟏
2. 0 or 11 or 111
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎 ,𝟏𝟏,𝟏𝟏𝟏 𝑹. 𝑬 .=𝟎|𝟏𝟏| 𝟏𝟏𝟏
𝑹 . 𝑬 .=𝒂 ∗
String having zero or more a.
3. 𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝜖,𝒂,𝒂𝒂,𝒂𝒂𝒂,𝒂𝒂𝒂𝒂…..

4. 𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝒂,𝒂𝒂,𝒂𝒂𝒂,
String having one or 𝑹a.. 𝑬 .=𝒂 +¿
𝒂𝒂𝒂𝒂…..
more

5. Regular expression over that represent all string of length 3.


𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝒂𝒃𝒄,𝒃𝒄𝒂,𝒃𝒃𝒃,𝒄𝒂𝒃,𝒂𝒃𝒂…. 𝑹.𝑬.=( 𝒂|𝒃|𝒄 )( 𝒂|𝒃|𝒄 ) (𝒂|𝒃|𝒄)
6. All binary string.
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎,𝟏𝟏,𝟏𝟎𝟏,𝟏𝟎𝟏𝟎𝟏,𝟏𝟏𝟏𝟏…𝑹. 𝑬 .=(𝟎∨𝟏)+¿
16
Regular expression examples
7. 0 or more occurrence of either a or b or both
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝜖,𝒂,𝒂𝒂,𝒂𝒃𝒂𝒃,𝒃𝒂𝒃… 𝑹. 𝑬 .=(𝒂∨𝒃)∗
8. 1 or more occurrence of either a or b or both
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝒂,𝒂𝒂,𝒂𝒃𝒂𝒃,𝒃𝒂𝒃,𝒃𝒃𝒃𝒂𝒂𝒂… 𝑹. 𝑬 .=(𝒂∨𝒃)+¿
9. Binary no. ends with 0
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎,𝟏𝟎,𝟏𝟎𝟎,𝟏𝟎𝟏𝟎,𝟏𝟏𝟏𝟏𝟎…
10. 𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟏,𝟏𝟎𝟏,𝟏𝟎𝟎𝟏,𝟏𝟎𝟏𝟎𝟏,…
Binary no. ends with 1 𝑹. 𝑬 .=(𝟎∨𝟏)∗𝟏
11. 𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟏𝟏,𝟏𝟎𝟏,𝟏𝟎𝟎𝟏,𝟏𝟎𝟏𝟎𝟏,…
Binary no. starts and ends with 1

12. 𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎𝟎,𝟏𝟎𝟏,𝒂𝒃𝒂,𝒃𝒂𝒂𝒃…
String starts and ends with same character

17
Regular expression examples
13. All string of a and b starting with a
… 𝑹. 𝑬 .=𝒂(𝒂∨𝒃)∗
14. String of 0 and 1 ends with 00
… 𝑹. 𝑬 .=(𝟎∨𝟏)∗𝟎𝟎
15. String ends with abb
… 𝑹. 𝑬 .=(𝒂∨𝒃)∗𝒂𝒃𝒃
16. String starts with 1 and ends with 0
… 𝑹. 𝑬 .=𝟏(𝟎∨𝟏)∗𝟎
17. All binary string with at least 3 characters and 3rd character should be
zero … 𝑹.𝑬.=( 𝟎|𝟏 )( 𝟎|𝟏) 𝟎(𝟎∨𝟏)∗
18. Language which consist of exactly two b’s over the set
… 𝑹. 𝑬 .=𝒂∗𝒃 𝒂∗𝒃𝒂∗
18
Regular expression examples
19. The language with such that 3rd character from right end of the string is
always
… 𝑹.𝑬.=(𝒂∨𝒃)∗𝒂(𝒂∨𝒃)(𝒂∨𝒃)
20. Any no. of followed by any no. of followed by any no. of
… 𝑹. 𝑬 .=𝒂∗𝒃∗𝒄 ∗
21. String should contain at least three
∗ ∗ ∗ ∗
…. 𝑹.𝑬.=(𝟎∨𝟏) 𝟏(𝟎∨𝟏) 𝟏(𝟎∨𝟏) 𝟏(𝟎∨𝟏)
22. String should contain exactly two
∗ ∗ ∗
….
𝑹 . 𝑬 .=𝟎
23. Length of string should be at least 1 and at most 3
𝟏 𝟎 𝟏 𝟎
…. 𝑹.𝑬.=( 𝟎∨𝟏)|( 𝟎∨𝟏)( 𝟎∨𝟏)|( 𝟎∨𝟏)( 𝟎∨𝟏 )( 𝟎∨𝟏
24. No. of zero should be multiple of 3
∗ ∗ ∗
…. 𝑹. 𝑬 .=(𝟏 𝟎𝟏 𝟎𝟏 𝟎
19
Regular expression - Exercise
1. The language with where should be multiple of 3
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝒂𝒂𝒂,𝒃𝒂𝒂𝒂,𝒃𝒂𝒄𝒂𝒃𝒂,𝒂𝒂𝒂𝒂𝒂𝒂.. ∗ ∗ ∗
𝑹.𝑬.=( ( 𝒃∨𝒄 ) 𝒂 ( 𝒃∨𝒄 ) 𝒂 ( 𝒃∨𝒄 ) 𝒂 ( 𝒃∨𝒄 ) )
∗∗

2. Even no. of 0
∗ ∗ ∗ ∗
…. 𝑹 . 𝑬 .=(𝟏 𝟎 𝟏 𝟎 𝟏 )
3. String should have odd length

…. 𝑹. 𝑬 .=( 𝟎∨𝟏 ) (( 𝟎|𝟏 ) (𝟎∨𝟏))
4. String should have even length

…. 𝑹 . 𝑬 .=( ( 𝟎|𝟏 ) ( 𝟎∨𝟏))
5. String start with 0 and has odd length

…. 𝑹. 𝑬 .=( 𝟎 ) ( ( 𝟎|𝟏 ) (𝟎∨𝟏))
6. String start with 1 and has even length

…. 𝑹. 𝑬 .=𝟏(𝟎∨𝟏)(( 𝟎|𝟏 ) (𝟎∨𝟏))
20
Regular expression - Exercise
7. All string begins or ends with 00 or 11
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎𝟎𝟏𝟎𝟏,𝟏𝟎𝟏𝟎𝟎,𝟏𝟏𝟎𝟎,𝟎𝟏𝟎𝟏𝟏… 𝑹.𝑬.=(𝟎𝟎∨𝟏𝟏)(𝟎∨𝟏)∗∨( 𝟎|𝟏 ) ∗(𝟎𝟎∨𝟏𝟏)
8. Language of all string containing both 11 and 00 as substring

𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎𝟎𝟏𝟏,𝟏𝟏𝟎𝟎,𝟏𝟎𝟎𝟏𝟏𝟎,𝟎𝟏𝟎𝟎𝟏𝟏…
9. String ending with 1 and not contain 00
𝑹 . 𝑬 .=( 𝟏|𝟎𝟏 ) +¿
𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝟎𝟏𝟏,𝟏𝟏𝟎𝟏,𝟏𝟎𝟏𝟏….
10. Language of C identifier

𝑺𝒕𝒓𝒊𝒏𝒈𝒔:𝒂𝒓𝒆𝒂,𝒊,𝒓𝒆𝒅𝒊𝒐𝒖𝒔,𝒈𝒓𝒂𝒅𝒆𝟏…. 𝑹. 𝑬 .=(¿∨ 𝑳)(¿∨𝑳∨𝑫 ) ∗

𝒘𝒉𝒆𝒓𝒆 𝑳𝒊𝒔𝑳𝒆𝒕𝒕𝒆𝒓 ∧𝐃𝐢𝐬𝐝𝐢𝐠𝐢𝐭

21
Precedence and associativity of operators
Operator Precedence Associative
Kleene * 1 left
Concatenation 2 left
Union | 3 left

22
Exercise:
Draw DFA over {a, b} for all strings with zero or more a followed
by exact one b a
RE: a*b

𝑞0 b
𝑞1

Draw DFA over {a, b} for all strings with one or more a followed
by exact one b a
RE: a+b

𝑞0 a
𝑞1 b
𝑞2

23
FA Examples
• (a+b)*baaa OR (a|b)*baaa b

a B a
b
b
A C

b b
a a

a
E D

24
Example of NFA for
δ Input
State

• is defined as

𝑞1
1 1

𝑞0 0
𝑞4
1 0

𝑞2 1
𝑞3
25
Languages

26
Language
• A set of strings all of which are chosen from some , where is a
particular alphabet, is called a language. If is an alphabet, and ,
then is said to be language over alphabet .
• Language comprises of:
• Set of characters –
• Set of strings (words) defined from set of character -
• Language L is defined from , and because contains many
string which may not satisfy the rules of language.
• Example:
• = {a, b}
• = {^, a, b, aa, ab, ba, bb, aaa, aab, aba, abb, baa, …}

27
Operations over Language
• Operations over the language are:
1. Concatenation
2. | (Union)
3. * (Kleene closure)
4. +
If then concatenation is defined as

Example:
= {hope, fear} and = {less, fully}
hopeless

= {hopeless, hopefully, fearless, fearfully}


28
Operations over Language
• Operations over the language are:
1. Concatenation
2. | (Union)
3. * (Kleene closure)
4. +
If then union is defined as

Example:
= {hope, fear} and = {less, fully}

= {hope, fear, less, fully}

29
Operations over Language
• Operations over the language are:
1. Concatenation
2. | (Union)
3. * (Kleene closure)
4. +
• If is a set of words then by we mean the set of all finite strings
formed by concatenating words from S, where any word may be
used as often, we like, and where the null string is also included.

Example: = {ab}

* = {^, ab, abab, ababab, abababab, ….}


30
Operations over Language
• Operations over the language are:
1. Concatenation
2. | (Union)
3. * (Kleene closure)
4. +
• If is a set of words then by we mean the set of all finite strings
formed by concatenating words from L, where any word may be
used as often, we like, and where the null string is not included.

Example: = {ab}

= {ab, abab, ababab, abababab, ….}


31
Chomsky Hierarchy
(Classification of Grammar)

Avram Noam Chomsky is an American linguist, philosopher, cognitive scientist,


historian, social critic, and political activist. Sometimes called "the father of modern
linguistics", Chomsky is also a major figure in analytic philosophy and one of the
founders of the field of cognitive science. ~ Wikipedia

The Noam Chomsky Website: https://chomsky.info/

32
Chomsky hierarchy (Classification of grammar)
Grammar

Unrestricted Restricted
grammar (type 0) grammar

Context Context Regular


sensitive free grammar
grammar grammar (type 3)
(type 1) (type 2)

33
Definition: Grammar
• A grammar is a 4-tuple where,
is finite set of non terminals,
is disjoint finite set of terminals,
is an element of and it’s a start symbol,
is a finite set of productions of the form

34
Type 0 grammar (Phrase Structure Grammar)
• Their productions are of the form:

• where both and can be strings of terminal and nonterminal


symbols.
• Example: S → ACaB
Bc → acB
CB → DB
aD → Db

35
Type 1 grammar (Context Sensitive Grammar)
• Their productions are of the form:

• where A is nonterminal and , , are strings of terminals and non


terminals.
• The strings and may be empty, but must be non-empty.
• Here, a string can be replaced by (or vice versa) only when it is
enclosed by the strings and in a sentential form.
• Example: AB → AbBc
A → bcA
B→b

36
Type 2 grammar (Context Free Grammar)
• Their productions are of the form:

• Where is nonterminal and is string of terminals and non


terminals.
• Example: S → Xa
X→a
X → aX
X → abc

37
Type 3 grammar (Linear or Regular grammar)
• Their productions are of the form:
or
• Where are nonterminals and is terminal.
• Example: X → a | aY
Y→b

38
Hierarchy of grammar

Type 3
(Regular)

39
Context free grammar

40
Context Free Grammar
• A context free grammar (CFG) is a 4-tuple where,
is finite set of non terminals,
is disjoint finite set of terminals,
is an element of and it’s a start symbol,
is a finite set of productions of the form where and .
• Application of CFG:
1. CFG are extensively used to specify the syntax of
programming language.
2. CFG is used to develop a parser.

41
Context Free Language
• Let be a CFG. The language generated by is

• A language is a context free Language (CFL) if there is a CFG so


that .

A Context Free Grammar is a set of recursive rules used to


generate patterns of strings. A Context Free Grammar can
describe all regular languages and more, but they cannot
describe all possible languages.

Context Free Grammar are studied in fields of theoretical


computer science, compiler design, and linguistics.

42
CFG Examples
If in any CFG the productions are −
S → AB
A → aaA | ε
B → Bb| ε
the partial derivation tree can be the following −

If a partial derivation tree contains the root S, it is called a sentential


form. The above sub-tree is also in sentential form.
43
CFG Examples
Let any set of production rules in a CFG be Left most derivation
X → X+X | X*X |X| a
over an alphabet {a}.

Input string: a + a * a

Solution: 1 Solution: 2
X → X+X X → X*X
X → a+X X → X*a
X → a + X*X X → X+X*a
X → a+a*X X → X+a*a
X → a+a*a X → a+a*a

44
CFG Examples
Let any set of production rules in a CFG be Right most derivation
X → X+X | X*X | a
over an alphabet {a}.

Input string: a + a * a

Solution: 1 Solution: 2
X → X+X X → X*X
X → a+X X → X*a
X → a + X*X X → X+X*a
X → a+a*X X → X+a*a
X → a+a*a X → a+a*a

45
CFG Examples
• Write CFG for either a or b
S a | b
• Write CFG for a+
S aS | a
• Write CFG for a*
S aS | Ɛ
• Write CFG for (ab)*
S abS | Ɛ
• Write CFG for any string of a and b
S aS | bS | a | b

46
CFG Exercise
Arithmetic expressions
The terminals are {+,-,*,a}. The symbol a represents a token that we identify by
other means. It could be a number, variable, etc.
CFG E⇒E+T
E→E+T|E-T|T E => T + T
T→T*F|F E⇒F+T
F→a E⇒x+T
Where a = {a,b,c,d,….z} E⇒x+T*F
E⇒x+F*F
Input string: x + y * z E⇒x+y*F
E⇒x+y*z

47
CFG Exercise
Balanced Parentheses
S⇒(S)
CFG S⇒(SS)
S → SS | (S) | ε S⇒((S)S)
S⇒((S)(S))
Input string: ( ( ) ( ) ) S⇒(()(S))
S⇒(()())

48
CFG Exercise
Program structure

CFG
Prog → { Stmts } Prog ⇒ { Stmts }
Stmts →Stmts ; Stmt ; Prog ⇒ { Stmts ; Stmt ;}
Stmts →Stmt; Prog ⇒ { Stmt ; Stmt ;}
Stmt →id = Expr Prog ⇒ { id = Expr ; Stmt ;}
Expr →id Prog ⇒ { id = id ; Stmt ;}
Expr →Expr + id Prog ⇒ { id = id ; id = Expr ;}
Prog ⇒ { id = id ; id = Expr + id ;}
Input string: Prog ⇒ { id = id ; id = id + id ;}
{ Prog ⇒ { id = id ; id = id + id ;}
id = id;
id = id + id;
}
49
CFG Exercise
Consider the following grammar

CFG
S → aB | bA
A → aS | bAA | a
B → bS | aBB | b

Input string:
aaabbabbba

Que:
Derive the string using leftmost derivation and rightmost derivation.
Draw parse tree for both derivations.

50
S → aB
CFG Exercise S → aaBB (Using B → aBB)
S → aaaBBB (Using B → aBB)
Consider the following grammar S → aaabBB (Using B → b)
CFG S → aaabbB (Using B → b)
S → aB | bA S → aaabbaBB (Using B → aBB)
A → aS | bAA | a S → aaabbabB (Using B → b)
B → bS | aBB | b S → aaabbabbS (Using B → bS)
S → aaabbabbbA (Using S → bA)
Input string: S → aaabbabbba (Using A → a)
aaabbabbba

51
Recursive Definitions

52
Recursive Definitions
1. Recursive Definition of {a,b}* CFG: S aS | bS | ^
˄∈L.
For any S∈L, aS∈L.
For any S∈L, bS∈L.
No other strings are in L.
2. Recursive Definition of Palindrome CFG: S aSa | bSb | a | b | ˄
˄, a, b ∈ L
For any S ∈ L , aSa ∈ L and bSb ∈ L
No other string are in L
3. Recursive Definition of the language {anbn | n≥0} CFG: S aSb | ˄
˄∈ L
For every S ∈ L, aSb ∈L
No other strings are in L
53
CFG Examples
• Write CFG for ab*
SaX
X˄| bX
• Write CFG for a*b*
SXY
XaX|˄
YbY|˄
• Write CFG for (a|b)*
SaS | bS | ^
• Write CFG for a(a|b)*
SaX
XaX | bX | ^
54
Extended Transition Function for FA
• Let be a Finite Automata. We define the function

as follows:
1. For any
2. For any and ,

55
Example
Consider FA
a
𝑞 𝑞1 b
𝑞2 c
𝑞3
Calculate

56
Exercise :
Consider following FA
0 1

𝐴 1
𝐵 𝐶
1

Calculate

57
Acceptance by FA
• Let be an FA. A string is accepted by if . If string is not accepted,
we can say it is rejected by . The language accepted by , or the
language recognized by , is the set

• If 𝐿 is any language over , is accepted or recognized by if and only


if .

58
Union, Intersection & Complement of Languages
• Suppose and accepts languages and , respectively. Let be an FA
defined by , where

and the transition function is defined by the formula

for any and and then


1. if , accepts the language
2. if , accepts the language
3. if , accepts the language

59
Example
Draw Finite Automata for following languages:
1. L1={x/x 00 is not substring of x, x ∈ {0,1}*}
2. L2={x/x ends with 01, x ∈ {0,1}*}
Draw FA for , and

1 0,1 1 0

0 1

𝐴 1
𝐵 0
𝐶 𝑃 0
𝑄 0
𝑅
1
𝑴𝟏 𝑴𝟐

60
Computation for , and
• Here and 1

• So,

𝐴𝑃 𝐵𝑃 𝐶𝑃
• Computing Transition Function 0

𝛿 ( ( 𝐴, 𝑃 ) , 0 ) =(𝛿 ( 𝐴, 0 ) , 𝛿 ( 𝑃 , 0 ) ) 𝐴𝑄 𝐵𝑄 𝐶𝑄
¿ 𝐵𝑄
𝛿 ( ( 𝐴, 𝑃 ) ,1 ) =(𝛿 ( 𝐴 ,1 ) , 𝛿 ( 𝑃 ,1 ))
¿ 𝐴𝑃 𝐴𝑅 𝐵𝑅 𝐶𝑅
BQ

61
Computation for , and
𝛿 ( ( 𝐵 ,𝑄 ) , 0 ) =(𝛿 ( 𝐵, 0 ) , 𝛿 (𝑄 , 0 ) ) 1
¿ 𝐶𝑄
𝛿 ( ( 𝐵 ,𝑄 ) , 1 ) =(𝛿 ( 𝐵 ,1 ) , 𝛿 ( 𝑄 , 1 ) )
¿ 𝐴𝑅
𝛿 ( ( 𝐶 ,𝑄 ) ,0 ) =(𝛿 ( 𝐶 ,0 ) , 𝛿 (𝑄 , 0 ) )
𝐴𝑃 𝐵𝑃 𝐶𝑃
0
¿ 𝐶𝑄 0
𝛿 ( ( 𝐶 ,𝑄 ) ,1 ) =(𝛿 ( 𝐶 ,1 ) , 𝛿 ( 𝑄 , 1 ) )
¿ 𝐶𝑅 1 𝐴𝑄 𝐵𝑄 0
𝐶𝑄
𝛿 ( ( 𝐴, 𝑅 ) , 0 ) =(𝛿 ( 𝐴 , 0 ) , 𝛿 ( 𝑅 , 0 ) ) 0
1
¿ 𝐵𝑄 1
𝛿 ( ( 𝐴, 𝑅 ) , 1 ) =(𝛿 ( 𝐴, 1 ) , 𝛿 ( 𝑅 ,1 ) )
¿ 𝐴𝑃
𝐴𝑅 𝐵𝑅 𝐶𝑅
BQ CQ AR CR

62
Computation for , and
𝛿 ( ( 𝐶 , 𝑅 ) ,0 ) =(𝛿 ( 𝐶 ,0 ) , 𝛿 ( 𝑅 , 0 ) ) 1 1

¿ 𝐶𝑄
𝛿 ( ( 𝐶 , 𝑅 ) ,1 ) =(𝛿 ( 𝐶 ,1 ) , 𝛿 ( 𝑅 , 1 ) ) 𝐴𝑃 𝐵𝑃 𝐶𝑃
¿ 𝐶𝑃 0
0 0
𝛿 ( ( 𝐶 , 𝑃 ) , 0 ) =(𝛿 ( 𝐶 , 0 ) , 𝛿 ( 𝑃 , 0 ) )
¿ 𝐶𝑄 1 𝐴𝑄 𝐵𝑄 0
𝐶𝑄 1

0
𝛿 ( ( 𝐶 , 𝑃 ) , 1 )=(𝛿 ( 𝐶 , 1 ) , 𝛿 ( 𝑃 ,1 ) ) 1
0 1

¿ 𝐶𝑃 𝐴𝑅 𝐵𝑅 𝐶𝑅
BQ CQ AR CR CP

63
Removing Unconnected States
1 1

𝐴𝑃 𝐵𝑃 𝐶𝑃
0
0 0

1 𝐴𝑄 𝐵𝑄 0
𝐶𝑄 1

0
0 1
1

𝐴𝑅 𝐵𝑅 𝐶𝑅

64
𝐿1 ∪ 𝐿2
1 1
𝐴1={ 𝐴, 𝐵 }
𝐴2={ 𝑅 }
As per theorem stated
𝐴𝑃 𝐶𝑃
0
earlier, the states which 0 0
consists A or B or R will be
Accepting states in the 1 𝐵𝑄 0
𝐶𝑄 1

resultant FA. 0
0 1
1

𝐴𝑅 𝐶𝑅

Accepting States

65
𝐿1 ∩ 𝐿2
𝐴1={ 𝐴, 𝐵 } 1 1

𝐴2={ 𝑅 }
Therefore, as per theorem 𝐴𝑃 𝐶𝑃
0
stated earlier, the states 0 0
which consists (A and R)
and (B and R) will be 1 𝐵𝑄 0
𝐶𝑄 1

Accepting states in the 0


0 1
resultant FA. 1

𝐴𝑅 𝐶𝑅

Accepting States
66
𝐿1 − 𝐿2
𝐴1={ 𝐴, 𝐵 } 1 1

𝐴2={ 𝑅 }
Therefore, as per theorem 𝐴𝑃 𝐶𝑃
0
stated earlier, the states 0 0
which consists A or B but
should not contain R with 1
𝐵𝑄 0
𝐶𝑄 1

them will be Accepting 0


0 1
states in the resultant FA. 1

𝐴𝑅 𝐶𝑅

Accepting States

67
Exercise
Draw Finite Automata for following languages:
1. L1={x/x 11 is not substring of x, x ∈ {0,1}*}
2. L2={x/x ends with 10, x ∈ {0,1}*}
Draw FA for , and .

0 0,1 0 1

1 0

𝐴 0
𝐵 1
𝐶 𝑃 1
𝑄 1
𝑅
0
𝑴𝟏 𝑴𝟐
68
Thank You

69

You might also like