AUTOMATA THEORY.

Slides:



Advertisements
Similar presentations
4b Lexical analysis Finite Automata
Advertisements

Lecture 6 Nondeterministic Finite Automata (NFA)
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
REGULAR LANGUAGES.
Theory of Languages and Automata
1 Chapter 2 Finite Automata (part b) Windmills in Holland.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Deterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.2)
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Lecture Notes 
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Overview of Previous Lesson(s) Over View  A token is a pair consisting of a token name and an optional attribute value.  A pattern is a description.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Theory of Computation Automata Theory Dr. Ayman Srour.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
Theory of Computation Automata Theory Dr. Ayman Srour.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
Nondeterminism The Chinese University of Hong Kong Fall 2011
CIS Automata and Formal Languages – Pei Wang
Lexical analysis Finite Automata
Lecture2 Regular Language
Non Deterministic Automata
Chapter 2 Finite Automata
Finite Automata a b A simplest computational model
Nondeterministic Finite Automata
Two issues in lexical analysis
Finite Automata & Regular Languages
Hierarchy of languages
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
Chapter Two: Finite Automata
Deterministic Finite State Automata
Non-Deterministic Finite Automata
Non Deterministic Automata
Introduction to Finite Automata
Finite Automata.
4b Lexical analysis Finite Automata
Chapter Five: Nondeterministic Finite Automata
Deterministic Finite Automaton (DFA)
4b Lexical analysis Finite Automata
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
Non Deterministic Automata
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

AUTOMATA THEORY

Chapter 02 FINITE AUTOMATA

Deterministic Finite Automata A Deterministic Finite Automaton (DFA) is a 5-tuple (Q, S, d, q0, F) where Q is a finite set of States S is an Alphabet, finite set of input symbol d: Q × S → Q is a Transition Function d (q, a)=p where q= present state p=next state and a=input q0 Î Q is the Initial State F Í Q is a set of Accepting States (or Final States) will be denoted by Double Loops.

Notations for DFA There are two preferred notations for describing automata: A Transition Diagram A Transition Table

TRANSITION DIAGRAM For each state in Q there is a node. d(q, a)=p arc from node q to p and labeled a. There is an arrow into start state q0, labeled start. Nodes corresponding to accepting states are marked by a double circle.

Example A=({q0,q1,q2},{0,1}, d ,q0,{q2}) Draw the Transition Diagram for the DFA accepting all string with a substring 01. 1 0,1 Start q0 q1 1 q2 A=({q0,q1,q2},{0,1}, d ,q0,{q2}) Check with the string 01,0111,110101,11101101

TRANSITION TABLE A transition table is a conventional, tabular representation of a function like d that takes two arguments and return a value. The rows of the table correspond to the states and return the columns correspond to the inputs. The start state is marked with an arrow and accepting states are marked with a star.

Example with Transition Table 1 0,1 Start q0 q1 1 q2 (q0,0)=q1 (q0,1)=q0 (q1,0)=q1 (q1,1)=q2 (q2,0)=q2 (q2,1)=q2 1 q0 q1 *q2 q2

TRY THIS Substring 011 Substring end with 01

How a DFA Process String The language of the DFA is the set of all strings that the DFA accepts. Suppose a1a2….an is a sequence of input symbols. We start out with the DFA in its start state q0. We consult the transition function d say d(q0,a1)=q1 to find the state that the DFA A enters after processing the first input symbol a1. We process the next input symbol a2, by evaluating d(q1,a2). Let us suppose this state is q2. we continue this manner, finding states q3,q4…qn such that d(qi-1, ai)=qi for each i. if qn is a member of F, then the input a1,a2…an is accepted, and if not then it is rejected.

Extended Transition Formula An Extended Transition Function that describes what happen when we start in any state and follow any sequence of inputs. d Transition Function d  Extended Transition Function ^

Extended Transition Formula ^ d takes a state p and a string w, and returns a state q. d(q, €)=q If are in state q and read no. of inputs then we are still in q. 2. d(q,w)=d (d(q,x),a) w xa a last symbol w string x string consisting of all but the last symbol ^ ^ ^

Example with Transition Table 1 0,1 Start q0 q1 1 q2 ^ d (q0, €)=q0 d(q0,1)= d(d(q0, €),1) = d(q0,1)=q0 d(q0,11)= d(d(q0, 1),1)= d(q0,1)=q0 d(q0,110)=d(d(q0,11),0)= d(q0,0)=q1 d(q0,1101)=d(d(q0,110),1)=d(q1,1)=q2 d(q0,11011)=d(d(q0,1101),1)=d(q2,1)=q2 Accepted w= 11011 x= 1101 a= 1 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^

The Language of a DFA L(A)={w| d(q0,w) is in F} The Language of a DFA, A=(Q, S, d, q0, F) is defined by, L(A)={w| d(q0,w) is in F} That is, the language of A is the set of strings w that take the start state q0 to one of the accepting states. If L is L(A) for some DFA, then we say L is a regular language. ^

Example Let us design a DFA to accept the language L={w | w has both an even number of 0’s and even number of 1’s} 1 Start q 1 q 1 1 *q0 q1 q2 q3 q0 1 q q 2 3 1

Extended transition function of the previous example with the following input

Nondeterministic Finite Automata Like the DFA, an NFA has a finite set of states. A finite set of input symbols, one start state and a set of accepting states. It also has a transition function d. For the NFA, d is a function that takes a state and input symbol as arguments but returns a set of zero, one or more states. A Nondeterministic Finite Automaton (NFA) is a 5-tuple (Q, S, d, q0, F)

Design an NFA An NFA accepting all strings that end in 01 0,1 Start q0 1 Fig: Transition Diagram Read Details from page -56

How an NFA Process Input Sequence 00101 An NFA accepting all strings that end in 01 0,1 q0 q1 q2 1 Start Fig: Transition Diagram q0 q0 q0 q0 q0 q0 q1 q1 q1 (Stuck) q2 q2 (Accepted) (Stuck) 1 1

Design an NFA An NFA accepting all strings that end in 01 1 q0 q1 *q2 0,1 Start q0 q1 q2 1 Fig: Transition Diagram 1 q0 q1 *q2 {q0,q1} Ø {q0} {q2} The NFA can be specified formally as ({q0,q1,q2},{0,1}, d ,q0,{q2}) Fig: Transition Table

Extended Transition Function Basis: d (q0, €) = {q} Induction: Suppose w=xa d (q ,x)= {p1,p2,p3………pn} Let U d (p ,a)= {r1,r2,r3,…………rm} Then d (q ,w)= {r1,r2,r3………rm} ^ ^ k i i=1 ^

^d Processing of input 00101 by the NFA 0,1 Start q0 q1 q2 1 ^ d (q0, €) = {q0} d (q0,0)= d (q0,0)= {q0,q1} d (q0,00)= d (q0,0) U d (q1, 0)= {q0,q1} U Ø ={q0,q1} d (q0,001)=d (q0,1) U d (q1,1)= {q0} U {q2} ={q0,q2} d (q0,0010)=d (q0,0) U d (q2,0) = {q0,q1} U Ø = {q0,q1} d (q0,00101)=d(q1,1) U d (q0,1)={q0} U {q2}={q0,q2} Accepted ^ ^ ^ ^ ^

The language of NFA If A= (Q, S, d, q0, F) is an NFA, then An NFA accepts a string w if it is possible to make any sequence of choice of next state, while reading the characters of w, and go from start state to any accepting states If A= (Q, S, d, q0, F) is an NFA, then L(A)={w| d(q0,w)∩F ≠Ø} That is L(A) is the set of strings w in S* such that d(q0,w) contains at least one accepting stat. ^ ^

Equivalence of DFA and NFA There are many language for which an NFA is easier than a DFA. Every language that can be describe by some NFA can also be described by some DFA. In the worst case the smallest DFA can have 2 states while the smallest NFA for the same language has n states. n

NFA TO DFA CONVERTION 1 0,1 Start q 0 q1 q 2 1 Ø {q0} {q1} *{q2} 1 1 Ø {q0} {q1} *{q2} {q0,q1} {q0,q2} {q1,q2} {q0,q1,q2} {q2}

NFA TO DFA CONVERTION 1 0,1 Start q0 q1 q2 1 Ø {q0} {q1} *{q2} {q0,q1} 1 1 Ø {q0} {q1} *{q2} {q0,q1} {q0,q2} {q1,q2} {q0,q1,q2} {q2} A B C *D E *F *G *H

NFA TO DFA CONVERTION 1 1 0,1 Start q0 q1 q2 1 Ø {q0} {q1} *{q2} 1 1 Ø {q0} {q1} *{q2} {q0,q1} {q0,q2} {q1,q2} {q0,q1,q2} {q2} 1 A B C *D E *F *G *H D F A B C *D E *F *G *H

NFA TO DFA CONVERTION From the 8 states in fig starting in the start state B, we can only reach states B,E and F. The other five states are inaccessible from the start state. The DFA constructed from the fig as… 1 Start B E F 1 1

NFA TO DFA CONVERTION 1 Start {q0} {q0,q1} {q0,q2} 1 1

Theorem 2.11,2.12 (Self) Exercise 2.3.1,2.3.2,2.3.3 (Self) 2.2.3,2.2.4,2.2.5,2.2.6,2.2.10,2.2.11(Self)

Thank You