foundations of computer science lecture 24 deterministic
play

Foundations of Computer Science Lecture 24 Deterministic Finite - PowerPoint PPT Presentation

Foundations of Computer Science Lecture 24 Deterministic Finite Automata (DFA) A Simple Computing Machine: A CPU with States and Transitions What Problems Can It Solve: Regular Languages Is There A Problem It Cant Solve? Computing Problems


  1. Foundations of Computer Science Lecture 24 Deterministic Finite Automata (DFA) A Simple Computing Machine: A CPU with States and Transitions What Problems Can It Solve: Regular Languages Is There A Problem It Can’t Solve?

  2. Computing Problems and Their Difficulty Computing Problem Computing Problem Language L : yes -set of finite binary strings Decision Problem Decision Problem Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

  3. Computing Problems and Their Difficulty Computing Problem Computing Problem Language L : yes -set of finite binary strings Decision Problem Decision Problem ? How hard is the problem? How complex is L ? How complex is L ? How hard is it to test membership in L ? How hard is it to test membership in L ? Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

  4. Computing Problems and Their Difficulty Computing Problem Computing Problem Language L : yes -set of finite binary strings Decision Problem Decision Problem ? How hard is the problem? How complex is L ? How complex is L ? How hard is it to test membership in L ? How hard is it to test membership in L ? A problem can be harder in two ways. 1 The problem needs more resources. For example, the problem can be solved with a similar machine to ours, except with more states. 2 The problem needs a different kind of computing machine, with superior capabilities. Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

  5. Computing Problems and Their Difficulty Computing Problem Computing Problem Language L : yes -set of finite binary strings Decision Problem Decision Problem ? How hard is the problem? How complex is L ? How complex is L ? How hard is it to test membership in L ? How hard is it to test membership in L ? A problem can be harder in two ways. 1 The problem needs more resources. For example, the problem can be solved with a similar machine to ours, except with more states. 2 The problem needs a different kind of computing machine, with superior capabilities. The first type of “harder” is the focus of a follow-on algorithms course. We focus on what can and can’t be solved on a particular kind of machine. Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 2 / 15 Today →

  6. Today: Deterministic Finite Automata (DFA) A simple computing machine. 1 States. Transitions. No scratch paper. What computing problems can this simple machine solve? 2 Vending machine. Regular languages. 3 Closed under all the set operations: union, intersection, complement, concatenation, Kleene-star. Are there problems that cannot be solved? 4 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 3 / 15 A Simple Computing Machine →

  7. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 q 6 q 2 q 5 q 3 q 4 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  8. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  9. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 states q 0 q 1 → q 0 no q 1 yes q 2 q 2 no Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  10. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0, transition to q 1 → q 0 no q 1 yes q 2 q 2 no Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  11. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no q 1 yes q 2 q 2 no Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  12. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no 3 : q 1 0 q 1 1 q 1 yes q 2 q 2 no Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  13. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no 3 : q 1 0 q 1 1 q 1 yes 4 : q 1 1 q 2 q 2 q 2 no Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  14. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no 3 : q 1 0 q 1 1 q 1 yes 4 : q 1 1 q 2 q 2 0,1 q 2 5 : q 2 0 q 2 no 6 : q 2 1 q 2 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  15. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no 3 : q 1 0 q 1 1 q 1 yes 4 : q 1 1 q 2 q 2 0,1 q 2 5 : q 2 0 q 2 no 6 : q 2 1 q 2 1: Process the input string (left-to-right) starting from the initial state q 0 . Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  16. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no 3 : q 1 0 q 1 1 q 1 yes 4 : q 1 1 q 2 q 2 0,1 q 2 5 : q 2 0 q 2 no 6 : q 2 1 q 2 1: Process the input string (left-to-right) starting from the initial state q 0 . 2: Process one bit at a time, each time transitioning from the current state to the next state according to the transition instructions. Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  17. A Simple Computing Machine 0 1 0 1 1 0 0 0 1 0 q 0 q 7 q 1 yes or q 6 q 2 q 5 q 3 no q 4 transitions states 1 : q 0 0 q 1 ← In state q 0 , if you read 0 q 0 q 1 0 0, transition to q 1 2 : q 0 1 q 2 1 → q 0 no 3 : q 1 0 q 1 1 q 1 yes 4 : q 1 1 q 2 q 2 0,1 q 2 5 : q 2 0 q 2 no 6 : q 2 1 q 2 1: Process the input string (left-to-right) starting from the initial state q 0 . 2: Process one bit at a time, each time transitioning from the current state to the next state according to the transition instructions. 3: When done processing every bit, output yes if the final resting state of the DFA is a yes -state; otherwise output no . Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 4 / 15 Running the Machine →

  18. Running the Machine on an Input 0 q 0 q 1 0 1 q 0 | ⊲ 010 0 1 0 1 q 2 0,1 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

  19. Running the Machine on an Input 0 q 0 q 1 0 1 q 0 | ⊲ 010 0 1 0 1 q 2 0,1 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 � M is the name � q 2 0,1 of our “Machine” Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

  20. Running the Machine on an Input 0 q 0 q 1 0 1 q 0 | ⊲ 010 0 1 0 1 q 2 0,1 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 � M is the name � q 2 0,1 of our “Machine” 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 M �→ q 2 | 01 ⊲ 0 q 2 0,1 Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

  21. Running the Machine on an Input 0 q 0 q 1 0 1 q 0 | ⊲ 010 0 1 0 1 q 2 0,1 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 � M is the name � q 2 0,1 of our “Machine” 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 M �→ q 2 | 01 ⊲ 0 q 2 0,1 0 M q 0 q 1 q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 0 1 M �→ q 2 | 01 ⊲ 0 0 1 0 1 M q 2 0,1 �→ q 2 | 010 ⊲ Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

  22. Running the Machine on an Input 0 q 0 q 1 0 1 q 0 | ⊲ 010 0 1 0 1 q 2 0,1 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 � M is the name � q 2 0,1 of our “Machine” 0 q 0 q 1 0 M q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 1 0 1 0 1 M �→ q 2 | 01 ⊲ 0 q 2 0,1 0 M q 0 q 1 q 0 | ⊲ 010 �→ q 1 | 0 ⊲ 10 0 1 M �→ q 2 | 01 ⊲ 0 0 1 0 1 M q 2 0,1 �→ q 2 | 010 ⊲ no , reject Pop Quiz. Give computation trace for ε , 010 , 000 . What strings does the machine accept and say yes ? Pop Quiz. Determine yes or no if you can from partial traces. q 0 | ? ⊲ 0000 ; ? ⊲ 0000 ; ? ⊲ 0000 . q 1 | q 2 | Creator: Malik Magdon-Ismail Deterministic Finite Automata (DFA): 5 / 15 Computing Problem Solved by a DFA →

Recommend


More recommend