SlideShare a Scribd company logo
1 of 17
THEORY OF AUTOMATA AND
FORMAL LANGUAGE
KLEENE STAR CLOSURE, PLUS OPERATION, RECURSIVE DEFINITION OF
LANGUAGES, INTEGER, EVEN, FACTORIAL, PALINDROME, LANGUAGES
OF STRINGS, CURSIVE DEFINITION OF RE, DEFINING LANGUAGES BY
RE,EXAMPLES
KLEENE STAR CLOSURE
• Given Σ, then the Kleene Star Closure of the alphabet Σ, denoted by
Σ*, is the collection of all strings defined over Σ, including Λ. It is to
be noted that Kleene Star Closure can be defined over any set of
strings.
• Examples
1) If Σ = {x} Then Σ* = {Λ, x, xx, xxx, xxxx, ….}
2) If Σ = {0,1} Then Σ* = {Λ, 0, 1, 00, 01, 10, 11, ….}
3) If Σ = {aaB, c} Then Σ* = {Λ, aaB, c, aaBaaB, aaBc, caaB, cc, ….}
• Note: Languages generated by Kleene Star Closure of set of strings,
are infinite languages. (By infinite language, it is supposed that the
language contains infinite many words, each of finite length).
PLUS OPERATION (+)
Plus Operation is same as Kleene Star Closure except that it does not
generate Λ (null string), automatically.
• Example
1) If Σ = {0,1} Then Σ+ = {0, 1, 00, 01, 10, 11, ….}
2) If Σ = {aab, c} Then Σ+ = {aab, c, aabaab, aabc, caab, cc, ….}
• Remark: It is to be noted that Kleene Star can also be operated on
any string i.e. a* can be considered to be all possible strings defined
over {a}, which shows that a* generates Λ, a, aa, aaa, …It may also be
noted that a+ can be considered to be all possible non empty strings
defined over {a}, which shows that a+ generates a, aa, aaa, aaaa, …
RECURSIVE DEFINITION OF LANGUAGES
• The following three steps are used in recursive definition
1) Some basic words are specified in the language.
2) Rules for constructing more words are defined in the
language.
3) No strings except those constructed in above, are allowed to
be in the language.
EXAMPLES
• Defining language of INTEGER
• Step 1: 1 is in INTEGER.
• Step 2: If x is in INTEGER then x+1 and x-1 are also in INTEGER.
• Step 3: No strings except those constructed in above, are allowed to
be in INTEGER.
• Defining language of EVEN
• Step 1: 2 is in EVEN.
• Step 2: If x is in EVEN then x+2 and x-2 are also in EVEN.
• Step 3: No strings except those constructed in above, are allowed to
EXAMPLES
• Defining the language PALINDROME, defined over Σ = {a,b}
• Step 1: a and b are in PALINDROME
• Step 2: if x is palindrome, then s(x)Rev(s) and xx will also be
palindrome, where s belongs to Σ*
• Step 3: No strings except those constructed in above, are allowed to
be in palindrome
• Defining the language {anbn }, n=1,2,3,… , of strings defined over
Σ={a,b}
• Step 1: ab is in {anbn}
• Step 2: if x is in {anbn}, then axb is in {anbn}
• Step 3: No strings except those constructed in above, are allowed to
EXAMPLES
• Defining the language L, of strings ending in a , defined over Σ={a,b}
• Step 1: a is in L
• Step 2: if x is in L then s(x) is also in L, where s belongs to Σ*
• Step 3: No strings except those constructed in above, are allowed to
be in L
• Defining the language L, of strings beginning and ending in same
letters , defined over Σ={a, b}
• Step 1: a and b are in L
• Step 2: (a)s(a) and (b)s(b) are also in L, where s belongs to Σ*
• Step 3: No strings except those constructed in above, are allowed to
EXAMPLES
• Defining the language L, of strings containing aa or bb , defined over
Σ={a, b}
• Step 1: aa and bb are in L
• Step 2: s(aa)s and s(bb)s are also in L, where s belongs to Σ*
• Step 3: No strings except those constructed in above, are allowed to
be in L
• Defining the language L, of strings containing exactly one a, defined
over Σ={a, b}
• Step 1: a is in L
• Step 2: s(a)s is also in L, where s belongs to b*
REGULAR EXPRESSION
• As discussed earlier that a* generates Λ, a, aa, aaa, … and a+ generates a, aa,
aaa, aaaa, …, so the language L1= {Λ, a, aa, aaa, …} and L2 = {a, aa, aaa, aaaa,
…} can simply be expressed by a* and a+, respectively. a* and a+ are called the
regular expressions (RE) for L1 and L2 respectively.
• Note :a+, aa* and a*a generate L2.
• Recursive definition of Regular Expression(RE)
Step 1: Every letter of Σ including Λ is a regular expression.
Step 2: If r1 and r2 are regular expressions then
• (r1)
• r1 r2
• r1 + r2 and
• r1*are also regular expressions.
Step 3: Nothing else is a regular expression.
REGULAR EXPRESSIONS
• Consider the language L={Λ, x, xx, xxx,…} of strings, defined
over Σ = {x}. We can write this language as the Kleene star
closure of alphabet Σ or L=Σ*={x}* .This language can also be
expressed by the regular expression x*
• Similarly the language L={x, xx, xxx,…}, defined over Σ = {x},
can be expressed by the regular expression x+.Now consider
another language L, consisting of all possible strings, defined
over Σ = {a, b}. This language can also be expressed by the
regular expression (a + b)*.
• Now consider another language L, of strings having exactly one
EXAMPLES
• Now consider another language L, of even length, defined over Σ =
{a, b}, then it’s regular expression may be ((a+b)(a+b))*.
• Now consider another language L, of odd length, defined over Σ = {a,
b}, then it’s regular expression may be (a+b)((a+b)(a+b))* or
((a+b)(a+b))*(a+b).
• Remark
It may be noted that a language may be expressed by more than one
regular expression, while given a regular expression there exist a
unique language generated by that regular expression.
EXAMPLES
• Consider the language, defined over Σ = {a , b} of words having at
least one a, may be expressed by a regular expression (a+b)*a(a+b)*.
• Consider the language, defined over Σ = {a, b} of words having at
least one a and one b, may be expressed by a regular expression
(a+b)*a(a+b)*b(a+b)*+ (a+b)*b(a+b)*a(a+b)*.
• Consider the language, defined over Σ ={a, b}, of words starting with
double a and ending in double b then its regular expression may be
aa(a+b)*bb
• Consider the language, defined over Σ ={a, b} of words starting with
a and ending in b OR starting with b and ending in a, then its regular
expression may be a(a+b)*b+b(a+b)*a
EXAMPLES
• The Language EVEN-EVEN: Language of strings, defined over Σ={a, b}
having even number of a’s and even number of b’s. i.e. EVEN-EVEN =
{Λ, aa, bb, aaaa,aabb,abab, abba, baab, baba, bbaa, bbbb,…}, its
regular expression can be written as
(aa+bb+(ab+ba)(aa+bb)*(ab+ba))*
• Note: It is important to be clear about the difference of the following
regular expressions
• r1 = a*+b*
• r2 = (a+b)*
Here r1 does not generate any string of concatenation of a and b,
while r2 generates such strings.
EQUIVALENT REGULAR EXPRESSIONS
Two regular expressions are said to be equivalent if they generate the
same language.
• Example
Consider the following regular expressions
• r1 = (a + b)* (aa + bb)
• r2 = (a + b)*aa + ( a + b)*bb then both regular expressions define
the language of strings ending in aa or bb.
Note: If r1 = (aa + bb) and r2 = ( a + b) then
r1+r2 = (aa + bb) + (a + b) , r1r2 = (aa + bb) (a + b)
= (aaa + aab + bba + bbb)
REGULAR LANGUAGES
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 r1+ r2,
r1r2( or r2r1) and r1*( or r2*) are also regular languages.
• Note: It is to be noted that if L1 and L2 are expressed by r1and r2,
respectively then the language expressed by
• r1+ r2, is the language L1 + L2 or L1 ∪ L2
• r1r2, , is the language L1L2, of strings obtained by prefixing every
string of L1 with every string of L2
• r1*, is the language L1*, of strings obtained by concatenating the
EXAMPLES
• If r1 = (aa+bb) and r2 = (a+b) then the language of strings
generated by r1+r2, is also a regular language, expressed by
(aa+bb) + (a+b)
• If r1 = (aa+bb) and r2 = (a+b) then the language of strings
generated by r1r2, is also a regular language, expressed by
(aa+bb)(a+b)
• If r = (aa+bb) then the language of strings generated by r*, is
also a regular language, expressed by (aa+bb)*
ALL FINITE LANGUAGES ARE REGULAR
• Example
• Consider the language L, defined over Σ = {a,b}, of strings of length
2, starting with a, then L = {aa, ab}, may be expressed by the regular
expression aa+ab. Hence L, by definition, is a regular language.
• Note: It may be noted that if a language contains even thousand
words, its RE may be expressed, placing ‘ + ’ between all the words.
• Here the special structure of RE is not important.
• Consider the language L = {aaa, aab, aba, abb, baa, bab, bba, bbb},
that may be expressed by a RE
aaa+aab+aba+abb+baa+bab+bba+bbb, which is equivalent to
(a+b)(a+b)(a+b).

More Related Content

What's hot (20)

Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Language
LanguageLanguage
Language
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lesson 04
Lesson 04Lesson 04
Lesson 04
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
Introduction to Computer theory (Automata Theory) 2nd Edition By Denial I.A. ...
 
Lesson 02
Lesson 02Lesson 02
Lesson 02
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
 
Regular Expression Examples.pptx
Regular Expression Examples.pptxRegular Expression Examples.pptx
Regular Expression Examples.pptx
 
Lesson 05
Lesson 05Lesson 05
Lesson 05
 
Lesson 03
Lesson 03Lesson 03
Lesson 03
 
Regular language and Regular expression
Regular language and Regular expressionRegular language and Regular expression
Regular language and Regular expression
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Flat unit 1
Flat unit 1Flat unit 1
Flat unit 1
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Context free grammars
Context free grammarsContext free grammars
Context free grammars
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
Flat unit 3
Flat unit 3Flat unit 3
Flat unit 3
 

Similar to Theory of Automata and Formal Languages (Kleene Star, Regular Expressions

Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdfkenilpatel65
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 028threspecter
 
01-Introduction&Languages.pdf
01-Introduction&Languages.pdf01-Introduction&Languages.pdf
01-Introduction&Languages.pdfTariqSaeed80
 
Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........NaumanAli215439
 
Theory of Automata Lesson 01
 Theory of Automata Lesson 01  Theory of Automata Lesson 01
Theory of Automata Lesson 01 hamzamughal39
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1Rajendran
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.pptRatnakar Mikkili
 
theory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq pointstheory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq pointsbushraphd2022
 
Lesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptLesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptashja1
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
Final formal languages
Final formal languagesFinal formal languages
Final formal languagesMegha Khanna
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptxmainakmail2585
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfDrIsikoIsaac
 
Handout Regular expression with examples and lecture
Handout Regular expression with examples  and lecture Handout Regular expression with examples  and lecture
Handout Regular expression with examples and lecture mariajan8
 

Similar to Theory of Automata and Formal Languages (Kleene Star, Regular Expressions (20)

L_2_apl.pptx
L_2_apl.pptxL_2_apl.pptx
L_2_apl.pptx
 
Syntax Analyzer.pdf
Syntax Analyzer.pdfSyntax Analyzer.pdf
Syntax Analyzer.pdf
 
theory of computation lecture 02
theory of computation lecture 02theory of computation lecture 02
theory of computation lecture 02
 
Specification-of-tokens
Specification-of-tokensSpecification-of-tokens
Specification-of-tokens
 
01-Introduction&Languages.pdf
01-Introduction&Languages.pdf01-Introduction&Languages.pdf
01-Introduction&Languages.pdf
 
Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........Theory of Automata ___ Basis ...........
Theory of Automata ___ Basis ...........
 
Theory of Automata Lesson 01
 Theory of Automata Lesson 01  Theory of Automata Lesson 01
Theory of Automata Lesson 01
 
Regular expressions h1
Regular expressions h1Regular expressions h1
Regular expressions h1
 
2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt2_2Specification of Tokens.ppt
2_2Specification of Tokens.ppt
 
Module 1 TOC.pptx
Module 1 TOC.pptxModule 1 TOC.pptx
Module 1 TOC.pptx
 
theory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq pointstheory of computation notes. introduction and mcq points
theory of computation notes. introduction and mcq points
 
Lesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.pptLesson-01-29092022-081117pm.ppt
Lesson-01-29092022-081117pm.ppt
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Lex analysis
Lex analysisLex analysis
Lex analysis
 
Final formal languages
Final formal languagesFinal formal languages
Final formal languages
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 
9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx9781284077247_PPTx_CH01.pptx
9781284077247_PPTx_CH01.pptx
 
To lec 03
To lec 03To lec 03
To lec 03
 
Chapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdfChapter2CDpdf__2021_11_26_09_19_08.pdf
Chapter2CDpdf__2021_11_26_09_19_08.pdf
 
Handout Regular expression with examples and lecture
Handout Regular expression with examples  and lecture Handout Regular expression with examples  and lecture
Handout Regular expression with examples and lecture
 

Recently uploaded

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Recently uploaded (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

Theory of Automata and Formal Languages (Kleene Star, Regular Expressions

  • 1. THEORY OF AUTOMATA AND FORMAL LANGUAGE KLEENE STAR CLOSURE, PLUS OPERATION, RECURSIVE DEFINITION OF LANGUAGES, INTEGER, EVEN, FACTORIAL, PALINDROME, LANGUAGES OF STRINGS, CURSIVE DEFINITION OF RE, DEFINING LANGUAGES BY RE,EXAMPLES
  • 2. KLEENE STAR CLOSURE • Given Σ, then the Kleene Star Closure of the alphabet Σ, denoted by Σ*, is the collection of all strings defined over Σ, including Λ. It is to be noted that Kleene Star Closure can be defined over any set of strings. • Examples 1) If Σ = {x} Then Σ* = {Λ, x, xx, xxx, xxxx, ….} 2) If Σ = {0,1} Then Σ* = {Λ, 0, 1, 00, 01, 10, 11, ….} 3) If Σ = {aaB, c} Then Σ* = {Λ, aaB, c, aaBaaB, aaBc, caaB, cc, ….} • Note: Languages generated by Kleene Star Closure of set of strings, are infinite languages. (By infinite language, it is supposed that the language contains infinite many words, each of finite length).
  • 3. PLUS OPERATION (+) Plus Operation is same as Kleene Star Closure except that it does not generate Λ (null string), automatically. • Example 1) If Σ = {0,1} Then Σ+ = {0, 1, 00, 01, 10, 11, ….} 2) If Σ = {aab, c} Then Σ+ = {aab, c, aabaab, aabc, caab, cc, ….} • Remark: It is to be noted that Kleene Star can also be operated on any string i.e. a* can be considered to be all possible strings defined over {a}, which shows that a* generates Λ, a, aa, aaa, …It may also be noted that a+ can be considered to be all possible non empty strings defined over {a}, which shows that a+ generates a, aa, aaa, aaaa, …
  • 4. RECURSIVE DEFINITION OF LANGUAGES • The following three steps are used in recursive definition 1) Some basic words are specified in the language. 2) Rules for constructing more words are defined in the language. 3) No strings except those constructed in above, are allowed to be in the language.
  • 5. EXAMPLES • Defining language of INTEGER • Step 1: 1 is in INTEGER. • Step 2: If x is in INTEGER then x+1 and x-1 are also in INTEGER. • Step 3: No strings except those constructed in above, are allowed to be in INTEGER. • Defining language of EVEN • Step 1: 2 is in EVEN. • Step 2: If x is in EVEN then x+2 and x-2 are also in EVEN. • Step 3: No strings except those constructed in above, are allowed to
  • 6. EXAMPLES • Defining the language PALINDROME, defined over Σ = {a,b} • Step 1: a and b are in PALINDROME • Step 2: if x is palindrome, then s(x)Rev(s) and xx will also be palindrome, where s belongs to Σ* • Step 3: No strings except those constructed in above, are allowed to be in palindrome • Defining the language {anbn }, n=1,2,3,… , of strings defined over Σ={a,b} • Step 1: ab is in {anbn} • Step 2: if x is in {anbn}, then axb is in {anbn} • Step 3: No strings except those constructed in above, are allowed to
  • 7. EXAMPLES • Defining the language L, of strings ending in a , defined over Σ={a,b} • Step 1: a is in L • Step 2: if x is in L then s(x) is also in L, where s belongs to Σ* • Step 3: No strings except those constructed in above, are allowed to be in L • Defining the language L, of strings beginning and ending in same letters , defined over Σ={a, b} • Step 1: a and b are in L • Step 2: (a)s(a) and (b)s(b) are also in L, where s belongs to Σ* • Step 3: No strings except those constructed in above, are allowed to
  • 8. EXAMPLES • Defining the language L, of strings containing aa or bb , defined over Σ={a, b} • Step 1: aa and bb are in L • Step 2: s(aa)s and s(bb)s are also in L, where s belongs to Σ* • Step 3: No strings except those constructed in above, are allowed to be in L • Defining the language L, of strings containing exactly one a, defined over Σ={a, b} • Step 1: a is in L • Step 2: s(a)s is also in L, where s belongs to b*
  • 9. REGULAR EXPRESSION • As discussed earlier that a* generates Λ, a, aa, aaa, … and a+ generates a, aa, aaa, aaaa, …, so the language L1= {Λ, a, aa, aaa, …} and L2 = {a, aa, aaa, aaaa, …} can simply be expressed by a* and a+, respectively. a* and a+ are called the regular expressions (RE) for L1 and L2 respectively. • Note :a+, aa* and a*a generate L2. • Recursive definition of Regular Expression(RE) Step 1: Every letter of Σ including Λ is a regular expression. Step 2: If r1 and r2 are regular expressions then • (r1) • r1 r2 • r1 + r2 and • r1*are also regular expressions. Step 3: Nothing else is a regular expression.
  • 10. REGULAR EXPRESSIONS • Consider the language L={Λ, x, xx, xxx,…} of strings, defined over Σ = {x}. We can write this language as the Kleene star closure of alphabet Σ or L=Σ*={x}* .This language can also be expressed by the regular expression x* • Similarly the language L={x, xx, xxx,…}, defined over Σ = {x}, can be expressed by the regular expression x+.Now consider another language L, consisting of all possible strings, defined over Σ = {a, b}. This language can also be expressed by the regular expression (a + b)*. • Now consider another language L, of strings having exactly one
  • 11. EXAMPLES • Now consider another language L, of even length, defined over Σ = {a, b}, then it’s regular expression may be ((a+b)(a+b))*. • Now consider another language L, of odd length, defined over Σ = {a, b}, then it’s regular expression may be (a+b)((a+b)(a+b))* or ((a+b)(a+b))*(a+b). • Remark It may be noted that a language may be expressed by more than one regular expression, while given a regular expression there exist a unique language generated by that regular expression.
  • 12. EXAMPLES • Consider the language, defined over Σ = {a , b} of words having at least one a, may be expressed by a regular expression (a+b)*a(a+b)*. • Consider the language, defined over Σ = {a, b} of words having at least one a and one b, may be expressed by a regular expression (a+b)*a(a+b)*b(a+b)*+ (a+b)*b(a+b)*a(a+b)*. • Consider the language, defined over Σ ={a, b}, of words starting with double a and ending in double b then its regular expression may be aa(a+b)*bb • Consider the language, defined over Σ ={a, b} of words starting with a and ending in b OR starting with b and ending in a, then its regular expression may be a(a+b)*b+b(a+b)*a
  • 13. EXAMPLES • The Language EVEN-EVEN: Language of strings, defined over Σ={a, b} having even number of a’s and even number of b’s. i.e. EVEN-EVEN = {Λ, aa, bb, aaaa,aabb,abab, abba, baab, baba, bbaa, bbbb,…}, its regular expression can be written as (aa+bb+(ab+ba)(aa+bb)*(ab+ba))* • Note: It is important to be clear about the difference of the following regular expressions • r1 = a*+b* • r2 = (a+b)* Here r1 does not generate any string of concatenation of a and b, while r2 generates such strings.
  • 14. EQUIVALENT REGULAR EXPRESSIONS Two regular expressions are said to be equivalent if they generate the same language. • Example Consider the following regular expressions • r1 = (a + b)* (aa + bb) • r2 = (a + b)*aa + ( a + b)*bb then both regular expressions define the language of strings ending in aa or bb. Note: If r1 = (aa + bb) and r2 = ( a + b) then r1+r2 = (aa + bb) + (a + b) , r1r2 = (aa + bb) (a + b) = (aaa + aab + bba + bbb)
  • 15. REGULAR LANGUAGES 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 r1+ r2, r1r2( or r2r1) and r1*( or r2*) are also regular languages. • Note: It is to be noted that if L1 and L2 are expressed by r1and r2, respectively then the language expressed by • r1+ r2, is the language L1 + L2 or L1 ∪ L2 • r1r2, , is the language L1L2, of strings obtained by prefixing every string of L1 with every string of L2 • r1*, is the language L1*, of strings obtained by concatenating the
  • 16. EXAMPLES • If r1 = (aa+bb) and r2 = (a+b) then the language of strings generated by r1+r2, is also a regular language, expressed by (aa+bb) + (a+b) • If r1 = (aa+bb) and r2 = (a+b) then the language of strings generated by r1r2, is also a regular language, expressed by (aa+bb)(a+b) • If r = (aa+bb) then the language of strings generated by r*, is also a regular language, expressed by (aa+bb)*
  • 17. ALL FINITE LANGUAGES ARE REGULAR • Example • Consider the language L, defined over Σ = {a,b}, of strings of length 2, starting with a, then L = {aa, ab}, may be expressed by the regular expression aa+ab. Hence L, by definition, is a regular language. • Note: It may be noted that if a language contains even thousand words, its RE may be expressed, placing ‘ + ’ between all the words. • Here the special structure of RE is not important. • Consider the language L = {aaa, aab, aba, abb, baa, bab, bba, bbb}, that may be expressed by a RE aaa+aab+aba+abb+baa+bab+bba+bbb, which is equivalent to (a+b)(a+b)(a+b).