Fooling Sets and. Lecture 5

Similar documents
Nondeterministic Finite Automata

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Chapter Five: Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 455/555: Finite automata

COM364 Automata Theory Lecture Note 2 - Nondeterminism

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CSC236 Week 11. Larry Zhang

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Intro to Theory of Computation

Inf2A: Converting from NFAs to DFAs and Closure Properties

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Nondeterministic finite automata

Theory of Computation (I) Yijia Chen Fudan University

Closure under the Regular Operations

Finite Automata and Regular languages

CS21 Decidability and Tractability

CSC236 Week 10. Larry Zhang

CSE 105 Theory of Computation Professor Jeanne Ferrante

Lecture 3: Nondeterministic Finite Automata

Chap. 1.2 NonDeterministic Finite Automata (NFA)

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

CS243, Logic and Computation Nondeterministic finite automata

Nondeterminism and Epsilon Transitions

CSE 105 THEORY OF COMPUTATION

Finite Automata Part Two

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Non-deterministic Finite Automata (NFAs)

Equivalence of DFAs and NFAs

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Computational Theory

Computer Sciences Department

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

Finite Automata. Mahesh Viswanathan

CPS 220 Theory of Computation REGULAR LANGUAGES

CPSC 421: Tutorial #1

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Takeaway Notes: Finite State Automata

CSE 105 THEORY OF COMPUTATION

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Computational Models - Lecture 5 1

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Nondeterministic Finite Automata

Proving languages to be nonregular

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Deterministic Finite Automata (DFAs)

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

1 More finite deterministic automata

Theory of Computation

Lecture 23 : Nondeterministic Finite Automata DRAFT Connection between Regular Expressions and Finite Automata

Nondeterministic Finite Automata. Nondeterminism Subset Construction

Properties of Context-Free Languages. Closure Properties Decision Properties

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

Deterministic Finite Automata (DFAs)

Computational Models - Lecture 4

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Nondeterministic Finite Automata

Deterministic Finite Automata (DFAs)

Formal Languages, Automata and Models of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Pushdown Automata (2015/11/23)

CISC 4090 Theory of Computation

Harvard CS 121 and CSCI E-207 Lecture 4: NFAs vs. DFAs, Closure Properties

Automata: a short introduction

1. Induction on Strings

Languages, regular languages, finite automata

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

2017/08/29 Chapter 1.2 in Sipser Ø Announcement:

Introduction to Turing Machines. Reading: Chapters 8 & 9

CSE 105 THEORY OF COMPUTATION

Notes on State Minimization

Sri vidya college of engineering and technology

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Chapter 6: NFA Applications

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

CS 154 Introduction to Automata and Complexity Theory

Computational Models: Class 3

UNIT-VI PUSHDOWN AUTOMATA

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

3515ICT: Theory of Computation. Regular languages

Theory of Computation

CSC173 Workshop: 13 Sept. Notes

UNIT-III REGULAR LANGUAGES

Further discussion of Turing machines

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

V Honors Theory of Computation

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

CS 154 Formal Languages and Computability Assignment #2 Solutions

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.

Turing Machines Part II

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Transcription:

Fooling Sets and Introduction to Nondeterministic Finite Automata Lecture 5

Proving that a language is not regular Given a language, we saw how to prove it is regular (union, intersection, concatenation, complement, reversal ) How to prove it is not regular?

Proving that a language is not regular Pick your favorite language L (= let L be an arbitrary language) For any strings x,y (x,y not necessarily in L) we define the following equivalence: x L y Means for EVERY string z Σ* we have xz L if and only if yz L

Proving that a language is not regular Conversely, x 6 L y Means for SOME string z Σ* we have either xz L and yz L or xz 2 L and yz L We say z distinguishes x from y (take z, glue it to x and see what belongs to L)

Example Pick your favorite language e.g. L = {strings with even zeroes and odd ones} Pick x= and y =. None of them in L! Can we find distinguishing suffix z? z=: z=: z=ε: xz= in L xz= not in L xz= not in L yz = not in L yz = in L yz = not in L

Example L = {strings with even zeroes and odd ones} Pick x= and y =. None of them in L! Can we find distinguishing suffix z? Bad choice for z! z=: z=: z=ε: xz= in L xz= not in L xz= not in L yz = not in L yz = in L yz = not in L

Why do I care? I can learn something about the equivalence relation by looking at every DFA that accepts L. Assume that after the DFA reads x and y it ends up at the same state: (s, x) = (s, y) ) x L y Proof: For any z, (s, xz) = (s, yz) ) (s, xz) 2 A, (s, yz) 2 A

Why do I care? This implication can be turned around: x 6 y ) (s, x) 6= (s, y) In ANY DFA for L ) Q 2 For the example before, we found two strings not equivalent. Any DFA for the language has AT LEAST two distinct states! Kind of trivial, cause what DFA has only one state?

Why do I care? Pushing it further: If we can find k strings x,,x k such that x i 6 x j 8i 6= j Then, any DFA for L has at least k states A way of formally proving how complicated a language is if it is regular

Our Example L = {strings with even zeroes and odd ones} x= x2= x3= x4=

Our Example L = {strings with even zeroes and odd ones} x= x2= x3= z= xz= not in L x2z = in L x4=

Our Example L = {strings with even zeroes and odd ones} x= x2= z=? x3= x4=

Our Example L = {strings with even zeroes and odd ones} x= x2= z= x3= x4=

Our Example L = {strings with even zeroes and odd ones} x= x2= x3= Any DFA for L has AT LEAST 4 states! What is a DFA for L? x4=

Our Example L = {strings with even zeroes and odd ones} x= OO OE x2= x3= x4= EO EE We proved that this (obvious) DFA is the minimal one!!!

Our Example L = {strings with even zeroes and odd ones} x= OO OE x2= x3= x4= EO EE Fooling set.

Proving that a language is not regular Suppose I can find an infinite fooling set for L. Infinite set of strings {x,x2, } such that x i 6 x j 8i 6= j Then every DFA for L has at least infinite number of distinct states L not regular!

Proving that a language is not regular Example: L={ n n n }= {ε,,, } Claim: This is a fooling set: F={ n n } Proof: Let x, y two arbitrary different strings in F. Therefore x y.

Proving that a language is not regular Example: L={ n n n }= {ε,,, } Claim: This is a fooling set: F={ n n } Proof: Let x, y two arbitrary different strings in F. x= i for some integer i y= j for some different integer j z= i Therefore x y.

Proving that a language is not regular Example: L={ n n n }= {ε,,, } Claim: This is a fooling set: F={ n n } Proof: Let x, y two arbitrary different strings in F. x= i for some integer i y= j for some different integer j xz= i i in L yz= j i not in L z= i Therefore x y.

Proving that a language is not regular To prove that L is not Regular: Find some infinite set F Prove for any two strings x and y in F there is a string z such that xz is in L XOR yz is in L. How to come up with those fooling sets? Be clever :) Think of what information you have to keep track of in a DFA for L.

What to keep track of? Example: L={ n n }= {ε,,, } Is a string in L? What do I have to keep track of? I need to keep track of the number of zeroes. So, every number of zeroes is intuitively a different state (different equivalence class). Fooling set is a set of strings that exercises all possible values that I need to keep track in my head. Sometimes easier to narrow it down.

What to keep track of? Another Example: L={ww R w Σ* }= even length palindromes What is a fooling set? I have to remember the whole string w. Attempt : Attempt 2: F=Σ* F={?} x= y=

What to keep track of? Another Example: L={ww R w Σ* }= even length palindromes What is a fooling set? I have to remember the whole string w. Attempt : Attempt 2: F=Σ* x= y= F=* x= i y= j

What to keep track of? Another Example: L={ww R w Σ* }= even length palindromes What is a fooling set? I have to remember the whole string w. F=* x= i y= j What z (exercise)?

What to keep track of? Another Example: L={ww R w Σ* }= even length palindromes What is a fooling set? I have to remember the whole string w. F=* x= i y= j z= i

What to keep track of? Another Example: L={w w=w R }= all palindromes What is a fooling set? F=* x= i y= j z= i

What to keep track of? Another Example: L={w w=w R }= all palindromes What is a fooling set : SAME! F=* x= i y= j z= i

What to keep track of? Another Example: L={w w=w R }= all palindromes over the alphabet {,,a,b,c,d,e,f} What is a fooling set : SAME! F=* x= i y= j z= i

Proving that a language is not regular Language is regular if and only if there is no infinite fooling set.

Aka Magic. Nondeterminism

Tracking Computation current state and remaining input A computation s configuration evolves in each time-step null 2 on input CS 374 32

Deterministic Computation null Deterministic: Each step is fully determined by the configuration of the previous step and the transition function. If you do it again, exactly the same thing will happen. 2 CS 374 33

Nondeterminism Determinism: opposite of free will Nondeterminism: you suddenly have choices!

Non-Deterministic FA What can be non-deterministic about an FA?, What language?, CS 374 At a given state, on a given input, a set of next-states set could be empty, could be all states 35

NFA : Formally DFA : M = (Σ, Q, δ, s, A) Σ: alphabet Q: state space s: start state A: set of accepting states δ : Q Σ Q δ(q, a) = a state NFA : N= (Σ, Q, δ, s, A) δ : Q Σ 2 Q = P(Q) CS 374 δ(q, a) = { a set of states } 36

NFA Input =,, L ={contains either or }

, NFA [s] [a] [b] [b] [t], [s] [s] [s] [s] [s] [a] CS 374 [b] [a] [t] [t] 38

, NFA [s] [a] [b] [b] [t], [s] [s] [s] [s] [s] [a] CS 374 39 [b] [a] [t] [t] One of the states are accepting. There needs to be AT LEAST one accepting state

Nondeterminism What is non determinism? Magic? Parallelism? Advice?

Nondeterminism What is non determinism? Suppose I wanted to prove to you that the string is in L ={contains either or } We built a DFA with product last time. Proof is an accepting computation

, NFA [s] [a] [b] [b] [t], [s] [s] [s] [s] [s] [a] CS 374 [b] [a] [t] [t] 42

Nondeterminism What is non determinism? Suppose I wanted to prove to you that the string is in L ={contains either or } We built a DFA with product last time. Proof is an accepting computation: guide for the reader to how to follow the steps to a given conclusion.

P vs. NP Nondeterminism Are they the same? Easier to give the proof than come up with the proof! (?)

Nondeterminism For FSM, nondeterminism does not give you more expressive power! Any language that can be accepted by an NFAs can also be accepted by a DFA. It is more efficient, last example had 4 states but product construction had 8!

DFA for L = {w: w contains or } CS 374 46,

NFA for L = {w: w contains or },,

NFA : More efficient Design an NFA to recognize L(M) = {w w : 7th character from the end is a },,,,,,, Minimum DFA for this language would have 2 7 states at least! CS 374 need to remember the last 7 symbols. 48

NFA : Formally NFA has 5 parts, similar to a DFA : N = (Σ, Q, δ, s, A) Σ: alphabet Q: state space s: start state F: set of accepting states δ : Q Σ P(Q)=2 Q transition function Define extended transition function: δ*: Q Σ P(Q)=2 Q CS 374 δ*(q, w)=.. if w=ε if w=ax 49

NFA : Formally NFA has 5 parts, similar to a DFA : N = (Σ, Q, δ, s, A) Σ: alphabet Q: state space s: start state F: set of accepting states δ : Q Σ P(Q)=2 Q transition function Define extended transition function: δ*: Q Σ* P(Q)=2 Q CS 374 δ*(q, w)= {q} if w=ε [ p2 (q,a) (p, x) if w=ax 5

CS 374 NFA : When does it accept? NFA accepts a string w if and only if δ*(s, w) A = ; 5