Deterministic Finite Automata (DFAs)

Size: px
Start display at page:

Download "Deterministic Finite Automata (DFAs)"

Transcription

1 Algorithms & Models of Computation CS/ECE 374, Fall 27 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, September 5, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

2 Part I DFA Introduction Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

3 DFAs also called Finite State Machines (FSMs) The simplest model for computers? State machines that are common in practice. Vending machines Elevators Digital watches Simple network protocols Programs with fixed memory Sariel Har-Peled (UIUC) CS374 3 Fall 27 3 / 36

4 A simple program Program to check if a given input string w has odd length int n = While input is not finished read next character c n n + endwhile If (n is odd) output YES Else output NO bit x = While input is not finished read next character c x flip(x) endwhile If (x = ) output YES Else output NO Sariel Har-Peled (UIUC) CS374 4 Fall 27 4 / 36

5 A simple program Program to check if a given input string w has odd length int n = While input is not finished read next character c n n + endwhile If (n is odd) output YES Else output NO bit x = While input is not finished read next character c x flip(x) endwhile If (x = ) output YES Else output NO Sariel Har-Peled (UIUC) CS374 4 Fall 27 4 / 36

6 Another view Machine has input written on a read-only tape Start in specified start state Start at left, scan symbol, change state and move right Circled states are accepting Machine accepts input string if it is in an accepting state after scanning the last symbol. Sariel Har-Peled (UIUC) CS374 5 Fall 27 5 / 36

7 Graphical Representation/State Machine q3 q2, q q Directed graph with nodes representing states and edge/arcs representing transitions labeled by symbols in Σ For each state (vertex) q and symbol a Σ there is exactly one outgoing edge labeled by a Initial/start state has a pointer (or labeled as s, q or start ) Some states with double circles labeled as accepting/final states Sariel Har-Peled (UIUC) CS374 6 Fall 27 6 / 36

8 Graphical Representation q q 3 q q 2, Where does lead?? Figure : DFA M for problem 5 Which strings end up in accepting state? Can you prove it? Every string w has a unique walk that it follows from a given hange the initial state to B? state q by reading one letter of w from left to right. hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 7 Fall 27 7 / 36

9 Graphical Representation q q 3 q q 2, Where does lead?? Figure : DFA M for problem 5 Which strings end up in accepting state? Can you prove it? Every string w has a unique walk that it follows from a given hange the initial state to B? state q by reading one letter of w from left to right. hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 7 Fall 27 7 / 36

10 Graphical Representation q q 3 q q 2, Where does lead?? Figure : DFA M for problem 5 Which strings end up in accepting state? Can you prove it? Every string w has a unique walk that it follows from a given hange the initial state to B? state q by reading one letter of w from left to right. hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 7 Fall 27 7 / 36

11 Graphical Representation q q 3 q q 2, Where does lead?? Figure : DFA M for problem 5 Which strings end up in accepting state? Can you prove it? Every string w has a unique walk that it follows from a given hange the initial state to B? state q by reading one letter of w from left to right. hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 7 Fall 27 7 / 36

12 Graphical Representation q q 3 q q 2, Definition Figure : DFA M for problem 5 A DFA M accepts a string w iff the unique walk starting at the start state and spelling out w ends in an accepting state. hange Definition the initial state to B? The language accepted (or recognized) by a DFA M is denote by L(M) and defined as: L(M) = {w M accepts w}. hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 8 Fall 27 8 / 36

13 Graphical Representation q q 3 q q 2, Definition Figure : DFA M for problem 5 A DFA M accepts a string w iff the unique walk starting at the start state and spelling out w ends in an accepting state. hange Definition the initial state to B? The language accepted (or recognized) by a DFA M is denote by L(M) and defined as: L(M) = {w M accepts w}. hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 8 Fall 27 8 / 36

14 Warning M accepts language L does not mean simply that that M accepts each string in L. It means that M accepts each string in L and no others. Equivalently M accepts each string in L and does not accept/rejects strings in Σ \ L. M recognizes L is a better term but accepts is widely accepted (and recognized) (joke attributed to Lenny Pitt) Sariel Har-Peled (UIUC) CS374 9 Fall 27 9 / 36

15 Warning M accepts language L does not mean simply that that M accepts each string in L. It means that M accepts each string in L and no others. Equivalently M accepts each string in L and does not accept/rejects strings in Σ \ L. M recognizes L is a better term but accepts is widely accepted (and recognized) (joke attributed to Lenny Pitt) Sariel Har-Peled (UIUC) CS374 9 Fall 27 9 / 36

16 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

17 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

18 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

19 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

20 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

21 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

22 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

23 Formal Tuple Notation Definition A deterministic finite automata (DFA) M = (Q, Σ, δ, s, A) is a five tuple where Q is a finite set whose elements are called states, Σ is a finite set called the input alphabet, δ : Q Σ Q is the transition function, s Q is the start state, A Q is the set of accepting/final states. Common alternate notation: q for start state, F for final states. Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

24 DFA Notation M = set of all states transition func ( {}}{{}}{ Q, }{{} Σ, alphabet δ, s }{{} start state, set of all accept states {}}{ A ) Sariel Har-Peled (UIUC) CS374 Fall 27 / 36

25 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

26 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

27 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

28 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

29 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

30 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

31 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

32 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

33 Example q q 3 q q 2, Q = {q, q, q, q 3 } Figure : DFA M for problem 5 Σ = {, } δ s = q hange the initial state to B? A = {q } hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

34 Extending the transition function to strings Given DFA M = (Q, Σ, δ, s, A), δ(q, a) is the state that M goes to from q on reading letter a Useful to have notation to specify the unique state that M will reach from q on reading string w Transition function δ : Q Σ Q defined inductively as follows: δ (q, w) = q if w = ɛ δ (q, w) = δ (δ(q, a), x) if w = ax. Sariel Har-Peled (UIUC) CS374 3 Fall 27 3 / 36

35 Extending the transition function to strings Given DFA M = (Q, Σ, δ, s, A), δ(q, a) is the state that M goes to from q on reading letter a Useful to have notation to specify the unique state that M will reach from q on reading string w Transition function δ : Q Σ Q defined inductively as follows: δ (q, w) = q if w = ɛ δ (q, w) = δ (δ(q, a), x) if w = ax. Sariel Har-Peled (UIUC) CS374 3 Fall 27 3 / 36

36 Formal definition of language accepted by M Definition The language L(M) accepted by a DFA M = (Q, Σ, δ, s, A) is {w Σ δ (s, w) A}. Sariel Har-Peled (UIUC) CS374 4 Fall 27 4 / 36

37 Example q q 3 q q 2, What is: δ (q, ɛ) Figure : DFA M for problem 5 δ (q, ) δ (q, ) hange the initial state to B? δ (q 4, ) hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 5 Fall 27 5 / 36

38 Example continued q q 3 q q 2, What is L(M) if start state is changed to q? Figure : DFA M for problem 5 What is L(M) if final/accept states are set to {q 2, q 3 } instead of {q }? hange the initial state to B? hange the set of final states to be {B} (with initial state A)? Sariel Har-Peled (UIUC) CS374 6 Fall 27 6 / 36

39 Advantages of formal specification Necessary for proofs Necessary to specify abstractly for class of languages Exercise: Prove by induction that for any two strings u, v, any state q, δ (q, uv) = δ (δ (q, u), v). Sariel Har-Peled (UIUC) CS374 7 Fall 27 7 / 36

40 Part II Constructing DFAs Sariel Har-Peled (UIUC) CS374 8 Fall 27 8 / 36

41 DFAs: State = Memory How do we design a DFA M for a given language L? That is L(M) = L. DFA is a like a program that has fixed amount of memory independent of input size. The memory of a DFA is encoded in its states The state/memory must capture enough information from the input seen so far that it is sufficient for the suffix that is yet to be seen (note that DFA cannot go back) Sariel Har-Peled (UIUC) CS374 9 Fall 27 9 / 36

42 DFA Construction: Example Assume Σ = {, } L =, L = Σ, L = {ɛ}, L = {}. L = {w {, } w is divisible by 5} L = {w {, } w ends with } L = {w {, } w contains as substring} L = {w {, } w contains or as substring} L = {w w has a k positions from the end} Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

43 DFA Construction: Example Assume Σ = {, } L =, L = Σ, L = {ɛ}, L = {}. L = {w {, } w is divisible by 5} L = {w {, } w ends with } L = {w {, } w contains as substring} L = {w {, } w contains or as substring} L = {w w has a k positions from the end} Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

44 DFA Construction: Example Assume Σ = {, } L =, L = Σ, L = {ɛ}, L = {}. L = {w {, } w is divisible by 5} L = {w {, } w ends with } L = {w {, } w contains as substring} L = {w {, } w contains or as substring} L = {w w has a k positions from the end} Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

45 DFA Construction: Example Assume Σ = {, } L =, L = Σ, L = {ɛ}, L = {}. L = {w {, } w is divisible by 5} L = {w {, } w ends with } L = {w {, } w contains as substring} L = {w {, } w contains or as substring} L = {w w has a k positions from the end} Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

46 DFA Construction: Example Assume Σ = {, } L =, L = Σ, L = {ɛ}, L = {}. L = {w {, } w is divisible by 5} L = {w {, } w ends with } L = {w {, } w contains as substring} L = {w {, } w contains or as substring} L = {w w has a k positions from the end} Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

47 DFA Construction: Example Assume Σ = {, } L =, L = Σ, L = {ɛ}, L = {}. L = {w {, } w is divisible by 5} L = {w {, } w ends with } L = {w {, } w contains as substring} L = {w {, } w contains or as substring} L = {w w has a k positions from the end} Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

48 DFA Construction: Example L = {Binary numbers congruent to mod 5} Example: = 7 = 2 mod 5, = = mod 5 Key observation: w mod 5 = a implies w mod 5 = 2a mod 5 and w mod 5 = (2a + ) mod 5 Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

49 DFA Construction: Example L = {Binary numbers congruent to mod 5} Example: = 7 = 2 mod 5, = = mod 5 Key observation: w mod 5 = a implies w mod 5 = 2a mod 5 and w mod 5 = (2a + ) mod 5 Sariel Har-Peled (UIUC) CS374 2 Fall 27 2 / 36

50 Part III Product Construction and Closure Properties Sariel Har-Peled (UIUC) CS Fall / 36

51 Part IV Complement Sariel Har-Peled (UIUC) CS Fall / 36

52 Complement Question: If M is a DFA, is there a DFA M such that L(M ) = Σ \ L(M)? That is, are languages recognized by DFAs closed under complement? q3 q2, q q Sariel Har-Peled (UIUC) CS Fall / 36

53 Complement Example... Just flip the state of the states! q3 q2, q3 q2, q q q q Sariel Har-Peled (UIUC) CS Fall / 36

54 Complement Theorem Languages accepted by DFAs are closed under complement. Proof. Let M = (Q, Σ, δ, s, A) such that L = L(M). Let M = (Q, Σ, δ, s, Q \ A). Claim: L(M ) = L. Why? δ M = δ M. Thus, for every string w, δ M (s, w) = δ M (s, w). δ M (s, w) A δ M (s, w) Q \ A. δ M (s, w) A δ M (s, w) Q \ A. Sariel Har-Peled (UIUC) CS Fall / 36

55 Complement Theorem Languages accepted by DFAs are closed under complement. Proof. Let M = (Q, Σ, δ, s, A) such that L = L(M). Let M = (Q, Σ, δ, s, Q \ A). Claim: L(M ) = L. Why? δ M = δ M. Thus, for every string w, δ M (s, w) = δ M (s, w). δ M (s, w) A δ M (s, w) Q \ A. δ M (s, w) A δ M (s, w) Q \ A. Sariel Har-Peled (UIUC) CS Fall / 36

56 Complement Theorem Languages accepted by DFAs are closed under complement. Proof. Let M = (Q, Σ, δ, s, A) such that L = L(M). Let M = (Q, Σ, δ, s, Q \ A). Claim: L(M ) = L. Why? δ M = δ M. Thus, for every string w, δ M (s, w) = δ M (s, w). δ M (s, w) A δ M (s, w) Q \ A. δ M (s, w) A δ M (s, w) Q \ A. Sariel Har-Peled (UIUC) CS Fall / 36

57 Part V Product Construction Sariel Har-Peled (UIUC) CS Fall / 36

58 Union and Intersection Question: Are languages accepted by DFAs closed under union? That is, given DFAs M and M 2 is there a DFA that accepts L(M ) L(M 2 )? How about intersection L(M ) L(M 2 )? Idea from programming: on input string w Simulate M on w Simulate M 2 on w If both accept than w L(M ) L(M 2 ). If at least one accepts then w L(M ) L(M 2 ). Catch: We want a single DFA M that can only read w once. Solution: Simulate M and M 2 in parallel by keeping track of states of both machines Sariel Har-Peled (UIUC) CS Fall / 36

59 Union and Intersection Question: Are languages accepted by DFAs closed under union? That is, given DFAs M and M 2 is there a DFA that accepts L(M ) L(M 2 )? How about intersection L(M ) L(M 2 )? Idea from programming: on input string w Simulate M on w Simulate M 2 on w If both accept than w L(M ) L(M 2 ). If at least one accepts then w L(M ) L(M 2 ). Catch: We want a single DFA M that can only read w once. Solution: Simulate M and M 2 in parallel by keeping track of states of both machines Sariel Har-Peled (UIUC) CS Fall / 36

60 Union and Intersection Question: Are languages accepted by DFAs closed under union? That is, given DFAs M and M 2 is there a DFA that accepts L(M ) L(M 2 )? How about intersection L(M ) L(M 2 )? Idea from programming: on input string w Simulate M on w Simulate M 2 on w If both accept than w L(M ) L(M 2 ). If at least one accepts then w L(M ) L(M 2 ). Catch: We want a single DFA M that can only read w once. Solution: Simulate M and M 2 in parallel by keeping track of states of both machines Sariel Har-Peled (UIUC) CS Fall / 36

61 Union and Intersection Question: Are languages accepted by DFAs closed under union? That is, given DFAs M and M 2 is there a DFA that accepts L(M ) L(M 2 )? How about intersection L(M ) L(M 2 )? Idea from programming: on input string w Simulate M on w Simulate M 2 on w If both accept than w L(M ) L(M 2 ). If at least one accepts then w L(M ) L(M 2 ). Catch: We want a single DFA M that can only read w once. Solution: Simulate M and M 2 in parallel by keeping track of states of both machines Sariel Har-Peled (UIUC) CS Fall / 36

62 Example M accepts # = odd M 2 accepts # = odd Sariel Har-Peled (UIUC) CS Fall / 36

63 Example M accepts # = odd M 2 accepts # = odd Cross-product machine Sariel Har-Peled (UIUC) CS374 3 Fall 27 3 / 36

64 Example II Accept all binary strings of length divisible by 3 and ,, 2, 3, 4,,, 2, 3, 4, 2, 2, 2 2, 2 3, 2 4, 2 Assume all edges are labeled by,. Sariel Har-Peled (UIUC) CS374 3 Fall 27 3 / 36

65 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

66 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

67 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

68 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

69 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

70 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

71 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

72 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

73 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

74 Product construction for intersection M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = A A 2 = {(q, q 2 ) q A, q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

75 Correctness of construction Lemma For each string w, δ (s, w) = (δ (s, w), δ 2 (s 2, w)). Exercise: Assuming lemma prove the theorem in previous slide. Proof of lemma by induction on w Sariel Har-Peled (UIUC) CS Fall / 36

76 Correctness of construction Lemma For each string w, δ (s, w) = (δ (s, w), δ 2 (s 2, w)). Exercise: Assuming lemma prove the theorem in previous slide. Proof of lemma by induction on w Sariel Har-Peled (UIUC) CS Fall / 36

77 Correctness of construction Lemma For each string w, δ (s, w) = (δ (s, w), δ 2 (s 2, w)). Exercise: Assuming lemma prove the theorem in previous slide. Proof of lemma by induction on w Sariel Har-Peled (UIUC) CS Fall / 36

78 Product construction for union M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = {(q, q 2 ) q A or q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

79 Product construction for union M = (Q, Σ, δ, s, A ) and M 2 = (Q, Σ, δ 2, s 2, A 2 ) Create M = (Q, Σ, δ, s, A) where Q = Q Q 2 = {(q, q 2 ) q Q, q 2 Q 2 } s = (s, s 2 ) δ : Q Σ Q where δ((q, q 2 ), a) = (δ (q, a), δ 2 (q 2, a)) A = {(q, q 2 ) q A or q 2 A 2 } Theorem L(M) = L(M ) L(M 2 ). Sariel Har-Peled (UIUC) CS Fall / 36

80 Set Difference Theorem M, M 2 DFAs. There is a DFA M such that L(M) = L(M ) \ L(M 2 ). Exercise: Prove the above using two methods. Using a direct product construction Using closure under complement and intersection and union Sariel Har-Peled (UIUC) CS Fall / 36

81 Things to know: 2-way DFA Question: Why are DFAs required to only move right? Can we allow DFA to scan back and forth? Caveat: Tape is read-only so only memory is in machine s state. Can define a formal notion of a 2-way DFA Can show that any language recognized by a 2-way DFA can be recognized by a regular (-way) DFA Proof is tricky simulation via NFAs Sariel Har-Peled (UIUC) CS Fall / 36

82 Things to know: 2-way DFA Question: Why are DFAs required to only move right? Can we allow DFA to scan back and forth? Caveat: Tape is read-only so only memory is in machine s state. Can define a formal notion of a 2-way DFA Can show that any language recognized by a 2-way DFA can be recognized by a regular (-way) DFA Proof is tricky simulation via NFAs Sariel Har-Peled (UIUC) CS Fall / 36

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) CS/ECE 374: Algorithms & Models of Computation, Fall 28 Deterministic Finite Automata (DFAs) Lecture 3 September 4, 28 Chandra Chekuri (UIUC) CS/ECE 374 Fall 28 / 33 Part I DFA Introduction Chandra Chekuri

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Spring 29 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, January 22, 29 L A TEXed: December 27, 28 8:25 Chan, Har-Peled, Hassanieh (UIUC) CS374 Spring

More information

Deterministic Finite Automata (DFAs)

Deterministic Finite Automata (DFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Deterministic Finite Automata (DFAs) Lecture 3 Tuesday, September 5, 27 Part I DFA Introduction Sariel Har-Peled (UIUC) CS374 Fall 27 / 36 Sariel

More information

Non-deterministic Finite Automata (NFAs)

Non-deterministic Finite Automata (NFAs) Algorithms & Models of Computation CS/ECE 374, Fall 27 Non-deterministic Finite Automata (NFAs) Part I NFA Introduction Lecture 4 Thursday, September 7, 27 Sariel Har-Peled (UIUC) CS374 Fall 27 / 39 Sariel

More information

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 3: DFA NFA, Regular Expressions CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and

More information

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 154. Finite Automata, Nondeterminism, Regular Expressions CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set

More information

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata. Finite Automata Automata (singular: automation) are a particularly simple, but useful, model of computation. They were initially proposed as a simple model for the behavior of neurons. The concept of a

More information

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont ) Sungjin Im University of California, Merced 2-3-214 Example II A ɛ B ɛ D F C E Example II A ɛ B ɛ D F C E NFA accepting

More information

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM) Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM) 1 Deterministic Turing Machine (DTM).. B B 0 1 1 0 0 B B.. Finite Control Two-way, infinite tape, broken into

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

Closure under the Regular Operations

Closure under the Regular Operations September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure

More information

CS 455/555: Finite automata

CS 455/555: Finite automata CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently

More information

Introduction to Turing Machines. Reading: Chapters 8 & 9

Introduction to Turing Machines. Reading: Chapters 8 & 9 Introduction to Turing Machines Reading: Chapters 8 & 9 1 Turing Machines (TM) Generalize the class of CFLs: Recursively Enumerable Languages Recursive Languages Context-Free Languages Regular Languages

More information

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0 Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0 Turing Machines Now for a machine model of much greater power.

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

CHAPTER 1 Regular Languages. Contents

CHAPTER 1 Regular Languages. Contents Finite Automata (FA or DFA) CHAPTER Regular Languages Contents definitions, examples, designing, regular operations Non-deterministic Finite Automata (NFA) definitions, euivalence of NFAs and DFAs, closure

More information

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages CS 154 Finite Automata vs Regular Expressions, Non-Regular Languages Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and guessing

More information

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata Sungjin Im University of California, Merced 1-27-215 Nondeterminism Michael Rabin and Dana Scott (1959) Michael Rabin Dana

More information

Chapter 5. Finite Automata

Chapter 5. Finite Automata Chapter 5 Finite Automata 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical

More information

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal

CSE 311 Lecture 23: Finite State Machines. Emina Torlak and Kevin Zatloukal CSE 3 Lecture 3: Finite State Machines Emina Torlak and Kevin Zatloukal Topics Finite state machines (FSMs) Definition and examples. Finite state machines with output Definition and examples. Finite state

More information

Equivalence of DFAs and NFAs

Equivalence of DFAs and NFAs CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs

More information

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS Automata Theory Lecture on Discussion Course of CS2 This Lecture is about Mathematical Models of Computation. Why Should I Care? - Ways of thinking. - Theory can drive practice. - Don t be an Instrumentalist.

More information

1 More finite deterministic automata

1 More finite deterministic automata CS 125 Section #6 Finite automata October 18, 2016 1 More finite deterministic automata Exercise. Consider the following game with two players: Repeatedly flip a coin. On heads, player 1 gets a point.

More information

Computational Models - Lecture 1 1

Computational Models - Lecture 1 1 Computational Models - Lecture 1 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. February 29/ March 02, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames

More information

FINITE STATE AUTOMATA

FINITE STATE AUTOMATA FINITE STATE AUTOMATA States An FSA has a finite set of states A system has a limited number of configurations Examples {On, Off}, {1,2,3,4,,k} {TV channels} States can be graphically represented as follows:

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

Finite Automata. Finite Automata

Finite Automata. Finite Automata Finite Automata Finite Automata Formal Specification of Languages Generators Grammars Context-free Regular Regular Expressions Recognizers Parsers, Push-down Automata Context Free Grammar Finite State

More information

Finite Automata. Mahesh Viswanathan

Finite Automata. Mahesh Viswanathan Finite Automata Mahesh Viswanathan In this lecture, we will consider different models of finite state machines and study their relative power. These notes assume that the reader is familiar with DFAs,

More information

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 5 CHAPTER 2 FINITE AUTOMATA 1. Deterministic Finite Automata DFA 2. Nondeterministic Finite Automata NDFA 3. Finite Automata

More information

Fooling Sets and. Lecture 5

Fooling Sets and. Lecture 5 Fooling Sets and Introduction to Nondeterministic Finite Automata Lecture 5 Proving that a language is not regular Given a language, we saw how to prove it is regular (union, intersection, concatenation,

More information

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

September 11, Second Part of Regular Expressions Equivalence with Finite Aut Second Part of Regular Expressions Equivalence with Finite Automata September 11, 2013 Lemma 1.60 If a language is regular then it is specified by a regular expression Proof idea: For a given regular language

More information

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION CSE 105 THEORY OF COMPUTATION "Winter" 2018 http://cseweb.ucsd.edu/classes/wi18/cse105-ab/ Today's learning goals Sipser Section 1.1 Design an automaton that recognizes a given language. Specify each of

More information

Course 4 Finite Automata/Finite State Machines

Course 4 Finite Automata/Finite State Machines Course 4 Finite Automata/Finite State Machines The structure and the content of the lecture is based on (1) http://www.eecs.wsu.edu/~ananth/cpts317/lectures/index.htm, (2) W. Schreiner Computability and

More information

Computational Models #1

Computational Models #1 Computational Models #1 Handout Mode Nachum Dershowitz & Yishay Mansour March 13-15, 2017 Nachum Dershowitz & Yishay Mansour Computational Models #1 March 13-15, 2017 1 / 41 Lecture Outline I Motivation

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages

More information

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is, Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the

More information

Context Free Languages and Grammars

Context Free Languages and Grammars Algorithms & Models of Computation CS/ECE 374, Fall 2017 Context Free Languages and Grammars Lecture 7 Tuesday, September 19, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 36 What stack got to do

More information

Nondeterministic Finite Automata

Nondeterministic Finite Automata Nondeterministic Finite Automata Mahesh Viswanathan Introducing Nondeterminism Consider the machine shown in Figure. Like a DFA it has finitely many states and transitions labeled by symbols from an input

More information

Formal Definition of Computation. August 28, 2013

Formal Definition of Computation. August 28, 2013 August 28, 2013 Computation model The model of computation considered so far is the work performed by a finite automaton Finite automata were described informally, using state diagrams, and formally, as

More information

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs CSE : Foundations of Computing Lecture : Finite State Machine Minimization & NFAs State Minimization Many different FSMs (DFAs) for the same problem Take a given FSM and try to reduce its state set by

More information

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata. CMSC 330: Organization of Programming Languages Last Lecture Languages Sets of strings Operations on languages Finite Automata Regular expressions Constants Operators Precedence CMSC 330 2 Clarifications

More information

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007. Proofs, Strings, and Finite Automata CS154 Chris Pollett Feb 5, 2007. Outline Proofs and Proof Strategies Strings Finding proofs Example: For every graph G, the sum of the degrees of all the nodes in G

More information

CS 154 Formal Languages and Computability Assignment #2 Solutions

CS 154 Formal Languages and Computability Assignment #2 Solutions CS 154 Formal Languages and Computability Assignment #2 Solutions Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak www.cs.sjsu.edu/~mak Assignment #2: Question 1

More information

Theory of Computation

Theory of Computation Thomas Zeugmann Hokkaido University Laboratory for Algorithmics http://www-alg.ist.hokudai.ac.jp/ thomas/toc/ Lecture 3: Finite State Automata Motivation In the previous lecture we learned how to formalize

More information

Deterministic Finite Automaton (DFA)

Deterministic Finite Automaton (DFA) 1 Lecture Overview Deterministic Finite Automata (DFA) o accepting a string o defining a language Nondeterministic Finite Automata (NFA) o converting to DFA (subset construction) o constructed from a regular

More information

CSE 105 Theory of Computation Professor Jeanne Ferrante

CSE 105 Theory of Computation  Professor Jeanne Ferrante CSE 105 Theory of Computation http://www.jflap.org/jflaptmp/ Professor Jeanne Ferrante 1 Today s agenda NFA Review and Design NFA s Equivalence to DFA s Another Closure Property proof for Regular Languages

More information

Finite-State Machines (Automata) lecture 12

Finite-State Machines (Automata) lecture 12 Finite-State Machines (Automata) lecture 12 cl a simple form of computation used widely one way to find patterns 1 A current D B A B C D B C D A C next 2 Application Fields Industry real-time control,

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION FORMAL LANGUAGES, AUTOMATA AND COMPUTATION DECIDABILITY ( LECTURE 15) SLIDES FOR 15-453 SPRING 2011 1 / 34 TURING MACHINES-SYNOPSIS The most general model of computation Computations of a TM are described

More information

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement

More information

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever.  ETH Zürich (D-ITET) September, Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) September, 24 2015 Last week was all about Deterministic Finite Automaton We saw three main

More information

CS243, Logic and Computation Nondeterministic finite automata

CS243, Logic and Computation Nondeterministic finite automata CS243, Prof. Alvarez NONDETERMINISTIC FINITE AUTOMATA (NFA) Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ Maloney Hall, room 569 alvarez@cs.bc.edu Computer Science Department voice: (67) 552-4333

More information

(Refer Slide Time: 0:21)

(Refer Slide Time: 0:21) Theory of Computation Prof. Somenath Biswas Department of Computer Science and Engineering Indian Institute of Technology Kanpur Lecture 7 A generalisation of pumping lemma, Non-deterministic finite automata

More information

Finite Automata and Regular languages

Finite Automata and Regular languages Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/

More information

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three

More information

Finite Automata. Seungjin Choi

Finite Automata. Seungjin Choi Finite Automata Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr 1 / 28 Outline

More information

CS 322 D: Formal languages and automata theory

CS 322 D: Formal languages and automata theory CS 322 D: Formal languages and automata theory Tutorial NFA DFA Regular Expression T. Najla Arfawi 2 nd Term - 26 Finite Automata Finite Automata. Q - States 2. S - Alphabets 3. d - Transitions 4. q -

More information

Theory of Computation Lecture 1. Dr. Nahla Belal

Theory of Computation Lecture 1. Dr. Nahla Belal Theory of Computation Lecture 1 Dr. Nahla Belal Book The primary textbook is: Introduction to the Theory of Computation by Michael Sipser. Grading 10%: Weekly Homework. 30%: Two quizzes and one exam. 20%:

More information

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa CS:4330 Theory of Computation Spring 2018 Regular Languages Finite Automata and Regular Expressions Haniel Barbosa Readings for this lecture Chapter 1 of [Sipser 1996], 3rd edition. Sections 1.1 and 1.3.

More information

Languages, regular languages, finite automata

Languages, regular languages, finite automata Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,

More information

Lecture 3: Nondeterministic Finite Automata

Lecture 3: Nondeterministic Finite Automata Lecture 3: Nondeterministic Finite Automata September 5, 206 CS 00 Theory of Computation As a recap of last lecture, recall that a deterministic finite automaton (DFA) consists of (Q, Σ, δ, q 0, F ) where

More information

Closure under the Regular Operations

Closure under the Regular Operations Closure under the Regular Operations Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have

More information

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA) Languages Non deterministic finite automata with ε transitions Recall What is a language? What is a class of languages? Finite Automata Consists of A set of states (Q) A start state (q o ) A set of accepting

More information

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2 5-25 Great Theoretical Ideas in Computer Science Lecture 4: Deterministic Finite Automaton (DFA), Part 2 January 26th, 27 Formal definition: DFA A deterministic finite automaton (DFA) M =(Q,,,q,F) M is

More information

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is Abstraction of Problems Data: abstracted as a word in a given alphabet. Σ: alphabet, a finite, non-empty set of symbols. Σ : all the words of finite length built up using Σ: Conditions: abstracted as a

More information

Computer Sciences Department

Computer Sciences Department 1 Reference Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER 3 objectives Finite automaton Infinite automaton Formal definition State diagram Regular and Non-regular

More information

CS 121, Section 2. Week of September 16, 2013

CS 121, Section 2. Week of September 16, 2013 CS 121, Section 2 Week of September 16, 2013 1 Concept Review 1.1 Overview In the past weeks, we have examined the finite automaton, a simple computational model with limited memory. We proved that DFAs,

More information

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application Examples of Regular Expressions 1. 0 10, L(0 10 ) = {w w contains exactly a single 1} 2. Σ 1Σ, L(Σ 1Σ ) = {w w contains at least one 1} 3. Σ 001Σ, L(Σ 001Σ ) = {w w contains the string 001 as a substring}

More information

Takeaway Notes: Finite State Automata

Takeaway Notes: Finite State Automata Takeaway Notes: Finite State Automata Contents 1 Introduction 1 2 Basics and Ground Rules 2 2.1 Building Blocks.............................. 2 2.2 The Name of the Game.......................... 2 3 Deterministic

More information

CSC173 Workshop: 13 Sept. Notes

CSC173 Workshop: 13 Sept. Notes CSC173 Workshop: 13 Sept. Notes Frank Ferraro Department of Computer Science University of Rochester September 14, 2010 1 Regular Languages and Equivalent Forms A language can be thought of a set L of

More information

CS 154 Introduction to Automata and Complexity Theory

CS 154 Introduction to Automata and Complexity Theory CS 154 Introduction to Automata and Complexity Theory cs154.stanford.edu 1 INSTRUCTORS & TAs Ryan Williams Cody Murray Lera Nikolaenko Sunny Rajan 2 Textbook 3 Homework / Problem Sets Homework will be

More information

Computational Models: Class 1

Computational Models: Class 1 Computational Models: Class 1 Benny Chor School of Computer Science Tel Aviv University October 19, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay

More information

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS 1. [6 POINTS] For language L 1 = {0 n 1 m n, m 1, m n}, which string is in L 1? ANSWER: 0001111 is in L 1 (with n =

More information

CS4026 Formal Models of Computation

CS4026 Formal Models of Computation CS4026 Formal Models of Computation Turing Machines Turing Machines Abstract but accurate model of computers Proposed by Alan Turing in 1936 There weren t computers back then! Turing s motivation: find

More information

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1) Definition 1 (Alphabet) A alphabet is a finite set of objects called symbols. Definition 2 (String)

More information

Finite Automata and Languages

Finite Automata and Languages CS62, IIT BOMBAY Finite Automata and Languages Ashutosh Trivedi Department of Computer Science and Engineering, IIT Bombay CS62: New Trends in IT: Modeling and Verification of Cyber-Physical Systems (2

More information

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh

NFA and regex. the Boolean algebra of languages. regular expressions. Informatics 1 School of Informatics, University of Edinburgh NFA and regex cl the Boolean algebra of languages regular expressions Informatics The intersection of two regular languages is regular L = even numbers L = odd numbers L = mod L = mod Informatics The intersection

More information

Subset construction. We have defined for a DFA L(A) = {x Σ ˆδ(q 0, x) F } and for A NFA. For any NFA A we can build a DFA A D such that L(A) = L(A D )

Subset construction. We have defined for a DFA L(A) = {x Σ ˆδ(q 0, x) F } and for A NFA. For any NFA A we can build a DFA A D such that L(A) = L(A D ) Search algorithm Clever algorithm even for a single word Example: find abac in abaababac See Knuth-Morris-Pratt and String searching algorithm on wikipedia 2 Subset construction We have defined for a DFA

More information

CpSc 421 Homework 1 Solutions

CpSc 421 Homework 1 Solutions CpSc 421 Homework 1 Solutions 1. (15 points) Let Σ = {a, b, c}. Figure 7 depicts two finite state machines that read Let L a and L b denote the languages recognized by DFA (a) and DFA (b) respectively.

More information

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University Finite Automata Wen-Guey Tzeng Computer Science Department National Chiao Tung University Syllabus Deterministic finite acceptor Nondeterministic finite acceptor Equivalence of DFA and NFA Reduction of

More information

Automata Theory for Presburger Arithmetic Logic

Automata Theory for Presburger Arithmetic Logic Automata Theory for Presburger Arithmetic Logic References from Introduction to Automata Theory, Languages & Computation and Constraints in Computational Logic Theory & Application Presented by Masood

More information

Further discussion of Turing machines

Further discussion of Turing machines Further discussion of Turing machines In this lecture we will discuss various aspects of decidable and Turing-recognizable languages that were not mentioned in previous lectures. In particular, we will

More information

September 7, Formal Definition of a Nondeterministic Finite Automaton

September 7, Formal Definition of a Nondeterministic Finite Automaton Formal Definition of a Nondeterministic Finite Automaton September 7, 2014 A comment first The formal definition of an NFA is similar to that of a DFA. Both have states, an alphabet, transition function,

More information

Extended transition function of a DFA

Extended transition function of a DFA Extended transition function of a DFA The next two pages describe the extended transition function of a DFA in a more detailed way than Handout 3.. p./43 Formal approach to accepted strings We define the

More information

Java II Finite Automata I

Java II Finite Automata I Java II Finite Automata I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz November, 23 Processing Regular Expressions We already learned about Java s regular expression

More information

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova. Introduction to the Theory of Computation Automata 1VO + 1PS Lecturer: Dr. Ana Sokolova http://cs.uni-salzburg.at/~anas/ Setup and Dates Lectures Tuesday 10:45 pm - 12:15 pm Instructions Tuesday 12:30

More information

Büchi Automata and their closure properties. - Ajith S and Ankit Kumar

Büchi Automata and their closure properties. - Ajith S and Ankit Kumar Büchi Automata and their closure properties - Ajith S and Ankit Kumar Motivation Conventional programs accept input, compute, output result, then terminate Reactive program : not expected to terminate

More information

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35

Finite Automata. Dr. Neil T. Dantam. Fall CSCI-561, Colorado School of Mines. Dantam (Mines CSCI-561) Finite Automata Fall / 35 Finite Automata Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Finite Automata Fall 2017 1 / 35 Outline Dantam (Mines CSCI-561) Finite Automata Fall 2017 2 / 35

More information

CISC 4090 Theory of Computation

CISC 4090 Theory of Computation 9/2/28 Stereotypical computer CISC 49 Theory of Computation Finite state machines & Regular languages Professor Daniel Leeds dleeds@fordham.edu JMH 332 Central processing unit (CPU) performs all the instructions

More information

Nondeterminism and Epsilon Transitions

Nondeterminism and Epsilon Transitions Nondeterminism and Epsilon Transitions Mridul Aanjaneya Stanford University June 28, 22 Mridul Aanjaneya Automata Theory / 3 Challenge Problem Question Prove that any square with side length a power of

More information

Lecture 1: Finite State Automaton

Lecture 1: Finite State Automaton Lecture 1: Finite State Automaton Instructor: Ketan Mulmuley Scriber: Yuan Li January 6, 2015 1 Deterministic Finite Automaton Informally, a deterministic finite automaton (DFA) has finite number of s-

More information

Computational Models Lecture 2 1

Computational Models Lecture 2 1 Computational Models Lecture 2 1 Handout Mode Ronitt Rubinfeld and Iftach Haitner. Tel Aviv University. March 16/18, 2015 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice

More information

Automata: a short introduction

Automata: a short introduction ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible

More information

CS21 Decidability and Tractability

CS21 Decidability and Tractability CS21 Decidability and Tractability Lecture 8 January 24, 2018 Outline Turing Machines and variants multitape TMs nondeterministic TMs Church-Turing Thesis So far several models of computation finite automata

More information

CPS 220 Theory of Computation REGULAR LANGUAGES

CPS 220 Theory of Computation REGULAR LANGUAGES CPS 22 Theory of Computation REGULAR LANGUAGES Introduction Model (def) a miniature representation of a thing; sometimes a facsimile Iraq village mockup for the Marines Scientific modelling - the process

More information

This lecture covers Chapter 6 of HMU: Pushdown Automata

This lecture covers Chapter 6 of HMU: Pushdown Automata This lecture covers Chapter 6 of HMU: ushdown Automata ushdown Automata (DA) Language accepted by a DA Equivalence of CFs and the languages accepted by DAs Deterministic DAs Additional Reading: Chapter

More information

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha. UNIT 2 Structure NON-DETERMINISTIC FINITE AUTOMATA

More information