Models of Computation: Automata and Processes. J.C.M. Baeten

Size: px
Start display at page:

Download "Models of Computation: Automata and Processes. J.C.M. Baeten"

Transcription

1 Models of Computtion: Automt nd Processes J.C.M. Beten Jnury 4, 2010

2 ii

3 Prefce Computer science is the study of discrete ehviour of intercting informtion processing gents. Here, ehviour is the centrl notion. Computer science is out processes, things hppening over time. We re concerned with n gent tht is executing ctions, tking input, emitting output, communicting with other gents. Moreover, this ehviour is discrete, tkes plce t seprte moments in time, nd we cn oserve seprte things hppening consecutively. Continuous ehviour is treted y dynmics or mechnics in physics, nd does not elong to computer science. (However, when we tlk out softwre control of mchine, the interply of continuous ehviour nd discrete ehviour ecomes importnt.) Thus, the study of nlog computers is no prt of computer science. An gent is simply n entity tht cn ct. Primrily, we think of computer executing piece of softwre, ut n gent cn lso e humn eing when we consider his (her) ehviour discretely. Techniques from computer science re incresingly pplied in systems iology, where we consider ehviour of living cell or components of cell. Also, n orgnistion or prts of n orgnistion cn e considered s gents, for instnce in workflow. In mechnicl engineering, the ehviour of mchine cn e modeled discretely. The study of components of n gent, their structure nd their design cn lso e considered prt of computer science. Interction is lso centrl notion in computer science. Agents interct mongst themselves, nd interct with the outside world. Usully, computer is not stnd-lone, with limited interction with the user, executing tch process, ut is lwys connected to other devices nd the world wide we. Informtion is the stuff of computer science, the things tht re processed, trnsformed, sent round. Given this definition of computer science, we cn explin fmilir notions in terms of it. A computer progrm is prescription of ehviour, y trnsformtion it cn generte specific ehviour. An lgorithm is description of ehviour. In this ook, we will give much more precise definition of wht n lgorithm is. Computtion refers to sequentil ehviour, not considering interction. Also this notion will e explined much more precisely here. Communiction is interction with informtion exchnge. Dt is mnifesttion of informtion. Intelligence hs to do with comprison etween different gents, in prticulr etween humn eing nd computer. This ook is n introduction to the foundtions of computer science, suitle for teching in ny undergrdute progrm in computer science or relted fields. It studies discrete ehviour, oth with nd without tking interction into ccount. It presents n strct model of discrete ehviour, clled n uiii

4 iv tomton or trnsition system. An strct model is mthemticl structure tht cptures the essentil fetures, leving out ll irrelevnt detil. A more elorte strct model is tht of the Turing mchine. This model provides us with the notion of computility nd the notion of n lgorithm. These re centrl notions in computer science: prolem clss tht is computle cn in principle e clculted y computer, provided certin limittions on speed nd memory re met; on the other hnd, prolem clss tht is non-computle cn never e solved on ny computer, no mtter how fst it is or how much memory it hs. Thus, we cn ssert wht computer cn do. More importntly, we cn ssert wht computer cnnot do. The clssicl Turing mchine model hs n importnt drwck: it does not consider interction. Thus, computer is studied s stnd-lone mchine, with no connections to other computers nd the world, nd computer progrm cn e seen s function tht trnsforms input into output. Adding interction leds to modifiction of Turing mchine, the so-clled Interctive Turing mchine. Alongside the notion of computle function, this gives us the notion of n executle process. Importnt notions: forml lnguge nd communicting process, utomton nd trnsition system, lnguge equivlence nd isimultion, grmmr nd recursive specifiction, Turing mchine, Chomsky hierrchy. Min references for the prt out forml lnguges nd utomt theory re [10], [9] [14] nd [1], min reference for the prt out process theory is [2] (see lso [11], ut lso older textooks [8], [12] cn e consulted). More specilized references re [3], [13], [4], [6], [7], [5].

5 Contents 1 Introduction 1 2 Finite Automt Automt nd lnguges Automt nd processes Bisimultion Recursive specifictions Deterministic utomt Automt with silent steps Brnching isimultion Identifying non-regulr lnguges Extending the Alger Sequentil Composition Itertion Interction Mutul exclusion protocol Alternting it protocol Push-Down Automt Push-down lnguges nd processes Recursive specifictions over SA Prsing nd miguity Simplifiction of specifictions nd norml forms Push-down nd context-free Push-down processes Identifying lnguges tht re not push-down Properties of push-down lnguges nd processes Computility nd Executility The Turing mchine Church-Turing thesis Other types of Turing mchines An undecidle prolem Executle processes v

6 vi CONTENTS

7 Chpter 1 Introduction Wht mkes something computer? When do we cll something computer? Well, color, size nd rnd do not mtter. Nor is it importnt whether it hs monitor, mouse or keyord. Externl World Finite Control Memory Figure 1.1: Astrct model of computer. Figure 1.1 presents n strct model of computer. It contins the following ingredients: 1. A finite control. A computer is in essence discrete: it evolves not y continuous chnge long trjectory (s physicl phenomenon), ut y discrete chnge from one stte to the next. Thus, the control hs finite numer of sttes, modes it cn e in. Ech time the computer does something, performs n elementry ction or instruction, it cn chnge stte, go from given stte to nother stte (or the sme stte). The control my e finite, ut not priori ounded: we cn ssume we hve s mny sttes s necessry in order to tckle given prolem. 2. The memory is fcility where things cn e put nd retrieved. There re lwys finite numer of things in memory, ut the memory is not ounded: there is lwys room to put more things, if this is needed. 3. The control nd the memory interct, cn exchnge informtion. The control cn store something in the memory, nd cn retrieve something from the memory. 4. The control intercts with the externl world. This externl world is not prt of the computer, nd includes user, other computers, the world wide we. From the externl world, something cn e input into the computer, nd from the computer, something cn e output to the externl world. 1

8 2 CHAPTER 1. INTRODUCTION Severl times in this enumertion, the notion of thing, n ction, instruction or dtum, piece of informtion is used, the stuff tht is sent round etween different prties. We do not specify wht this stuff is exctly, ut just ssume throughout some given non-empty finite set A clled the lphet, which is not further specified. In similr vein, we ssume given non-empty finite set of sttes clled S. The set of sttes contins n initil stte, the stte t strtup, nd suset of finl sttes, where termintion cn tke plce. A finite control over given lphet nd given set of sttes with n initil stte nd set of finl sttes is clled finite (non-deterministic) utomton. The memory will e modeled y prticulr process, the Turing tpe. The tpe holds sequence of things clled dt, nd t every moment is ctive t n element of the sequence, the focus. At the focus, the dtum cn e output or new dtum cn e input, or the focus cn shift one element to the right or left. Now the strct model to e considered in this ook is the model of the Interctive Turing mchine: there is finite control denoted s n utomton, intercting with the externl world, nd memory denoted s Turing tpe, intercting with the control. Schemticlly, this is presented in Figure 1.2. Automton Tpe Figure 1.2: Interctive Turing mchine. This is the model tht concerns the prt of this ook out processes. In the prt out forml lnguges, we simplify this picture even further. We do this y hiding the notion of interction. First, we limit the interction with the externl world y only llowing input t the initil stte, nd only llowing output t finl stte. This mens we consider the computer s stnd-lone device, tht does not interct with the externl world during computtion. We consider the computer s device tht trnsforms input into output, function from input to output. Thus, we hve tch process such s they existed efore the dvent of the terminl. Finlly, we still hve the interction with the memory, ut will hide this interction in our description. Due to these limittions, it is possile to ssume tht input nd output consist of finite sequence of ctions or dt, string. The content of the memory will lso e string of ctions t ny given time (ut it cn grow or shrink over time). This leds to the strct model of Figure 1.3, which is clled the clssicl Turing mchine. When interction is involved, this picture of seprting input nd output is not dequte ny longer. Consider n irline reservtion system. It is not the cse tht user intercting with this system will hve series of ctions redy t the strt of the interction, rther, the user will hve n initil ction, the system responds with wepge contining numer of choices, the user will select numer of options, the system rects, etc. This mens series of

9 3 Input Automton Output Tpe Figure 1.3: Clssicl Turing mchine. ctions s input eventully leding to series of ctions s output is not dequte to descrie this interction. In prticulr, the irline reservtion system my not hve finl nswer, it my e lwys on. Thus, it is importnt to keep informtion out ctions, even when these ctions do not led to finl stte. Moreover, it is lso importnt to keep trck of the moments of choice pssed in the course of the interction. Therefore, considering interction, we will use the interctive Turing mchine rther thn the clssicl Turing mchine. In the next chpter, we simplify Figures 1.2 nd 1.3 even further, y leving out the memory ltogether. We use the following nottions: elements of A re denoted with lower cse letters from the eginning of the lphet,, c,.... A finite sequence of elements of A is clled string or word nd denoted y juxtposition, so e.g. nd c re strings. If w, v re two strings, then wv is the conctention of the two strings, the string consisting of w followed y v, so if w = nd v = c then wv = c. The empty string consisting of no letters is denoted ε, nd the set of ll strings is denoted A. This set cn e inductively defined s follows: 1. (sis) ε A, the empty string is string; 2. (step) For ll A nd ll w A, the string tht strts with nd follows with the string w is string, w A. Every string cn e mde in this wy, strting from the empty string, nd ech time dding one element of A in the front. Adding n element of A in front of string is clled prefixing the string with this element. Insted of ε, we often write just for the string consisting of just the letter. Conctention is inductively defined s follows: 1. If w = ε, then wv = v; 2. If w = w, then wv = (w v). A suset L of A is clled lnguge. The length of string is the numer of elements it contins, nd is defined inductively s follows: 1. ε = 0; 2. For ll w A nd A we hve w = w + 1. A string v is prefix of string w iff there is string u such tht vu = w, nd v is sustring of w iff there re strings u, x such tht xvu = w. The numer of s in w, # (w), cn gin e defined inductively:

10 4 CHAPTER 1. INTRODUCTION 1. # (ε) = 0; 2. For ll w A we hve # (w) = # (w) if, A,, nd # (w) = # (w) + 1. The reverse of string w, denoted w R is the string red ckwrds. Defined inductively: 1. ε R = ε; 2. For ll w A nd A we hve (w) R = (w R ) (the conctention of string w R nd string ). Exercises Prove y induction on u tht for ll strings u, v A we hve uv = u + v Define for string u A nd nturl numer n the power u n y induction on n: () u 0 = ε; () u n+1 = uu n. Use induction on n to show tht u n = n u for ll u A nd n Prove tht (uv) R = v R u R for ll strings u, v A. Also, prove (w R ) R = w for ll strings w A The set of strings {w} consists of the string w repeted n ritrry numer of times n (n 0). Prove {} = { n n 0}. Find four elements of {}.

11 Chpter 2 Finite Automt 2.1 Automt nd lnguges Strting from the strct model of the Turing mchine in the previous chpter, we remove the memory nd the interction with the memory, nd we just hve finite control tht trnsforms the input (n element of A ) into output (gin, n element of A ). We mke one further simplifiction: we limit the set of outputs to yes or no. If certin input string leds to yes, we sy the mchine ccepts the string. See Figure 2.1. Input Automton yes/no Figure 2.1: Astrct model of n utomton. An utomton hs given set of sttes S, given lphet A, trnsition reltion tht explins how to get from one stte to the next stte, n initil stte nd set of finl sttes. Definition 2.1 (Automton). An utomton M is quintuple (S, A,,, ) where: 1. S is finite set of sttes, 2. A is finite lphet, 3. S A S is the set of trnsitions or steps, 4. S is the initil stte, 5. S is the set of finl sttes. If (s,, t), we write s t, nd this mens tht the mchine, when it is in stte s, cn consume input symol nd therey move to stte t. If s is finl stte, s, we write s. Writing s, t mens tht oth s t nd s t. 5

12 6 CHAPTER 2. FINITE AUTOMATA Notice tht it is possile tht there re sttes s, t, u S nd A with s t nd s u nd t u. Occurrence of this is clled non-determinism. It mens tht from given stte, consuming my led to different sttes, the outcome is not determined. It reflects uncertinty out the exct circumstnces of step, or hiding of the detils of determintion (just like the input of string into serch engine will never give the sme nswer). Notice tht etween two given sttes, there is t most one step with lel, such step either exists or not. Exmple 2.2. Let us consider n exmple. The utomton in Figure 2.2 hs the initil stte leled y smll incoming rrow, nd the finl sttes leled y smll outgoing rrows. All trnsitions re leled y A. Notice tht nmes of sttes re often not given s they cnnot e oserved. We will consider two utomt tht only differ in the nming of sttes or the lyout to e the sme. Stted formlly, we sy we consider isomorphic utomt to e the sme. We will not define isomorphism on utomt, insted, we will ddress more extensively when two utomt re considered the sme in the next section. Notice tht from the initil stte, there re two different outgoing trnsitions with the sme lel, which mens there is non-determinism: executing from the initil stte my led to two different sttes. Notice tht the stte on the ottom right cn never e reched from the initil stte y executing trnsitions. Such stte, nd its ttched trnsitions, will e clled unrechle. Unrechle sttes nd trnsitions will not ply role in the following considertions. Figure 2.2: Exmple utomton. We mke precise the notion of rechle stte in n utomton. Definition 2.3. Let utomton M = (S, A,,, ) e given. We generlize the trnsition reltion to pths, y n inductive definition. Let w A e string, nd s, t S. Then s w t denotes pth from s to t with lel w, nd s w t holds exctly when it cn e derived y mens of the following cluses: 1. For ll s S, we hve s ε s; 2. For ll s, t, u S, if s t nd t w u, then s w u. If there is pth from s to t, we sy t is rechle from s, nd write s t. A stte s is rechle in M iff s.

13 2.1. AUTOMATA AND LANGUAGES 7 For exmple, in the utomton shown in Figure 2.2, if s is the finl stte on the top right, then s, nd if t is the finl stte on the ottom, then t, t, etc. In generl, n t for every even n > 0. If we hve given certin utomton, then it will ccept those input strings for which there is pth from the initil stte to finl stte with this series of letters s lels, consecutively. So the utomton in Figure 2.2 ccepts the strings nd n for every even n > 0, nd no others, so the set of strings { n n > 0, n is even or n = 3}. We mke this precise in the following definition. Definition 2.4. The utomton M ccepts the string w, if there is stte s S with w s nd s. In this cse we lso sy the pth from to s is trce of M. Finlly, the lnguge of M is the set of ll strings ccepted y M, L(M) = {w A s S : w s, s }. A consequence of this definition is tht if string w is not in the lnguge of n utomton M, then it holds tht whenever w is the lel of pth of the utomton, then either it does not strt from the initil stte or it does not end in finl stte. But it cn lso hppen tht w is not the lel of ny pth of the utomton. Exmple 2.5. We give nother exmple. Consider the utomton M in Figure 2.3. Then its lnguge is L(M) = { n n 0}. In the initil stte, the ction cn e executed n ritrry numer of times, remining in the sme stte, until t some time the edge leled is tken to the finl stte. The right-most edge, leled, hs no influence on the lnguge t ll, since tking it cn never led to finl stte. The right-most stte is so-clled dedlock stte, where no ctivity whtsoever is possile. Figure 2.3: L = { n n 0}. Thus, given n utomton, we cn determine its lnguge. It is lso interesting to consider the reverse direction: given lnguge, find n utomton tht ccepts this lnguge. We strt with simple exmple. Exmple 2.6. Consider the set of ll strings over A = {, } tht strt with the prefix. To find n utomton tht ccepts this lnguge, just mke pth from the initil stte to finl stte with lel. Upon reching this finl stte, llow ny step, i.e., dd step with lel nd lel from this stte to itself. See Figure 2.4. Exmple 2.7. To give more complicted exmple, consider the set of ll strings over A = {, }, tht do not contin sustring, so L = {w A is not sustring of w}. To egin with, trce out the string from the initil stte, ut now mke ll the sttes except the right-most stte finl sttes,

14 8 CHAPTER 2. FINITE AUTOMATA Figure 2.4: L = {w A prefix of w}. see Figure 2.5. The left-most stte denotes the stte where no initil prt of string possily leding to hs occurred. There, ny numer of s cn tke plce, ut s soon s one occurs, we move one stte to the right. There, executing cnnot led to the string ny longer, so we move left gin, ut executing n leds to stte where two consecutive s hve occurred. There, executing leds to dedlock (the -step could lso hve een left out), ut executing n dditionl mkes no difference: still, two consecutive s hve occurred, nd the next step cnnot e. Figure 2.5: L = {w A is not sustring of w}. Thus, we see tht for numer of lnguges, we cn find n utomton tht ccepts this lnguge. However, this is y no mens true for ll lnguges, there is only very limited numer of things tht cn e done y computer without memory. One thing tht computer without memory cnnot do is counting. We illustrte this s follows. Tke the lphet A = {, } nd consider L = { n n n 0}. We cn drw picture for this lnguge s shown in Figure 2.6. Notice tht the initil stte is lso finl stte. This system cn tke in ny numer of s, rememer how mny s it hs received, nd then count off just s mny s. Thus, it cn check whether the numer of s nd the numer of s is the sme, it cn compre quntities. As it cn rememer ny given numer, we cn cll this mchine simple counter. Notice tht this is not n utomton, s the numer of sttes is infinite. We cll system tht is like n utomton, ut my hve infinitely mny sttes trnsition system. We clim there is no utomton tht ccepts this lnguge. Theorem 2.8. Let L = { n n n 0}. There is no utomton tht ccepts L. Proof. Proof y contrdiction, so suppose there is n utomton M = (S, A,,, ) tht ccepts L. Then for ech n 0, there is pth in M from to finl stte with lel n n. Fix such pth for ech n, nd cll s n the stte this pth

15 2.1. AUTOMATA AND LANGUAGES 9 Figure 2.6: Simple counter. is in fter the s nd efore the s. This gives us sttes s 0, s 1,..., s n,... in S. Since S is finite, t lest two of these sttes must e the sme, sy s k = s m for certin k m. Then there is pth with lel k from to s k nd pth with lel m from s m to finl stte, from which it follows tht there is pth with lel k m from to finl stte, nd k m is ccepted y M. This is contrdiction, so such n utomton M cnnot exist. Lter on, we will present more generl technique in order to prove tht some lnguge is not ccepted y ny utomton. Definition 2.9. Let L A e lnguge. L is clled regulr iff there is n utomton M tht ccepts L. If two utomt M, M ccept the sme lnguge, L(M) = L(M ), we sy the utomt re lnguge equivlent, nd write M M. The theorem ove implies tht L = { n n n 0} is not regulr. Erlier, we sw exmples of lnguges tht re regulr. It will turn out tht the set of regulr lnguges is very limited, or, stted differently, computers without memory cnnot do much. Lnguge equivlence is indeed n equivlence reltion. Theorem Lnguge equivlence is n equivlence reltion on utomt. Proof. 1. Reflexivity: M M s L(M) = L(M), so we hve reflexivity for every utomton M. 2. Symmetry: if M M for two utomt M, M, then their lnguges re the sme, so lso M M, nd we hve symmetry. 3. Trnsitivity: if M M nd M M, then L(M) = L(M ) nd L(M ) = L(M ), so L(M) = L(M ), which implies M M so we hve trnsitivity. Exmple Mny rel-life processes cn e conveniently modeled y n utomton. A university tht orgnises colloquium could drw the following utomton for its internl process, see Figure 2.7. Registrtion strts y the receipt of filled-in weform. It is checked whether or not this weform hs ll the necessry informtion. If it does not, the customer is sked to complete the

16 10 CHAPTER 2. FINITE AUTOMATA form. If it does, it is checked whether or not the registrtion hs VIP-code. If it does, the registrtion is complete nd n invittion is sent. If it does not, the customer hs to pye150 efore the erly registrtion dedline, nde195 fter this dte. When the money is received, code is sent to the customer nd n invittion is sent. sktocomplete not complete rec.weform complete sendinvite VIPcode nocode sendcode e195 e150 fterdte eforedte Figure 2.7: Registrtion process. Exmple The control flow of progrm cn e modeled s n utomton. Consider the following PASCAL progrm to clculte fctorils: PROGRAM fctoril(input,output); VAR i, n, f: 0..mxint; BEGIN red(n); i := 0; f := 1; WHILE i < n DO BEGIN i := i + 1; f := f * i END; write(f) END The control flow of this progrm cn e modeled s n utomton s shown in Figure 2.8. Exercises Let A = {, }. Construct utomt tht ccept exctly:

17 Exercises 11 red(n) i:=0 f:=1 f:=f*i i>=n i<n write(f) i:=i+1 Figure 2.8: PASCAL progrm. () ll strings with exctly one ; () ll strings with t lest one ; (c) ll strings with t most one ; (d) ll strings with no more thn three s; (e) ll strings with t lest two s nd t most two s Let A = {, }. Construct n utomton for ech of the following lnguges: () The lnguge of ll strings in which ech occurrence of is immeditely followed y n occurrence of ; () The lnguge of ll strings in which ech mximl -sustring hs even length; (c) The lnguge of ll strings in which oth nd do not occur s sustrings; (d) The lnguge of ll strings in which the numer of s is even nd the numer of s is odd; (e) The lnguge of ll strings in which neither nor occur s sustring; (f) The lnguge of ll strings where the numer of s nd twice the numer of s is divisile y 5; (g) L = { n m n 3 m}, i.e., the lnguge of ll strings of the form n m where n nd m re equl modulo Give n utomton for the following lnguges: () L = {w w {, } }; () L = { n m n 2, m 3}; (c) L = {uv u, v {, } } Find n utomton for the following lnguges, A = {, }: () L = {w w mod 3 = 0}; () L = {w # (w) mod 3 = 0}: (c) L = {w # (w) # (w) > 1}:

18 12 CHAPTER 2. FINITE AUTOMATA Give n utomton for the lnguge of ll strings over {,, c} where the first precedes the first or the first precedes the first Consider the set of ll strings on {0, 1} defined y the requirements elow. For ech, construct n ccepting utomton. () Every 00 is immeditely followed y 1. Thus, strings 0001 or re not in the set. () All strings contining 00 ut not 000. (c) All strings of which the leftmost symol differs from the rightmost symol. (d) All strings tht contin two consecutive identicl symols, ut never three consecutive identicl symols Give n utomton tht ccepts the lnguge tht contins ll strings representing floting point numers. Assume the following syntx for floting point numers. A floting point numer is n optionl sign, followed y deciml numer followed y n optionl exponent. A deciml numer my e of the form x or x.y where x nd y re nonempty strings of deciml digits. An exponent egins with E nd is followed y n optionl sign nd then n integer. An integer is nonempty string of deciml digits. Mke sure tht ny superfluous leding 0 s re not llowed. E.g., the string 007 should not e llowed Give n utomton tht ccepts ll strings over the lphet {,, c,..., x, y, z} in which the vowels, e, i, o, nd u, occur in lpheticl order. The lnguge should thus ccept strings stemious, fcetious, screligious, nd pple. But it does not contin tencious Give n utomton tht ccepts ll strings over the lphet {,, c, d} such tht t lest one of the symols of this lfet does not occur in the string For ech of the sttements elow, decide whether it is true or flse. If it is true, prove it. If not, give counterexmple. All prts refer to lnguges over the lphet {, }. () If L 1 L 2 nd L 1 is not regulr, then L 2 is not regulr. () If L 1 is regulr, L 2 is not regulr, nd L 1 L 2 is regulr, then L 1 L 2 is not regulr Suppose tht certin progrmming lnguge permits only identifiers tht egin with letter, contin t lest one ut no more thn three digits, nd cn hve ny numer of letters. Give n utomton tht ccepts precisely ll such identifiers In the romn numer system, numers re represented y strings over the lphet {M, D, C, L, X, V, I}. Give n utomton tht ccepts such strings only if they re properly formed romn numers. For simplicity, replce the sutrction convention in which the numer nine is represented y IX with n dditionl equivlent tht uses V IIII insted.

19 Exercises 13 Figure 2.9: Counter Construct n utomton tht ccepts string over {0, 1} if nd only if the vlue of the string, interpreted s inry representtion of n integer, is divisile y Let us define n opertion truncte, which removes the rightmost symol from ny string. The opertion cn e extended to lnguges y truncte(l) = {truncte(w) w L}. Prove tht, in cse L is regulr, lso truncte(l) is regulr Design n utomton with no more thn five sttes tht ccepts the lnguge { n n 0} { n n 0} Find n utomton with three sttes tht ccepts the lnguge { n n 1} { m k m, k 0}. Cn this e done with n utomton with fewer sttes? Show tht the lnguge L = {vwv v, w {, }, v = 1} is regulr Show tht the lnguge L = { n n 0, n 3} is regulr Show tht the lnguge L = { n n is multiple of 3, ut not multiple of 5 } is regulr Suppose the lnguge L is regulr. Show tht L {ε} is regulr Suppose the lnguge L is regulr nd A. Show tht L {} is regulr Suppose M is n utomton with sttes s, t S such tht s vw t. Show tht there is stte u S with s v u nd u w t Suppose we chnge the definition of n utomton so tht more thn one initil stte is llowed. Give this definition formlly. A string w is ccepted y such n utomton if from every initil stte, there is pth with lel w to finl stte. Show tht every lnguge ccepted y such n utomton with multiple initil sttes is regulr Let the lnguge L over lphet A = {, } e defined s follows: L = {w A # (w) = # (w) nd for ll prefixes v of w we hve # (v) # (v)}. This lnguge is sometimes clled the rcket lnguge (to see this, interpret s open rcket, nd s close rcket). Argue tht this lnguge is ccepted y the trnsition system shown in Figure 2.9. This is counter, interpreting s n increment nd s decrement. Show s in the proof of Theorem 2.8, tht this lnguge is not regulr.

20 14 CHAPTER 2. FINITE AUTOMATA 2.2 Automt nd processes In the previous section we looked t n utomton s generting set of strings, lnguge. But widely different utomt cn generte the sme lnguge. Just looking t n utomton s n input-output function, considering the lnguge is sufficient, ut when we consider the model of intercting utomt, more cn e oserved of n utomton. The sic oservtions of n utomton re the execution of n ction ( step..) nd termintion (. ). Automt tht hve the sme oservtions cn e considered to e the sme. But we hve to tke cre in formlising this. First of ll, we lredy stted we do not find the nmes of sttes to e relevnt. Sttes cnnot e oserved directly, they cn only e distinguished y the steps they do or do not llow. Second, ll the rechle sttes of n utomton re relevnt, not just the sttes tht cn led to finl stte. Also steps tht led to dedlock cn e oserved. Third, two sttes tht hve the sme oservtions cn e identified. If there re two sttes tht only llow step followed y step followed y termintion, then there is no oservtion tht cn tell the two sttes prt. The fourth point is the most sutle one. It sttes tht the moment of choice is relevnt. We illustrte with n exmple. Exmple We hve look t Frnk Stockton s story The Ldy or the Tiger? (see [15]). open open open et mrry et mrry Figure 2.10: The ldy or the tiger? A prisoner is confronted with two closed doors. Behind one of the doors is dngerous tiger, nd ehind the other there is eutiful ldy. If the prisoner opens the door hiding the tiger he will e eten. On the other hnd, if he opens the door hiding the eutiful ldy, the ldy nd he will get mrried nd he will e free. Unfortuntely, the prisoner does not know wht hides ehind wht door. This sitution cn e descried s n utomton depicted in Figure 2.10 on the left-hnd side, using the following ctions:

21 2.2. AUTOMATA AND PROCESSES open representing the ct of opening door; 2. et representing the ct of (the tiger) eting the young mn; 3. mrry representing the ct of the eutiful ldy nd the prisoner getting mrried. This utomton models the fct tht fter door hs een opened the prisoner is confronted with either the tiger or the eutiful ldy. He does not hve the possiility to select his fvorite, which conforms to the description ove. Note tht step mrry ends in finl stte, wheres step et does not. This cn e interpreted to men tht the mrry step results in successful termintion of the process, nd tht the et trnsition results in unsuccessful termintion. A non-terminting stte in which no ctions re possile, such s the stte resulting from the et trnsition, is often clled dedlock stte. Now hve look t the right-hnd utomton in Figure As the lefthnd utomton, it hs the lnguge {open.mrry}. However, there re good resons why the sitution modeled y the right utomton of Figure 2.10 is different from the sitution descried y the other utomton. In the right utomton, the choice etween the tiger nd the ldy is only mde fter opening door. It could descrie sitution with only one door leding to oth the tiger nd the ldy; in this cse, the prisoner still hs choice fter opening door. Clerly, this sitution differs considerly from the sitution descried ove. The set of oservtions of the utomt differs: in the left-hnd utomton, step open cn e oserved leding to stte where only the oservtion et is possile, nd step open cn e oserved leding to stte where only the oservtion mrry is possile. On the right-hnd side, there is only the oservtion of step open to stte where oth oservtions et nd mrry re possile. Thus, the middle stte on the right differs from oth middle sttes on the left, s its set of oservtions is different. Thus, if for some reson ction et is impossile, is locked, then the utomton on the left cn ecome stuck fter the execution of n open ction, wheres the one on the right cnnot. The choice whether or not to execute et or mrry in the left utomton is mde (implicitly) upon execution of the open ction in the initil stte, wheres the sme choice is mde only fter execution of the initil open ction in the right utomton. It is sid tht the utomt hve different rnching structure. It is often desirle to e le to distinguish etween utomt with the sme strings of ctions tht hve different termintion ehvior or tht hve different rnching structure. In order to do this, notion of equivlence is defined tht is finer thn lnguge equivlence, in the sense tht it distinguishes utomt ccepting the sme lnguge ut with different termintion ehvior or rnching structure. We will focus on isimultion equivlence. However, there re mny other equivlence reltions in etween lnguge equivlence nd isimultion equivlence, tht could lso serve the purpose. In literture, there is lengthy dete going on s to which equivlence is the right one to use in this sitution. We will not enter this dete, nd just note tht isimultion is the one most used nd most studied, nd isimultion will certinly meet ll the requirements tht we might come up with.

22 16 CHAPTER 2. FINITE AUTOMATA Exercises Give n utomton for trffic light. The ctions re the colours of the trffic light: red,yellow,green. Initilly, the trffic light is red Give n utomton for crossing of two one-wy streets, where ech street hs one trffic light. The ctions involved re red 1,yellow 1,green 1, red 2,yellow 2,green 2. Mke sure tht collisions cnnot occur, ssuming tht drivers respect the trffic lights. Initilly, oth trffic lights re red Give n utomton for n elevtor. The elevtor serves 5 floors numered 0 through 4, strting t floor 0. The ctions re up,down denoting move to the next floor up resp. down Consider stopwtch with two uttons nd one disply. Initilly, the disply is empty. As soon s the strt utton is pressed, the stopwtch strts counting time in seconds from zero up. Pushing the stop utton results in stopping the counting of seconds. After stopping the counting, on the disply the mount of time tht hs elpsed is displyed. Use ctions strt, stop, tick, disply(s) (s nturl numer). Drw trnsition system. Wht hppens when the strt utton is pushed while counting? Cn termintion occur? 2.3 Bisimultion We estlished tht lnguge equivlence is not sufficient to cpture the ehviour of n intercting utomton. In the previous section, we rgued tht it is importnt to oserve the difference of sttes tht hve different set of outgoing ctions: we cn see the difference etween stte tht hs oth n outgoing - nd -ction, nd stte tht hs just one of the two. Thus, we cn see whether or not stte exists with certin set of outgoing ctions, ut not how mny times such stte occurs. The notion of isimultion does exctly this: relted sttes hve the sme set of outgoing ctions, ut dupliction of sttes is disregrded. Definition Let M = (S, A,,, ) nd M = (S, A,,, ) e two utomt with the sme lphet. The utomt M nd M re isimilr, M M, iff there is reltion R etween their rechle sttes tht preserves trnsitions nd termintion, i.e. 1. R reltes rechle sttes: every rechle stte of M is relted to rechle stte of M nd every rechle stte of M is relted to rechle stte of M; 2. is relted y R to ; 3. whenever s is relted to s, srs nd s t, then there is stte t in M with s t nd trt ; this is the trnsfer condition from left to right (see Figure 2.11);

23 2.3. BISIMULATION whenever s is relted to s, srs nd s t, then there is stte t in M with s t nd trt ; this is the trnsfer condition from right to left (see Figure 2.12); 5. whenever srs, then s if nd only if s (see Figures 2.13 nd 2.14). The reltion R links sttes in the two utomt tht hve the sme ehvior. s s s s t t t Figure 2.11: Trnsfer condition from left to right. s s s s t t t Figure 2.12: Trnsfer condition from right to left. s s s s Figure 2.13: Trnsfer condition for finl sttes from left to right. One cn think of the notion of isimilrity in terms of two-person gme. Suppose two plyers ech hve their own utomton. The gme is plyed s follows. First, one of the plyers mkes trnsition or move from the initil stte. The role of the other plyer is to mtch this move precisely, lso strting from the initil stte. Next, gin one of the plyers mkes move. This does

24 18 CHAPTER 2. FINITE AUTOMATA s s s s Figure 2.14: Trnsfer condition for finl sttes from right to left. not hve to e the sme plyer s the one tht mde the first move. The other must try to mtch this move, nd so on. If oth plyers cn ply in such wy tht t ech point in the gme ny move y one of the plyers cn e mtched y move of the other plyer, then the utomt re isimilr. Otherwise, they re not. Exmple In Figure 2.15, n exmple of isimultion reltion on utomt is given. Relted sttes re connected y dshed line. Figure 2.15: Exmple of isimultion. Exmple Figure 2.16 reclls two y now well-known utomt. It should not come s surprise tht they re not isimilr. Sttes tht cn possily e relted re connected y dshed line. The sttes where the ehviors of the two systems differ re indicted y dshed lines leled with question mrk. None of the two indicted pirs of sttes stisfies the trnsfer conditions of Definition So fr, isimilrity is just reltion on trnsition systems. However, it hs lredy een mentioned tht it is ment to serve s notion of equlity. For tht purpose, it is necessry tht isimilrity is n equivlence reltion. It is not difficult to show tht isimilrity is indeed n equivlence reltion. Theorem 2.17 (Equivlence). Bisimilrity is n equivlence.

25 2.3. BISIMULATION 19?? c c Figure 2.16: Two utomt tht re not isimilr. Proof. Proving tht reltion is n equivlence mens tht it must e shown tht it is reflexive, symmetric, nd trnsitive. Let M = (S, A,,, ) e n utomton. First, it is not hrd to see tht the reltion R = {(s, s) s S, s} is isimultion reltion. This implies tht M M. Second, ssume tht M M for utomt M, M. If R is isimultion reltion relting the rechle sttes of M nd M, then the reltion R = {(t, s) srt} is isimultion reltion s well, nd srt if nd only if tr s. Hence, M M, proving symmetry of. Finlly, for trnsitivity of, it must e shown tht the reltion composition of two isimultion reltions results in isimultion reltion gin. Let M, M, M e utomt, nd let R 1 nd R 2 e isimultion reltions etween the rechle sttes of M nd M, respectively M nd M. The reltion composition R 1 R 2, defined y sr 1 R 2 t iff there is u with sr 1 u nd ur 2 t, is isimultion relting the rechle sttes of M nd M, implying trnsitivity of. Two utomt tht re isimilr re certinly lnguge equivlent. Theorem If M M, then M M. Proof. Tke string w L(M). By definition, this mens there is pth w s to stte s in M with s. Tke isimultion reltion R etween M nd M. For ech stte in the given pth, we cn find stte in M tht is isimilr to it, nd is connected y the sme step. In prticulr, R reltes to nd s to some stte s in M with w s nd s. This mens w L(M ). The other direction is similr. Oviously, the reverse of this theorem does not hold. This mens tht the set of utomt is divided into set of equivlence clsses of utomt tht re lnguge equivlent, nd tht ech of these lnguge equivlence clsses is divided into numer of isimultion equivlence clsses. A isimultion equivlence clss of utomt is clled regulr process.

26 20 CHAPTER 2. FINITE AUTOMATA We cn use the definition of isimultion just s well on (infinite) trnsition systems. Consider gin the trnsition system of the simple counter presented erlier (2.6), reproduced here. Figure 2.17: Simple counter. Notice tht no two sttes of this trnsition system cn e relted y isimultion reltion (every stte on the top row is uniquely chrcterized y the numer of consecutive -steps tht cn e executed, together with the possiility to execute n -step, every stte on the ottom row lso hs unique numer of consecutive -steps possile, nd no possiility to execute ). Thus, this trnsition system is not isimilr to ny finite utomton, the system does not denote regulr process. Definition A regulr process is isimultion equivlence clss of trnsition systems tht contins finite utomton. We sy tht trnsition system tht is isimilr to finite utomton denotes regulr process. It cn lso e seen from Theorem 2.8 tht the trnsition system of Figures 2.17 nd 2.6 does not denote regulr process: since the lnguge of this trnsition system is not regulr, it cnnot e lnguge equivlent to finite utomton, nd thus it cnnot e isimilr to finite utomton. Another chrcteriztion of isimultion is in terms of coloring. Definition Let C e given finite set, the set of colors. A coloring of n utomton M = (S, A,,, ) is mpping c from the rechle sttes of M to C. Given coloring, nd pth s w t from s to t with lel w, sy w = n, the colored pth from s to t is the lternting sequence of steps nd colors c(s) 0 c(..) 1... n c(t). We cn lso denote tht the endpoint of pth is finl, in this cse lso c(s) 0 c(..) 1... n c(t) is colored pth. We cll coloring consistent if every two sttes tht hve the sme color hve the sme colored pths strting from them. Theorem Any consistent coloring on utomton M is isimultion etween M nd M (n utoisimultion on M). Any utoisimultion on M gives consistent coloring, y coloring ny relted sttes the sme. We cn lso color ny pir of utomt. Then, two utomt re isimilr exctly when there is consistent coloring on oth utomt tht gives the initil sttes the sme color.

27 Exercises 21 Figure 2.18: Bisimilr utomt? Theorem Let R nd R e two isimultions etween M nd M. Then lso R R is isimultion etween M nd M. Thus, the union of isimultions is gin isimultion. If two utomt re isimilr, then the mximl isimultion etween the two utomt is otined y tking the union of ll isimultions etween them. Given n utomton, we cn reduce the utomton s much s possile y identifying ll sttes tht re relted y the mximl utoisimultion. This will give the smllest utomton tht is isimilr to the given utomton. In it, consistent coloring will color ll sttes differently. This smllest utomton is often used s the representtive of its isimultion equivlence clss. To end this section, we consider dedlock. Definition 2.23 (Dedlock). A stte s of n utomton is dedlock stte if nd only if it does not hve ny outgoing trnsitions nd it does not llow successful termintion, i.e., if nd only if for ll A, s, nd s. A trnsition system hs dedlock if nd only if it hs rechle dedlock stte; it is dedlock free if nd only if it does not hve dedlock. An importnt property tht hs lredy een suggested when motivting the notion of isimilrity is tht isimilrity preserves dedlocks. Exercise 4 sks for proof of this fct. Exercises Are the pirs of utomt in Figures 2.18, 2.19, 2.20, 2.21, 2.22 isimilr? If so, give isimultion etween the two utomt; otherwise, explin why they re not isimilr Give isimultion etween ny two of the utomt in Figure Which of the trnsition systems of Exercises 1 nd 2 re dedlock free? Let M nd M e two isimilr utomt. Show tht M hs dedlock if nd only if M hs dedlock Consider the two utomt in Figure If they re isimilr, exhiit isimultion. If they re not isimilr, explin why not. For ech

28 22 CHAPTER 2. FINITE AUTOMATA c c c Figure 2.19: Bisimilr utomt? Figure 2.20: Bisimilr utomt? Figure 2.21: Bisimilr utomt?

29 Exercises 23 Figure 2.22: Bisimilr utomt? Figure 2.23: All utomt re isimilr.

30 24 CHAPTER 2. FINITE AUTOMATA c c c c c c c c d e d e Figure 2.24: Bisimilr utomt? utomton, reduce it s much s possile with respect to isimultion. Next, do the exercise gin with e replced y d Prove tht the reltion composition of two isimultion reltions is gin isimultion Prove tht the trnsition system of Exercise 24 in Section 2.1 does not denote regulr process. 2.4 Recursive specifictions While the visuliztion of n utomton is intuitively ppeling nd useful in mny respects, it is not so useful mthemticlly, for doing clcultions. For this reson, we will consider presenttion of utomt s mthemticl expressions, in n lger. Definition We proceed to define the Miniml Alger MA. MA hs very simple syntx: 1. There is constnt 0; this denotes inction, no possiility to proceed, dedlock stte; 2. There is constnt 1; this denotes termintion, finl stte; 3. For ech element of the lphet A, there is unry opertor. clled ction prefix; term.x will execute the elementry ction nd then proceed s x; 4. There is inry opertor + clled lterntive composition; term x + y will either execute x or execute y, choice will e mde etween the lterntives.

31 2.4. RECURSIVE SPECIFICATIONS 25 Thus, MA hs expressions.0, (.0) + (.1),.((.1) + 0). We use rckets nd sometimes omit the symol of ction prefixing s is customry in rithmetic, so e.g. 0 + cd1 + e0 denotes ((.(.0)) + (c.(d.1))) + (e.0). Every term over this syntx will denote n utomton. Before defining this utomton, we first interpret every term s stte in n utomton, nd define when such stte is finl stte, nd when such stte hs trnsition to nother stte. We do this y method which is clled Structurl Opertionl Semntics, SOS for short. It defines the sic oservtions of term. Definition We hve 1, stte nmed 1 is finl stte; 2. For ll A nd ll terms x,.x x, stte nmed.x hs trnsition leled to stte x; 3. For ll terms x, y, z nd ll A we hve tht x + y z whenever x z or y z; stte x+y hs trnsition to certin stte exctly when x or y hs such trnsition; 4. For ll terms x, y we hve tht x+y whenever x or y ; x+y is finl stte exctly when x or y is finl stte. Notice tht nothing is defined for term 0. This mens 0 is not finl stte, nd hs no outgoing trnsition. Moreover, notice tht when term y is rechle from x, x y, then y is suterm of x. Thus, from given term, only finitely mny terms re rechle. For future reference, we list the rules of Definition 2.25 in Tle 1. x x x + y x 1.x x y y x + y y x x + y y x + y Tle 1: Opertionl rules for MA ( A). We use prticulr formt to present these rules. Ech rule hs centrl dividing line. Aove the line re the premises, elow the conclusion. If rule hs no premises, it is clled n xiom. Definition We define the utomton of term t, M(t), s follows: 1. The set of sttes is the set of terms rechle from t; 2. The lphet is A; 3. The initil stte is t; 4. The set of trnsitions nd the finl sttes re defined y mens of the opertionl rules in Tle 1. The lnguge of term t, L(t), is just L(M(t)).

32 26 CHAPTER 2. FINITE AUTOMATA Figure 2.25: Automt of 0,1, c.1.1 c.1 c 1 Figure 2.26: Automton of..1 +.c.1. Figure 2.25 shows the utomt of terms 0,1 nd.1. A more complicted exmple is given in Figure Since..1.1, the initil stte hs n -leled trnsition to.1. The other trnsition from the initil stte follows from.c.1 c.1. We cn clculte the lnguges ccepted y the terms over this syntx. Theorem The lnguges ccepted y terms over MA re s follows: 1. L(0) = ; 2. L(1) = {ε}; 3. L(.x) = {w A w L(x)}; 4. L(x + y) = L(x) L(y). Proof. 1. See Figure M(0) hs no finl stte. 2. See Figure The only pth from the initil stte to itself hs lel ε. 3. Suppose there is pth from the initil stte to finl stte with lel w. As the initil stte is not finl (there is no wy to derive.x ), nd the only step tht cn e tken from the initil stte hs lel, we must hve w = v for some string v. Now v must e the lel of pth from the initil stte of M(x) to finl stte, so v L(x). 4. Suppose w L(x + y). If w = ε, then (x + y), so either x or y nd w L(x) or w L(y). Otherwise, there re A nd string v with w = v. Then x + y p, so either x p or y p. Agin we otin w L(x) or w L(y). Notice the difference etween L(0) nd L(1): the ltter ccepts the empty string, the former ccepts no string.

33 2.4. RECURSIVE SPECIFICATIONS 27 We considered the lnguge of terms in MA, now let us consider isimultion. From the definition of n utomton of term we derive the following principles of clcultion. Theorem The following lws hold for MA terms: 1. x + y y + x, 2. (x + y) + z x + (y + z), 3. x + x x, 4. x + 0 x. Proof. 1. x + y y + x, the order of the summnds does not mtter. The utomton of x + y is exctly the sme s the utomton of y + x, prt from the nme of the initil stte. Thus, the identity reltion on sttes together with the pir (x + y, y + x) is isimultion reltion. For, if x + y z for certin A nd term z, then we must hve x z or y z. But then lso y + x z. Similrly, if x + y, then x or y. But then lso y + x. 2. (x+y)+z x+(y+z), in cse there re more thn two summnds it does not mtter how they re grouped. The utomton of (x+y)+z is exctly the sme s the utomton of x + (y + z), prt from the nme of the initil stte. Thus, the identity reltion on sttes together with the pir ((x+y)+z, x+(y +z)) is isimultion reltion. For, if (x+y)+z p for certin A nd term p, then we must hve x + y p or z p. The former implies x p or y p. If y p or z p, then lso y + z p. Otherwise x p, so in oth cses x + (y + z) p. Similrly (x + y) + z just in cse x + (y + z). 3. x+x x, duplicte lterntives cn e removed. The utomton of x+x is exctly the sme s the utomton of x, prt from the nme of the initil stte. Thus, the identity reltion on sttes together with the pir (x + x, x) is isimultion reltion. For, if x + x y we must hve x y, nd if x y then lso x + x y. Likewise x + x just in cse x. 4. x +0 x, there is only dedlock stte if there re no lterntives. The utomton of x+0 is exctly the sme s the utomton of x, prt from the nme of the initil stte. Thus, the identity reltion on sttes together with the pir (x +0, x) is isimultion reltion. For, if x +0 y then we must hve x y, s 0 y cnnot occur. Likewise x + 0 exctly when x. We conclude tht the + opertor on utomt is commuttive, ssocitive, idempotent, nd hs 0 s unit element. For future reference, we list these lws in Tle 2. As isimilrity implies lnguge equivlence, these lws lso hold for. Aprt from the lws shown in Tle 2, MA hs two more lws, the distriutivity of ction prefix over lterntive composition nd the lw for zero shown

34 28 CHAPTER 2. FINITE AUTOMATA x + y y + x (x + y) + z x + (y + z) x + x x x + 0 x Tle 2: Bisimultion lws of MA..x +.y.(x + y).0 0 Tle 3: Lnguge equivlence lws of MA ( A). in Tle 3. Appliction of these lws will chnge n utomton to different utomton, ut will preserve lnguge cceptnce. Theorem Let x, y e two terms over MA. Then utomt.(x + y) nd.x +.y ccept the sme lnguge. Proof. L(.(x + y)) = {w w L(x + y)} = {w w L(x) L(y)} = {w w L(x)} {w w L(y)} = L(.x) L(.y) = L(.x +.y). Theorem Automt.0 nd 0 ccept the sme lnguge. Proof. L(.0) = L(0) =. The distriutive lw will turn out to e very useful in the following. For the ppliction of the lws, we will use the fct tht lnguge equivlence is n equivlence reltion, see the previous section. Furthermore, we lso need to e le to pply the lws in context, i.e. we need tht lnguge equivlence is congruence reltion. By this, we men the following. Theorem Let x, y e two terms over MA, nd suppose the utomt denoted y x nd y ccept the sme lnguge, x y. Then: 1. For ll ctions A, lso.x nd.y ccept the sme lnguge,.x.y; 2. For ll terms z, lso x+z nd y+z ccept the sme lnguge, x+z y+z. Proof. Strightforwrd. Also isimilrity is n equivlence reltion. It is lso congruence reltion. Theorem Bisimilrity is congruence reltion on MA terms. Proof. 1. If x y nd A, then.x.y. If R is isimultion reltion etween M(x) nd M(y), then R = R {(.x,.y)} is isimultion reltion etween M(.x) nd M(.y); 2. If x y nd x y, then x + x y + y. Tke isimultion reltion R relting M(x) nd M(y) nd isimultion reltion R relting M(x ) nd M(y ). Then R = R R {(x+x, y+y )} is isimultion reltion etween M(x + x ) nd M(y + y ). It is in tking this union tht one stte cn ecome relted to more thn one stte.

Formal Languages and Automata

Formal Languages and Automata Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University

More information

Minimal DFA. minimal DFA for L starting from any other

Minimal DFA. minimal DFA for L starting from any other Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA

More information

Convert the NFA into DFA

Convert the NFA into DFA Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:

More information

Designing finite automata II

Designing finite automata II Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of

More information

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd

More information

1 Nondeterministic Finite Automata

1 Nondeterministic Finite Automata 1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you

More information

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or

More information

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton 25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q

More information

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014 CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite

More information

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1 Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more

More information

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4 Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one

More information

3 Regular expressions

3 Regular expressions 3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll

More information

Parse trees, ambiguity, and Chomsky normal form

Parse trees, ambiguity, and Chomsky normal form Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for context-free grmmrs

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions

More information

Formal languages, automata, and theory of computation

Formal languages, automata, and theory of computation Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm

More information

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v. 1 Exercises Chpter 1 Exercise 1.1. Let Σ e n lphet. Prove wv = w + v for ll strings w nd v. Prove # (wv) = # (w)+# (v) for every symol Σ nd every string w,v Σ. Exercise 1.2. Let w 1,w 2,...,w k e k strings,

More information

Nondeterminism and Nodeterministic Automata

Nondeterminism and Nodeterministic Automata Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely

More information

Coalgebra, Lecture 15: Equations for Deterministic Automata

Coalgebra, Lecture 15: Equations for Deterministic Automata Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic

More information

Finite Automata-cont d

Finite Automata-cont d Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww

More information

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

State Minimization for DFAs

State Minimization for DFAs Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid

More information

Chapter 2 Finite Automata

Chapter 2 Finite Automata Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2 CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb. CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt

More information

First Midterm Examination

First Midterm Examination Çnky University Deprtment of Computer Engineering 203-204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does

More information

CM10196 Topic 4: Functions and Relations

CM10196 Topic 4: Functions and Relations CM096 Topic 4: Functions nd Reltions Guy McCusker W. Functions nd reltions Perhps the most widely used notion in ll of mthemtics is tht of function. Informlly, function is n opertion which tkes n input

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed

More information

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9. Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.

More information

Lecture 08: Feb. 08, 2019

Lecture 08: Feb. 08, 2019 4CS4-6:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny

More information

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA) Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr

More information

DFA minimisation using the Myhill-Nerode theorem

DFA minimisation using the Myhill-Nerode theorem DFA minimistion using the Myhill-Nerode theorem Johnn Högerg Lrs Lrsson Astrct The Myhill-Nerode theorem is n importnt chrcteristion of regulr lnguges, nd it lso hs mny prcticl implictions. In this chpter,

More information

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny

More information

Lecture 3: Equivalence Relations

Lecture 3: Equivalence Relations Mthcmp Crsh Course Instructor: Pdric Brtlett Lecture 3: Equivlence Reltions Week 1 Mthcmp 2014 In our lst three tlks of this clss, we shift the focus of our tlks from proof techniques to proof concepts

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

CS 330 Formal Methods and Models

CS 330 Formal Methods and Models CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q

More information

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers 80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES 2.6 Finite Stte Automt With Output: Trnsducers So fr, we hve only considered utomt tht recognize lnguges, i.e., utomt tht do not produce ny output on ny input

More information

CS375: Logic and Theory of Computing

CS375: Logic and Theory of Computing CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks

More information

Exercises with (Some) Solutions

Exercises with (Some) Solutions Exercises with (Some) Solutions Techer: Luc Tesei Mster of Science in Computer Science - University of Cmerino Contents 1 Strong Bisimultion nd HML 2 2 Wek Bisimultion 31 3 Complete Lttices nd Fix Points

More information

Regular expressions, Finite Automata, transition graphs are all the same!!

Regular expressions, Finite Automata, transition graphs are all the same!! CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104-W11 1

More information

Tutorial Automata and formal Languages

Tutorial Automata and formal Languages Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we

More information

More on automata. Michael George. March 24 April 7, 2014

More on automata. Michael George. March 24 April 7, 2014 More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose

More information

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A. 378 Reltions 16.7 Solutions for Chpter 16 Section 16.1 Exercises 1. Let A = {0,1,2,3,4,5}. Write out the reltion R tht expresses > on A. Then illustrte it with digrm. 2 1 R = { (5,4),(5,3),(5,2),(5,1),(5,0),(4,3),(4,2),(4,1),

More information

Lecture 09: Myhill-Nerode Theorem

Lecture 09: Myhill-Nerode Theorem CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives

More information

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation Strong Bisimultion Overview Actions Lbeled trnsition system Trnsition semntics Simultion Bisimultion References Robin Milner, Communiction nd Concurrency Robin Milner, Communicting nd Mobil Systems 32

More information

Closure Properties of Regular Languages

Closure Properties of Regular Languages Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L

More information

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions

More information

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted

More information

Let's start with an example:

Let's start with an example: Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regular Expressions to Discrete Finite Automata: A Tutorial Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

More information

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)

More information

Harvard University Computer Science 121 Midterm October 23, 2012

Harvard University Computer Science 121 Midterm October 23, 2012 Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is

More information

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true. York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr

More information

Thoery of Automata CS402

Thoery of Automata CS402 Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...

More information

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings... Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive

More information

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30 Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100

More information

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy: Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes

More information

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010 CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w

More information

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018 CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA

More information

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.) CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts

More information

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More

More information

Name Ima Sample ASU ID

Name Ima Sample ASU ID Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to

More information

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38 Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control

More information

SWEN 224 Formal Foundations of Programming WITH ANSWERS

SWEN 224 Formal Foundations of Programming WITH ANSWERS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 3 Hours EXAMINATIONS 2011 END-OF-YEAR SWEN 224 Forml Foundtions of Progrmming

More information

Homework Solution - Set 5 Due: Friday 10/03/08

Homework Solution - Set 5 Due: Friday 10/03/08 CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl.

More information

Context-Free Grammars and Languages

Context-Free Grammars and Languages Context-Free Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;

More information

First Midterm Examination

First Midterm Examination 24-25 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet

More information

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016 CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple

More information

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages 5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive

More information

1.4 Nonregular Languages

1.4 Nonregular Languages 74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll

More information

Lecture 9: LTL and Büchi Automata

Lecture 9: LTL and Büchi Automata Lecture 9: LTL nd Büchi Automt 1 LTL Property Ptterns Quite often the requirements of system follow some simple ptterns. Sometimes we wnt to specify tht property should only hold in certin context, clled

More information

Theory of Computation Regular Languages

Theory of Computation Regular Languages Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of

More information

p-adic Egyptian Fractions

p-adic Egyptian Fractions p-adic Egyptin Frctions Contents 1 Introduction 1 2 Trditionl Egyptin Frctions nd Greedy Algorithm 2 3 Set-up 3 4 p-greedy Algorithm 5 5 p-egyptin Trditionl 10 6 Conclusion 1 Introduction An Egyptin frction

More information

Formal Languages and Automata Theory. D. Goswami and K. V. Krishna

Formal Languages and Automata Theory. D. Goswami and K. V. Krishna Forml Lnguges nd Automt Theory D. Goswmi nd K. V. Krishn Novemer 5, 2010 Contents 1 Mthemticl Preliminries 3 2 Forml Lnguges 4 2.1 Strings............................... 5 2.2 Lnguges.............................

More information

Model Reduction of Finite State Machines by Contraction

Model Reduction of Finite State Machines by Contraction Model Reduction of Finite Stte Mchines y Contrction Alessndro Giu Dip. di Ingegneri Elettric ed Elettronic, Università di Cgliri, Pizz d Armi, 09123 Cgliri, Itly Phone: +39-070-675-5892 Fx: +39-070-675-5900

More information

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

Formal Language and Automata Theory (CS21004)

Formal Language and Automata Theory (CS21004) Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge

More information

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p

More information

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t

More information

Worked out examples Finite Automata

Worked out examples Finite Automata Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will

More information

Deterministic Finite Automata

Deterministic Finite Automata Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite

More information

Bases for Vector Spaces

Bases for Vector Spaces Bses for Vector Spces 2-26-25 A set is independent if, roughly speking, there is no redundncy in the set: You cn t uild ny vector in the set s liner comintion of the others A set spns if you cn uild everything

More information

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont. NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD

More information

set is not closed under matrix [ multiplication, ] and does not form a group.

set is not closed under matrix [ multiplication, ] and does not form a group. Prolem 2.3: Which of the following collections of 2 2 mtrices with rel entries form groups under [ mtrix ] multipliction? i) Those of the form for which c d 2 Answer: The set of such mtrices is not closed

More information

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck. Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent

More information

GNFA GNFA GNFA GNFA GNFA

GNFA GNFA GNFA GNFA GNFA DFA RE NFA DFA -NFA REX GNFA Definition GNFA A generlize noneterministic finite utomton (GNFA) is grph whose eges re lele y regulr expressions, with unique strt stte with in-egree, n unique finl stte with

More information

Finite-State Automata: Recap

Finite-State Automata: Recap Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under

More information

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1 CS4 45- Determinisitic Finite Automt -: Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother

More information

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)

More information

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn

More information

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power CS411-2015S-12 Turing Mchine Modifictions 1 12-0: Extending Turing Mchines When we dded stck to NFA to get PDA, we incresed computtionl power Cn we do the sme thing for Turing Mchines? Tht is, cn we dd

More information

This lecture covers Chapter 8 of HMU: Properties of CFLs

This lecture covers Chapter 8 of HMU: Properties of CFLs This lecture covers Chpter 8 of HMU: Properties of CFLs Turing Mchine Extensions of Turing Mchines Restrictions of Turing Mchines Additionl Reding: Chpter 8 of HMU. Turing Mchine: Informl Definition B

More information

NFAs continued, Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,

More information

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.

More information

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique? XII. LINEAR ALGEBRA: SOLVING SYSTEMS OF EQUATIONS Tody we re going to tlk out solving systems of liner equtions. These re prolems tht give couple of equtions with couple of unknowns, like: 6= x + x 7=

More information