Finite Autmata 2017/08/22 Chapter 1.1 in Sipser 1
Last time Thery f cmputatin Autmata Thery Cmputability Thery Cmplexity Thery Finite autmata Pushdwn autmata Turing machines 2
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Design an FA 3
Definitin f FA (Q,,,q0,F) 4
Definitin f FA (Q,,,q0,F) Q = {q0,q1,q3} Q = {q0,q1,q2} = {a, b} = Q! Q q0 F = {q1} 5
Definitin f FA (Q,,,q0,F) Ntes abut FA ; Can F be {} r? Can we have tw initial states? Tw accept states? Can the initial state als be an accept state? Can we have tw arrws ut f a state n the same symbl? 6
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Design an FA 7
Cmputatin f FA (Q,,,q0,F) Cmputatin Input string: a finite length string ver the alphabet input 8
Cmputatin f FA (Q,,,q0,F) Cmputatin input 9
Cmputatin f FA (Q,,,q0,F) Cmputatin input 10
Cmputatin f FA (Q,,,q0,F) Cmputatin input input ends: reject 11
Cmputatin f FA (Q,,,q0,F) Cmputatin The cmputatin stps in an nn-accept state: reject The cmputatin stps in an accept state: accept 12
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Design an FA 13
Regular language (Q,,,q0,F) A language is a set f strings Let A be the set f strings that a machine M accepts: A is the language f machine M, r equivalently M recgnizes A, and write L(M) = A What is A in the abve example? 14
Regular language Hw t describe the language f a machine M? 15
Lexicgraphic rder f strings v Review: Alphabet: any nnempty finite set f symbls (als knwn as symbls f an alphabet) String (ver an alphabet): a finite sequence f symbls, length f a string, zer length string r empty string, Q: is {} the same as { }? 1 = {a, b, c, d} 2 = {0, 1} w : all the strings ver the alphabet " Q: des include? " " w 16
Lexicgraphic rder f strings Lexicgraphic rder: similar t dictinary rder An rdering relatin < n the symbls f an alphabet: < In English, (a, b) 2<, (b, c) 2<, (a, c) 2<, r simplified as, a < b, b < c, a < c Mre frmally, x, y we write x apple y iff 2 ver 1) y = xu fr sme u 2, OR 2) x = uav, y = ua w and a apple a fr sme u, v, w 2 and a, a 2 What is the lexicgraphic rder fr {0, 1} *? 17
Lexicgraphic rder f strings Lexicgraphic rder: similar t dictinary rder An rdering relatin < n the symbls f an alphabet: < In English, (a, b) 2<, (b, c) 2<, (a, c) 2<, r simplified as, a < b, b < c, a < c Mre frmally, x, y we write x apple y iff ver 1) y = xu fr sme u 2, OR 2) x = uav, y = ua w and a apple a fr sme u, v, w 2 and a, a 2 What is the lexicgraphic rder fr {0, 1} *? Identify the rdering relatin n the symbls, let s say 0 < 1 " 2 (, 0, 00, 000, 0000,, 00000..001, 00000..010, 00000..011, ) 18
Lexicgraphic rder f strings Shrtlex rder: similar t lexicgraphic rder, except that shrter strings precede lnger strings " (, 0, 00, 000, 0000,, 00000..001, 00000..010, 00000..011, ) " (, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, ) Cnsider the fllwing strings: ab, aa, a, aba, acbab, abaaaa Lexicgraphic rder Shrtlex rder 19
Lexicgraphic rder f strings Shrtlex rder: similar t lexicgraphic rder, except that shrter strings precede lnger strings " (, 0, 00, 000, 0000,, 00000..001, 00000..010, 00000..011, ) " (, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, ) Cnsider the fllwing strings: ab, aa, a, aba, acbab, abaaaa Lexicgraphic rder: {a, aa, ab, aba, abaaaa, acbab} Shrtlex rder: {a, aa, ab, aba, acbab, abaaaa} 20
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings 21
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } 22
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } 23
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } w w A = { cntains at least ne 1 and an even number f 0s fllwing the last 1} 24
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } 25
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } 26
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } 27
Regular language Hw t describe the language f a machine M? List all the strings in shrtlex rder Cmpare patterns fr accept and reject strings " w w " = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } A = { is the empty string r ends in a 0} 28
Regular language = {, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, } L(M) = {", 0, 00, 10, 000, 010, } " L(M) = {1, 01, 11, 001, 011, } r cmplement f L(M) 29
Regular language Ntes abut a regular langauge a regular language (recgnized by a FA) may cntain an infinite number f strings an FA recgnizes a unique language. Why? 30
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Design an FA Reading assignment fr the next class: Sipser Sec. 0.3, 0.4, http://jflap.rg/tutrial/ ->Finite Autmata- >Cnstruct and Run->Building Yur First Finite Autmatn (UP TO Running the Finite Autmatn n Multiple Strings) Quiz link will be sent ut; due date is befre the beginning f the next class 31
Finite Autmata (Cnt.) 2017/08/24 Chapter 1.1 in Sipser Ø Annuncement: q Office hurs mved t 5:30 t 6:30PM T/Th q Answers t quiz questins will be psted sn after the due date; answers t yur questins are immediately available after the due date q HW1 will be annunced later tday; due in a week 32
Last time Finite autmata Definitin f FA Cmputatin f FA Regular language Regular language and FA Regular peratins Design an FA 33
Lexicgraphic Human-aware rder f Rb.cs strings (review) Lexicgraphic rder: similar t dictinary rder An rdering relatin < n the symbls f an alphabet: < In English, (a, b) 2<, (b, c) 2<, (a, c) 2<, r simplified as, a < b, b < c, a < c Mre frmally, x, y we write x apple y iff ver 1) y = xu fr sme u 2, OR 2) x = uav, y = ua w and a < a fr sme u, v, w 2 and a, a 2 What is the lexicgraphic rder fr {0, 1} *? Identify the rdering relatin n the symbls, let s say 0 < 1 " 2 (, 0, 00, 000, 0000,, 00000..001, 00000..010, 00000..011, ) 34
Lexicgraphic Human-aware rder f Rb.cs strings (review) Shrtlex rder: similar t lexicgraphic rder, except that shrter strings precede lnger strings " (, 0, 00, 000, 0000,, 00000..001, 00000..010, 00000..011, ) " (, 0, 1, 00, 01, 10, 11, 000, 001, 010, 011, ) Cnsider the fllwing strings: ab, aa, a, aba, acbab, abaaaa Lexicgraphic rder: {a, aa, ab, aba, abaaaa, acbab} Shrtlex rder: {a, aa, ab, aba, acbab, abaaaa} 35
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Regular language and FA Regular peratins Design an FA 36
Regular peratin Ntes abut regular peratins Unary and binary peratins Similaries and differences between A * and 37
Regular peratin 38
Clsed cllectin Definitin - A cllectin (r set) is clsed under an peratin if applying this peratin t members f the cllectin returns a member in the cllectin Are the set f integers, Z, clsed under additin? multiplicatin? divisin? What abut ratinal numbers, Q? What if we add in the square rt peratin? 39
Clsed under peratin Definitin - A cllectin (r set) is clsed under an peratin if applying this peratin t members f the cllectin returns a member in the cllectin Are the set f integers, Z, clsed under additin? multiplicatin? divisin? What abut ratinal numbers, Q? What if we add in the square rt peratin? 40
Clsed under unin v Review: Prf by cnstructin Prf by cntradictin Prf by inductin 41
Clsed under unin v Review: Prf by cnstructin Prf by cntradictin Prf by inductin 42
Clsed under unin 1. Given any RLs A1 and A2 1. Prve that A1 [ A2 is als a RL 43
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject 44
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject 45
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject 46
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject 47
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject 48
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject 49
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject Q = Q 1 Q 2 F = F 1 Q 2 [ F 2 Q 1 M =(Q,,,q 0 s 0,F) 50
Clsed under unin 1. Given any RLs A1 and A2 2. Based n the definitin, we can cnstruct M1 fr A1 and M2 fr A2 M 1 =(Q 1,, 1,q 0,F 1 ) M 2 =(Q 2,, 2,s 0,F 2 ) [ 1. Prve that A1 A2 is als a RL 2. Cnstruct a machine M t simulate bth M1 and M2 at the same time and accept if either ne accepts Keep a cpy f bth M1 and M2; fr every step in M, run a step frm M1 and then a step in M2; M accepts if either M1 r M2 accepts; therwise, reject First run M1, if M1 accpets, M accepts; therwise, run M2 with the same input, if M2 accepts, M accepts; therwise, reject M =(Q,,,q 0 s 0,F) Q = Q 1 Q 2 F = F 1 Q 2 [ F 2 Q 1 q What if F = F 1 F 2? q Nte: what if we want t find the cmplement f a language? 51
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Regular language and FA Regular peratins Design an FA 52
Design an FA Dwnlad JFLAP!! BB Cntent Sftware Libraries 53
Design an FA Bk exampe: L(M) = { {0, 1} * and 001 is a substring f } Pretend that yu are the machine reading the string Identify hw much memry yu need r what are the states yu need t remember? What are the states w w2 w 54
Design an FA Bk exampe: L(M) = { {0, 1} * and 001 is a substring f } Pretend that yu are the machine reading the string Identify hw much memry yu need r what are the states yu need t remember? What are the states w w2 haven t just seen any symbls f the pattern have just seen a 0 have just seen 00 have been the entire pattern 001 w 55
Design an FA Exampe: L(M) = { {0, 1} * and 001 is a suffix f } Pretend that yu are the machine reading the string Identify hw much memry yu need r what are the states yu need t remember? What are the states w w2 w Is this crrect? 56
Design an FA Exampe: L(M) = { {0, 1} * and 001 is a suffix f } Pretend that yu are the machine reading the string Identify hw much memry yu need r what are the states yu need t remember? What are the states w w2 haven t just seen any symbls f the pattern have just seen a 0 have just seen 00 have been the entire pattern 001 w let us revisit ur previus example where 001 is a substring 57
Design an FA Exampe: L(M) = { {0, 1} * and 001 is a suffix f } Pretend that yu are the machine reading the string Identify hw much memry yu need r what are the states yu need t remember? What are the states w w2 haven t just seen any symbls f the pattern have just seen a 0 have just seen 00 have been the entire pattern 001 w 58
Design an FA Exampe: Assume that we have an elevatr serving 3 flrs Build a finite autmatn M that satisifes If n requests, stays idle First in first serve unless the elevatr unless the new requests are n the way; therwise, the request will be drpped until the current request is served Alphabet {1, 2, 3, 1up, 2up, 2dn, 3dn, at1, at2, at3} r design yur wn; n simultaneus actins and sensr utputs Accept nly when idle States? 59
Design an FA One pssible FA: 60
Design an FA Exampe: Assume that we have an elevatr serving 3 flrs Build a finite autmatn M that satisifes If n requests, stays idle First in first serve unless the elevatr unless the new requests are n the way; therwise, the request will be drpped until the current request is served Alphabet {1, 2, 3, 1up, 2up, 2dn, 3dn, at1, at2, at3} r design yur wn; n simultaneus actins and sensr utputs Accept nly when idle Ø State abstractin is the key here! 61
Outline fr tday Finite autmata Definitin f FA Cmputatin f FA Regular language Regular language and FA Regular peratins Design an FA Reading assignment fr the next class: Sipser Sec. 1.1 (up t page 58, clsure under the regular peratins) Quiz link will be sent ut; due date is befre the beginning f the next class 62