0% found this document useful (0 votes)
31 views

TOC Lec2

Uploaded by

Mohammed Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
31 views

TOC Lec2

Uploaded by

Mohammed Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 48
AUTOMATA + An automaton is an abstract model of a di; | computer. + It can read input. + Itmay have a temporary storage device. + Itcan produce output. + Ithas a control unit + Itcan be in any ofa finite number of internal states. + It can also change the state in some defined configuration. Input file ptt rey trol unit k—J Storage ee Ourpue mw ° Categories J * Automata can be divided into the following categories based on the availability of temporary memory * Finite Automata No temporary memory + Pushdown Automata Stack + Turing Machine Random access memory * Automata can be divided into the following categories based on the output generated. * Accepter: An automaton whose output response is limited to a simple “yes” or “no” is known as an accepter. * Transducer: An automaton capable of producing strings of symbols as output, is known as a transducer. Accept/Allowed String Input {ata * Reject/Rejected String | \ Loop forever ww tcc he Categories * Determi ic Automata * A deterministic automaton is one in which each move is uniquely determined by the current configuration. * Current configuration- Internal state + Current input Symbol +Storages’ content * Non-deterministic automata * Anon-deterministic automaton is one in which each move is not uniquely determined by the current configuration. FINITE AUTOMATA * Finite automata are automata with * No temporary memory * Accepter/Transducer * Deterministic/Non-deterministic * A finite automaton has a finite number of states and can remember only a limited number of things. Input Stri *Accepter “DFA “NEA Output Finite lame String Transducer Automaton *Moore M/c +*Mealy M/c Deterministic Finite Accepter (DFA) * It is a simple model of computation. * It has no temporary storage. * It consists of a finite number of states. + It is deterministic. + Next move is uniquely determined by the current configuration. * It is an accepter. + The output response is limited to a simple “yes” or “no”. A DFA is a quintuple ™) = (0, > , 0, G,, / ), where: + Qisa finite set of internal states, + Disa finite set of symbols (input alphabet, without empty string), + 8:QxZ-—Q is the transition function of M + g) - initial state (9, © ©) + F is a subset of © and represents the set of final or accepting states of ™. What do you mean by 5? Finite Automata Representation + Representation 1: Transition graph/bubble diagram + Good for visualization + Representation 2: Transition table * Good for computer simulation M = (Q, 2, 5, qo, F) % N N % + The circles represent states, with a double circle being an accepting state. + The arcs represent the transitions of the transition function. * The state with an incoming edge (not originating from any state) is an initial state. M = (Q, E, 8, dor F) = ({c40r ai}: {9b}, 5, or {Ao}) DFA-Deterministic ? * The transition function makes the automaton deterministic * At each moment in time, the automaton has exact instructions as to what will happen next. * Current configuration- Internal state + Current input Symbol a b Gu) 0 N N U1 rH DFA FINITE INFORMATION . HOW? DFA M = (Q,£, 8, qo F) 0:0xzx>0 O={40,91,42543544,95} a, b 3=fa,b) F={g,} initial accepting state state state transition HOW TO IDENTIFY A DFA? M= (Q, &, &, dor FY _¢ b/ a am bY’ +Go)-2 qi) 6 .@2) b .@3) 4 initial accepting state state transition state Complete, incomplete, and NFA? DFA-OPERATIONS ACCEPT/REJECT (A/R) The machine always starts in th ial state looking at the leftmost symbol. The transition function specifies, for each state and symbol, the next state the automaton will enter. * &(q), b) = qa, refers that if the automaton is in state q, and the next symbol is b, then the state of the automaton becomes state q.. The automaton stops after reading the rightmost symbol (i.e. Reading all symbols in the string). * If it stops in a non-final state, the string is REJECTED. * If it stops ina final state, the string is ACCEPTED. (DFA)-INITIAL CONFIGURATION 1 a|b|b\a Input String READING THE INPUT 9 le NEXT TRANSITION ao <+— NEXT TRANSITION oe LAST TRANSITION wT * Input finished DFA-EXAMPLE (ACCEPT /REJECT) a,b Strings abba -A aaaaa -R abbaabb -R initial state transition state accepting state DFA-Example-(Accept/Reject) } 2 woe Lh {PF A-Example (Accept/Reject) _) alalb DETERMINISTIC FINITE AUTOMATA/ACCEPTER ( Finite set of states CONTROL eS Tis TAPE Move to the right one cell at HEAD. atime Input of the DFA Can be of any length EXTENDED TRANSITION FUNCTION(ETF) MRQncd > Q So (qw)=q' It describes the resulting state after scanning string Ww starting from state q. For any state q, o (g.4) = q ForallqeQ,wed*,aed 6 (gq, wa) = 5(6 * (q,w), a) 5: QxZ— Q is the transition function of M 5(q,a)=q' ack a ETF EXAMPLE - — — 5°@.A)=4 6 (9,ab) = 9, 5 (g,wa )= 6(5 * (q,w), a) 5 (q,ab) = 5(6* (qy,a),b) = 5(5(5 * (qo,A),a),b) = 6(5(qo,4),b) = 5(4,,b) = qs Example- abba ran — aabbb b/ So 4 < / ay a b/ bb 4 YY a o 190-2 (45)-P 043-b 095.4 —— poy = ta7 ° ETF Observation Observation: If there is a walk from q to q’ with label W, then 5*(qw)=q' W=0107°*:O; o Oy ® O o* (40 s abbbaa) = 45 b ay if au b/ —90}-2-(9)-© 42) 43)-4 + Ga) ETF Example (Caution(A/R))... 5 (g,,bba) = 4, YS Does DFA acceptor reject string bba? Reject _ ww an 7 LANGUAGE OF A DFA Let M = (Q, 2, 6, qo, F) be a DFA. The language of M is the set of all strings accepted by M. L(M) = {@E2Z*iqg, @) Ly (qs. &) for some gy € F } or LOM) = {@eX*| 8*(qy, @) € F} L(M )= {abba} LANGUAGE OF A DFA-EXAMPLES L(M )= {A, ab, abba} yo There is no transition with A , but it accepts A as a string. OBSERVATION!!! M =(0,3,6,q9,F) L(M)={wed*:d5*(qo,w)e F} L(M) is set of strings accepted by the DFA. OR L(M) is the set of all strings w such that there exists a walk from qo to q’ with label w, q' € F. Ww (G , u @) qeF —E a,b Observation: q is a useful state if a ; *There exists a path from initial state qo to state q a oe and b a a pf “> sThere exists a path from state q to. q, EF +(40)-9-(41-6 ¥(q2)-» 143)-9.( Ga) or Gir Gar 43 and q, are useful states. OBSERVATION LANGUAGE REJECTED BY DFAM: T(M) = {we Xl*:5*(qo,w)¢ F} L(M)is set of strings rejected by the DFA. OR L[M)is the set of all strings w such that there exists a walk from qq to q’ with label w such that 7’ # F, (4o) "4 @) aca M M —(90)-2-.(9))-b (43) 193)-4.(@S)) DESIGNING DFA DFA can be constructed for all finite languages but not necessarily for all infinite languages. Determine what a DFA needs to memorize to recognize strings in the language. * Use the property of the strings in the language. * Find the regular pattern in the strings of the language. Determine how many states are required to memorize what we want. * Final state(s) memorizes the property of the strings in the language. Find out how the pattern DFA memorizes changes once the next input symbol is read. * From this change, we get the transition function. What about languages having “no common pattern” or “multiple patterns” ? poy lw ° Designing DFA L(M)= { all strings with any number of a followed by b } L(M)={a"b:n20} y= {a,b} Step-1 Step-2 40) +) 4) *(4,) 6: Qx Z— Q is the transition function of M ~ N44 } = — © Designing DFA Pa o) L(M)= { all strings with any number of a followed by b } 2={a, b} L(M)={a"b:n=0} Step-3 fa\\a,b > iy 42) siti 6: Qx Z— Q is the transition function of M - aw ° Designing DFA Draw DFAs ==fa, b, ch L1= fato"c :n 2 1, m2 1} = fabe, aabbe, abbe, aabe, } L2= {arb™c :1n 2 1, m 2 O} L3= {atb%c :n 20, m2 1} oO L4= {anb™c : n 2 O, m 2 O} Ss aw ° Designing DFA Draw DFAs, >=fa, b, c, d} L1=falb"ord :12 1,m21,n2 1} L2= faloond 112 1, m2 1,n20} L3= falbond 112 1, m20,n2 1} L4= falbmond 112 1, m20,n20} L5= falbmond 112.0, m21,n2 1} L6= falbo'd 12.0, m2 1,n20} L7= {alb™end $12.0, m20,n2 1} L8= falb™ond 112 0, m20,n 20} eine DESIGNING DFA L(M)= { any number a followed by single b } L(M)={a"b:n>0} ( 0) X= {a,b} L(M) = {all strings with prefix ab } 2 = {a,b} a,b Designing DFA > = {0,1}, l= { ALL STRINGS CONTAINING SUBSTRING 001} DESIGNING DFA L(M) = {x © {0,1}*| The number of 1’s in x is odd} = {1, 001, 11100, 111000,...} S-even state, F-odd state L={awa: we {a,b}*} Se o_t935 ae a) € dae \ 7° DFA: Typical Examples d= {a,b} 5 ={a,b} X= {a,b} C) a,b a,b —(4o) | (4) a,b d L(M)={} L(M) =>" L(M) = {4} Language of the Empty, String y a comet AL DESIGNING DFA.... * Construct a DFA that accepts the language = {010, B = {0 1} ) SG ©) Note: DFA exists for all finite languages. DESIGNING DFA... Construct a DFA over alphabet {0, 1} that accepts all strings with at most three 1s. {0*} U {0*10*} U {0*10*10*} U {0*10*10*10*} 0 0 0 0 0,1 gg g§-g-8 mw) YF Construct a DFA over alphabet {0, 1} that accepts all strings with exactly three 1s. DESIGNING DFAS * We cannot construct DFA for the language L = {a’b": n20}, because * Itneeds an infinite number of states * But {a"b’: 1 w mod 4 = 0 . multiple of 4 +1 > wmod 4=1 1 2. 3. multiple of 4 + 2 > w mod 4 = 2 4. multiple of 4 + 3 > w mod 4=3 000002 Designing DFAs DFA M1 accepts (ab)"e MI M1 is incomplete DFA. The string abec is rejected since M1 is unable to process the final ¢ from state q, M2 accepts the same language as M1. M2 is complete DFA. The state q, is the trap state. DESIGNING DFAS Strings over {a, b} with at least 3 a’s Strings over {a, b} with length mod 3 = 0 Strings over {a, b} with length not multiple of 3 DESIGNING DFAS Strings over {a, b} without 3 consecutive a’s b Strings over {a, b} that contain the substring bb wT ¢ ; Design DFAs ‘+ For ® = {0, 1}, deign DFAs for the following languages- “~~ Allstrings ending in 00. = _Allstrings with three consecutive 0's (not necessarily at the end), Al strings that contain exactly 4 “0's. = Allstrings ending in “1101”, = Allstrings containing exactly 4"0"s and at least 2 “1's. = _Allstrings whose fourth symbol from the left end is a 1. All strings that contain the substring 0101 = Allstrings that start with 0 and have an odd length or start with 1 and have an even length. ~ _Allstrings that don't contain the substring 110. = _Allstrings of length at most five. = Allstrings where every odd position is a 1. = _Allstrings that contain an even number of 1’s (Maximum 2 states), = Allstrings which do not contain the substring 10 (Maximum 3 states), = The set of strings that either begin or end (or both) with 01. + For each of the following languages L,, lz, L, and L, give a deterministic finite accepter (DFA), Consider the following languages over the alphabet 5 = {a,b}. = Ly: All strings that contain at least three a's. = I All strings that contain at most one b. = Ig: All strings that contain at least three a's but at most one b. Lg: All strings that contain no b's. l= {a by Find Languages? @) Pate ' «0@) @))e bC(a WO

You might also like