1 / 73

CS 208: Computing Theory

CS 208: Computing Theory. Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics. Automata Theory. Finite Sate Machines. Motivation. Question : What is a computer? Too complex to allow a precise mathematical model

Download Presentation

CS 208: Computing Theory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics

  2. Automata Theory Finite Sate Machines

  3. Motivation • Question: What is a computer? • Too complex to allow a precise mathematical model • We introduce an abstract idealized computer • Computational model • One such a model is called finite automaton

  4. Key ideas • Formal definition of a finite automaton • Deterministic vs. nondeterministic finite automaton • Regular languages • Operations on regular languages • Regular expressions • Pumping Lemma

  5. Automata Theory Deterministic Finite Automaton

  6. Front pad Rear pad door Example: Automatic door Opens when someone approaches Holds open until person clears Doesn’t open when someone is standing behind the door

  7. Automatic door Sensors • The door has 4 sensors • FRONT: someone on rear pad • BEHIND: someone on the rear pad • BOTH: someone on both pads • NEITHER: no one on either pad

  8. Automatic door states • The door has two states • OPEN • CLOSE

  9. Automatic door: state diagram CLOSED OPEN

  10. Automatic door: state diagram FRONT REAR BOTH CLOSED OPEN

  11. Automatic door: state diagram REAR BOTH NEITHER FRONT REAR BOTH CLOSED OPEN

  12. Automatic door: state diagram REAR BOTH NEITHER FRONT REAR BOTH FRONT CLOSED OPEN

  13. REAR BOTH NEITHER FRONT REAR BOTH FRONT CLOSED OPEN NEITHER Automatic door: state diagram

  14. REAR BOTH NEITHER FRONT REAR BOTH FRONT CLOSED OPEN NEITHER Automatic door: state transition table NEITHER FRONT REAR BOTH CLOSED OPEN CLOSED OPEN CLOSED CLOSED CLOSED OPEN OPEN OPEN

  15. Informal definition 0 1 1 0 q1 q2 q3 0,1 • The machine M has • States: q1,q2, and q3 • Start state: q1 (incoming arrow from nowhere) • Accept state: q2 (thick circle) • State transitions: arrows

  16. Informal definition 0 1 1 0 q1 q2 q3 0,1 • The machine M on input string • begins in start stateq1 • after reading each symbol, 1 takes transition with matching symbol

  17. Informal definition 0 1 1 0 q1 q2 q3 0,1 • After processing all the input string machine M produces output • accept if M is in an accepting state • reject otherwise

  18. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 1101 • 0010 • 01100

  19. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 1101

  20. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 1101

  21. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 1101

  22. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 1101 • Accept

  23. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 0010

  24. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 0010

  25. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 0010

  26. Informal definition 0 1 1 0 q1 q2 q3 0,1 • What happens on input string? • 0010 • Reject

  27. Informal definition 0 1 1 0 q1 q2 q3 0,1 • Can you describe the language consisting of all string that M actually accepts?

  28. Informal definition 0 1 1 0 q1 q2 q3 0,1 • M actually accepts • any string that ends with a 1 • 1,01,11,01010101010101,… • any string the ends with an even number of 0’s after the last 1 • 100, 101010000,…

  29. Formal Definitions • A finite automaton is a 5-tuple (Q,∑,ξ,q0,F), where • Q is a finite set of states • ∑ is a finite set of symbols called the alphabet • ξ : Q x ∑  Q is the transition function • q0 Є Q is the start state • F ⊆ Q is the set of accept states or final states

  30. Back to M 0 1 1 0 q1 q2 q3 0,1 • M is a 5-tuple (Q,∑,ξ,q1,F), where • Q is a finite set of states {q1,q2,q3} • ∑ is {0,1} • ξ : Q x ∑  Q is the transition function • q1 Є Q is the start state • F ⊆ Q is {q2} ξ 0 1 q1 q2 q3 q1 q2 q3 q2 q2 q2

  31. Another example: M1 0 1 1 q1 q2 0 • M1 is a 5-tuple (Q,∑,ξ,q1,F), where • Q is a finite set of states {q1,q2} • ∑ is {0,1} • ξ : Q x ∑  Q is the transition function • q1 Є Q is the start state • F ⊆ Q is {q2} ξ 0 1 q1 q2 q1 q2 q1 q2

  32. Another example: M1 0 1 1 q1 q2 0 • What language does M1 accept?

  33. Another example:M1 0 1 1 q1 q2 0 • What language does M1 accept? • M1 accepts all the strings that end with a 1

  34. Another example:M2 s a b b a q1 r1 a b a b q2 r2 b a

  35. Another example:M2 s a b b a q1 r1 a b a b q2 r2 • What language does M2 accept? b a

  36. Another example:M2 s a b b a q1 r1 a b a b q2 r2 • What language does M2 accept? • M1 accepts all the strings that start and end with the same symbol! b a

  37. Languages • The language of machine M is the set of strings A that M accepts • L(M) = A • Note that • M can accept many strings • … but M accepts only one language • We say that M recognizeslanguage A if • A= {w | M accepts w}

  38. Regular language • A language is called a regular language if some finite automaton recognizes it

  39. Formal model of computation • Let M= (Q,∑,ξ,q0,F) be a Deterministic Finite Automaton (DFA) • Let w=w1w2…wn be a string over ∑ • M accepts w if a sequence of states r0,…,rnexist such that: • r0=q0 • ξ(ri,wi+1)=ri+1, i<n • rnЄ F

  40. Formal model of computation • Let M= (Q,∑,ξ,q0,F) be a Deterministic Finite Automaton (DFA) • Let w=w1w2…wn be a string over ∑ • M accepts w if a sequence of states r0,…,rnexist such that: • r0=q0 : the machine starts in the start state • ξ(ri,wi+1)=ri+1, i<n: the machines goes from state to state according to the transition function • rnЄ F: machine accepts its input if it ends up in an accept state

  41. The regular operations • Union operation • A U B = {x | x Є A or x Є B} • It takes all string and A and B and puts them together into one language

  42. The regular operations • Union operation • A U B = {x | x Є A or x Є B} • It takes all string in A and B and puts them together into one language • Let A={good, bad} and B ={boy, girl} •  A U B ={good, bad, boy, girl}

  43. The regular operations • Concatenation operation • A o B = {xy| x Є A and y Є B} • It attaches a string from B to the end of a string from A in the new language

  44. The regular operations • Concatenation operation • A o B = {xy| x Є A and y Є B} • It attaches a string from B to the end of a string from A in the new language • Let A={good, bad} and B ={boy, girl} • A o B = {goodboy, goodgirl, badboy, badgirl}

  45. The regular operations • Star operation • A*={x1x2…xk| k is positive and each xiЄ A} • It applies to a single language • Attaches any number of string from A to get a string in the new language

  46. The regular operations • Star operation • A*={x1x2…xk| k is positive and each xiЄ A} • It applies to a single language • Attaches any number of string from A to get a string in the new language • Let A={good, bad} •  A* = {Ø, good,bad, goodgood, goodbad, badbad, badgood, gooodgooodgood, goodgoodbad, goodbadgood,…}

  47. “Closed under” • The set of natural number N={1,2,3,….} is closed under multiplication • For any a and b in N, a x b is also in N • 3 x 5 = 15: 3, 5, and 15 are all naturals • In general, a collection of objects is closed under some operation if applying that operation to members of the collection returns and object still in the collection • Note; the set of natural numbers is not closed under division • 3 / 5 is not a natural number

  48. Regular languages closed under union • Theorem: The class of regular languages is closed under the union operation • If A1 and A2 are regular languages, so is A1 U A2

  49. Proof idea • How to prove such a theorem? • Remember that the only result we have seen so far is • “A language is called a regular language if some finite automaton recognizes it”

  50. Proof idea • “A language is called a regular language if some finite automaton recognizes it” • So, let us look at our theorem from this perspective: • If A1 and A2 are regular languages, so is A1 U A2 M1

More Related