1. All words words in which a appears appears tripled, tripled, if at all. This This means that that every clump clump of a's contains contains 3 or 6 or 9 or 12... a's. Solution !aaa " #$% 2. &rove that that f ( is a finite finite lan)ua)e lan)ua)e !a lan)ua)e lan)ua)e with only finitely finitely many many words$, words$, then ( can can #e defined #y a re)ular e*pression. Solution +onsider ( - a#,#a,aa,##, a finite lan)ua)e consistin) of four words only. /e can write a re)ular e*pression for ( as a#"#a"aa"##. 3. +onstruct +onstruct a re)ular re)ular e*pression e*pression definin) definin) the followin) followin) lan)ua)e lan)ua)e over the the alpha#et alpha#et -a, #. i. All st strin)s n)s th that hav havee an an even num#er of a's and an odd num#er of #'s. ii. All st strin)s n)s th that hav havee an an odd num#er of a's and an odd num#er of #'s. Solution
0. efine !in !in en)lish en)lish phrases$ phrases$ rules rules that repres represent ent this this re)ular re)ular e*pression e*pression !a"#$% a#!a"#$% " #%a% Solution 1. is is in in lan lan)u )ua) a)ee 2. All the strin)s strin)s of this this lan)ua)e lan)ua)e must contain contain su#stri su#strin) n) a# 4 some #5s #5s followed followed #y some some num#er of a5s.
Quiz # 3 Section(B-D)
1. efine a re)ular e*pression that denotes all the words with at least three a's Solution #% a #% a #% a !a "# $% 2. +onstruct a re)ular e*pression definin) the followin) lan)ua)e over the alpha#et -a, #. a$ All strin)s in which any #'s that occur are found in clumps of an odd numer at a time, such as a#aa###a#. Solution !a%#!##$% a"$% 3. escri#e !in 7n)lish phrases$ the lan)ua)es associated with the followin) re)ular e*pressions. i! ((a " )a) Solution 1. is in the lan)ua)e. 2. All the words must end with a. 3. The lan)ua)e does not contains ## means no consective #5s can come to)ether. # is always followed #y an a. 4 0. All the words with even len)ths in which # is separated #y some a5s and a occupies all even positions. 0. 8ind a re)ular e*pression correspondin) to the lan)ua)e L defined recursively as follows 4ule 1 is in L and a is in L . 4ule 2 f * is in L , then aa#* is in L and ##* is in L . 4ule 3 othin) is in L unless it can #e o#tained from the a#ove two clauses. Solution (aa " )(a " )
Quiz # 3 Section($)
1. efine a re)ular e*pression of all words in which
i. ii.
a is tripled or is tripled, #ut not #oth. This means each word contains the su#strin) aaa or the su#strin) ### #ut not #oth. All words that contain e*actly three 's in total.
Solution i$ !a " #a " ##a$% !##" # " $ aaa !a " #a " ##a$% !##" # " $ " !# " a# " aa#$% !aa" a " $ ### !# " a# " aa#$% !aa" a " $ ii$ a% # a% # a% # a% 2. (et us reconsider the re)ular e*pression (a " )a(a " )(a " ). Show that this is e:uivalent to (a " )a(a " ) in the sense that they define the same lan)ua)e. Solution (et !a " #$; a!a " #$; #!a " #$; a# And !a " #$; a#!a " #$; a# This shows #oth re)ular e*pressions must contain su#strin) a#. Any num#er of a5s or #5s can occur #efore or after a#.
3. efine a re)ular e*pression of all words in which a appears dou#led, if at all. This means that every clump of a's contains 2 or 0 or 6 or <... a's. Solution !aa"#$% 0. escri#e !in 7n)lish phrases$ the lan)ua)es associated with the followin) re)ular e*pressions. a! (a " ) and (a " ) (a " ) 1. is in the lan)ua)e 2. The lan)ua)e contains all the strin)s containin) a or #. (a " )
1. is in the lan)ua)e 2. The lan)ua)e contains all the strin)s containin) a or #.