CS18) Lecture conversion between (Notes Regex continued pt 2) . and Automath recap . 2 Recap 5 algot Kleene's Start /NFA and convert it to T regex GBBBB By ... "BBUF state other than starts ②Choose accept and eliminate it 8) . * Y roin &B j do ③ If have parallel edyes & I endup in O G donors want to eliminate this chosen State , but need to add shortcuts # Onia of end up in either : of these situations 2020 Ans : & ↑ regex " To fro every donor to every Donor to receiver, state middle in receiver by passing Need to introduce as many shortcuts as there are donor and receiver pairs smart · Can choose way to eliminate states . 3 NFA 5 to Regex Conversion Example Example of converting NFA to regex : ↑ or 1 O Q · E - 20 - 0 00 Go000 ofYo O May need to Introduce 6 state - can less & shortcuts for one choose more elimina smartly choose incomings outgoing , arrow E on - d Yo in -00 of & O E > - nor do · Or objido paralleareduce T can ⑳ this - * EU 10 1 to combine parallel edyes ↳ ⑧ remaneedenorets outgoing be have ↓ 2 arrows union G o - incoming a us eliminate state this -or - Penae ( answer "1"in regex = union 5 4 RE to . NFA conversion opposite direction example : MenS Partition into implement blocks then Thorst connect · h O 0-0 mis yy Or need loop on regex blocks 01 luniOe) doesn't enforce order need add w/ new state E trans optio can'tadda better H t oppoto is o opt / L Did of structuron · optozoo ↑ 80 ↳ ↑ This is not the simplest machine but be very careful we simplifying O to Did ⑧ Mosmyrear , mon prop Examis z more were m 6 Lemma Pumping technique for how then given general (not all langs reg, prove some not reg, lang not reg = "pumping unmal) to prove 6 1 nonregular lang First . The dren - = 501 0011 , is number of Os andIs, only this is n = , finitely many 000 111 , : on p = As automaton visits some y only D accept 000 -..... Il =-. I w - p+/ an ones . accept state reads O, must state 9. more than once y part of z= ..... inside first loop after m because ( enter a state at least twice . part of w before first loop. w acupress string E X= = states states zeros · many OS t = w Must end up at wi0 number of p+ 1 · acceptina - DFF now of 3 bas Run # of states, can't keep frame seen so far . for L : Assume DFA · regular . nonregular Pf By contradiction - non LOL ame 00001111-.. ↑ : s d = 13 304 185A Ling ↓ while reading the OS 000000000 IIIIIIIIIIII sys X Y Z mor Since DFA accepts Xy2 it also accept m x2 contradiction be XZ is not in the Lang 6 . Lemma Pumping 2 ↑ free exam points, unlike closure questions, exam pumping lema is n Then, there is good for every longa · in X - 2, 2 · L Ce i XyztL for all i P - Xandy occupy earacters at mostP can Y = z 0, 1/ - - be can pumped L 11 strings are (xy)p # - t . · * E string non s . much easier empty PEIN Regular pump into string many times langs o patterns : in the xyz = L xyyyzt Xyyyyyyy can first p chars. z + XztL ↑ have can determine L what - pump y out least pr X # of states of the DFA a what about empty lang or or I string lang exist docent p is , a lang with · at finite strings , give me ur and fold what lang pis . Pumping Cemma proof If Do L: for DFA exam wi p · · DFA on length of string need to repeat is p symbols, some states = ---- use when pumping - 1 w/Lp . Does DFA capture all computational power ↳ /whim w accepts) After No, can't even check that #of OS is equal to out more y part accept state or first before cut can loop part -------inside--- = Languages lemma : at an w of = y appliesranular > can lang ? - be the size ## of states) . must end up X on =numberaes Run this only what should any string weL-s t Take practice pumpand DEA # of 1s . # notice Zine Context Free Grammars Y -------- even CFGS then : are not (check · conditions · #s then - twice some state at least while reading the of Y first O symbols) L for all is 0 furing machine (must visit (xy) = p repeated d 19 is repeated w = Xy z Xyiz a powerful enough (prev page) yE · · Lemma willmust statesa unvisited states when at Start 20 State and to take more need p symbols just at the start ↑ has full power Of computer More pumpingLemma on : contra pos 6 3 contra positive form = original . Pumping Lemma original Original If L is Fira contrapositive - form : - If fre not blue box then ( is non regular Negation of original blue box F => Xp L is nonrey . J WEL (w) =p V X/ y/ z : properties hold cant simultaneously . If first 3 fre last (4m) H 7i is false xyizL existential/universal . - Ex I love someone I love everyone . someone loves Everyone loves > EX - : : I love X I love X everyone I EXXY someone X -Y X loves X loves Y maritiesFront Y Example 6 4 . EX) for Pumping Lemma Examples L 204 = n20] : ↑ can't be implemented pickedyou for by Automata once someon p- you s define w Ia let p -string (V) in lang , at least choose i in control ⑳ P P string in than Is not cang anymore p chars Le28 : CS18) Last Lecture on Midterm 1 material Tool to ↳ prove langs are not pumpling lemma sufficiently long strings -2 shows all are regular - Lemma ~ Op no control over p. chosen (f) vint string explain why it can't be pumped while preserving 6 . membership in the lang alternate between F, 7 L = EW : W are as many game - is their loss Conly one winner) length regular contains zero sum your win contronit continued emply ! ur disadvantage 4 you to - Lis can choose ⑰we L 1w/2p 4 be pumpable. Prove nonregularity Pumping in Dx Os as 1s] Ty Let V = arbitrary Define W = 000 p T consider Al O II I ... -u .... p p F -anyt X/Y : 2 such that these properties hold: use or somewhere in between X choose and -p - + p - Xy2z@LEL nonney in E -pump string y - to i to result nonres in , i times string not language (will disrupt balance btween X(y) FX A ↓ from adversary E from "Exist" chooses this y written backwards ~= y outdoo C "All" if pump up or down string remains in language o fl - length at least p and in the lang + - L bad choice of string adversary . partitions string XY 2 to preventfrom pushing string outside work (can't prove because is XyizL Fi ↑ not is mistake choosing string then defining favorable . Doesn't #1 a X /Y , 2 How do you choose w ? lang Estrials error lang irregular) in control of the partition, you only pick w solution for Another L= GW : what equally many non regular Monday, - & If L reg was ↳ cangtang) reg lang, = but it's not = ↳ nin vey lang, so I must be non reg na03 "ow this is not nec can conclude t is : nonvey rec regular Os and 1s] L10 ON EXAM 0 = use Treg on ey &* orey EX) ( ~ = Con : n + m) -p + +P- & edit adversary may choose Y to be oneO but can't rely on this outside : adversary may of vey lang nonvey ? Alternate 3y + E down to pump = all regea push string out of lang #of Is z to pump - has numbergal > 80 + ↑ confusing ! nonney veg/reg he know is = canneveem eyed xy2 , from class reg nonnegut reg/nonreg up or one Divisie divisible zes case on on bu down, are equal - # of zeos make # of As to in exams w/o proof - pump 11 in string quisin V of, : chooseBotbetter po ! + p Xy] subset of ( lang? diff setup = can be Owilains = any statement proved class = non reg EX) 30 % / = : n > m3 ein lany Y W X need pump down &. to - of y) Xz has symbols : X2 would this bad w p-1 ones at most p-1 zeros . d . & L work if we w Adversary chooses y nonempty substring in first p noir onea remount good chose = me EX)L Slowin = : 11 3 ⑳on 2 im case y can en. be . XIL because doesn't start w/ 1 XzL because # of zeros < p Y unized wouldwork couldbeoutwo oomta not Y now to Picsing barely in Lang - = = Ein EE , 0 1 , 1 1111 , unary lang, string uses Exam Q Last III IIIIII III , .... 9 4 symbol (only one symbols same 3 langs of figure which reg , prove it gap between integers very large when #S get layer figure out Heuswill He prepare us > - square of sur long or non of closure pumping lemma) ↑ ceinus p2 is at So int n to be smallestent thats and a square p least p acceptable pl at most p (y)(p 1)2 ↓ < (xyz) + in soonesible p2 + 2p + 1 of be we Do both practiceams to be ↓ posted Xy 2 + = quee + p Hi ab it Capplication p2 Y examn of submitab rey prove im 3 bunch given consecutive squares, At least p chars : is the next squhre L . com make exams i EX) L = Ew = wR : weE0- 13 3 & * as X palindromes palindome ↓ are copies not of each other useless , anything 0000000000000 prev langs, strings accepted bols , w= not as standard pumping - doesn't make it ↓) noprovement to nonpalindrone w = 18000001 Occan's razor -try simplest ideas W Y = 00000000000000 adversary first palindne picks y symbols (always this --- xyyzz Grumpina Bumping copies more string is oddanyth "I" is - restriction) pumping down z in second half, not a palindrome first p from 00 XZ ↓ has less tuan p zeros then then ↑ hard to p more zes / explain , string may 1 or ↑ not palindrome may not have even/odd L ↑ need explanation even > always - EX) ~ L = 3ww w : + length 50- 13 ] * Y w =s string becomes 0000000 1 odd - 0 + 2025 So adversary can't Seitner is odd: zeros . NEED to have first half of OR remove all IX21 in length 0 Xy2fL or even XZ . 0 explanation and ends w/ starts second half ends W/ . 1 Ex) All strings of prime length L Sw / w/ prime = : come p = q = up w/ string at least p and length prime arbitrary s any prime . t . qIp . Need Y 0000000 = (xyy2) = a I ways to some this one * I much easier Nxy2 + lyl upqaddivan xyy ztL to pump up or down composite integer 2 + 121 - 9 -composite -ly1) · (not primes .6 5 True false ? or 1) closed under infinite unions Rey langs ↳ False Eoh n203 · are : infinitea = Y n C) = [buthourey 0 subsets of · ↳ regular languages are regular FALSE Soh n2032S * : w ↳ nonreg subsets · of reg nonregular languages are ↳ False because 0 50YV : n nonregular 203 · g · Nonney langs are closed under complement 6 True ↓ is regular #[ Thus, 1 is nonnegular is regular E) I nonvey II closed under union Nonregular langs ↳ False take any L that's nonney I is · are , L 1[ non · ↓ nonney rey 1) Nonvey FALSE = 20 langs : non Grey are or + LVT & nonney honey very = intersection & closed under 1 n203150/ rey nonrey so : n nonrey + m3 = "A nonvey lang & Tme is necessarily infinite Every finite large is of contraposive . reg 9 Lecture Mon . April 28 Cs181 Automata can't even ensure # the of Os and Is * -> Var not bound to 7 ( T CONTEXT-TE Automate to Turing Machines Notions Basic Example 2 = CFG C Ea, b3 # L V = its context GRAMMARS equivalent to automate but with one .I 7 are the same terminals states, instead of variables have - ES A, B) , stars - A S - B transition 7 A + a Ab - E A additional feature nonterminals/variables rules substitu tion rules B + bBa X : A derivation S - A eaAb > - Set of a Abb rure #1 rule #3 rule #3 > aaa Abbb - mie#3 > agabbb - rule#4 strings can derive from grammar languagethe grammar Lef The lang be derived can seatB] EX) set of G is the grammar of strings that . using G collapsing 2 mus to one Se A s + B A-aAblE B-6 Ba/E Lang ab : Sahb" : n = 03 UEbra" noS : ↓ anAbb Def A grammar is a tuple (V , E R S) where V = Set of vars = S Set of = (finite, non empty) terminals & set of R : , , rules start variable - 4 2 . EX) Reading CFGS STAA does - A terminate because can't eliminate all vars A - ↑ ↓ nothing changes not set of if we o removerl strings that can be derived 0 ↑ no strings : EX) Stabs/a ↳ regex In * (ab) a not required this to have Exam exam is is Ihr soin hours solid exams graded Mware midterm 25 % EX)s + aSb/E anbh ↑ : 30 points on exam Fou miss get = 0 n full 16 of exam, points built in curve- cantement Na FAIDFA EX)s + aSa/B B/Ea "b * * b an Ans : an beah : n / m2o 25 : points only collect EX) SeaSa/aBa In regex : - 65/b-b abrah : n , m2) Ex)S + ss/as/b + + ↓ (a b) Sess - sends with a 'S * SSS better E much wording M Saabla at s + SS - an 6 S for every SSS * b/chunce tab SSS - aS a SS > a SaaS S - a was was anabas ab abagabaab Saga SS > a S aaa SaS > a - EX S- AB * (aa) Ettals bBb/gt(bb) - * even # of As: as followed by even # of 6's (aa)"(bb)" or_ easier : * * (aa) (bb) - nimzo tonseed -only inna an ⑪ seelat/bT SET-aS0S round ↓ goana Answer : (EE) y delay terminating T does not terminate like by an extra S round * ⑪ arb FA CFGCanMement any nonaccept states dont generated mem break Aer : constructing CFGs EX)(av(avb)2 n 203 EEE : aa ... ... s - ElaSE 2 - alb string of even length EX) [(vb) "a (avb)r : n = 03 S + alES[ 2 - alb = Sahbu +- . aT/S nmSpeti S - El a Sb on cusing pocket analogy) * pla equal and Beb/E b's Exsambm n>m3 : much harder than prev s - aSB convention Beb/aX allows tothana ↓ as TeaT)aS ingramma ersive sa : alternationa of as 5-9Sb/Expase lang that we already know works salbm : Omeans alll confusing Se aSBBBIE Be bla E 3w : w = wRz * palindrome SeEsElE- - 2- alb does not wor , only s+ no coordination between & generates even length strings aSalb5b/El alb E) swiw contains 13 as seXaXaXaX X + &X)E 2 + alb Ex sw : w contains b aa Se XbaaX X + 2X/E 2 - alb ? &* Designing Programming Lang Using CFGs . programming langs All # · (av Identifiers = 4 .... are uz)(au var names (don't start / · program is CFGs· Uzu Oulv a Sa, b..... z, ↓ 0 . 1, 2, ..... 943 , + D ↑ any pos digit -112/3) OR - OR )9Edigit in D- D + Lealbic . - . /zletter we [L/ID) ↑ identifies ⑧ NeND/ ↑ numbers D + start (identifer W- quantity ↑ = Y E Clive a num content i wq or conditional WTWenWS/ devoid bybas meaning of their Eng if w wQ) test identifier optional C + I whitespace Qw' > Q identifer where & white space optional aw < wq var A + =w 2) W T + Qw = Gumber & All assignment: ww mandatory ↑ I - compared identifier E digit 10 any letterof alphabet · Ican be program mem (regex) nument quartity T symbol · -> stored one · ran number Q - IIN pos -. 93 = V- L quantity = Gall valid programs · # line breas CFG = ug) letters, not #s) - 2 ... assignment/conditional single statement statement types : · .... on numbers numbers = positive · based When wsweese was somigea statement
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )