Thoery of Automata CS402

Size: px
Start display at page:

Download "Thoery of Automata CS402"

Transcription

1 Thoery of Automt C402

2 Theory of Automt Tle of contents: Lecture N ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N ummry... 9 Kleene tr Closure... 9 Recursive definition of lnguges... 9 Lecture N ummry Regulr Expression Recursive definition of Regulr Expression(RE) Method 3 (Regulr Expressions) Lecture N Equivlent Regulr Expressions Method 4 (Finite Automton) Lecture N Lecture N Equivlent FAs Lecture N FA corresponding to finite lnguges Method 5 (Trnsition Grph) Lecture N Exmples of TGs: ccepting ll strings, ccepting none, strting with, not ending in, contining, contining or Lecture N Generlized Trnsition Grphs Lecture N Nondeterminism Kleene s Theorem Lecture N Proof(Kleene s Theorem Prt II) Lecture N Kleene s Theorem Prt III Lecture N Lecture N Lecture N Nondeterministic Finite Automton (NFA) Converting n FA to n equivlent NFA Lecture N NFA with Null tring Lecture N NFA nd Kleene s Theorem Lecture N NFA corresponding to Conctention of FAs NFA corresponding to the Closure of n FA Lecture N Memory required to recognize lnguge Distinguishle strings nd Indistinguishle strings Lecture N Finite Automton with output Moore mchine Lecture N Mely mchine Lecture N Copyright Virtul University of Pkistn

3 Theory of Automt Equivlent mchines Lecture N Lecture N Regulr lnguges Complement of lnguge Lecture N Nonregulr lnguges Lecture N Pumping Lemm Lecture N Pumping Lemm version II Lecture N Pseudo theorem Lecture N Decidility Determining whether the two lnguges re equivlent or not? Lecture N Lecture N Context Free Grmmr (CFG) CFG terminologies Lecture N Trees Lecture N Polish Nottion (o-o-o) Lecture N Totl lnguge tree Regulr Grmmr Lecture N Null Production Lecture N Chomsky Norml Form (CNF) Lecture N A new formt for FAs Lecture N Nondeterministic PDA Lecture N PDA corresponding to CFG Lecture N Conversion form of PDA Lecture N Lecture N Lecture N Non-Context-Free lnguge Pumping lemm for CFLs Lecture N Decidlity Prsing Techniques Lecture N Turing mchine Copyright Virtul University of Pkistn 3

4 Theory of Automt Theory of Automt Lecture N0. 1 Reding Mteril Introduction to Computer Theory Chpter 2 ummry Introduction to the course title, Forml nd In-forml lnguges, Alphets, trings, Null string, Words, Vlid nd In-vlid lphets, length of string, Reverse of string, Defining lnguges, Descriptive definition of lnguges, EQUAL, EVEN-EVEN, INTEGER, EVEN, { n n }, { n n n }, fctoril, FACTORIAL, DOUBLEFACTORIAL, QUARE, DOUBLEQUARE, PRIME, PALINDROME. Wht does utomt men? It is the plurl of utomton, nd it mens something tht works utomticlly Introduction to lnguges There re two types of lnguges Forml Lnguges (yntctic lnguges) Informl Lnguges (emntic lnguges) Alphets Definition A finite non-empty set of symols (clled letters), is clled n lphet. It is denoted y Σ ( Greek letter sigm). Exmple Σ = {,} Σ = {0,1} (importnt s this is the lnguge which the computer understnds.) Σ = {i,j,k} Note Certin version of lnguge ALGOL hs 113 letters. Σ (lphet) includes letters, digits nd vriety of opertors including sequentil opertors such s GOTO nd IF trings Definition Conctention of finite numer of letters from the lphet is clled string. Exmple If Σ = {,} then,,, Note Empty string or null string ometimes string with no symol t ll is used, denoted y (mll Greek letter Lmd) λ or (Cpitl Greek letter Lmd) Λ, is clled n empty string or null string. The cpitl lmd will mostly e used to denote the empty string, in further discussion. Words Definition Words re strings elonging to some lnguge. Exmple If Σ= {x} then lnguge L cn e defined s L={x n : n=1,2,3,..} or L={x,xx,xxx,.} Here x,xx, re the words of L Note All words re strings, ut not ll strings re words. Copyright Virtul University of Pkistn 4

5 Theory of Automt Vlid/In-vlid lphets While defining n lphet, n lphet my contin letters consisting of group of symols for exmple Σ 1 = {B, B,, d}. Now consider n lphet Σ 2 = {B, B,, d} nd string BB. This string cn e tokenized in two different wys (B), (), (B) (B), (), (B) Which shows tht the second group cnnot e identified s string, defined over Σ = {, }. As when this string is scnned y the compiler (Lexicl Anlyzer), first symol B is identified s letter elonging to Σ, while for the second letter the lexicl nlyzer would not e le to identify, so while defining n lphet it should e kept in mind tht miguity should not e creted. Remrks While defining n lphet of letters consisting of more thn one symols, no letter should e strted with the letter of the sme lphet i.e. one letter should not e the prefix of nother. However, letter my e ended in letter of sme lphet. Conclusion Σ 1 = {B, B,, d} Σ 2 = {B, B,, d} Σ 1 is vlid lphet while Σ 2 is n in-vlid lphet. Length of trings Definition The length of string s, denoted y s, is the numer of letters in the string. Exmple Σ={,} s= s =5 Exmple Σ= {B, B,, d} s=bbbd Tokenizing=(B), (B), (), (B), (d) s =5 Reverse of tring Definition The reverse of string s denoted y Rev(s) or s r, is otined y writing the letters of s in reverse order. Exmple If s=c is string defined over Σ={,,c} then Rev(s) or s r = c Exmple Σ= {B, B,, d} s=bbbd Rev(s)=dBBB Defining Lnguges The lnguges cn e defined in different wys, such s Descriptive definition, Recursive definition, using Regulr Expressions(RE) nd using Finite Automton(FA) etc. Descriptive definition of lnguge The lnguge is defined, descriing the conditions imposed on its words. Copyright Virtul University of Pkistn 5

6 Theory of Automt Exmple The lnguge L of strings of odd length, defined over Σ={}, cn e written s L={,,,..} Exmple The lnguge L of strings tht does not strt with, defined over Σ ={,,c}, cn e written s L ={L,, c,,, c, c, c, cc, } Exmple The lnguge L of strings of length 2, defined over Σ ={0,1,2}, cn e written s L={00, 01, 02,10, 11,12,20,21,22} Exmple The lnguge L of strings ending in 0, defined over Σ ={0,1}, cn e written s L={0,00,10,000,010,100,110, } Exmple The lnguge EQUAL, of strings with numer of s equl to numer of s, defined over Σ={,}, cn e written s {Λ,,,,,, } Exmple The lnguge EVEN-EVEN, of strings with even numer of s nd even numer of s, defined over Σ={,}, cn e written s {Λ,,,,,,,,,,, } Exmple The lnguge INTEGER, of strings defined over Σ={-,0,1,2,3,4,5,6,7,8,9}, cn e written s INTEGER = {,-2,-1,0,1,2, } Exmple The lnguge EVEN, of stings defined over Σ={-,0,1,2,3,4,5,6,7,8,9}, cn e written s EVEN = {,-4,-2,0,2,4, } Exmple The lnguge { n n }, of strings defined over Σ={,}, s { n n : n=1,2,3, }, cn e written s {,,,, } Exmple The lnguge { n n n }, of strings defined over Σ={,}, s { n n n : n=1,2,3, }, cn e written s {,,,, } Exmple The lnguge fctoril, of strings defined over Σ={0,1,2,3,4,5,6,7,8,9} i.e. {1,2,6,24,120, } Exmple The lnguge FACTORIAL, of strings defined over Σ={}, s { n! : n=1,2,3, }, cn e written s {,,, }. It is to e noted tht the lnguge FACTORIAL cn e defined over ny single letter lphet. Exmple The lnguge DOUBLEFACTORIAL, of strings defined over Σ={, }, s { n! n! : n=1,2,3, }, cn e written s {,,, } Exmple The lnguge QUARE, of strings defined over Σ={}, s Copyright Virtul University of Pkistn 6

7 Theory of Automt { n 2 : n=1,2,3, }, cn e written s {,,, } Exmple The lnguge DOUBLEQUARE, of strings defined over Σ={,}, s { n 2 n 2 : n=1,2,3, }, cn e written s {,,, } Exmple The lnguge PRIME, of strings defined over Σ={}, s { p : p is prime}, cn e written s {,,,, } An Importnt lnguge PALINDROME The lnguge consisting of Λ nd the strings s defined over Σ such tht Rev(s)=s. It is to e denoted tht the words of PALINDROME re clled plindromes. Exmple For Σ={,}, PALINDROME={Λ,,,,,,,,,...} Remrk There re s mny plindromes of length 2n s there re of length 2n-1. To prove the ove remrk, the following is to e noted: Note Numer of strings of length m defined over lphet of n letters is n m. Exmples The lnguge of strings of length 2, defined over Σ={,} is L={,,, } i.e. numer of strings = 2 2 The lnguge of strings of length 3, defined over Σ={,} is L={,,,,,,, } i.e. numer of strings = 2 3 To clculte the numer of plindromes of length(2n), consider the following digrm, which shows tht there re s mny plindromes of length 2n s there re the strings of length n i.e. the required numer of plindromes re 2 n. To clculte the numer of plindromes of length (2n-1) with s the middle letter, consider the following digrm, which shows tht there re s mny plindromes of length 2n-1 s there re the strings of length n-1 i.e. the required numer of plindromes re 2 n-1. Copyright Virtul University of Pkistn 7

8 Theory of Automt imilrly the numer of plindromes of length 2n-1, with s middle letter, will e 2 n-1 s well. Hence the totl numer of plindromes of length 2n-1 will e 2 n n-1 = 2 (2 n-1 )= 2 n. Copyright Virtul University of Pkistn 8

9 Theory of Automt Theory of Automt Lecture N0. 2 Reding Mteril Introduction to Computer Theory Chpter 3 ummry Kleene tr Closure, Plus opertion, recursive definition of lnguges, INTEGER, EVEN, fctoril, PALINDROME, { n n }, lnguges of strings (i) ending in, (ii) eginning nd ending in sme letters, (iii) contining or (iv) contining exctly one Kleene tr Closure Given Σ, then the Kleene tr Closure of the lphet Σ, denoted y Σ *, is the collection of ll strings defined over Σ, including Λ. It is to e noted tht Kleene tr Closure cn e defined over ny set of strings. Exmples If Σ = {x} Then Σ * = {Λ, x, xx, xxx, xxxx,.} If Σ = {0,1} Then Σ * = {Λ, 0, 1, 00, 01, 10, 11,.} If Σ = {B, c} Then Σ * = {Λ, B, c, BB, Bc, cb, cc,.} Note Lnguges generted y Kleene tr Closure of set of strings, re infinite lnguges. (By infinite lnguge, it is supposed tht the lnguge contins infinite mny words, ech of finite length). PLU Opertion ( + ) Plus Opertion is sme s Kleene tr Closure except tht it does not generte Λ (null string), utomticlly. Exmple If Σ = {0,1} Then Σ + = {0, 1, 00, 01, 10, 11,.} If Σ = {, c} Then Σ + = {, c,, c, c, cc,.} Remrk It is to e noted tht Kleene tr cn lso e operted on ny string i.e. * cn e considered to e ll possile strings defined over {}, which shows tht * genertes Λ,,,, It my lso e noted tht + cn e considered to e ll possile non empty strings defined over {}, which shows tht + genertes,,,, Recursive definition of lnguges The following three steps re used in recursive definition ome sic words re specified in the lnguge. Rules for constructing more words re defined in the lnguge. No strings except those constructed in ove, re llowed to e in the lnguge. Exmple Defining lnguge of INTEGER tep 1: 1 is in INTEGER. tep 2: If x is in INTEGER then x+1 nd x-1 re lso in INTEGER. tep 3: No strings except those constructed in ove, re llowed to e in INTEGER. Exmple Copyright Virtul University of Pkistn 9

10 Theory of Automt Defining lnguge of EVEN tep 1: 2 is in EVEN. tep 2: If x is in EVEN then x+2 nd x-2 re lso in EVEN. tep 3: No strings except those constructed in ove, re llowed to e in EVEN. Exmple Defining the lnguge fctoril tep 1: As 0!=1, so 1 is in fctoril. tep 2: n!=n*(n-1)! is in fctoril. tep 3: No strings except those constructed in ove, re llowed to e in fctoril. Defining the lnguge PALINDROME, defined over Σ = {,} tep 1: nd re in PALINDROME tep 2: if x is plindrome, then s(x)rev(s) nd xx will lso e plindrome, where s elongs to Σ * tep 3: No strings except those constructed in ove, re llowed to e in plindrome Defining the lnguge { n n }, n=1,2,3,, of strings defined over Σ={,} tep 1: is in { n n } tep 2: if x is in { n n }, then x is in { n n } tep 3: No strings except those constructed in ove, re llowed to e in { n n } Defining the lnguge L, of strings ending in, defined over Σ={,} tep 1: is in L tep 2: if x is in L then s(x) is lso in L, where s elongs to Σ * tep 3: No strings except those constructed in ove, re llowed to e in L Defining the lnguge L, of strings eginning nd ending in sme letters, defined over Σ={, } tep 1: nd re in L tep 2: ()s() nd ()s() re lso in L, where s elongs to Σ * tep 3: No strings except those constructed in ove, re llowed to e in L Defining the lnguge L, of strings contining or, defined over Σ={, } tep 1: nd re in L tep 2: s()s nd s()s re lso in L, where s elongs to Σ * tep 3: No strings except those constructed in ove, re llowed to e in L Defining the lnguge L, of strings contining exctly one, defined over Σ={, } tep 1: is in L tep 2: s()s is lso in L, where s elongs to * tep 3: No strings except those constructed in ove, re llowed to e in L Copyright Virtul University of Pkistn 10

11 Theory of Automt Theory of Automt Lecture N0. 3 Reding Mteril Introduction to Computer Theory Chpter 4 ummry RE, Recursive definition of RE, defining lnguges y RE, { x}*, { x}+, {+}*, Lnguge of strings hving exctly one, Lnguge of strings of even length, Lnguge of strings of odd length, RE defines unique lnguge (s Remrk), Lnguge of strings hving t lest one, Lnguge of strings hving t lest one nd one, Lnguge of strings strting with nd ending in, Lnguge of strings strting with nd ending in different letters. Regulr Expression As discussed erlier tht * genertes Λ,,,, nd + genertes,,,,, so the lnguge L 1 = {Λ,,,, } nd L 2 = {,,,, } cn simply e expressed y * nd +, respectively. * nd + re clled the regulr expressions (RE) for L 1 nd L 2 respectively. Note +, * nd * generte L 2. Recursive definition of Regulr Expression(RE) tep 1: Every letter of Σ including Λ is regulr expression. tep 2: If r 1 nd r 2 re regulr expressions then (r 1 ) r 1 r 2 r 1 + r 2 nd r 1 * re lso regulr expressions. tep 3: Nothing else is regulr expression. Method 3 (Regulr Expressions) Consider the lnguge L={Λ, x, xx, xxx, } of strings, defined over Σ = {x}. We cn write this lnguge s the Kleene str closure of lphet Σ or L=Σ * ={x} *. This lnguge cn lso e expressed y the regulr expression x *. imilrly the lnguge L={x, xx, xxx, }, defined over Σ = {x}, cn e expressed y the regulr expression x +. Now consider nother lnguge L, consisting of ll possile strings, defined over Σ = {, }. This lnguge cn lso e expressed y the regulr expression ( + )*. Now consider nother lnguge L, of strings hving exctly one, defined over Σ = {, }, then it s regulr expression my e **. Now consider nother lnguge L, of even length, defined over Σ = {, }, then it s regulr expression my e ((+)(+))*. Now consider nother lnguge L, of odd length, defined over Σ = {, }, then it s regulr expression my e (+)((+)(+))* or ((+)(+))*(+). Remrk It my e noted tht lnguge my e expressed y more thn one regulr expression, while given regulr expression there exist unique lnguge generted y tht regulr expression. Exmple Consider the lnguge, defined over Σ = {, } of words hving t lest one, my e expressed y regulr expression (+)*(+)*. Consider the lnguge, defined over Σ = {, } of words hving t lest one nd one, my e expressed y regulr expression (+)*(+)*(+)*+ (+)*(+)*(+)*. Consider the lnguge, defined over Σ ={, }, of words strting with doule nd ending in doule then its regulr expression my e (+)* Consider the lnguge, defined over Σ ={, } of words strting with nd ending in OR strting with nd ending in, then its regulr expression my e (+)*+(+)* Copyright Virtul University of Pkistn 11

12 Theory of Automt Theory of Automt Lecture N0. 4 Reding Mteril Introduction to Computer Theory Chpter 4, 5 ummry Regulr expression of EVEN-EVEN lnguge, Difference etween * + * nd (+)*, Equivlent regulr expressions; sum, product nd closure of regulr expressions; regulr lnguges, finite lnguges re regulr, introduction to finite utomton, definition of FA, trnsition tle, trnsition digrm An importnt exmple The Lnguge EVEN-EVEN Lnguge of strings, defined over Σ={, } hving even numer of s nd even numer of s. i.e. EVEN-EVEN = {Λ,,,,,,,,,,, }, its regulr expression cn e written s (++(+)(+)*(+))* Note It is importnt to e cler out the difference of the following regulr expressions r 1 = *+* r 2 = (+)* Here r 1 does not generte ny string of conctention of nd, while r 2 genertes such strings. Equivlent Regulr Expressions Definition Two regulr expressions re sid to e equivlent if they generte the sme lnguge. Exmple Consider the following regulr expressions r 1 = ( + )* ( + ) r 2 = ( + )* + ( + )* then oth regulr expressions define the lnguge of strings ending in or. Note If r 1 = ( + ) nd r 2 = ( + ) then r 1 +r 2 = ( + ) + ( + ) r 1 r 2 = ( + ) ( + ) = ( ) (r 1 )* = ( + )* Regulr Lnguges Definition The lnguge generted y ny regulr expression is clled regulr lnguge. It is to e noted tht if r 1, r 2 re regulr expressions, corresponding to the lnguges L 1 nd L 2 then the lnguges generted y r 1 + r 2, r 1 r 2 ( or r 2 r 1 ) nd r 1 *( or r 2 *) re lso regulr lnguges. Note It is to e noted tht if L 1 nd L 2 re expressed y r 1 nd r 2, respectively then the lnguge expressed y r 1 + r 2, is the lnguge L 1 + L 2 or L 1 «L 2 r 1 r 2,, is the lnguge L 1 L 2, of strings otined y prefixing every string of L 1 with every string of L 2 r 1 *, is the lnguge L 1 *, of strings otined y conctenting the strings of L, including the null string. Exmple If r 1 = (+) nd r 2 = (+) then the lnguge of strings generted y r 1 +r 2, is lso regulr lnguge, expressed y (+) + (+) If r 1 = (+) nd r 2 = (+) then the lnguge of strings generted y r 1 r 2, is lso regulr lnguge, expressed y (+)(+) If r = (+) then the lnguge of strings generted y r*, is lso regulr lnguge, expressed y (+)* Copyright Virtul University of Pkistn 12

13 Theory of Automt All finite lnguges re regulr Exmple Consider the lnguge L, defined over Σ = {,}, of strings of length 2, strting with, then L = {, }, my e expressed y the regulr expression +. Hence L, y definition, is regulr lnguge. Note It my e noted tht if lnguge contins even thousnd words, its RE my e expressed, plcing + etween ll the words. Here the specil structure of RE is not importnt. Consider the lnguge L = {,,,,,,, }, tht my e expressed y RE , which is equivlent to (+)(+)(+). Introduction to Finite Automton Consider the following gme ord tht contins 64 oxes There re some pieces of pper. ome re of white colour while others re of lck colour. The numer of pieces of pper re 64 or less. The possile rrngements under which these pieces of pper cn e plced in the oxes, re finite. To strt the gme, one of the rrngements is supposed to e initil rrngement. There is pir of dice tht cn generte the numers 2,3,4, 12. For ech numer generted, unique rrngement is ssocited mong the possile rrngements. It shows tht the totl numer of trnsition rules of rrngement re finite. One nd more rrngements cn e supposed to e the winning rrngement. It cn e oserved tht the winning of the gme depends on the sequence in which the numers re generted. This structure of gme cn e considered to e finite utomton. Method 4 (Finite Automton) Definition A Finite utomton (FA), is collection of the followings Finite numer of sttes, hving one initil nd some (mye none) finl sttes. Finite set of input letters (Σ) from which input strings re formed. Finite set of trnsitions i.e. for ech stte nd for ech input letter there is trnsition showing how to move from one stte to nother. Exmple Σ = {,} ttes: x, y, z where x is n initil stte nd z is finl stte. Trnsitions: At stte x reding, go to stte z At stte x reding, go to stte y At stte y reding, go to stte y At stte z reding, go to stte z These trnsitions cn e expressed y the following tle clled trnsition tle Copyright Virtul University of Pkistn 13

14 Theory of Automt Old ttes x - y z + Reding z y z New ttes Reding y y z Note It my e noted tht the informtion of n FA, given in the previous tle, cn lso e depicted y the following digrm, clled the trnsition digrm, of the given FA, x Z+ Remrk The ove trnsition digrm is n FA ccepting the lnguge of strings, defined over Σ = {, }, strting with. It my e noted tht this lnguge my e expressed y the regulr expression ( + )* y, Copyright Virtul University of Pkistn 14

15 Theory of Automt Theory of Automt Lecture N0. 5 Reding Mteril Introduction to Computer Theory Chpter 5 ummry Different nottions of trnsition digrms, lnguges of strings of even length, Odd length, strting with, ending in, eginning with, not eginning with, eginning nd ending in sme letters Note It my e noted tht to indicte the initil stte, n rrow hed cn lso e plced efore tht stte nd tht the finl stte with doule circle, s shown elow. It is lso to e noted tht while expressing n FA y its trnsition digrm, the lels of sttes re not necessry., Exmple Σ = {,} ttes: x, y, where x is oth initil nd finl stte. Trnsitions: At stte x reding or go to stte y. At stte y reding or go to stte x., These trnsitions cn e expressed y the following trnsition tle Old ttes Reding New ttes Reding x ± y y y x x It my e noted tht the ove trnsition tle my e depicted y the following trnsition digrm. x ±,, y The ove trnsition digrm is n FA ccepting the lnguge of strings, defined over Σ={, } of even length. It my e noted tht this lnguge my e expressed y the regulr expression ((+ ) ( + )) * Exmple: Consider the lnguge L of strings, defined over Σ={, }, strting with. The lnguge L my e expressed y RE ( + ) *, my e ccepted y the following FA, +, 1 Exmple Consider the lnguge L of strings, defined over Σ={, }, ending in. The lnguge L my e expressed y RE (+) *. Copyright Virtul University of Pkistn 15

16 Theory of Automt This lnguge my e ccepted y the FA shown side + There my e nother FA corresponding to the given lnguge, s shown side + Note It my e noted tht corresponding to given lnguge there my e more thn one FA ccepting tht lnguge, ut for given FA there is unique lnguge ccepted y tht FA. It is lso to e noted tht given the lnguges L 1 nd L 2,where L 1 = The lnguge of strings, defined over Σ ={, }, eginning with. L 2 = The lnguge of strings, defined over Σ ={, }, not eginning with The Λ does not elong to L 1 while it does elong to L 2. This fct my e depicted y the corresponding trnsition digrms of L 1 nd L 2. FA 1 Corresponding to L 1, +, The lnguge L 1 my e expressed y the regulr expression ( + ) * FA 2 Corresponding to L 2, ± +, The lnguge L 2 my e expressed y the regulr expression ( + ) * + Λ Exmple Consider the Lnguge L of trings of length two or more, defined over Σ = {, }, eginning with nd ending in sme letters. The lnguge L my e expressed y the following regulr expression ( + ) * + ( + ) * It is to e noted tht if the condition on the length of string is not imposed in the ove lnguge then the strings nd will then elong to the lnguge. This lnguge L my e ccepted y the FA s shown side + + Copyright Virtul University of Pkistn 16

17 Theory of Automt Theory of Automt Lecture N0. 6 Reding Mteril Introduction to Computer Theory Chpter 5 ummry Lnguge of strings eginning with nd ending in different letters, Accepting ll strings, ccepting nonempty strings, ccepting no string, contining doule s, hving doule 0 s or doule 1 s, contining triple s or triple s, EVEN-EVEN Exmple Consider the Lnguge L of trings, defined over Σ = {, }, eginning with nd ending in different letters. The lnguge L my e expressed y the following regulr expression ( + ) * + ( + ) * This lnguge my e ccepted y the following FA The lnguge L my lso e ccepted y the following FA, Exmple Consider the Lnguge L, defined over Σ = {, } of ll strings including Λ. The lnguge L my e ccepted y the following FA, The lnguge L my e expressed y the regulr expression ( + ) * ± Exmple Consider the Lnguge L, defined over Σ = {, } of ll non empty strings. The lnguge L my e ccepted y the following FA,, - + The ove lnguge my e expressed y the regulr expression ( + ) + 1±, Exmple Consider the following FA, defined over Σ = {, }, -, + It is to e noted tht the ove FA does not ccept ny string, even it does not ccept the null string; s there is no pth strting from initil stte nd ending in finl stte. Equivlent FAs It is to e noted tht two FAs re sid to e equivlent, if they ccept the sme lnguge, s shown in the following FAs. FA 1,, + Copyright Virtul University of Pkistn 17

18 Theory of Automt, FA 2 1-, 2 FA 3 Note 1-, 2 3+ FA 1 hs lredy een discussed, while in FA 2, there is no finl stte nd in FA 3, there is finl stte ut FA 3 is disconnected s the sttes 2 nd 3 re disconnected. It my lso e noted tht the lnguge of strings ccepted y FA 1, FA 2 nd FA 3 is denoted y the empty set i.e. { } OR Ø Exmple Consider the Lnguge L of strings, defined over Σ = {, }, contining doule. The lnguge L my e expressed y the regulr expression (+) * () (+) *. This lnguge my e ccepted y the following FA., Exmple Consider the lnguge L of strings, defined over Σ={0, 1}, hving doule 0 s or doule 1 s, The lnguge L my e expressed y the regulr expression (0+1) * ( ) (0+1) * This lnguge my e ccepted y the following FA x,, 0 0 0, y Copyright Virtul University of Pkistn 18

19 Theory of Automt Exmple Consider the lnguge L of strings, defined over Σ={, }, hving triple s or triple s. The lnguge L my e expressed y RE (+) * ( + ) (+) * 2 4 This lnguge my e ccepted y the FA s shown side, ± Exmple Consider the EVEN-EVEN lnguge, defined over Σ = {, }. As discussed erlier tht EVEN-EVEN lnguge cn e expressed y the regulr expression (++(+)(+) * (+)) * EVEN-EVEN lnguge my e ccepted y the FA s shown side Copyright Virtul University of Pkistn 19

20 Theory of Automt Theory of Automt Lecture N0. 7 Reding Mteril Introduction to Computer Theory Chpter 5, 6 ummry FA corresponding to finite lnguges(using oth methods), Trnsition grphs. FA corresponding to finite lnguges Exmple Consider the lnguge L = {Λ,,, }, defined over Σ ={, }, expressed y Λ OR Λ + (Λ + + ). The lnguge L my e ccepted y the FA s shown side, y, 1± It is to e noted tht the sttes x nd y re clled Ded ttes, Wste Bskets or Dvey John Lockers, s the moment one enters these sttes there is no wy to leve it., Note It is to e noted tht to uild n FA ccepting the lnguge hving less numer of strings, the tree structure my lso help in this regrd, which cn e oserved in the following trnsition digrm for the 4 Lnguge L, discussed in the ove exmple x, 1± ,,, 8, 2+ 7+,, x Exmple Consider the lnguge L = {,,, }, defined over Σ ={, }, expressed y OR (Λ + ) + ( + ) The ove lnguge my e ccepted y the FA s shown side , 11+, y, Copyright Virtul University of Pkistn, 5+ 20

21 Theory of Automt Exmple Consider the lnguge L = {w elongs to {,} * : length(w) 2 nd w neither ends in nor }. The lnguge L my e expressed y the regulr expression (+) * (+) This lnguge my e ccepted y the following FA Copyright Virtul University of Pkistn 21

22 Theory of Automt Note It is to e noted tht uilding n FA corresponding to the lnguge L, discussed in the ove exmple, seems to e quite difficult, ut the sme cn e done using tree structure long with the technique discussed in the ook Introduction to Lnguges nd Theory of Computtion, y J. C. Mrtin so tht the strings ending in,, nd should end in the sttes leled s,, nd, respectively; s shown in the following FA Λ Exmple Consider the lnguge FA corresponding to r 1 +r 2 cn e determined s L = {w elongs to {,} * : w does not end in }. The lnguge L my e expressed y the regulr expression Λ (+) * (++). This lnguge my e ccepted y the following FA Λ Method 5 (Trnsition Grph) Definition: A Trnsition grph (TG), is collection of the followings Finite numer of sttes, t lest one of which is strt stte nd some (mye none) finl sttes. Finite set of input letters (Σ) from which input strings re formed. Finite set of trnsitions tht show how to go from one stte to nother sed on reding specified sustrings of input letters, possily even the null string (Λ). Copyright Virtul University of Pkistn 22

23 Theory of Automt Theory of Automt Lecture N0. 8 Reding Mteril Introduction to Computer Theory Chpter 6 ummry Exmples of TGs: ccepting ll strings, ccepting none, strting with, not ending in, contining, contining or Note It is to e noted tht in TG there my exist more thn one pths for certin string, while there my not exist ny pth for certin string s well. If there exists t lest one pth for certin string, strting from initil stte nd ending in finl stte, the string is supposed to e ccepted y the TG, otherwise the string is supposed to e rejected. Oviously collection of ccepted strings is the lnguge ccepted y the TG. Exmple Consider the Lnguge L, defined over Σ = {, } of ll strings including Λ. The lnguge L my e ccepted y the following TG,, L + The lnguge L my lso e ccepted y the following TG, TG 1 ±, TG 2, ± + Exmple Consider the following TGs TG 1 TG 2 TG 3 -, - 1, - 1, It my e oserved tht in the first TG, no trnsition hs een shown. Hence this TG does not ccept ny string, defined over ny lphet. In TG 2 there re trnsitions for nd t initil stte ut there is no trnsition t stte 1. This TG still does not ccept ny string. In TG 3 there re trnsitions t oth initil stte nd stte 1, ut it does not ccept ny string. Thus none of TG 1, TG 2 nd TG 3 ccepts ny string, i.e. these TGs ccept empty lnguge. It my e noted tht TG 1 nd TG 2 re TGs ut not FA, while TG 3 is oth TG nd FA s well. It my e noted tht every FA is TG s well, ut the converse my not e true, i.e. every TG my not e n FA. Exmple Consider the lnguge L of strings, defined over Σ={, }, strting with. The lnguge L my e expressed y RE ( + ) *, my e ccepted y the following TG, æ + Copyright Virtul University of Pkistn 23

24 Theory of Automt Exmple Consider the lnguge L of strings, defined over Σ={, }, not ending in. The lnguge L my e expressed y RE Λ + ( + ) *, my e ccepted y the following TG, + Exmple Consider the Lnguge L of strings, defined over Σ = {, }, contining doule. The lnguge L my e expressed y the following regulr expression (+) * () (+) *. This lnguge my e ccepted y the following TG,, Exmple Consider the lnguge L of strings, defined over Σ={, }, hving doule or doule. The lnguge L cn e expressed y RE (+) * ( + ) (+) *. The ove lnguge my lso e expressed y the following TGs. Λ 1-2+ x +,, + y OR OR, -,, +,, 1-2+,, 3-4+ Note In the ove TG if the sttes re not leled then it my not e considered to e single TG Copyright Virtul University of Pkistn 24

25 Theory of Automt Theory of Automt Lecture N0. 9 Reding Mteril Introduction to Computer Theory Chpter 6 ummry TGs ccepting the lnguges: contining or, eginning nd ending in different letters, eginning nd ending in sme letters, EVEN-EVEN, s occur in even clumps nd ends in three or more s, exmple showing different pths trced y one string, Definition of GTG Exmple Consider the lnguge L of strings, defined over Σ = {, }, hving triple or triple. The lnguge L my e expressed y RE (+) * ( + ) (+) * This lnguge my e ccepted y the following TG 2 4,, OR OR Exmple Consider the lnguge L of strings, defined over Σ = {, }, eginning nd ending in different letters. The lnguge L my e expressed y RE ( + ) * + ( + ) * The lnguge L my e ccepted y the following TG Copyright Virtul University of Pkistn 25

26 Theory of Automt Exmple Consider the Lnguge L of strings of length two or more, defined over Σ = {, }, eginning with nd ending in sme letters. The lnguge L my e expressed y the following regulr expression ( + ) * + ( + ) * This lnguge my e ccepted y the following TG Exmple Consider the EVEN-EVEN lnguge, defined over Σ = {, }. As discussed erlier tht EVEN-EVEN lnguge cn e expressed y regulr expression (++(+)(+) * (+)) * The lnguge EVEN-EVEN my e ccepted y the following TG Exmple Consider the lnguge L, defined over Σ={, }, in which s occur only in even clumps nd tht ends in three or more s. The lnguge L cn e expressed y its regulr expression () * ( * +(() * ) * ) OR () * ( * +( () + ) * ). The lnguge L my e ccepted y the following TG Exmple Consider the following TG Copyright Virtul University of Pkistn 26

27 Theory of Automt Consider the string. It my e oserved tht the ove string trces the following three pths, (using the sttes) ()() () () () () () () () (-)(4)(4)(+)(+)(3)(2)(2)(1)(+) ()() (()()) () () () () () (-)(4)(+)(+)(+)(3)(2)(2)(1)(+) ()(() ()) () () () () () () (-) (4)(4)(4)(+) (3)(2)(2)(1)(+) Which shows tht ll these pths re successful, (i.e. the pth strting from n initil stte nd ending in finl stte). Hence the string is ccepted y the given TG. Generlized Trnsition Grphs A generlized trnsition grph (GTG) is collection of three things Finite numer of sttes, t lest one of which is strt stte nd some (mye none) finl sttes. Finite set of input letters (Σ) from which input strings re formed. Directed edges connecting some pir of sttes leled with regulr expression. It my e noted tht in GTG, the lels of trnsition edges re corresponding regulr expressions Copyright Virtul University of Pkistn 27

28 Theory of Automt Theory of Automt Lecture N0. 10 Reding Mteril Introduction to Computer Theory Chpter 6, 7 ummry Exmples of GTG ccepting the lnguges of strings: contining or, eginning with nd ending in sme letters, eginning with nd ending in different letters, contining or, Nondeterminism, Kleene s theorem (prt I, prt II, prt III), proof of Kleene s theorem prt I Exmple Consider the lnguge L of strings, defined over Σ = {,}, contining doule or doule. The lnguge L cn e expressed y the following regulr expression (+) * ( + ) (+) * The lnguge L my e ccepted y the following GTG. Exmple Consider the Lnguge L of strings, defined over Σ = {, }, eginning with nd ending in sme letters. The lnguge L my e expressed y the following regulr expression (+)+ ( + ) * + ( + ) *. This lnguge my e ccepted y the following GTG Exmple Exmple Consider the lnguge L of strings of, defined over Σ = {, }, eginning nd ending in different letters. The lnguge L my e expressed y RE ( + ) * + ( + ) * The lnguge L my e ccepted y the following GTG The lnguge L my e ccepted y the following GTG s well Exmple Consider the lnguge L of strings, defined over Σ = {, }, hving triple or triple. The lnguge L my e expressed y RE (+) * ( + ) (+) * This lnguge my e ccepted y the following GTG Copyright Virtul University of Pkistn 28

29 Theory of Automt Nondeterminism TGs nd GTGs provide certin relxtions i.e. there my exist more thn one pth for certin string or there my not e ny pth for certin string, this property cretes nondeterminism nd it cn lso help in differentiting TGs or GTGs from FAs. Hence n FA is lso clled Deterministic Finite Automton (DFA). Kleene s Theorem If lnguge cn e expressed y FA or TG or RE then it cn lso e expressed y other two s well. It my e noted tht the theorem is proved, proving the following three prts Kleene s Theorem Prt I If lnguge cn e ccepted y n FA then it cn e ccepted y TG s well. Kleene s Theorem Prt II If lnguge cn e ccepted y TG then it cn e expressed y n RE s well. Kleene s Theorem Prt III If lnguge cn e expressed y RE then it cn e ccepted y n FA s well. Proof(Kleene s Theorem Prt I) ince every FA cn e considered to e TG s well, therefore there is nothing to prove. Copyright Virtul University of Pkistn 29

30 Theory of Automt Theory of Automt Lecture N0. 11 Reding Mteril Introduction to Computer Theory Chpter 7 ummry proof of Kleene s theorem prt II (method with different steps), prticulr exmples of TGs to determine corresponding REs. Proof(Kleene s Theorem Prt II) To prove prt II of the theorem, n lgorithm consisting of different steps, is explined showing how RE cn e otined corresponding to the given TG. For this purpose the notion of TG is chnged to tht of GTG i.e. the lels of trnsitions re corresponding REs. Bsiclly this lgorithm converts the given TG to GTG with one initil stte long with single loop, or one initil stte connected with one finl stte y single trnsition edge. The lel of the loop or the trnsition edge will e the required RE. tep 1 If TG hs more thn one strt sttes, then introduce new strt stte connecting the new stte to the old strt sttes y the trnsitions leled y Λ nd mke the old strt sttes the non-strt sttes. This step cn e shown y the following exmple Exmple The ove TG cn e converted to tep 2: If TG hs more thn one finl sttes, then introduce new finl stte, connecting the old finl sttes to the new finl stte y the trnsitions leled y Λ. This step cn e shown y the previous exmple of TG, where the step 1 hs lredy een processed Exmple Copyright Virtul University of Pkistn 30

31 Theory of Automt The ove TG cn e converted to tep 3: If stte hs two (more thn one) incoming trnsition edges leled y the corresponding REs, from the sme stte (including the possiility of loops t stte), then replce ll these trnsition edges with single trnsition edge leled y the sum of corresponding REs. This step cn e shown y prt of TG in the following exmple Exmple The ove TG cn e reduced to Note The step 3 cn e generlized to ny finite numer of trnsitions s shown elow The ove TG cn e reduced to tep 4 (ypss nd stte elimintion) If three sttes in TG, re connected in sequence then eliminte the middle stte nd connect the first stte with the third y single trnsition (include the possiility of circuit s well) leled y the RE which is the conctention of corresponding two REs in the existing sequence. This step cn e shown y prt of TG in the following exmple Exmple r 3 To eliminte stte 5 the ove cn e reduced to Consider the following exmple contining circuit Copyright Virtul University of Pkistn 31

32 Theory of Automt Exmple Consider the prt of TG, contining circuit t stte, s shown elow To eliminte stte 3 the ove TG cn e reduced to Exmple Consider prt of the following TG To eliminte stte 3 the ove TG cn e reduced to To eliminte stte 4 the ove TG cn e reduced to Note It is to e noted tht to determine the RE corresponding to certin TG, four steps hve een discussed. This process cn e explined y the following prticulr exmples of TGs Exmple Consider the following TG To hve single finl stte, the ove TG cn e reduced to the following Copyright Virtul University of Pkistn 32

33 Theory of Automt To eliminte sttes 2 nd 3, the ove TG cn e reduced to the following To eliminte stte 1 the ove TG cn e reduced to the following Hence the required RE is (+)(+) * (+) Copyright Virtul University of Pkistn 33

34 Theory of Automt Theory of Automt Lecture N0. 12 Reding Mteril Introduction to Computer Theory Chpter 7 ummry Exmples of writing REs to the corresponding TGs, RE corresponding to TG ccepting EVEN-EVEN lnguge, Kleene s theorem prt III (method 1:union of FAs), exmples of FAs corresponding to simple REs, exmple of Kleene s theorem prt III (method 1) continued Exmple Consider the following TG To hve single initil nd single finl stte the ove TG cn e reduced to the following To otin single trnsition edge etween 1 nd 3; 2 nd 4, the ove cn e reduced to the following To eliminte sttes 1,2,3 nd 4, the ove TG cn e reduced to the following TG OR Copyright Virtul University of Pkistn 34

35 Theory of Automt To connect the initil stte with the finl stte y single trnsition edge, the ove TG cn e reduced to the following Hence the required RE is (+) * +(+) * Exmple Consider the following TG, ccepting EVEN-EVEN lnguge 1± It is to e noted tht since the initil stte of this TG is finl s well nd there is no other finl stte, so to otin TG with single initil nd single finl stte, n dditionl initil nd finl stte re introduced s shown in the following TG To eliminte stte 2, the ove TG my e reduced to the following To hve single loop t stte 1, the ove TG my e reduced to the following To eliminte stte 1, the ove TG my e reduced to the following Hence the required RE is (++(+)(+) * (+)) * Kleene s Theorem Prt III ttement: If the lnguge cn e expressed y RE then there exists n FA ccepting the lnguge. Copyright Virtul University of Pkistn 35

36 Theory of Automt As the regulr expression is otined pplying ddition, conctention nd closure on the letters of n lphet nd the Null string, so while uilding the RE, sometimes, the corresponding FA my e uilt esily, s shown in the following exmples Exmple Consider the lnguge, defined over Σ = {,}, consisting of only, then this lnguge my e ccepted y the following FA which shows tht this FA helps in uilding n FA ccepting only one letter Exmple Consider the lnguge, defined over Σ = {,}, consisting of only Ÿ, then this lnguge my e ccepted y the following FA As, if r 1 nd r 2 re regulr expressions then their sum, conctention nd closure re lso regulr expressions, so n FA cn e uilt for ny regulr expression if the methods cn e developed for uilding the FAs corresponding to the sum, conctention nd closure of the regulr expressions long with their FAs. These three methods re explined in the following discussion Method1 (Union of two FAs): Using the FAs corresponding to r 1 nd r 2 n FA cn e uilt, corresponding to r 1 + r 2. This method cn e developed considering the following exmples Exmple Let r 1 = (+) * defines L 1 nd the FA 1 e nd r 2 = (+ ) * (+ ) * defines L 2 nd FA 2 e Let FA 3 e n FA corresponding to r 1 + r 2, then the initil stte of FA 3 must correspond to the initil stte of FA 1 or the initil stte of FA 2. ince the lnguge corresponding to r 1 + r 2 is the union of corresponding lnguges L 1 nd L 2, consists of the strings elonging to L 1 or L 2 or oth, therefore finl stte of FA 3 must correspond to finl stte of FA 1 or FA 2 or oth. ince, in generl, FA 3 will e different from oth FA 1 nd FA 2, so the lels of the sttes of FA 3 my e supposed to e z 1,z 2, z 3,, where z 1 is supposed to e the initil stte. ince z 1 corresponds to the sttes x 1 or y 1, so there will e two trnsitions seprtely for ech letter red t z 1. It will give two possiilities of sttes either z 1 or different from z 1. This process my e expressed in the following trnsition tle for ll possile sttes of FA 3. Copyright Virtul University of Pkistn 36

37 Theory of Automt Old ttes z 1 (x 1,y 1 ) z 2 (x 1,y 2 ) New ttes fter reding (x 1,y 2 ) z 2 (x 2,y 1 ) z 3 (x 1,y 3 ) z 4 (x 2,y 1 ) z 3 z 3 + (x 2,y 1 ) z 4 + (x 1,y 3 ) z 5 + (x 2,y 3 ) (x 1,y 2 ) z 2 (x 1,y 3 ) z 4 (x 1,y 3 ) z 4 (x 2,y 1 ) z 3 (x 2,y 3 ) z 5 (x 2,y 3 ) z 5 RE corresponding to the ove FA my e r 1 +r 2 = (+) * + (+ ) * (+ ) *. Note: Further exmples re discussed in the next lecture. Copyright Virtul University of Pkistn 37

38 Theory of Automt Theory of Automt Lecture N0. 13 Reding Mteril Introduction to Computer Theory Chpter 7 ummry Exmples of Kleene s theorem prt III (method 1) continued, Kleene s theorem prt III (method 2: Conctention of FAs), Exmple of Kleene s theorem prt III (method 2 : Conctention of FAs) Note It my e noted tht the exmple discussed t the end of previous lecture, FA 1 contins two sttes while FA 2 contins three sttes. Hence the totl numer of possile comintions of sttes of FA 1 nd FA 2, in sequence, will e six. For ech comintion the trnsitions for oth nd cn e determined, ut using the method in the exmple, numer of sttes of FA 3 ws reduced to five. Exmple Let r 1 = (+) * nd the corresponding FA 1 e lso r 2 = (+)((+)(+)) * or ((+)(+)) * (+) nd FA 2 e, x 1 - x 2 + y 1 - y 2 +, FA corresponding to r 1 +r 2 cn e determined s x 1 - x 2 +, y 1 - y 2 + Old ttes z 1 - (x 1,y 1 ) z 2 + (x 2,y 2 ), New ttes fter reding (x 2,y 2 ) z 2 (x 1,y 2 ) z 3 (x 2,y 1 ) z 4 (x 1,y 1 ) z 1 z 3 + (x 1,y 2 ) (x 2,y 1 ) z 4 (x 1,y 1 ) z 1 z 4 + (x 2,y 1 ) z 1 - (x 2,y 2 ) z 2 z 2 + (x 1,y 2 ) z 3 z 3 + Exmple Let r 1 = ((+)(+)) * nd the corresponding FA 1 e, z 4 + x 1 ± x, 2 Copyright Virtul University of Pkistn 38

39 Theory of Automt lso r 2 = (+)((+)(+)) * or ((+)(+)) * (+) nd FA 2 e, y 1 - y 2 + FA corresponding to r 1 +r 2 cn e determined s Old ttes, New ttes fter reding z 1 ± (x 1,y 1 ) z 2 + (x 2,y 2 ) Hence the required FA will e s follows (x 2,y 2 ) z 2 (x 1,y 1 ) z 1, (x 2,y 2 ) z 2 (x 1,y 1 ) z 1 z 1 ± z, 2 + Method2 (Conctention of two FAs): Using the FAs corresponding to r 1 nd r 2, n FA cn e uilt, corresponding to r 1 r 2. This method cn e developed considering the following exmples Exmple Let r 1 = (+) * defines L 1 nd FA 1 e x 1 - x 2 + nd r 2 = (+ ) * (+ ) * defines L 2 nd FA 2 e, y 1 - y 2 y 3 + Let FA 3 e n FA corresponding to r 1 r 2, then the initil stte of FA 3 must correspond to the initil stte of FA 1 nd the finl stte of FA 3 must correspond to the finl stte of FA 2.ince the lnguge corresponding to r 1 r 2 is the conctention of corresponding lnguges L 1 nd L 2, consists of the strings otined, conctenting the strings of L 1 to those of L 2, therefore the moment finl stte of first FA is entered, the possiility of the initil stte of second FA will e included s well. ince, in generl, FA 3 will e different from oth FA 1 nd FA 2, so the lels of the sttes of FA 3 my e supposed to e z 1,z 2, z 3,, where z 1 stnds for the initil stte. ince z 1 corresponds to the sttes x 1, so there will e two trnsitions seprtely for ech letter red t z 1. It will give two possiilities of sttes which correspond to either z 1 or different from z 1. This process my e expressed in the following trnsition tle for ll possile sttes of FA 3 x 1 - x 2 +, y 1 - y 2 y 3 + Copyright Virtul University of Pkistn 39

40 Theory of Automt Old ttes New ttes fter reding z 1 - x 1 z 2 (x 2,y 1 ) z 3 (x 1,y 2 ) z 4 + (x 1,y 3 ) z 5 + (x 2,y 1,y 3 ) z 6 + (x 1,y 2,y 3 ) Hence the required FA will e s follows x 1 z 1 (x 1,y 2 ) z 3 (x 1,y 3 ) z 4 (x 1,y 3 ) z 4 (x 1,y 2,y 3 ) z 6 (x 1,y 3 ) z 4 z 2 z 3 (x 2,y 1 ) z 2 (x 2,y 1 ) z 2 (x 2,y 1 ) z 2 (x 2,y 1,y 3 ) z 5 (x 2,y 1,y 3 ) z 5 (x 2,y 1,y 3 ) z 5 z 1 - z 4 + z 6 + z 5 + Note: Another exmple is discussed in the next lecture. Copyright Virtul University of Pkistn 40

41 Theory of Automt Theory of Automt Lecture N0. 14 Reding Mteril Introduction to Computer Theory Chpter 7 ummry Exmples of Kleene s theorem prt III (method 1) continued,kleene s theorem prt III (method 2: Conctention of FAs), Exmples of Kleene s theorem prt III(method 2:conctention FAs) continued, Kleene s theorem prt III (method 3:closure of n FA), exmples of Kleene s theorem prt III(method 3:Closure of n FA) continued Exmple Let r 1 = ((+)(+)) * nd the corresponding FA 1 e, lso r 2 = (+)((+)(+)) * or ((+)(+)) * (+) nd FA 2 e FA corresponding to r 1 r 2 cn e determined s x 1 ± x 2,, y 1 - y 2 +, Old ttes New ttes fter reding z 1 - (x 1,y 1 ) z 2 + (x 2,y 2 ) Hence the required FA will e s follows (x 2,y 2 ) z 2 (x 1,y 1 ) z 1 (x 2,y 2 ) z 2 (x 1,y 1 ) z 1 Method3: (Closure of n FA), Building n FA corresponding to r *, using the FA corresponding to r. It is to e noted tht if the given FA lredy ccepts the lnguge expressed y the closure of certin RE, then the given FA is the required FA. However the method, in other cses, cn e developed considering the following exmples Closure of n FA, is sme s conctention of n FA with itself, except tht the initil stte of the required FA is finl stte s well. Here the initil stte of given FA, corresponds to the initil stte of required FA nd non finl stte of the required FA s well., y 1 - y 2 + Exmple Let r = (+) * nd the corresponding FA e x 1 - x 2 + Copyright Virtul University of Pkistn 41

42 Theory of Automt then the FA corresponding to r * my e determined s under x 1 - x 2 + x 1 - x 2 + New ttes fter reding Old ttes Finl z 1 ± x 1 Non-finl z 2 x 1 z 3 + (x 2,x 1 ) x 1 z 2 x 1 z 2 x 1 z 2 (x 2,x 1 ) z 3 (x 2,x 1 ) z 3 (x 2,x 1 ) z 3 The corresponding trnsition digrm my e s under z 1 ± z 3 + z 2 Exmple Let r = (+) * (+) * nd the corresponding FA e, y 1 - y 2 y 3 + then the FA corresponding to r * my e determined s under New ttes fter reding Old ttes Finl z 1 ± y 1 Non-Finl z 2 y 1 z 3 y 2 z 4 + (y 3,y 1 ) z 5 + (y 3,y 1,y 2 ) y 2 z 3 y 2 z 3 (y 3,y 1 ) z 4 (y 3,y 1,y 2 ) z 5 (y 3,y 1,y 2 ) z 5 y 1 z 2 y 1 z 2 y 1 z 2 (y 3,y 1 ) z 4 (y 3,y 1 ) z 4 The corresponding trnsition digrm my e z 1 ± z 3 z 4 + z 5 + z 2 Copyright Virtul University of Pkistn 42

43 Theory of Automt Exmple Consider the following FA, ccepting the lnguge of strings with s second letter, y 1 - y 2, y 3 + y 4, then the FA corresponding to r * my e determined s under Old ttes New ttes fter reding z 1 ± y 1 z 2 y 2 z 3 y 4 z 4 + (y 3,y 1 ) z 5 + (y 3,y 1,y 2 ) z 6 (y 1,y 1,y 2,y 4 ) The corresponding trnsition digrm my e y 2 z 2 y 4 z 3 y 4 z 3 (y 3,y 1,y 2 ) z 5 (y 3,y 1,y 2,y 4 ) z 6 (y 1,y 1,y 2,y 4 ) z 6 y 2 z 2 (y 3,y 1 ) z 4 y 4 z 3 (y 3,y 1,y 2 ) z 5 (y 3,y 1,y 2 ) z 5 (y 1,y 1,y 2,y 4 ) z 6, z 1 ± z 2, z 3 z 4 +, z 5 + z 6 +, Copyright Virtul University of Pkistn 43

44 Theory of Automt Theory of Automt Lecture N0. 15 Reding Mteril Introduction to Computer Theory Chpter 7 ummry Exmples of Kleene s theorem prt III (method 3), NFA, exmples, voiding loop using NFA, exmple, converting FA to NFA, exmples, pplying n NFA on n exmple of mze Note It is to e noted tht s oserved in the exmples discussed in previous lecture, if t the initil stte of the given FA, there is either loop or n incoming trnsition edge, the initil stte corresponds to the finl stte nd nonfinl stte s well, of the required FA, otherwise the initil stte of given FA will only correspond to single stte of the required FA (i.e. the initil stte which is finl s well). Nondeterministic Finite Automton (NFA) Definition An NFA is TG with unique strt stte nd property of hving single letter s lel of trnsitions. An NFA is collection of three things Finite mny sttes with one initil nd some finl sttes Finite set of input letters, sy, = {,, c} Finite set of trnsitions, showing where to move if letter is input t certin stte (Ÿ is not vlid trnsition), there my e more thn one trnsition for certin letters nd there my not e ny trnsition for certin letters. Oservtions It my e oserved, from the definition of NFA, tht the string is supposed to e ccepted, if there exists t lest one successful pth, otherwise rejected. It is to e noted tht n NFA cn e considered to e n intermedite structure etween FA nd TG. The exmples of NFAs cn e found in the following Exmple It is to e noted tht the ove NFA ccepts the lnguge consisting of nd.,, Exmple It is to e noted tht the ove NFA ccepts the lnguge of strings, defined over Σ = {, }, contining. Note It is to e noted tht NFA helps to eliminte loop t certin stte of n FA. This process is done converting the loop into circuit. But during this process the FA remins no longer FA nd is converted to corresponding NFA, which is shown in the following exmple. Exmple Consider prt of the following FA with n lphet Σ = {,,c,d} c 5+ 7 c d Copyright Virtul University of Pkistn 44

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings... Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

Worked out examples Finite Automata

Worked out examples Finite Automata Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will

More information

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

Lexical Analysis Finite Automate

Lexical Analysis Finite Automate Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition

More information

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

More information

FABER Formal Languages, Automata and Models of Computation

FABER Formal Languages, Automata and Models of Computation DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

More information

Some Theory of Computation Exercises Week 1

Some Theory of Computation Exercises Week 1 Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c - {w w hs even s nd one or two s} First we sk whether

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1 CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

More information

1 From NFA to regular expression

1 From NFA to regular expression Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-* Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

More information

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

More information

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1 Non-Deterministic Finite Automt Fll 2018 Costs Busch - RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch - RPI 2 Nondeterministic Finite Automton (NFA) Alphbet

More information

Name Ima Sample ASU ID

Name Ima Sample ASU ID Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

More information

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 1-4) Weeks

More information

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun: CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with -trnsitions Tody: Prove n NFA- is no more powerful thn n NFA Introduce

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15 Models of Comput:on Lecture #8 Chpter 7 con:nued Any lnguge tht e defined y regulr expression, finite utomton, or trnsi:on grph cn e defined y ll three methods We prove this y showing tht ny lnguge defined

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints) C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regular Expressions to Discrete Finite Automata: A Tutorial Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

More information

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

More information

Tutorial Automata and formal Languages

Tutorial Automata and formal Languages Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15 Regulr Lnguge Nonregulr Lnguges The Pumping Lemm Models of Comput=on Chpter 10 Recll, tht ny lnguge tht cn e descried y regulr expression is clled regulr lnguge In this lecture we will prove tht not ll

More information

Fundamentals of Computer Science

Fundamentals of Computer Science Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

Languages & Automata

Languages & Automata Lnguges & Automt Dr. Lim Nughton Lnguges A lnguge is sed on n lphet which is finite set of smols such s {, } or {, } or {,..., z}. If Σ is n lphet, string over Σ is finite sequence of letters from Σ, (strings

More information

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers 80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES 2.6 Finite Stte Automt With Output: Trnsducers So fr, we hve only considered utomt tht recognize lnguges, i.e., utomt tht do not produce ny output on ny input

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks

More information

ɛ-closure, Kleene s Theorem,

ɛ-closure, Kleene s Theorem, DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛ-closure, Kleene

More information

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.

More information

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T

More information

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy: Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes

More information

1.3 Regular Expressions

1.3 Regular Expressions 56 1.3 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions,

More information

Formal Languages and Automata Theory. D. Goswami and K. V. Krishna

Formal Languages and Automata Theory. D. Goswami and K. V. Krishna Forml Lnguges nd Automt Theory D. Goswmi nd K. V. Krishn Novemer 5, 2010 Contents 1 Mthemticl Preliminries 3 2 Forml Lnguges 4 2.1 Strings............................... 5 2.2 Lnguges.............................

More information

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model? CS125 Lecture 11 Fll 2016 11.1 Finite Automt Motivtion: TMs without tpe: mybe we cn t lest fully understnd such simple model? Algorithms (e.g. string mtching) Computing with very limited memory Forml verifiction

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

Chapter 7. Kleene s Theorem. 7.1 Kleene s Theorem. The following theorem is the most important and fundamental result in the theory of FA s:

Chapter 7. Kleene s Theorem. 7.1 Kleene s Theorem. The following theorem is the most important and fundamental result in the theory of FA s: Chpte 7 Kleene s Theoem 7.1 Kleene s Theoem The following theoem is the most impotnt nd fundmentl esult in the theoy of FA s: Theoem 6 Any lnguge tht cn e defined y eithe egul expession, o finite utomt,

More information

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v. 1 Exercises Chpter 1 Exercise 1.1. Let Σ e n lphet. Prove wv = w + v for ll strings w nd v. Prove # (wv) = # (w)+# (v) for every symol Σ nd every string w,v Σ. Exercise 1.2. Let w 1,w 2,...,w k e k strings,

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014 CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51 Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices

More information