Transparency No. 2-1 Formal Language and Automata Theory Chapter 2 Deterministic Finite Automata (DFA) (include Lecture 3 and 4)

Slides:



Advertisements
Similar presentations
Chapter Three: Closure Properties for Regular Languages
Advertisements

Lecture 16 Deterministic Turing Machine (DTM) Finite Control tape head.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Chapter Two: Finite Automata
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Transparency No. P2C3-1 Formal Language and Automata Theory Chapter 3 Pushdown Automata and Context-Free Languages.
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
Transparency No. P2C3-1 Formal Language and Automata Theory Chapter 3 Pushdown Automata and Context-Free Languages.
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.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
1 Languages and Finite Automata or how to talk to machines...
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.
Transparency No. 3-1 Formal Language and Automata Theory Chapter 3 Nondeterministic Finite Automata (NFA) (include lecture 5 and 6)
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Transparency No. P2C1-1 Formal Language and Automata Theory Part II Pushdown Automata and Context-Free Languages.
Transparency No. ?-0 Formal Language and Automata Theory Chapter 6 Homomorphisms (lecture 10) Transparency No. 6-1.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
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
Transparency No. 8-1 Formal Language and Automata Theory Chapter 8 DFA state minimization (lecture 13, 14)
Great Theoretical Ideas in Computer Science.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Rosen 5th ed., ch. 11 Ref: Wikipedia
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Lecture 2UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 2.
Transparency No. 3-1 Formal Language and Automata Theory Chapter 3 Nondeterministic Finite Automata (NFA)
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CS 203: Introduction to Formal Languages and Automata
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Classifications LanguageGrammarAutomaton Regular, right- linear Right-linear, left-linear DFA, NFA Context-free PDA Context- sensitive LBA Recursively.
Transparency No. P2C5-1 Formal Language and Automata Theory Part II Chapter 5 The Pumping Lemma and Closure properties for Context-free Languages.
Transparency No. 4-1 Formal Language and Automata Theory Chapter 4 Patterns, Regular Expressions and Finite Automata (include lecture 7,8,9) Transparency.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Transparency No. 1 Formal Language and Automata Theory Homework 1.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
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.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Acceptance by DFA. Defining DFAs For each description let’s draw a DFA that recognizes the language it describes { aa,ab,ac} {  a, abb, abbbb, …,ab.
Lecture Three: Finite Automata Finite Automata, Lecture 3, slide 1 Amjad Ali.
CIS Automata and Formal Languages – Pei Wang
Lecture2 Regular Language
Chapter 2 Finite Automata
COSC 3340: Introduction to Theory of Computation
Hierarchy of languages
Introduction to Finite Automata
Finite Automata Reading: Chapter 2.
CSE 2001: Introduction to Theory of Computation Fall 2009
Chapter Five: Nondeterministic Finite Automata
Deterministic Finite Automaton (DFA)
Finite-State Machines with No Output
Presentation transcript:

Transparency No. 2-1 Formal Language and Automata Theory Chapter 2 Deterministic Finite Automata (DFA) (include Lecture 3 and 4)

Deterministic Finite Automata Transparency No. 2-2 Finite Automata and regular sets (languages) States and transitions: Ex: Consider a counter data structure (system): unsigned integer counter: pc; { initially pc = 0} operations: inc, dec; ==> The instantaneous state of the system can be identified by the value of the counter. Operations called from outside world will cause transitions from states to states and hence change the current state of the system. Problem: how to describe the system : Mathematical approach: CS = ( S, O, T, s, F) where S = The set of all possible states = N O = the set of all possible [types of] operations T = the response of the system on operations at all possible states. (present state, input operation) --> (next state)

Deterministic Finite Automata Transparency No. 2-3 Example of a state machine T can be defined as follows : T: SxO --> S s.t., for all x in S, T(x, inc) = x + 1 and T(x, dec) = x - 1 ; { = def 0 } s = 0 is the initial state of the system F  S is a set of distinguished states, each called a final state. (we can use it to, say, determine who can get a prize) Graphical representation of CS: Note: The system CS is infinite in the sense that S (the set of all possible states) and Transitions ( the set of possible transitions) are infinite. A system consists of only finitely many states and transitions is called a finite-state transition system. The mathematical tools used to model finite-state transition system are called finite automata. examples of state-transition systems: electronic circuits; digital watches, cars, elevators, etc.

Deterministic Finite Automata Transparency No. 2-4 Deterministic Finite automata (the definition) a DFA is a structure M = (Q, , ,s,F) where Q is a finite set; elements of  are called states  is a finite set called the input alphabet  :Qx  --> Q is the transition function with the intention that if M is in state q and receive an input a, then it will move to state  (q,a).  e.g; in CS:  (3, inc) = 4 and  (3, dec) = 2. s in Q is the start state F is a subset of Q; elements of F are called accept or final states. To specify a finite automata, we must give all five parts (maybe in some other forms) Other possible representations: [state] transition diagram or [state] transition table

Deterministic Finite Automata Transparency No. 2-5 Example and other representations Ex 3.1: M 1 = (Q,S, ,s,F) where Q={0,1,2,3}, S={a,b}, s = 0, F = {3} and  is define by:  (0,a) = 1;  (1,a) = 2;  (2,a) =  (3,a) = 3 and  (q,b)=q if q = {0,1,2,3}. problem: Although precise but tedious and not easy to understand (the behavior of) the machine. Represent M 1 by a table: =====> Represent M 1 by a diagram:  aaa b bb a,b state-transition diagram for M 1 note: the naming of states is not necessary

Deterministic Finite Automata Transparency No. 2-6 Strings accepted by DFAs Operations of M 1 on the input 'baabbaab': S ince M 1 can reach a final state (3) after scanning all input symbols starting from initial state, we say the string 'baabbaab' is accepted by M 1. Problem: How to formally define the set of all strings accepted by a DFA ? M1

Deterministic Finite Automata Transparency No. 2-7 The extended transition function  Meaning of the transition function: q1 -- a --> q2 [or  (q1,a) = q2 ] means if M is in state q1 and the currently scanned symbol (of the input strings is a) then 1. Move right one position on the input string (or remove the currently scanned input symbol) 2. go to state q2. [So M will be in state q2 after using up a) Now we extend  to a new function  : Q x  * --> Q with the intention that :  (q1,x) =q2 iff starting from q1, after using up x the machine will be in state q  is a multi-step version of . Problem: Given a machine M, how to define  [according to  ] ? Note: when string x is a symbol (i.e., |x| = 1) then  (q,x) =  (q,x). for all state q, so we say  is an extension of .

Deterministic Finite Automata Transparency No. 2-8 The extended transition function  (cont'd)  can be defined by induction on |x| as follows: Basis: |x|= 0 (i.e., x =  ) ==>  (q,  ) = q --- (3.1) Inductive step: (assume  (q,x) has been defined ) then  (q, xa) =  (  (q,x), a) --- (3.2) --- To reach the state  (q,xa) from q by using up xa, first use up x (and reach  (q,x)) and then go to  (( ,qx),a) by using up a. Exercise: Show as expected that  (q,a) =  (q,a) for all a in . pf:  (q,a) =  (q,  a) =  (  (q,  ),a) =  (q,a).

Deterministic Finite Automata Transparency No. 2-9 Uniqueness of the extended transition funciton Note:  is uniquely defined by M, i.e., for every DFA M, there is exactly one function f:Qx  * --> Q satisfying property (3.1) and (3.2.) --- a direct result of the theorem of recursive definition. pf: Assume  distinct f1 and f2 satisfy (3.1&3.2). Now let x be any string with least length s.t. f1(q,x)  f2(q,x) for some state q. ==> 1. x   (why ?) 2. If x = ya ==> by minimum of |x|, f1(q,y) = f2(q,y), hence f1(q,ya)=  (f1(q,y),a) =  (f2(q,y),a) = f2(q,ya), a contradiction. Hence f1 = f2.

Deterministic Finite Automata Transparency No Languages accepted by DFAs M = (Q, , ,s,F) : a DFA;x: any string over  ;  : the extended transition function of M. 1. x is said to be accepted by M if  (s,x)  F x is said to be rejected by M if  (s,x)  F. 2. The set (or language) accepted by M, denoted L(M), is the set of all strings accepted by M. i.e., L(M) = def {x   * |  (s,x)  F }. 3. A subset A  * (i.e., a language over  ) is said to be regular if A is accepted by some finite automaton (i.e., A = L(M) for some DFA M). Ex: The language accepted by the machine of Ex3.1 is the set L(M1) = {x  {a,b}* | x contains at least three consecutive a's}

Deterministic Finite Automata Transparency No Another example Ex 3.2: Let A = {xaaay | x,y ∈ {a,b}*} = {x  {a,b}* | x contains substring aaa }. Then baabaaaab  A and babbabab  A. An Automaton accept A: (diagram form) Table form: |a b >0 |1 0 1 | |3 0 3F |3 3

Deterministic Finite Automata Transparency No More on regular sets (Lecture 4) a little harder example: Let A = {x  {0,1}* | x represent a multiple of 3 in binary}. notes: leading 0's permitted;  represents zero. example: , 0, 00 ==> 0; 011,11,.. ==> 3; 110 ==> 6; 1001 ==> 9; 1100,.. ==> 12; 1111 => 15;... Problem: design a DFA accepting A. sol: For each bit string x, let s(x) = #(x) mod 3, where #(x) is the number represented by x. Ex: s(  ) = 0 mod 3 = 0; s(101) = 5 mod 3 = 2;... ==> A = { x | s(x) = 0 } 1. s(  ) = 0; s(x0) and s(x1) can be determined from s(x) as follows:

Deterministic Finite Automata Transparency No a little harder example Since #(x0) = 2 #(x) ==> s(x0) = #(x0) mod 3 = 2(#(x) mod 3) mod 3 = 2s(x) mod 3 ==> s(x) can be show as follows: (note: the DFA M defined by the table is also the automata accepting A) Exercise: draw the diagram form of the machine M accepting A. Fact: L(M) = A. (i.e., for all bit string x, x in A iff x is accepted by M) pf: by induction on |x|. Basis: |x| = 0 => x =  in A and is accepted by M. Ind. step: x = yc where c in {0,1} =>  (0, yc) =  (  (0,y),c) =  (#(y) mod 3, c) = (2#(y) mod 3 +c) mod 3 = #(xc) mod 3. QED >0F s(x) s(x0) s(x1)

Deterministic Finite Automata Transparency No Some closure properties of regular sets Issue: what languages can be accepted by finite automata ? Recall the definitions of some language operations: A U B = {x | x  A or x  B}. A  B = {x | x  A /\ x  B} ~A =  * - A = {x   * | x  A} AB = {xy | x  A /\ y  B} A* = {x 1 x 2...x n | n  0 /\ x i  A for 0  i  n} and more... ex: A / B = {x |  y  B s.t. xy  A }. Problem: If A and B are regular [languages], then which of the above sets are regular as well? Ans: ______.

Deterministic Finite Automata Transparency No The product construction M 1 = (Q 1, ,  1,s 1,F 1 ), M 2 = (Q 2, ,  2,s 2,F 2 ) : two DFAs Define a new machine M 3 = (Q 3, ,  3, s 3, F 3 ) where Q 3 = Q 1 x Q 2 = {(q 1,q 2 ) | q 1  Q 1 and q 2  Q 2 } s 3 = (s 1,s 2 ); F 3 =F 1 xF 2 = {(q 1,q 2 ) | q 1  F 1 /\ q 2  F 2 } and  3 :Q 3 x  --> Q 3 is defined to be  3 ( (q 1,q 2 ), a) = (  (q 1,a),  (q 2,a)) for all (q 1,q 2 )  Q, a  . The machine M 3, denoted M 1 xM 2, is called the product of M 1 and M 2. The behavior of M 3 may be viewed as the parallel execution of M 1 and M 2. Lem 4.1: For all x   *,  3 ((p,q),x) = (  1 (p,x),  2 (q,x)). Pf: by induction on the length |x| of x. Basis: |x|= 0: then  3((p,q),  ) = (p,q) = (  (p,  ),  2(q,  ))

Deterministic Finite Automata Transparency No The product construction (cont'd) Ind. step: assume the lemma hold for x in  *, we show it holds for xa, where a in .  3 ((p,q),xa) =  3 (  3 ((p,q),x), a) --- definition of  3 =  3 ((  1 (p,x),  (q,x)), a) --- Ind. hyp. = (  1 (  1 (p,x),a),  2 (  (q,x),a) --- def. of  3 = (  1 (p,xa),   (p,xa)) QED--- def of  1 and  2. Theorem 4.2: L(M 3 ) = L(M 1 )  L(M 2 ). pf: for all x   *, x  L(M 3 ) iff  3 (s 3,x)  F def. of acceptance iff  3 ((s 1,s 2 ),x)  F def. of s 3 iff (  1 (s 1,x),  2 (s 2,x))  F 3 = F 1 xF2 --- def. of F 3 iff  1 (s 1,x)  F 1 and  2 (s 2,x)  F def. of set product iff x  L(M 1 ) and x  L(M 2 ) --- def. of acceptance iff x  L(M 1 )  L(M 2 ).QED--- def. of intersection.

Deterministic Finite Automata Transparency No Regular languages are closed under U,  and ~ Theorem: IF A and B are regular than so are A  B, ~A and AUB. pf: (1) A and B are regular =>  DFA M 1 and M 2 s.t. L(M 1 ) = A and L(M 2 ) = B -- def. of RL => L(M 1 xM 2 ) = L(M 1 )  L(M 2 ) = A  B --- Theorem 4.2 ==> A  B is regular. -- def. of RL. (2) Let M = (Q, , ,s,F) be the machine s.t. L(M) = A. Define M' = (Q, ,d,s,F') where F' = ~F = {q  Q | q  F}. Now for all x in  *, x  L(M')  (s,x)  F' = ~F --- def. of acceptance  (s,x)  F--- def of ~F x  L(M) iff x  A. -- def. of acceptance Hence ~A is accepted by L(M') and is regular ! (3). Note that AUB = ~(~A  ~B). Hence the fact that A and B are regular implies ~A, ~B, (~A  ~B) and ~(~A  ~B) = AUB are regular too.