Closure Properties of DFAs

Slides:



Advertisements
Similar presentations
CS2303-THEORY OF COMPUTATION Closure Properties of Regular Languages
Advertisements

CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Properties of Regular Languages
8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
Automata and Formal Languages Tim Sheard 1 Lecture 9 Reasoning with DFAs.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Regular operations Sipser 1.2 (pages 47-63). First… a sample proof Latex files on ella.
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
Regular operations Sipser 1.2 (pages 47-63). First… a sample proof
Prof. Busch - LSU1 Properties of Context-Free languages.
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
1 Languages and Finite Automata or how to talk to machines...
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
Fall 2006Costas Busch - RPI1 Properties of Regular Languages.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
NFA Closure Properties. NFAs also have closure properties We have given constructions for showing that DFAs are closed under 1.Complement 2.Intersection.
NFA Closure Properties Sipser pages pages NFAs also have closure properties We have given constructions for showing that DFAs are closed under.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 Let L= { w= u v : u  {a, b}*, v  {c, d}* and |u|= |v|} 1.Design a context-free grammar that generates L. 2.Use your grammar and the construction from.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CS 203: Introduction to Formal Languages and Automata
Costas Busch - LSU1 Properties of 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.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
P Symbol Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
1 Closure E.g., we understand number systems partly by understanding closure properties: Naturals are closed under +, , but not -, . Integers are closed.
1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.
Lecture 15: Theory of Automata:2014 Finite Automata with Output.
Regular Languages, Regular Operations, Closure
Languages.
Closure Properties of Regular Languages
Properties of Regular Languages
FORMAL LANGUAGES AND AUTOMATA THEORY
PDAs Accept Context-Free Languages
Single Final State for NFA
Jaya Krishna, M.Tech, Assistant Professor
CSE 105 theory of computation
Non-deterministic Finite Automata (NFA)
Intro to Theory of Computation
Closure Properties for Regular Languages
CSE322 PROPERTIES OF REGULAR LANGUAGES
Properties of Regular Languages
CS 154, Lecture 3: DFANFA, Regular Expressions.
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
CSE 2001: Introduction to Theory of Computation Fall 2009
Closure Properties of Context-Free languages
Closure Properties of Regular Languages
Properties of Context-Free languages
Closure Properties of Regular Languages
Instructor: Aaron Roth
Convert to a DFA: Start state: Final States: P Symbol Q E(Q) a b.
Chapter 1 Regular Language
Instructor: Aaron Roth
CSCI 2670 Introduction to Theory of Computing
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
CSE 105 theory of computation
NFAs accept the Regular Languages
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
Presentation transcript:

Closure Properties of DFAs Sipser pages 44 - 47

Closure properties of DFAs Languages captured by DFA’s are closed under Union Concatenation Kleene Star Complement Intersection That is to say if L1 and L2 are recognized by a DFA, then there exists another DFA, L3, such that L3 = complement L1 { x | x  L1 } L3 = L1  L2 { x | x  L1 or x  L2 } L3 = L1 ∩ L2 { x | x  L1 and x  L2 } L3 = L1* L3 = L1  L2 (The first 3 are easy, we’ll wait on 4 and 5) .

Complement Complementation Take a DFA for L and change the status - final or non-final - of all its states. The resulting DFA will accept exactly those strings that the first one rejects. It is, therefore, a DFA for the Complent(L). Thus, the complement of DFA recognizable language is DFA recognizable.

Complement Example Contains a “0” Contains only “1”

2nd Complement Example Just “abc” Anything but “abc”

As a Haskell Program compDFA :: (Ord q) => DFA q s -> DFA q s compDFA m = DFA (states m) (symbols m) (trans m) (start m) new where new = [ s | s <- states m , not(elem s (accept m))]

Intersection The intersection L Ç M of two DFA recognizable languages must be recognizable by a DFA too. A constructive way to show this is to construct a new DFA from 2 old ones.

Constructive Proof The proof is based on a construction that given two DFAs A and B, produces a third DFA C such that L(C) = L(A) Ç L(B). The states of C are pairs (p,q) , where p is a state of A and q is a state of B. A transition labeled a leads from (p,q) to (p',q') iff there are transitions in A and B. The start state is the pair of original start states; the final states are pairs of original final states. The transition function dAÇB(q,a) = ( dA(q,a), dB(q,a) ) This is called the product construction.

Example 1 aa+aaa+aaaa a+aa+aaa What is the intersection? Make a new DFA where states of the new DFA are pairs of states form the old ones

Reachable states only Intersection {a,aa,aaa} ∩ {aa,aaa,aaaa}

Example 2 p q r s 1 0,1 1 0,1 A – string contains a 0 q p A – string contains a 0 0,1 1 s r B – string contains a 1 0,1 C – string contains a 0 and a 1

Contains a “0” Contains both a “1” and a “0” Contains a “1”

As a Haskell Program intersectDFA (DFA bigQ1 s1 d1 q10 f1) (DFA bigQ2 s2 d2 q20 f2) = DFA [(q1,q2) | q1 <- bigQ1, q2 <- bigQ2] s1 (\ (q1,q2) a -> (d1 q1 a, d2 q2 a)) (q10,q20) [(q1,q2) | q1 <- f1, q2 <- f2])

Difference The identity: L - M = L Ç C(M) reduces the closure under set-theoretical difference operator to closure under complementation and intersection.

M={aa,aaa,aaaa} Example Difference L={a,aa,aaa} L - M = L Ç C(M) - =

Union The union of the languages of two DFAs (over the same alphabet) is recognizable by another DFA. We reuse the product construction of the intersection proof, but widen what is in the final states of the constructed result. Let A=(Qa,S,Ta,sa,Fa) and B = (Qb,S,Tb,sb,Fb) Then: A  B =((QaQb),S,d,(sa,sb),Final) Final = { (p,q) | p  Fa, q  Qb}  { (p,q) | p  Qa, q  Fb} d((a,b),x) = ( Ta(a,x), Tb(b,y) )

B={bc} A={ab} A  B ={ab,bc}

Only reachable from start

As a Haskell Program unionDFA (DFA bigQ1 s1 d1 q10 f1) (DFA bigQ2 s2 d2 q20 f2) = DFA [(q1,q2) | q1 <- bigQ1, q2 <- bigQ2] s1 (\ (q1,q2) a -> (d1 q1 a, d2 q2 a)) (q10,q20) ([(q1,q2) | q1 <- f1, q2 <- bigQ2] ++ [(q1,q2) | q1 <- bigQ1, q2 <- f2])

Example Closure Construction Given a language L, let L' be the set of all prefixes of even length strings which belong to L. We prove that if L is regular then L' is also regular. It is easy to show that prefix(L) is regular when L is (How?). We also know that the language Even of even length strings is regular (How?). All we need now is to note that L' = Even Ç prefix(L) and use closure under intersection.

What’s next We have given constructions for showing that DFAs are closed under Complement Intersection Difference Union In order to establish the closure properties of Reversal Kleene star Concatenation We will need to introduce a new computational system.