Principles of Computing – UFCFA3-30-1

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

Reducing DFA’s Section 2.4. Reduction of DFA For any language, there are many DFA’s that accept the language Why would we want to find the smallest? Algorithm:
CMPS 3223 Theory of Computation
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
1 Languages and Finite Automata or how to talk to machines...
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
Finite Automata Costas Busch - RPI.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Finite-State Machines with No Output Longin Jan Latecki Temple University Based on Slides by Elsa L Gunter, NJIT, and by Costas Busch Costas Busch.
Finite-State Machines with No Output
Lecture 03: Theory of Automata:08 Finite Automata.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automaton (DFA) Input Tape “Accept” or “Reject” String Finite Automaton Output.
Transition Diagrams Lecture 3 Wed, Jan 21, Building Transition Diagrams from Regular Expressions A regular expression consists of symbols a, b,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Modeling Computation: Finite State Machines without Output
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Formal Languages Finite Automata Dr.Hamed Alrjoub 1FA1.
Lecture #5 Advanced Computation Theory Finite Automata.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Costas Busch - LSU1 Deterministic Finite Automata And Regular Languages.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
Languages.
Deterministic Finite Automata And Regular Languages.
Lexical analysis Finite Automata
Lecture2 Regular Language
Non Deterministic Automata
CSE 105 theory of computation
Busch Complexity Lectures: Reductions
Reductions.
Theory of Computation Lecture # 9-10.
Lecture 9 Theory of AUTOMATA
Recognizer for a Language
Principles of Computing – UFCFA3-30-1
Chapter 2 FINITE AUTOMATA.
COSC 3340: Introduction to Theory of Computation
CSE322 Finite Automata Lecture #2.
Some slides by Elsa L Gunter, NJIT, and by Costas Busch
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
Non-Deterministic Finite Automata
Principles of Computing – UFCFA3-30-1
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Decidable Languages Costas Busch - LSU.
Non Deterministic Automata
Transition Diagrams Lecture 3 Fri, Jan 21, 2005.
Principles of Computing – UFCFA3-30-1
Theory of Computation Lecture #
NFAs and Transition Graphs
Finite Automata.
4b Lexical analysis Finite Automata
Principles of Computing – UFCFA3-30-1
Recap lecture 6 Language of strings, beginning with and ending in different letters, Accepting all strings, accepting non-empty strings, accepting no string,
Principles of Computing – UFCFA Lecture-2
Deterministic Finite Automaton (DFA)
4b Lexical analysis Finite Automata
Principles of Computing – UFCFA3-30-1
CSCI 2670 Introduction to Theory of Computing
CSC312 Automata Theory Transition Graphs Lecture # 9
Regular Language Equivalence and DFA Minimization
LECTURE # 07.
Lexical Analysis Uses formalism of Regular Languages
Part Two : Nondeterministic Finite Automata
Presentation transcript:

Principles of Computing – UFCFA3-30-1 Week-4 Instructor : Mazhar H Malik Email : mazhar@gcet.edu.om Global College of Engineering and Technology

Extended Topics in DFA

Trap or Dead State A trap is state that, once entered, one can never leave. Used to reject partly read strings that will never be accepted, or to accept partly read strings that will definitely be accepted. Trap State: Dead states are those non final states which transits (Self Loop) in itself for all the symbol.

Set of States Q Q  q0 , q1, q2 , q3, q4 , q5 Example • a,b q5 a,b

Input Alphabet  • Example   a,b a,b q5 a,b q4 b q0 b q3 q1 b q2 b

q0 Initial State Example a,b q5 a,b q4 b q0 b q3 q1 b q2 b

Example: •  q0 , a  q1 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

 q0 ,b  q5 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

 state s symbols Transition Table for  • b q0 q1 q5 q2 q3 q4 a,b q5

Example a,b a,b b q0 q1 Accept state q2 trap state 11

b Input String a,b a,b b q0 q1 q2 12

b a,b a,b b q0 q1 q2 13

b a,b a,b b q0 q1 q2

Input finished b a,b accept a,b b q0 q1 q2

A rejection case b Input String a,b a,b b q0 q1 q2

b a,b a,b b q0 q1 q2

b a,b a,b b q0 q1 q2

Input finished b a,b a,b b q0 q1 q2 reject

L  {a nb : n  0} Language Accepted: a,b a,b b q0 q1 q2

Another Example EVEN  {x : x  * and x is even} Alphabet:   {1} 1 q0 q1 Language Accepted: EVEN  {x : x  * and x is even}  {, 11, 1111, 111111, }

Example 2.3 Design a DFA that accept set of strings that containing four 1’s every string over alphabet ∑ = {0,1} Solution: DFA should accepts the string 1111, 0101011, 0110110000… Let DFA be M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q4} Trap State: Dead states are those non final states which transits in itself for all the symbol. So q5 is example of dead state

Example 2.4 Design a DFA (Graph and Table) that accept set of strings that containing exactly 1 every string over alphabet ∑ = {0,1} Solution: DFA should accepts the string 1, 010000, 00010000… Let DFA be M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q1} ∂/∑ 1 -> q0 q0 q1 * q1 q2 Self Loop

Example 2.5 Design a DFA that accept Language L = {ω ∈ (0,1)* / second symbol of ω is ‘0’ and fourth input is 1} Solution: So after analyzing the problem we find that every string of the language is like 0001, 1011, 10110000… Let DFA be M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q4} For securing the second and fourth position we need trap state

Example 2.6 For the given DFA Write the language and also given the transition table ∂/∑ 1 -> q0 q1 q0 q2 *q2 Solution: Let the language be L for FA shown in Example 2.6 L = {ω ∈ (0,1)* /every string ω of the language containing 00 as substring}. Transition Table:

Example 2.7 Design DFA for the Language L = {(01)i 12j | i ≥ j≥1} Solution: Let analyzing the language be L for FA accept strings start with any with any number of 01 (no empty) and end with even number of 1’s Let FA be. M = {Q, ∑ ,∂, q0, F}, Q = {q0, q1, q2, q4, q5}, F = {q4}, ∑ = {0,1}

 * :Q  *  Q  * (q,w )  q  Extended Transition Function Describes the resulting state after scanning string w from state q

Example:  * q0,ab   q2 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

 * q0,abbbaa   q5 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

 q , bba *  q 1 4 a,b q5 a,b q4 b q0 b q3 q1 b q2 b

Special case: for any state q  * q,   q

q q w  * q,w   q  w  12 k In general: implies that there is a walk of transitions w  12 k 1  2  k q q states may be repeated w q q

Minimization of DFA’s To remove Dead State Inaccessible State Equivalent State Useless State

Step-2: ->q0 q5 q1 q2 q6 *q2 q0 q4 q7 Draw the transition table for test states, after removing q3 (unreachable state) ∂/∑ a b ->q0 q5 q1 q2 q6 *q2 q0 q4 q7

Step-3: ->q0 q5 q1 q2 q6 q4 q7 *q2 q2 q0 Now divide rows of transition table in two sets as: One set contains only those rows, which starts from non-final states i.e. Other set contains only those rows, which starts from final state Non-final states ∂/∑ a b ->q0 q5 q1 q2 q6 q4 q7 Final states ∂/∑ a b *q2 q2 q0

Step-4: Apply step-4 on both the sets individually. Now consider set-1 ∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 q4 q7 q1 3 4 5 q7 6

Step-4: Row 2 and row 6, are similar since q1 and q7 transit to same states on a and b. So skip one of them skip skip row 6, then q7 in the rest . Write the rest as follows: ∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 q4 3 4 5

Step-5: Repeat Step-4 on the rest set-1, till you are finding similar rows and write rest, now this set is minimized ∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 q4 4 q7 q0 5 3

Step-5: Now minimized set is ∂/∑ a b Rows ->q0 q5 q1 1 q2 q6 2 4 q4 q0 5

Step-6: Do same process for set 2 as Final states ∂/∑ a b *q2 q2 q0

Step-7: Now combine set-1 and set-2 as ∂/∑ a b ->q0 q5 q1 q2 q6 q4 q0 *q2

Minimized DFA Transition Graph ∂/∑ a b ->q0 q5 q1 q2 q6 q4 q0 *q2

Minimized DFA - Comparison

Your Turn… Minimize the following DFA

Minimization by Transition Graph 46

Minimization Example Start with a DFA 48

Minimization Example Miniature version  49

Sources http://www.jflap.org/tutorial/ www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt Theory of computation by A. Pandey http://www.cburch.com/proj/autosim/