Lecture#03, FA, Union, Complement, Intersection, Concatenation, Kleene Star
Lecture#03, FA, Union, Complement, Intersection, Concatenation, Kleene Star
Lecture#03
Finite Automata, Union of Languages, Intersection of Languages, Complement of a
Language, Kleene’s Star of a Language, Concatenation of Languages
Lecture Contents
Regular Languages
Finite Languages
Relation between Finite & Regular Languages
Finite Automaton
Identifying Languages accepted by FA
Transition Table for FA
Creating FA to accept a Language
Creating FA to accept a Finite Language
Creating FA for Union of Two Languages
Creating FA for Intersection of Two Languages
Creating FA for Negation of a Language
Creating FA for Concatenation of Two Languages
Creating FA for Cleene’s Star of a Language
Regular Expressions
If r1 = (aa + bb) and r2 = ( a + b) then
r1+r2 = (aa + bb) + (a + b)
r1r2 = (aa + bb) (a + b) = (aaa + aab + bba + bbb)
(r1)* = (aa + bb)*
Regular Languages
Definition
The language generated by any regular expression is called
a regular language
It is to be noted that if r1, r2 are regular expressions,
corresponding to the languages L1 and L2 then the
languages generated by
1. r1 + r2
2. r1 r2( or r2 r1) and
3. r1 *( or r2*)
are also regular languages
Regular Languages
Note
It is to be noted that if L1 and L2 are expressed by r1and r2,
respectively then the language expressed by
1) r1+ r2, is the language L1 + L2
2) r1r2, is the language L1L2, of strings obtained by prefixing
every string of L1 with every string of L2
3) r1*, is the language L1*, of strings obtained by
concatenating the strings of L1, including the null string
Finite Languages
A language is said to be a finite language if it contains finite
words into it
YES
What language is represented by r1+r2?
According to set theory: L1UL2 (Union of both L1 & L2)
Example: if r1 = (a+b)(a+b) and r2 = (a+b)
Then
r1 + r2 = (a+b)(a+b) +(a+b)
i.e. r1 + r2 = aa + ab + ba + bb + a + b
Regular Languages; R1R2
If r1 & r2 be two regular expressions of languages L1 & L2
respectively then “Is r1r2 a regular Expression?”
YES
What language is represented by r1r2?
Language of all words formed by concatenation of
words from L1 & L2
Examples to be discussed
Regular Languages; R1R2
For Example:
If r1 = (a+b)(a+b), r2 = (a+b)
Then r1r2 = (a+b)(a+b)(a+b)
i.e. r1r2=(aa+ab+ba+bb)(a+b)
= (aaa+aba+baa+bba+aab+abb+bab+bbb)
YES
1,0
1
1,0
0,1
If above machine accepts only strings with input ending in a double circle,
what kind of machine is it? (What is pattern in strings that above machine
accepts?)
Identify the Language Σ = {0,1}
0,1 1,0
1
0
1,0
a b
b
a
a
a b
b
a
a
b
a
a b
b a
b a
How to do it?
Any Ideas????????
FA corresponding to Finite Languages
Simple idea!!!
1. Initiating from Start State, show two transactions from every state to
new states
2. Every new state that refers to the end of word(s) should be marked as
final state
3. When all words have been accepted then complete transitions on every
state (all letters of alphabet) to a new non-final state
That is It. You are done.
Union Theorem
Rule 1:
Q= Any state of resulting FA corresponds to pair of states
(one from F1 and other from F2)
Rule 2:
Starting state for resulting FA q0 is corresponding to starting state
of both FAs (F1 and F2)
Rule 3:
Any state in resulting FA is considered to be final state if any of two
or both corresponding FA states are final
Union (of languages) Theorem: (Demonstration)
Let L1 and L2 be two languages over such that Σ = {a,b}
L1 = “Language of all words having substring ab”
L2 = “Language of all words ending on a”
Corresponding FA’s are as follows
Union of above languages is a language that contains all words that are
either ending on a or having substring ab
Creating FA for Union of FA1 & FA2
Current State New State on Input = a New State on Input = b
Qz0 (Qx OR Q0) Qz1 (Qy OR Q1) Qz0 (Qx OR Q0)
Qz1 (Qy OR Q1) FINAL STATE Qz1 (Qy OR Q1) Qz2 (Qz OR Q0)
Qz2 (Qz OR Q0) FINAL STATE Qz3 (Qz OR Q1) Qz2 (Qz OR Q0)
Qz3 (Qz OR Q1) FINAL STATE Qz3 (Qz OR Q1) Qz2 (Qz OR Q0)
Creating FA for Union of FA1 & FA2 from Transition Table
Current State New State on Input = a New State on Input = b
Qz0 (Qx OR Q0) Qz1 (Qy OR Q1) Qz0 (Qx OR Q0)
Qz1 (Qy OR Q1) FINAL STATE Qz1 (Qy OR Q1) Qz2 (Qz OR Q0)
Qz2 (Qz OR Q0) FINAL STATE Qz3 (Qz OR Q1) Qz2 (Qz OR Q0)
Qz3 (Qz OR Q1) FINAL STATE Qz3 (Qz OR Q1) Qz2 (Qz OR Q0)
a b a
b
a
a b Qz3
Qz0 Qz1 Qz2
b
FA for Union FA1 & FA2 from Transition Table
Same method should be followed to get FA for Union of two FAs
Above method proves that there always FA available for Union of two
FAs (FAs for any arbitrary languages)
Since every language that can be accepted by FA is regular, hence Union
language of any two regular language is always a Regular Language
Intersection (of languages) Theorem
Rule 1:
Q= Any state of resulting FA corresponds to pair of states
(one from F1 and other from F2)
Rule 2:
Starting state for resulting FA q0 is corresponding to starting state
of both FAs (F1 and F2)
Rule 3:
Any state in resulting FA is considered to be final state if only both
of corresponding FA states are final
Intersection (of languages) Theorem: (Demonstration)
Let L1 and L2 be two languages over such that Σ = {a,b}
L1 = “Language of all words having substring ab”
L2 = “Language of all words ending on a”
Corresponding FA’s are as follows
a b a
b
a
a b Qz3
Qz0 Qz1 Qz2
b
FA for Intersection of FA1 & FA2 from Transition Table
Same method should be followed to get FA for Intersection of two FAs
Above method proves that there always FA available for Intersection of
two FAs (FAs for any arbitrary languages)
Since every language that can be accepted by FA is regular, hence
Intersection language of any two regular language is always a Regular
Language
Negation of a Language
Rule 1:
Q= Any state of resulting FA corresponds to exactly same
state in original FA (F1)
Rule 2:
Starting state for resulting FA q0 is corresponding to starting state
of original FA (F1)
Rule 3:
Any state in resulting FA will be final state if corresponding state in
original FA (F1) was not final and vice versa.
Negation (of language) Theorem: (Demonstration)
Let L1 be a language over such that Σ = {a,b}
L1 = “Language of all words having substring ab”
Corresponding FA is as follows
Rule 1:
Q= Any state of resulting FA can correspond to state of one FA
or two FAs (F1 and F2)
Rule 2:
Starting state for resulting FA q0 is corresponding to starting state
of one FA (F1) only
Rule 3:
Any state in resulting FA is considered to be final state if it matches
with final state of FA (F2) only
Concatenation(of languages) Theorem: (Demonstration)
Let L1 and L2 be two languages over such that Σ = {a,b}
L1 = “Language of all words having substring ab”
L2 = “Language of all words ending on a”
Corresponding FA’s are as follows
a b a
b
a
a b Qz3
Qz0 Qz1 Qz2
b
FA for Concatenation of FA1 & FA2 from Transition Table
Same method should be followed to get FA for Intersection of two FAs
Above method proves that there is always FA available for
Concatenation of two FAs (FAs for any arbitrary regular languages)
Since every language that can be accepted by FA is regular, hence
Concatenation language of any two regular language is always a
Regular Language
Kleene’s (of languages) Theorem
Rule 1:
Q = Any state of resulting FA will correspond to state of one
FA(F1)
Rule 2:
Starting state for resulting FA q0 is corresponding to starting state
of one FA (F1) only
Rule 3:
Any state in resulting FA is considered to be final state if it matches
with final state of FA (F1) only
Kleene’s Star Theorem: (Demonstration)
Let L1 be a language over such that Σ = {a,b}
L1 = “Language of all words exactly three b”
Corresponding FA is as follows