You are on page 1of 48
-profajauPashankar:- com E Theor of Computation AVPHABETS « An alphabet is a finite, non-emphy ser of fymbole - We ute the simbo! = for an alphaser e9- Es LOAS is the binary aphaner. string A. string (or sometimes word) is a Finite sequente of Symbols Choate, From some alphabets - 24: \oo10 is a string Gom the binary alphaket = 40/1% EMpry string Emph stving is the string with zere occurenes of the Symbols Penvied by €- LENGTH OF STRING The no- of Symbols in the string carditis, Notation for length of string w is lol “the cep of all strings over an ajphaber & is denoted by st gorge LE 10,1, 01,10, 11, 090, e*cescus’ vet... 2 ye zere or more oceusentt ete E'UZU---- empty Shi79 = finite Ser eke et uv te5 a. 7 . ek a7 —ineinie ets zt - ey : 4 one or more fs sabaa bi We Bebe6, abiphobek Uv =r strings he concatenation of toe strings Wand v is the ing the symbol of V to the wighh end of W) 1g obtained by WV > abagbaa Reverse of Shing 1 we aan ean denvted by wk T wr = An 2 AL AY Language: Language is denoted by L Complement of Language L is a 4 ale Reverse of a language is the Set of abl string vevertels f= {o®iwery Concalenation of 4100 lariguagen. Ly and be — 7 Lyles AIT RELI Yerry ‘orale ‘Stang Wc emPHL Shing Star ctecure™ . a 7 ° gre = 42rd Me. Povurte. est { ok — Tew oy Mone Posinve closure L 4 oe ee ene, eens Page) Parse “Tree or Syntoy aree Cees reas ore inmates Ney (rteun Phase) who om PN ) dd f.Q | The looman the Irae WE do Parsi jog 40 check A ; Sy} Srammer whether the centente it according to the rules of emcees | Productivo —s yuo | NPI 2 Lartice7? < Nour te Anounry > frit | N — sek of terminals seu S 3 stirt symbol / Ss N= Tis} Alphaber VenuT Non-texminal Noder art those Node» Fro & is special Nen-Tewninal node mn WIL you can clerive nodes. ardmo ‘hon wd —_——- epowomy tel Copewarmy sing) BUD BES a1iMtt 2Zs7 => _ > > The woman chirectty cterives Finite Stale Machine (Finite Automate > Finite, Automata cee FA se owpuk . FA wwithour output Moore. Mealy [ E-NFA Machine, Machine DFA NFA DFA ~ Deterministic. Finite Automata “Em SEF is the simplest model of computation = Tr has a very limited memory Circle is known a: states = 4/8,¢,D €dges- is transition leveling of extgeo is inpubs- A fs the initial or starting dates of DEA — arcu D is *he final or texminating state of DFA- Double Cirte. Dees. TT (G-2,40,F,&) ~~ Qa set of all stator Ss inputs qo = Stavt state /initial stare Fa set of Final stares . 6 = transition Arction From $2 9x2 50 Shae, ep Seay ad ale |e | Lo= 44 ey BlD A F =1Dk : 7 e[A ]o eS p| 8 c Deterministic. Finite Automate Exee—% Liz set o¢ at) Strings Mab start estin RG? = {0,00, PL 000, 010, O11,66 Sova Dead state or rap state . Bg. oo) ee 3 ° ° 1 4 ac tete4 intel ite O— OO ®-_ State Eg toy A ‘ %, ! Shia inital ee ®->© SQ SO — Nor Final state oe Deteemi A roomate Cexample Coshuck @ DEA that accepts sets of ad) shi = =. LOY L= $00, 01 19,114 > AD Over $0,175 OF lengiha, ASQ) FO = fie stave Beteeminishic Finite Mutmate Cexample-3) ae Fhe Autprnats, Cerrie 3) Consmuck a DFA that accepts any strings over 19,64 that cloes nok contain he shying aabb in i}, =Zzlay Thy 42 design a simper proviem ter us constnict a DEA thak accepts all strings Over {a,b} thar contains ame shing Gabb In iF. aaabe, gabe. — Flip ane states Make The Final shake Fate Nen-Fined siete ~ mate. tN. non-Fina! stoke inte Fines states cep” 2 b SME Eis mot a fined State string is mob etccepted. pase@® Deteeminishe Finite Automaty vy DETERMINISM % In DFA , giver the cuetant srabe, We Knee thet Lshat the newt sie etl! be. 7 Tr has ony one unique next state. % Tt has no choices or randomness DTr is simple and ‘e987 +0 deoisn Lo deleeminise Finite Awemala NON- DETERMINISM > Tn NFA, dive the current ctue Hheee could multiple nent stares. The next stale may be chosen ak random D7 AN The Next states may be chosen in parallel. is fits. E = this stag can aloo accept erry naw Se NFA- Formal Definition 12 Lie of all srrings thal end with 03 (9, =, 40,F, 8) Q@= set of stares — ABS Se topos = Lory ex Stark ste initia sre — A F = sep of inal stater ~B 62 axs>2 EEA S TOA. a4 ee AAD A,BABO. 2 x pen a ste. ALG Bx 2P7 ee, axl oor A Ad A,B,6/RB/AC/ BE PEED prok ~~ NFA Exame on 62 LES sep of el sheings that end with OF 3° \oo 1 O02 7o *%- Bap * LiF there is ceny way to run the machine “that ends in any set of Stelea out of Which QHeask one sie is a Final state thenthe NFA accep] NFA ExAmeLes 2 L= {ser of all stings ther star with 04 = §e,00,01,000,----4 49:50 col & O2O2O-® *%3- lol x @>¢ Dead conhigutation | | conshuch a NEA thar acceph cess of al) shings over 40! of length eesioly . | La {00,01 10,113 4g) 00 | oe i O2OLO @O2O© 4g: 00) x OOO? i pagseG) NFA - Exameves 3 Ex) Lisfser of all Stings thak with 13 ! & a { (OW 61, omy of 15) 101, Moy> Env) L2o4 sek of all shings Hot cntaiy lo. €& 3) Las {sek of al shings thak starts usith ‘103 60263" ER4) Lys Grek of alt sinays thet Coatem [0173 os @- Ss Use Lser of aul shings -ttabends eoith "ay" 3 ont @-—-©--©) Assignment: IF you were to conshvc the equiundent DFAS for the above NFs —rfen tell me hew orang minnun number Staten would yoy we foy —pRe zonshudion of each oF the DFAS - dL ve D4 4 QB ex x) DD | be Conversion of NEA to DEA Eveu DEP is an NEA, bub nok Vice Vers Bub there 12 An equivalen’ OFA fr every / NFA, “oft &- GAS >a) NEA $2 9x E324 NPA = DFA Lz {set of all strings over{o/ I) Thak Starts with ‘ol % e240 oan eagetnt on ae ale pe ° z e.8 o—-©. | ® oo} CoPend cro A Be cpap see sis eB ele ¢ rase@ Conversion of NEA +. DFA Cxranpte Lb On OF NFA te DFA exarngte L= Lset of alt stings over Co, 2%, 1) hak endo usith 43 yee o,) 1 Se ©) rN PUA °\e ¢ ot AS -ing le state, AHAY fray AB | fay £aBy for Caltatating AB use Union ser oF Aand B&B Ave. AB™ O Yeubser Construction Method) goo © shy gubaah Consiewelhs Aten pase@) Finite Aulomata lith owbeuts, Mealy ine (6, 2,4, 6,>,40) where @ = Finite sek of sere Tx Finite nonsemy Bheuraeccie oF A x The set of otuput Alphatels & Lae outpah function EBA Yor Titi fre [start state vansition. function @RE2G Vb oa. Q <) ‘Na ore outpur 14 dependent on inpar and at E9* \O1O pO oa 4 SAD wee Moore Machine (8, EA, 6) rere + Qe Fivite ser OF Stmeo Sa Finite nonwemrty a of Tapur obrhoree ic The at oF oun iphone Gs Transition Renton: axere Aa cure fanciers - gee Gio = Toivial sinde [start stots fesse ob ote SM none) pae® Consictien oF Mesh) Machine reve EXON) Lonsimach 4 Mealy Machine that Produces the Oe any bineryy inpuk swing, US Complement oy) —so lvtoo & Vo oletl oroty "S Complernemt S72 wonshack & Mealy Machine thab prinb 'a! Whenever the Sequente, ‘ov iS encountered in anq inp isinary ciring Satory aafa,s% oe 50 loco x 9 BT bbee ba bb moe GD : Conversion of Mealy Machine fp Moore Mathine Convert the fellowin. ‘ 9 Meaty Machine 40 ib equivalent Moore Machine eefory Axtasy Sama Moore 2 Mealy = Ne of smuce est one op No -oF States Facrensest aati se) —_ os xt FRRD no og Simlex a Manis uan - Pace) CHAPTER 2:- Erma languages Noam chemsky geve a Mathematical model af Grammar whith is effective for \iriting computer, languages. The Four type of Grammar according to Noam Chomsky are: Grammar Type| Grammar Aceplea Language Accepted | Automaton TNPE-O Unreshided Grammar Recursively Enumerable (Turing Mathing < Type -1 Contexh Seabiive context Sensitive «| Linear Boun: Grammar St Aaoee “TYPE “2 Context Free Context Free Language Puchdown Autowahi Grammar Finite State Tre -3 Regular Grammar Repuar Aanguage 2 a Automotey Grammar :— A Grammar’ Gr can ve Formally described Using 4 tuples as G=(N,T 6, P) Where > = Set of Variables or Non-Teeminal symtois Vv TS Set of Terminal symbole Sc stort simvol Pp = Production nutes for Tetminals and Non—Texminale A Production rules has the form a—s[2 where a and Bare strings on ( VUT and atleack one cimbo} of a belongs to N. Example :- SMES G=(1S/NB4 $4,645 Ssn0, A> 9,833) e9 N= {S/R 8% SF gag T= 19 by 2aB @-5 ab Pz SSAB Aa, Bab i rose) _ Regular srammar Regular Grammar can be cliviced: inte two types t Right Linear Grammar - are __ Leet Linear Grammar A grammar is said to be Right Linear A grammar is said to be Lef4 Linear IF ad) productions are of the Fern \f all productions ave of the form A> xB A>Bx Ctegies AROx where A,BEV and xET where A, GEV and LET: EBs arSlb + right linear 65> Sbblb 3 left linear S->Sbblb > left linear Tyre 3+ Regular Grammar Righ® Vinew Leet linea d Ta formal Language theory, % conteat fren hangunge is a Lonjacse oe by some Content free Grammar. Context free Grammar / Languoge ( Sei ate) The Sek of all CEL ig Identico) +o the set of languages accepted by pushdown Jutomalis, Conkat Free Grammar is defined & 7 ee teples as GH wonere. Gr=iv Ss py Viz Ser oF Variables or Non-Texminal Spmsels Sx seh of terminal symbois SG = ster symbol Pc production rule Toment Free Grammar has production Rule oF tiny form Aza where, es LVUEF® and AEN Sample :. For a enezaki . i i ng a language that Senerotes equal OUMber of 5 a) » and b's in the form ab”, the Content Free Grarmmar will be dcfined ev. Giz { (SR), (a,b), (s-seb, As aAble)y S 2 aAb > aahbb (by APaAD Daaaghbbb (7 A3aAb) Saaaebbb (uyA3E) — > aqaqbbb > a3 pa” Derivations fem a Grammar “The set of al) Shings thak can be derived from a grammar is Sate to be “the LANGUAGE genexoted from that Grammar - Example I; Consider the Grammar Git =(45/A4, {a/b}, s_ {S2aAb,ahraahb A2¢}3) S2adb Lbs anh] —paghbb Cry aA aadb] —Saaakbbb Ley eA aaAb] > aaaesss C1 APET > aaa bbb 3 AB, APT BO ’y) eS Example 2:- Gas (4S/AB4, ta bb SiS so AB sap Lby A>9 eae Le (G2) = Lele — The ony sting generated by Grammer Sram 2 6a (45,n84, 1463/5. 1s 9AB, AD Ala , B20B|b4) SAB —aAb SAB — sab ChyA?a, B2ed >aab eee vaca Batt Trams pahent ea IST pee fa,” | M20 and \ nzoy ae Regular Expressions are usd for representing ceetain sets of Stings io on akebric fashion Rules bor Regular Expression Y Any termined simbot induding Ab o ines Symbois € E anc and dh are regular expressions - YThe union of -hoo egular expressions is also aq regular expression. @,Ro Bit Ra) 9) The Concakenation oF 4.00 regular expressions fe alio a regular expression. Re Ro Ra) 4) The iHevation (or closure) of a MeGuiak erpression, is also a Tegutax enpresion R> RF OF Asan aaa... SD The regular expression over = 2 Ga,abs | Roa ob 1) fabb,a,y beat ebb ora orb or bba R= abbta tot bba » ta, 0-0 Closure of O | R2e™ i it looks like 4 Closure, bub A 73 -Qhient , l eet = : Fase @ > O4+ran D PR +RO= oO D> er=reir » EF Le ang bee 6) RF Rope D reteptr 2 Pah =® S (R*FL pt De TAR* =E+RFR= RF 1 (par* p= PLAP)*® \> Cp4 aos (Pm aM) HOp* + a) * 1D Cp+@)R=EPRTQ@R and RUP* QD = RPTRE Avdens “theorem IF Pp and @ ave two Regular Expressions over = and E then the Following equation in R given by R=@+RP has Solution fe. R= @P* R=Q+RP —> © reap ; =QrQPp*P = ole +p*P) [eretree*] = * =F proved Roa+ree” = g+ferrdP = Q+ @rrRPe 2 = at @Prlarrrir = Q+QP+SPP+RP> = @PPERP™? Cec ep*] gp OP if P docs not Contain @ unique page @) Gonemchg Terntay Jo CHORE. S aLerrtrey--- 7 p* pon” or™ An Example Prof using Tdentitics of Regutar Expreasions Prove that C14 00%!) + (100% 1) (orlo®19* (oF 10 1) 1S eqred to oF] (or lo 1) * . LHS = ( Leoorr) + 400% 1) (or io¥ 1) * (or 10%) = (1 400%) [E + Cor we IK Corto 1D T ° x ae Cpro01) (ot lo# 1)* ep EFRIRE RK = (E.1400*1) Co oI * -pERER =(ero0¥)& 1 (oF eI = oF Corto * 1* _ oo -> ErptRer™ ans Desion Regular Expression For the Following languages over $2.63 1 Language ace ctl of engin emmy 2 2 Language accepting ebings OF length ableask 2 3) Language accepting shings of length atmosh 2 so : 2) ips faaab ba, be Faaa, 1) Liz §aq,ab,ba, bbd peG@eb) (ath) Carb) * Recaatattba +4b ses tego or mere 2 acarb) +blare) Aan tue =la+b? (a+b) z * » bis $60,644 Bb, be bby Re E+ atbyaarab4+ Latbb = (E Fath) (E+ard) page@) Find ic the Regular Erpreasion Foy the Fiiowing DFA Fiz €+4.b +139 —3O Vr= 4,4 >@ a= de SG), V4 = 0+ dab FTA tQibe 2@ O q=erarvine pubting vatues oF q,and 43 hom u® and © GE EFYAb + 4pbo <1 er <2 REQTRP ah ae ae Regp*® Ardens theorem j = ae > ere (abrba) ee | 4 = (ae +69)* L> Regular Expression .. Designing Regular Expression - Examples: <2 _ Find the Regular Expresion for the following NFA b& a a 4 B= 42% —-O | Gy ex | | —, des apetaa tie -@ Or aGe=%29 _ | =G,a+rdoet 13%) ea By Ae = qyaar 42a + qaba - 3D D Are Pardue t dsb — putting vate of a3 bom @ a +472 H429) © bt4,0% > 4 ayrrh - RoGHRP - m7 te a . oe ~ + R2Gpe Ardent Theor’ me Fs oe e4 a 4 Qa) pran)* —= © Sx Ms Et qatas Putting value OF G2 fom@ Viz E+ 4,04+((q,a)Cb Faby *)b R=9tP = E+ 4,(a talbtab)*)b ae i ly! a R @ & P ER=R d= € (Cara letar)* yee h La+albt+ay*y* _ eo Final stue G= 42a 4 = 6400 (o tav)* a Gaz (aralbra® by | Corav)*a Pulting value of q., from @ putting value of @ From (AV | \ ly ace * of Regular Expression’ to Finite Auromarg QS o ALY ® (a-b) a* eS Convension of Regular Expression to Finite Automaly - Grampleo (Fart dD Convert the Following Regular Expressions 10 ‘thelr equivalent Finite Automate : > varb a alee D pa¥b » (atwe< bb, bab, baab, ---- | | | 6+ © 2» Carede ac,” bev as -©) ateebe bebe he a, abe, vo Pas<@i) Conversion of Regular Expression tp Finite Automata - Cramplet rart-2) Convert the following Regular Expression +o its equivalent Finike Autornata > 19 +(O+H)O*# © (OFTO* | Sites to identify equivalence Y For any Pair of stoves $4; 454 the Arancition for input 26% is defined by Fhe ee ne Sharada and 669584244 “The Heo automata are not equivalent iF for a Fair £40,44% one is INTERMEDIATE Steve and the other is FiMAL Shue 2) TE initial Steve is Final stele of one Automaton , then fn second malin alse TTnial state must be Fina) state for them 4o be equivalent . 2 G-§@ | a( } 4 i. Gx a___\d4,, pase @s) States Cs o (4.4 " vote) CH) (42,45) x 4 by FS Is rs 2,45) ( Ka 146) (4,44) be OLY (43,46) re Fs {921499 (43.44) Br sf & ney fornet (42,49) (43,4) (4,44) vy oH a & A and & are equivelent Conversion of Regulat Exprestion 40 Finite Automate - Grarnpiee Partogy J Convert the Following Regular Expression to ils equivalent Finite Automata y * Lae & are song t atef aaa aaa nad ahs Lesalan/aanech Qe GQ) ~, a | Designing Regutax Expreation -Examples ( Pert it) | (when there are Multiple Final States) | Find the. Expression for the, | qyzeru,0 —>O gino sto 241th! ~O Ov» 43a= 4,04 429+431 © waz “7 ie Final Get 42, 4, = (eo) ---ERORF | = at az 0o* —@ aa thitde vin | ne —" Reunion of both the finol states = O* + O*1UIy* o* 4 OF VV = o*(e+\1*) erro me o* \* Ld Required Expression * Pumping Lemma (For Regular Languages) Y> Pumping Lema is uted to Prove thak q Language io rior REGULAR. D> T+ cannot be wed fo prve that a Languye fe Regular, TE Ais a Regular Languaje, then A has a Pumping Length "RP such Mab any string's' where | S1zP may be divided into 3 parts S=EAIZ Such thak the following Conditions mut be rue Q) nuiz EA for every Tz0 QO wi7o GB) jays? Lewaetnanell Je iS nek Regular, Using PUMPING LEMMA follows below Slepss (we Pave wing Contradiction) > Ascume that A is Regular — > Tt has tohave a Pumping Length (say P) > AN strings longer than P can be pumped |S] > Now Find a ching 'S' in A such thar ae => Divide S inte WE > show thar ~yiz EA for some i — > “Then Consider all ways thar S con be divided into aye > show that none of these Can calisFy all the & pumping conditions ak the Same time -y S Cannot be Pumped SE (ONTRAPICTION - pose (27) Pum oe ing Lemma (For lax Languages)- Example (part <2) ind Pumping Lemena Prove thal the | language A. Poe TH 203 cn Assume thor A ic Repro Tumping length = p sid => St aaa aagabbbtbbb xyz Poe Case 1: the y Past js in the ‘a’ Part agaaagabbbbbbb NC + Zz (ase 2: The Y is in the ‘b! Part : AQaaagaa bbbbbbb aaaaaag obberde yz cs case 8: “the Y ts To the ‘a! and 'b! Pack aaneges b peLeey, em ee > aa! ay a this Shing doce nok We in our lan | a aaca aacaabbesths becaute No of ofa and UE are moh enna) | ug F for Cosh . I ye mT “This string coer nok lie fy our language | qaqaaaa bb bbbb bbbbb s becauwe No-of .0's and B'S ave not opual | ne#N — : La TIME hing does nob We is ur language | forcawin ao Lecaue No of a's and Lis ylTe Ye FAM ee nab egal aaaaabl bebkb aath ebbbb aa a

You might also like