Lecture 5: Computation Theory PDF
Document Details
Dr. Abdulrazzak Ali
Tags
Summary
This document presents a lecture on computation theory, focusing on deterministic and nondeterministic finite automata (DFA and NFA). It covers the definitions, properties, and examples of these concepts, including conversion between DFA and NFA, and provides exercises on regular expressions (RE).
Full Transcript
COMPUTATION THEORY Lecture Five Dr. Abdulrazzak Ali Deterministic Finite Automaton(DFA) In DFA, for each input symbol, one can determine the state to which the machine will move. Hence, it is called Deterministic Automaton. As it has a finite number of states, the machine is called...
COMPUTATION THEORY Lecture Five Dr. Abdulrazzak Ali Deterministic Finite Automaton(DFA) In DFA, for each input symbol, one can determine the state to which the machine will move. Hence, it is called Deterministic Automaton. As it has a finite number of states, the machine is called Deterministic Finite Machine or Deterministic Finite Automaton. Definition of a DFA A DFA can be represented by: 1. A finite set of states. 2. A finite set of symbols called the alphabet (Σ). 3. The transition function. 4. The initial state from where any input is processed. 5. A final state/states. Properties of DFA: There are two condition must be achieving together: 1. It has no transition on input ∧. 2. For each state (S) and input symbol (a) there almost one edge label (a) leave (S). Nondeterministic Finite Automaton (NFA) If the basic finite automata model is modified in such a way that from a state on an input symbol zero, one or more transitions are permitted, then the corresponding finite automata is called a "Nondeterministic finite automata" (NFA). NFA is finite automata in which there may exist more than one paths corresponding to x in ∑* (because zero, one, or more transitions are permitted from a state on an input symbol). Whereas in a DFA, there exists exactly one path corresponding to x in ∑*. A Nondeterministic finite automaton (NFA) is a collection of three things: 1. A finite set of states with one start state and some final states. 2. An alphabet ∑ of possible input letters. 3. A finite set of transitions that describe how to proceed from each state to other states along edges labeled with letters of the alphabet, where we allow the possibility of more than one edge with the same label from any state and some states for which certain input letters have no edge. Properties of NFA: One or both of these conditions must be achieve: 1. It has transition on input ∧ / 𝛆. 2. For each state (S) and input symbol (a) there almost more than one edge label (a) leave (S). Ex: Draw Nondeterministic finite automaton (NFA) transition diagram for the following Regular Expressions (RE). 1. a a 0 1 𝜀 2. a* 𝜀 a 𝜀 0 1 2 3 𝜀 3. (a + b) a 𝜀 1 2 𝜀 0 5 𝜀 𝜀 3 b 4 4. (a + b)* 𝜀 a 𝜀 2 3 𝜀 𝜀 𝜀 0 1 6 7 𝜀 𝜀 4 5 b 𝜀 5. (a + b)*abb 𝜀 a 𝜀 2 3 𝜀 𝜀 a b 0 𝜀 1 6 7 8 b 9 10 𝜀 𝜀 4 5 b 𝜀 Homework: Draw Nondeterministic finite automaton (NFA) transition diagram for the following Regular Expressions (RE). 1- a(a +b)*a(a + b) 2- (a + b)(a + b)+ 3- (a +b)*ba Convert Nondeterministic Finite Automaton(NFA) to Deterministic Finite Automaton(DFA) Example: Convert the following NFA to its equivalent DFA: 01*(0+1) 1 0 S 0 1 0 0 1 0 1 ∅ 2 1 2 {1,2} 1 2 ∅ ∅ NFA 0 S 0 1 0 1 ∅ 0 0 1 2 1 2 {1,2} DFA Table Transition 1 *2 ∅ ∅ S 0 1 A 0 1 ∅ B 1 2 {1,2} 0 0 A B C C *2 ∅ ∅ 0 1 0 D *{1,2} 2 {1,2} E ∅ ∅ ∅ E D 1,0 1,0 1 DFA Example: Convert NFA to DFA S 0 1 𝜀 𝜀 1 2 ∅ 1 0 3 1 4 2 3 5 2 1 0 2 3 ∅ 4 3 1 𝜀 5 0 6 4 ∅ ∅ 1,4 5 6 ∅ 1,5 𝜀 6 ∅ ∅ 1,6 DFA Table Transition S 0 1 1 *A *1 2 ∅ 0 0 B 2 3 {1,5} A B C 1 C 3 ∅ 1 1 0 *D *{1,5} {1,2,6} ∅ D E *E *{1,2,6} 2 {1,5} DFA 0 (a + b)*abb 𝜀 a 𝜀 2 3 𝜀 0 𝜀 1 6 𝜀 7a 8 b 9 b 10 𝜀 𝜀 4 5 b 𝜀 S a b A {0,1,2,4,7} {1,2,3,4,6,7,8} {1,2,4,5,6,7} B {1,2,3,4,6,7,8} {1,2,3,4,6,7,8} {1,2,4,5,6,7,9} C {1,2,4,5,6,7} {1,2,3,4,6,7,8} {1,2,3,4,5,6,7} D {1,2,4,5,6,7,9} {1,2,3,4,6,7,8} {1,2,4,5,6,7,10} E {1,2,4,5,6,7,10} {1,2,3,4,6,7,8} {1,2,4,5,6,7} Homework Convert NFA to DFA