Principles of Computing – UFCFA3-30-1

Slides:



Advertisements
Similar presentations
Finite-State Machines with No Output Ying Lu
Advertisements

4b Lexical analysis Finite Automata
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
Lecture 6 Nondeterministic Finite Automata (NFA)
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
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 Minimization; Pumping Lemma. October 2, Agenda Minimization Algorithm Guarantees smallest possible DFA for a given regular language Proof of.
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
Fall 2006Costas Busch - RPI1 Deterministic Finite Automaton (DFA) Input Tape “Accept” or “Reject” String Finite Automaton Output.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
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
MINIMIZATION May 12, Agenda 2  These slides are not mine www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt.
Formal Languages Finite Automata Dr.Hamed Alrjoub 1FA1.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
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.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Introduction to Automata Theory Theory of Computation Lecture 3 Tasneem Ghnaimat.
Theory of Computation Pushdown Automata pda Lecture #10.
Languages.
Deterministic Finite Automata And Regular Languages.
Lexical analysis Finite Automata
Non Deterministic Automata
PROPERTIES OF REGULAR LANGUAGES
Busch Complexity Lectures: Reductions
Reductions.
Pushdown Automata PDAs
Pushdown Automata.
Lecture 9 Theory of AUTOMATA
Recognizer for a Language
Principles of Computing – UFCFA3-30-1
Chapter 2 FINITE AUTOMATA.
CSE322 Finite Automata Lecture #2.
Non-deterministic Finite Automata (NFA)
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
Non Deterministic Automata
Principles of Computing – UFCFA3-30-1
NFAs and Transition Graphs
Finite Automata.
4b Lexical analysis Finite Automata
4b Lexical analysis Finite Automata
Principles of Computing – UFCFA3-30-1
Principles of Computing – UFCFA3-30-1
CSC312 Automata Theory Transition Graphs Lecture # 9
NFAs and Transition Graphs
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

The Game of MINIMIZE All useless players are disqualified. Game proceeds in rounds. Start with 2 teams: ACCEPT vs. REJECT. Each round consists of sub-rounds – one sub- round per team. Two members of a team are said to agree if for a given label, they want to pass the buck to same team. Otherwise, disagree. During a sub-round, disagreeing members split off into new maximally agreeing teams. If a round passes with no splits, STOP. 47

Minimization Example Start with a DFA 48

Minimization Example Miniature version  49

Minimization Example Split into two teams. ACCEPT vs. REJECT 50

Minimization Example 0-label doesn’t split up any teams 51

Minimization Example 1-label splits up REJECT's 52

Minimization Example No further splits. HALT! Start team contains original start 53

Minimization Example. End Result States of the minimal automata are remaining teams. Edges are consolidated across each team. Accept states are break-offs from original ACCEPT team. 54

Minimization Example. Compare 100100101 55

Minimization Example. Compare 100100101 56

Minimization Example. Compare 100100101 57

Minimization Example. Compare 100100101 58

Minimization Example. Compare 100100101 59

Minimization Example. Compare 100100101 60

Minimization Example. Compare 100100101 61

Minimization Example. Compare 100100101 62

Minimization Example. Compare 100100101 63

Minimization Example. Compare 100100101 ACCEPTED. 64

Minimization Example. Compare 10000 65

Minimization Example. Compare 10000 66

Minimization Example. Compare 10000 67

Minimization Example. Compare 10000 68

Minimization Example. Compare 10000 69

Minimization Example. Compare 10000 REJECT. 70

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/