1 - 3 - 3. Deterministic Finite Automata (36 Min.)

download 1 - 3 - 3. Deterministic Finite Automata (36 Min.)

of 14

Transcript of 1 - 3 - 3. Deterministic Finite Automata (36 Min.)

okay, an alphabet is simply a finite setof symbols, we see many common exampleslike ascii, or Unicode are sets of symbolsused in, in the various computerapplications in most of our examples wewill use simpler alphabets which willinclude... Some of the alphabet,consisting of the number zero, one, onecalled the binary alphabet. Sometimes I'lluse a small set of letters like A, B, C,or for the, for the case of our, ourtennis example, we had the set of S and Oas our input alphabet. Another interestingexample might be the set of signals usedby a protocol, such as transmit end and soon. Okay, a string, first of all, everystring is over some particular alphabetwhich we'll call a capital sigma it's,it's a list of elements each of which is amember sigma. And we'll show strings withno commas or quotes. So for example, ABCis a string, over the, it could bealphabetic C or it could be ascii alphabet011 01 is probably a is a string probablyover the binary alphabet of zero and onethis could be over any other alphabet thatcontains the ON1, strings are essentiallythe usual data type that you've seen inlanguages like C or java, Oral, we aregoing to write them without the specialquotes It's also legitimate to see stringsas lists of symbols as long as they'rechosen from some particular alphabetsigma, and of course we never use commasor any other separator between the,symbols of the string. We'll use thenotation sigma star to mean the set of allpossible strings over, a particular finitealphabet sigma. The length of the stringis the number of positions and it shouldbe a common idea from a language likejava. And we will use epsilon to stand forthe empty string or string of length zero.Something which you meant find by quote,quote, in, one or another programminglanguage. Okay, so here is an example,first of all, zero one star is the set ofall strings over the binary alphabet ofzero and one. Here is a list of some ofthe, strings, We'll do it shortest lengthfirst so the empty string is of course oflength zero and then zero is the stringconsisting of the single character zero,one, again a string of length one, with acharacter one, and then you have thingslike zero, zero and so on the four stringsof length two, and so on. There areinfinite number of strings of course inzero, one, star. [sound] eh, you mightnotice that when I write something likezero, that could either be the characterzero, the symbol zero, or it could be astring of length one that has one positionand in that position is a zero, it theseare not the same thing, they are differenttypes of objects, no question about that,but, you can generally tell whether I amtalking about strings or, or symbols forexample only strings can be members oflanguages, symbols can't be members of alanguage although you could have obviouslya string of length one which looks like asymbol [sound] Now language is a sets ofstrings and they can be finite or infinitesets of strings. The only limitation thatwe place on a language is that there issome finite alphabet from which all thestrings of the language are composed. TheLanguage L given as an example has 01 asits alphabet. It has all strings that donot have two consecutive 1s okay, so theempty string is there and both strings oflength one, that is zero and one, of thestrings of length two all are there exceptone, one, right, because one, one doesobviously have two consecutive ones. Fiveof the eight possible strings of lengththree are there. The other three possiblestrings do have consecutive ones. And Ihaven't shown it all here, but there areeight of the sixteen strings of lengthfour, are present. Now, just to give you,throw out a little bit of, of a question,you see that there is one of length zero,two of length one, three of length two,five of length three Eight of length four,you might think about how many would therebe of length five. There' s an obviouspattern, it would be interesting for youto try to figure that out. Okay. Now,deterministic finite automata okay it's aformalism for defining languages and thatformalism consists of a finite set ofstates okay, and with any use cap Qtypically as the set of states of a[inaudible] if I don't tell you anythingelse, give it ano-. Give that set ofstates another name, but then think of itas Q. There will be an input, inputalphabet which we will typically callcapital Sigma. There will be a transitionfunction typically again denoted delta.There will be a start state, and the startstate's always in obviously it's one ofthe states, so it's in the set Q,typically write it as Q0. As you seethere. And there will be a set of finalstates which we will typically call F andthe set of final states is always a subset of obviously the set of all states.The thing that makes the automaton work isthe transition function. This functionusually denoted by delta takes twoarguments. A state Q and an input symbolA. It gives you back the state that theautomaton goes to when it is in state Q,and the next input symbol to arrive is A.The function delta is total, that is ithas a value for every state and symbol.There are examples of automata where wereally don't want to continue in certainsituations. For example our example ourtennis automaton did not have transitionsout of the two states where one player orthe other has won the game. To fix up suchsituations, we have to introduce a deadstate. A dead state is a state that is notaccepting and that has a transition toitself on every input symbol. Once you getto a dead state you cannot leave and youcan never accept, so dead is a pretty gooddescription of what is going on. We'regoing to use the, abbreviation DFA fordeterministic finite automaton. Thedeterministic means that there is a uniquetransition for every state and inputsymbol. We're going to meetnon-deterministic automata soon and there,it is possible to transition to manystates from one state on one input. Hereis a tennis example. Notice that the twofinal states have two transitions out. Sowe add a dead state And all the missingtransitions go to that state. Thetransitions from the dead state are toitself on all possible inputs. In thiscase that would be just S and O. Noticethis is the probably the first examplewhere we have more than one symbol, label,labeling in R. That's just fine. Now,we're going to represent a general DFAs bygraphs. Pretty much as was done in thetennis example. Nodes of the graph,correspond to states of the DFA. An arcrepresents a transition func- thetransition function. An arc from say stateP to state Q. Labeled will be labeled byall those symbols say A and B. That havetransitions from P to Q. There will be anarrow labeled start to the start state sowe do something like this perhaps andwe'll indicate final states by doublecircles so if Q is final, we would put adouble circle around there. This is aninteresting circle of an automaton thatprocesses text. The goal is to recognizethe string read so far in [inaudible] inI, N, G. Okay, the start state which wesee here... Represents a condition wherewe have made no progress towards seeing I,N, G If in that state we see an I, that wehave made some progress. So we go to astate that says I was the last symbol C.That's the state that we call saw I.Otherwise, we're going to stay in thestart states so there's a transition onevery symbol, every letter but I. To thestart state that says that we're really,we made no progress. Now, from the saw Istate, If we next see an N then we've mademore progress and we go to the state,that, as we've seen The sequence IN. Onthe other hand, if from saw I we seeanother I, then we've not made progressbut neither have we lost ground. We may bereading a word like skiing with a double Iand thus the transition from state saw Ion I is to itself, that's right here. Onany symbol other than I or N we go fromthe saw I state back to the start statewhere we're seeing nothing. In state sawN. If we next see G then we win. We havejust seen ING and we go to the acceptingstate which is saw ING. On the other hand,if we're in state saw N and we see an Ithen the pattern IN is broken but there'sa new pattern beginning I that has startedso we're gonna go back to the saw I state.That's this transition. On any input otherthan I or G including an N from the saw instate we have no progress at all so we goback to the start state. Finally, from thestate saw ING we can only go back to saw Iif we see another I. That's this. Or if wesee anything but an I, we have to go backto the start state where we've seen Here'sanother example. It's an automaton thatrepresents the simplest possible protocolfor sending data. The program is in one oftwo states; ready and sending. It startsin the ready state. And eventually it getsa signal that some data has been loadedinto its buffer at that point it entersthe sending state where it does whateveris necessary to transmit the contents ofthe buffer the receiver will send an actsymbol when the content is received inwhich case we can return to the ready stepHowever if the receiver is down, we mayinstead get a local timeout signal thatwarns something is wrong and the buffermust be retransmitted. This automaton doesnot complete. There are no final statesbecause the automaton is designed to runforever without rendering a decision. Alsothere are missing transitions. Now it isokay to ignore the act or timeout signalswhen you are in the ready state, stayingtherefore in the ready state so we mightdraw for example In R from ready to readyand that could include signals, time out,and ack. Okay. That's probably okay.However, a data in single in the sendingstate is an indication of an error so wemight want to go to an error state. So youare going to have an error state. And ifyou are in the sending state and youreceive a data in signal, you go to thaterror state. Okay, now, each, state, ofcourse error er, has a transition out oneach of the three signals, static and actand time out. A tech, a technical questionthat's asked about protocol is whether youcan get to an error state. We could forexample make the error state the finalstate so I'll garble carefully here andoh, by the way, it's really a dead stateso I probably oughta add transitions onany of the three sym-, input symbols. Andone of the interesting things about[inaudible] is that it's possible toanswer questions like can this [inaudible]ever get into the error state. Okay,that's a question of course you could notask about programs in general. For arunning example, we're going to use thisautomaton. It's language is the set ofbinary strings that do not contain twoconsecutive zeros. State A, where theautomaton will be whenever the inputstring seems so far is good. That is itcontains no consecutive 1s. Also it doesnot end in a one. Surely the state shouldbe a start state since when no input hasbeen received, there are two no twoconsecutive 1s and moreover the input doesnot end in a one. We get to state B whenthe input is good, that is no twoconsecutive ones, but the last symbol seenis a one. Notice that the only way to getto B is to be in A and then get an inputone. C is actually a dead state. We'rethere whenever two consecutive ones havebeen received. We arrive at C for thefirst time from B, which you recall meansthat the previous input was one, and instate B we receive a second one. Once in Cwe stay there because once a string hasone, one you can never undo that fact, nomatter how many zeroes you see. Okay. Hereis, the other representation that we'regoing to use for finite automata. Atransition table, okay. The ... This, thistransition table that we are showing hererepresents the same automaton as thelittle graph that I ... I show in the, inthe corner over here. Okay. Now in thetable the rows correspond to the states.So you can see there, there is a row forA, B, and C. The columns correspond to theinput symbols. We have columns for zeroand for one. A final state will representby starring it in its column in its rowsorry and we will put an arrow next to thestar state now the entries to the tableare the values of delta, so for example,this entry is in the row for B and thecolumn for one. So it represents delta ofB and one, that is the transition that youmake from state B when you get input one.And you can see on the, well, here at theautomaton, if you're in state B and yousee a one, you go to state C. So that'swhy the entry there is a C. Okay, nowwe're gonna use a convention which isactually very important because it remindsyou of the types of things that mightotherwise be confusing. That is, we willuse lower case letters near the end of thealphabet; w, x, y, z and maybe uoccasionally to represent strings of inputsymbols. On the other hand, letters at thebeginning of the alphabet, typically A, Bor C will represent single input symbols,remember these are analogous, to,characters in a language like java or, orC. Now, The delta function was defined yougive it, you give it a, a state, and yougive it a single input symbol. We want toextend it so that you can give thefunction a, an argument that's a state andanother argument that's any string ofsymbols including the empty string. Okay,and we want the extended delta applied tostate Q and any string W to tell us wherethe automaton get to, if follows the pathof the transition diagram from Q, wherethe arcs are labeled by each of thesymbols of W in order That is we look forthe unique path who's labels form W. Inthe text we put a hat over the delta toremind us that it is the extended version.However, as we are going to see veryshortly the extended delta agrees with thegiven delta when the string W is of lengthone. That is, when it's a single symbol.Thus there's not really a need todistinguish the extended and the originaldeltas and we're not going to do thathere. Now the, extended delta is definedinductively, that is it's an induction onthe length of the string. The basis saysthat delta of Q and the empty string isjust Q. That is, if you're in state Q andnothing arrives in the input then you'regonna stay in state Q. That's the natureof how an automaton works. For theinduction, suppose the input string is WA.Okay, now remember our convention,whenever you see something like WA youknow that W is a string of some length,could be empty even but it is a string.And A being at the beginning of thealphabet is a single symbol. Okay, this issort of the mathematical analog of typedefinitions of program variables. Now, theinductive rule says that, we first seewhere you get, where you get from state Qon string of inputs W. That is, we'regoing to recursively use the extendeddelta to figure out what delta of Q and Wis. And then that is going to be somestate. I dunno what it is, P. Then weapply the original delta function to deltaof that state. And put, the last inputsymbol A. Okay so here is an example I amusing the, transition, table,representation of the, same automaton wehave been playing with. Okay. I want tofigure out what the extended delta is fromstate B and 011. Now, 011 is broken upinto a string that is 01 and a finalsymbol one. Okay. So what that tells us todo is figure out what delta of being 01 isthat that's the string everything but thelast symbol. And then apply the originaldelta function to that string and the lastsymbol one Now, what's delta of B and zeroone. Well, it's a string and anothersymbol. So I can break that up using therecursive rule to say that it's the delta,the standard delta function applied todelta of D and zero and the final symbolone. And then, okay. Now I know what deltaB and zero is, I can look it up. Oh, here,B and zero is A. So I can replace this byan A. That's what I have here. Okay. Now,I know what delta of A and one is. I'lllook it up A, one that's B. Okay. So Ireplace that by B. And now what's delta ofB and one? It's C. That's, that's that. AsI mentioned, the extended delta wears ahat in the text book. However we reallydon't need to distinguish the two deltasbecause they agree on the single symbols.That is, if we want the extended delta fora state Q and a string consisting of onesymbol A, formally we treat that string asthe empty string followed by the symbol A.Then we have to compute delta hat of Q andepsilon. That's, what we have done here.But we know by the basis rule that that'sQ itself and therefore, the extended deltaof Q and A is just the original deltaapplied to Q and A. In fact I reallycheated on the previous slide. I neededdelta hat of B and zero and I just went tothe table and looked it up as if it wasdelta of B and zero. Now we see that it isso there was no harm, no foul. There aremany different kinds of automata. We'veseen only the deterministic [inaudible] ofautomata so far. But there are manyothers. But no matter what kind ofautomaton, its job is to define somelanguage. We'll use the notation L of A torefer to the language defined by theautomaton A. If A is a deterministicfinite automaton, then the language itdefines is the set of strings to take thestart state to a final state. That is,your zero is as high as the star[inaudible] and set of strings That getyou to a final state. Okay, formally thatwas defined that the language of A is theset of strings W such that delta of Q zeroand W is in F. Okay, so, here's anexample, string 101 is in the language ofrunning DFA. We start in the start stateright here. We follow the first one. That,that's a string. From B we follow the zerothat gets back to A. From A we follow thethird one, the third addition, which is aone getting us to B, B is an acceptingstate so 101 is in the language. Thatmakes sense given that the lang-, theautomaton is supposed to accept thelanguage of all strings that don't havetwo consecutive 1s and obviously 101 doesnot. Okay, the expression, this expressionIt is called the set former. It startswith a curly brace and then an expressionrepresenting the things that we want toput in the set. So, in this case, theexpression simply says that the setconsists of some string's W. We know againthat they're strings because of ourconvention. That, that the letters at theend of the alphabet represent strings. Thevertical bar can be read such that Andthen there will follow a description ofwhat must be true for something to be amember of the set. In this case, it'ssaying that W is, binary string that it'sin, it's in the strings over alphabet zeroone. And W does not have two consecutiveones. That that's what I've been tellingyou all along the language of thisautomaton was. We're going to prove thatthe DFA that we've been playing withaccepts the language I claimed it does: aset of binary strings without consecutiveones. I'm going to spend a good deal oftime proving this simple result because itwill give you all the details about howone proves something about languages. Inthe future I'm not going to be so focusedon proofs, but I think it's important thateveryone go through one of these proofs inall of its gory detail. To prove setsequal we generally mean to just prove twothings, that each is contained in theother. That is we stop by assuming W is amember of one so as and we use that factto prove that W is in the other too. Thenwe start all over and we assume that W isin two. We use that to prove W is also inS In what follows, we take S to be the DFAthat we've been playing with and T to bethe set of binary strings withoutconsecutive 1s. First, we're going toprove that if W is accepted by theautomaton, then W has no one ones and theproof is an induction on the length of W.It turns out that if we simply try toprove this statement we fail. And I'llpoint out in a few slides what goes wrong.A common trick for inductive proofs is tomake a more detailed statement than youreally want because it makes the inductiveproof work. Here you need to distinguishwhether an accepted string gets you tostate A or B because we need to knowwhether or not the string ends in one eventhough the conclusion no one ones is truein both the states A and B. The inductivehypothesis will have two parts. Okay, partone says that if W gets you to state Athen not only is W good in the sense thatit doesn't have consecutive 1s but itdoesn't even end in one Part two says thatif W gets you to state B, then W is stillgood but it must end in one. Okay. Thebasis is when the length of W is zero,that is W is the empty string. By the waynotice that the bars around the stringrepresent the, that we want the length ofthat string. So bar W bar means length ofW. Now let us prove part one of the basis.Delta of A and the empty string does equalA so if part is true but the conclusion isalso true because the empty stringobviously does not have executive 1s anddoes not end in one. For part two, thethings are a little trickier. It is falsethat delta of A and the empty stringequals B, but unfortunately it is alsofalse that the empty string ends in asingle one. Okay, however an importantprinciple of logic is that the statementfalse implies false is true. That is,whenever the if portion of the statementis false it doesn't matter whether thethen, portion is true or not. Thestatement as a whole is true. Thus astatement like, 'if I am superman, then Iwear red undershorts' is a true statementsimply because I am not superman. Youdon't have to concern yourself with thecolor of my undershorts. The mathematicalterm for an if then statement that is truebecause it is the [inaudible], [inaudible]is that the statement holds vacuously. Tobegin the proof of the inductus step weassume W is a string of length of at leastone and we assume that the inductor hasopposites that is statements one and twoof that string that gets the automaton tostage A and B. It's true that [inaudible]shorter than W Let W equal XA by ourconvention A is the last symbol of W and Xis all the symbols, possibly none, up tonot including the last symbol of W. SinceX is shorter than W, we assume theinductive hypothesis for X. We're going toimprove both statements one and two for W.[sound] let's start with one. That is ifdelta of A and W is A then W is good anddoes not end in one. How do you get to Aby reading string X followed by symbol A?Well look at the diagram. The onlytransitions into A Are on input zero, thatis they're here and here. So A must bezero. That immediately lets us concludethe unit does not end in one. Furthermorethese transitions to A are only from A andB. Thus X must get us to either A or B. Ineither case we can conclude using theinductive hypothesis that X is good it hasno consecutive 1s. Thus W has no one noconsecutive 1s, and surely does not end inone. Now for part two. If delta of A and Wis B, then W is good and ends in one. Nowthere is only one way to get B. You haveto be in state A and the input has to bein one. That is this transition righthere. Thus if W is X followed by A. Thenwe know X gets us to state A and the, theinput symbol little a is one. We cantherefore conclude that W ends in one. Nowwe imply the inductive hypothesis, to Xand we conclude that X not only has noconsecutive 1's, but it doesn't end in onebecause it got us to state A. Thus thefact that W is X followed by A doesn'tallow the possibility that W ends ineleven. And since any occurrence of one,one and W, would either have to be at theend or lie completely with an X weconclude that W does not have anyconsecutive ones. Notice that if we go anduse this more complicated inductivehypothesis where we distinguish betweenstates A and B according to whether thestring ends in one, string X ends in one,then we can not make the inductive proof.If we know only that X gets us to A or Bif it's good, then it might end in one andget us to state A in which case W equalsXA would have two consecutive 1s and yetget us to B. That therefore we would notbe able to push though inductivehypothesis that didn't distinguish betweenwhether we get to state A or B. [sound]Well we're not done. We still have toprove that T is contained in S, that is ifW is a good strength, no consecutive onesthen it's accepted by the automaton. It ishelpful to restate what we need to provein it's contra-positive form which islogically equivalent to the original. Thecontra positive of an if then statementsay if X then Y is if not Y then not X. Wecan see why this is an equivalentstatement since if Y is false it couldn'tbe that X is true because whenever X istrue Y is true. In this case X is thestatement that W is a good string. That isit has no 11s. And, and Y is the statementthat W is accepted by the automaton. Thecontra-positive is that if W is notaccepted by the automaton then W is not agood strength that is it contains one, oneas a sub string. Because there is anunique transition from every state andevery input symbol, each W gets the, DFAto exactly one state. Thus the only way Wis not accepted is if it gets you to C.Notice that the only way to get theautomaton to see it, is for some string Xto get it to B. That is, that is here. Andthen from input one to follow. Once in C,you stay in C so anything can follow the Xand the one. We'll call that Y, that isany string W that gets the automaton tosee must be of the form X one Y where Xgets us to B. [sound] We already observedthat the only way to get to B is by astring that ends in one. Since the onlytransition into B is on a one. That'sthis. Thus X must be of the form Z1 forsome Z. Thus W can be written as Z11Y andwe conclude that delta of A and W if W ...Sorry. We can conclude that if delta of Aand W is C then W is bad. That is itdefinitely contains two consecutive ones.Now we introduce a class of languagescalled regular languages. These are thelanguages that have a DFA accepting them.That means that the languages exactly theset of strings accepted by this automaton.Soon we shall see that there are severalother ways to describe the regularlanguages including the regularexpressions and several forms of nondeterministic automaton. [inaudible] Whilemany common languages are regular thereare also many that are not. Intuitively[inaudible] automaton cannot count beyonda fixed number thus they cannot do thingslike check whether it has seen the samenumber of zeros as ones on the input orcheck the parentheses are balanced and arearithmetic expression. For these tasks weneed more powerful mechanisms such ascontext free grammars which we shall meetsoon enough. Here is an example of alanguage that is simple to understand butis not a regular language. To understandwhat this notation is saying we first needto know that at exponent I and a symbol isshorthand for the string consisting ofhigh copies of that symbol. Thus zero tothe fourth is a shorthand for zero, zero,zero, zero. We read the [inaudible] fromher that is as zero to the N one to the Nsuch that N is greater than or equal toone or more [inaudible]. The set ofstrings consisting of N zeros followed byN ones such that n is at least one. Thestrings in the language L1 are thus 010011 three zeros followed by three onesand so on you get the pattern alright.[sound] Okay here's another example theset of W such that W is in the set ofstrings formed by the left and rightparentheses and W is balanced. Okay I hopepeople are familiar with the idea ofbalanced parentheses, but intuitivelythey're just those sequences ofparentheses that can appear in somearithmetic expression. For example thisstring could appear in an arithmeticexpression like A plus B times C plus D,notice you've got left, right, left,right. Okay. An example of strings thatare not balanced, well, right then leftis, is obviously not balanced. You can'thave, ever have in any prefix of thestring more right parenthesis than youhave left parentheses. Another example ofa non-balanced string would be left, left,right, because there you have more, leftsthan rights. However regular languages arecommon. For example in each language thereis a format for floating point numbers andthis format can be quite complicated withoptional E's and or optional decimalpoints and strings of digits that could orcould not be empty. But in all programminglanguages I know about the set of stringsthat represent some floating point numberforms a regular language. Okay. This is avery interesting case illustrating whatfinite memory really means. We want toknow if a binary number is divisible bytwenty three. We're going to read the bitshigh order first, but we have only finitememory. How can we remember exactly whatsequence of bits has been read since thesequence can grow very long and inparticular longer than the number ofstates or longer than any limit that youmight care to put on it. Okay. But there'sa trick. We don't really need to remembereverything about the bits read. It'ssufficient to remember what the remainderis. When we divide the number by twentythree. Thus, we're gonna have twenty threestates, corresponding with the twentythree possible remainders when an integeris divided by twenty three. These are ofcourse zero through twenty two. The startstate is zero because we interpret anempty string as representing zero. Thatmay be a bit of an assumption, but nothingelse makes sense and treating it as zeromakes everything work out right. The statezero is also the only final state since wewant the inputs that leave a, that leave aremainder of zero when divided by twentythree. We're going to assume that thingsare working right after reading a binarystring W. That is W takes state zero tothe state that is the correct remainderwhen W is divided by twenty three. I'musing the C style percent operator todenote remainder. You can also read thepercent as modulo, which is just anotherway of saying the remainder when dividedby. Okay? So, I percent twenty three isthe remainder when I is divided by twentythree or I modulo twenty three. Thetransition from each state I on input zerois to the state that is the remainder of2I divided by twenty three. To see whythis works, we know that I is, can, let'ssee can be written as I equals twentythr-, sorry, twenty three A plus B forsome integer A and some integer B that'sin the range zero to twenty two. That is Bis the remainder or I modulo twenty three.Okay. Then two I is what? It's, well it'sforty six A plus two B. Since forty six isdivisible by twenty three we can sort offorget it, okay, so what we have, what wehave left is that two I is two B. Okay.Now if we want the remainder, of two Iwhen I is divided by twenty three, we canjust take the remainder of two B dividedby twenty three. The important point isthat we never need to know what A is andwe never need to know I exactly. We justneed to know its remainder. Now, for thesame reason, when a one arrives in theinput we can go from state I to the statethat is the remainder of two I plus one,when that's divided by twenty three.That's two I plus one mod-, modulo twentythree. For some examples, delta of fifteenand a zero, that's state fifteen and inputzero, double the fifteen you get thirtyand then you take the remainder of thirty,divided by twenty three and that's seven.On, in, but zero state fifteen goes tostate seven. For another example, ifyou're in state eleven and a one comes in.Well, twice eleven is twenty two plus oneis twenty three. So it's twenty three modtwenty three which is zero. So that sayswhenever you're in state eleven and a onecomes in, you go to state zero. And whatthat means is that any string that leavesa remainder of eleven no matter how longthat string is if it leaves a remainder ofeleven you follow it by a one, it will beexactly divisible, divisible by 23.Interestingly you can also recognize allthe binary strings divisible by 23 or anyother particular number if we like. If we[inaudible] the strings in backwards thatis [inaudible] first for example thisstring zero one, one, one, zero one zero,zero is in the, this language because ifyou reverse it you get this string: zero,zero one, zero one, one zero. And if youconvert that to binary you get forty sixand obviously forty six is divisible bytwenty three. Now, I challenge you toconstruct the DFA for this language Lfour, but it exists. Okay. There's atheorem which we're soon going to see thatsays if a language is regular than itsreversal, that is what you get byreversing each of its strings, is also aregular language. The proof of the theoremwill let us construct the DFA for thereverse language from the DFA we just saw.