Presentation is loading. Please wait.

Presentation is loading. Please wait.

Theory of Computation Automata Theory Dr. Ayman Srour.

Similar presentations


Presentation on theme: "Theory of Computation Automata Theory Dr. Ayman Srour."— Presentation transcript:

1 Theory of Computation Automata Theory Dr. Ayman Srour

2 TOPIC 2: REGULAR LANGUAGES OUTLINE 2.1 Introduction 2.2 Finite Automata 2.3 Nondeterminism 2.4 Regular Expressions 2.5 Generalized Nondeterministic Finite Automaton

3 2.3 Non-determinism Determinism: ” given the current state we know what the next state will be” Only one unique next stat. No choice. No randomness (Perfect repeatability). No oracle. No Cheating (No error, No malfunction).

4 2.3 Non-determinism Normal computers are deterministic? Except they take random input. Random error may produced. So forget about it.

5 2.3 Non-determinism Nondeterminism is a useful concept that has had great impact on the theory of computation. So far in our discussion, every step of a computation follows in a unique way from the preceding step. Nondeterminism is the ability to make guesses, which we can later verify When the machine is in a given state and reads the next input symbol, we know what the next state will be-it is determined. We call this deterministic computation. In a nondeterministic machine, several choices may exist for the next state at any point. Nondeterminism is a generalization of determinism, so every deterministic finite automaton is automatically a nondeterministic finite automaton.

6 2.3 Non-determinism This is a kind of automaton that allows you to make guesses Each state can have zero, one, or more transitions out labeled by the same symbol State q 1 has two transitions labeled 1. Upon reading 1, we have the choice of staying in q 1 or moving to q 2. State q 2 has no transition labeled 1, instead have epsilon ε and 0. Upon reading 1 in q 2, we die; upon reading 0 or ε, we continue to q 3 Zero, one, or many arrows may exit from each state with the label ε.

7 2.3 Non-determinism How does an NFA compute? Suppose that we are running an NFA on an input string and come to a state with multiple ways to proceed. For example, say that we are in state q1 in NFA N 1 and that the next input symbol is a 1. after reading that symbol, the machine splits into multiple copies of itself and follows all the possibilities in parallel Each copy of the machine takes one of the possible ways to proceed and continues as before.

8 2.3 Non-determinism If there are subsequent choices, the machine splits again. If the next input symbol doesn't appear on any of the arrows exiting the state occupied by a copy of the machine, that copy of the machine dies, along with the branch of the computation associated with it. Finally, if anyone of these copies of the machine is in an accept state at the end of the input, the NFA accepts the input string.

9 2.3 Non-determinism Another way to think of a nondeterministic computation is as a tree of possibilities. The root of the tree corresponds to the start of the computation. Every branching point in the tree corresponds to a point in the computation at which the machine has multiple choices. The machine accepts if at least one of the computation branches ends in an accept state, as shown in the next slide.

10 2.3 Non-determinism

11 Try this string 010110

12 2.3 Non-determinism every NFA can be converted into an equivalent DFA, and constructing NFAs is sometimes easier than directly constructing DFAs. An NFA may be much smaller than its deterministic counterpart, or its functioning may be easier to understand.

13 2.3 Non-determinism 1 0 0, 1 qq qq qq NFA:

14 2.3 Non-determinism 1 0 0, 1 qq qq qq NFA: DFA: 1 qq q 0 or q 1 q 0 or q 2 1 0 0 0

15 2.3 Non-determinism/ Formal definition A nondeterministic finite automaton (NFA) is a 5-tuple (Q, , , q 0, F) where Q is a finite set of states  is an alphabet  : Q ×  → subsets of Q is a transition function q 0  Q is the initial state F  Q is a set of accepting states (or final states). Only difference from DFA is that output of  is a set of states

16 2.3 Non-determinism/ Example 1 0 1 0, 1 qq qq qq qq alphabet  = {0, 1} start state Q = {q 0, q 1, q 2, q 3 } initial state q 0 accepting states F = {q 3 } states inputs 0 1 q0q0 q1q1 q2q2 {q 0, q 1 } transition function  q3q3 {q 0 } {q 2 }    {q 3 } 

17 2.3 Non-determinism Obviously, an NFA can do everything a DFA can do But can it do more?

18 2.3 Non-determinism Obviously, an NFA can do everything a DFA can do But can it do more? Theorem A language L is accepted by some DFA if and only if it is accepted by some NFA. NO!


Download ppt "Theory of Computation Automata Theory Dr. Ayman Srour."

Similar presentations


Ads by Google