Closure under the Regular Operations

Similar documents
Closure under the Regular Operations

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

Nondeterministic Finite Automata

Computer Sciences Department

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Automata: a short introduction

Theory of Computation (I) Yijia Chen Fudan University

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

Chapter Five: Nondeterministic Finite Automata

Computational Models - Lecture 1 1

CS 455/555: Finite automata

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Theory of Computation (II) Yijia Chen Fudan University

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

Finite Automata and Regular languages

Lecture 3: Nondeterministic Finite Automata

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

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

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

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,

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Computational Models #1

Equivalence of DFAs and NFAs

CSE 105 THEORY OF COMPUTATION

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

CS 121, Section 2. Week of September 16, 2013

CS 154, Lecture 3: DFA NFA, Regular Expressions

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

1 Alphabets and Languages

CISC 4090 Theory of Computation

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Sri vidya college of engineering and technology

Non-deterministic Finite Automata (NFAs)

Finite Automata. Seungjin Choi

Nondeterminism. September 7, Nondeterminism

Uses of finite automata

FINITE STATE AUTOMATA

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Equivalence of Regular Expressions and FSMs

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

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

UNIT-III REGULAR LANGUAGES

Decision, Computation and Language

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

Theory of Languages and Automata

Name: Student ID: Instructions:

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

Formal Definition of a Finite Automaton. August 26, 2013

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

Chapter 2: Finite Automata

Intro to Theory of Computation

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

Deterministic Finite Automata (DFAs)

CPS 220 Theory of Computation REGULAR LANGUAGES

CSE 105 THEORY OF COMPUTATION

Deterministic Finite Automata (DFAs)

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Finite Automata and Regular Languages

Chapter 6. Properties of Regular Languages

CHAPTER 1 Regular Languages. Contents

Languages, regular languages, finite automata

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Kleene Algebras and Algebraic Path Problems

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

Part I: Definitions and Properties

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

Theory of Computation Lecture 1. Dr. Nahla Belal

CS243, Logic and Computation Nondeterministic finite automata

Finite Automata. Mahesh Viswanathan

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

September 7, Formal Definition of a Nondeterministic Finite Automaton

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

CSE 105 THEORY OF COMPUTATION

Course 4 Finite Automata/Finite State Machines

Nondeterministic Finite Automata

Lecture 17: Language Recognition

Homework 1 Due September 20 M1 M2

Mathematical Preliminaries. Sipser pages 1-28

Computational Models - Lecture 4

Introduction to Turing Machines. Reading: Chapters 8 & 9

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CS21 Decidability and Tractability

Finite Automata. Finite Automata

CpSc 421 Final Exam December 15, 2006

Theory of Computation

Computational Theory

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

CpSc 421 Homework 1 Solutions

Transcription:

Closure under the Regular Operations

Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure for union using a Cartesian product of DFA For uniformity reason we reconstruct that proof using NFA

Theorem 1.22 The class of regular languages is closed under the union operation Proof idea: Let regular languages A 1 and A 2 be recognized by NFA N 1 and N 2, respectively To show that A 1 A 2 is regular we will construct an NFA N that recognizes A 1 A 2 N must accept its input if either N 1 or N 2 accepts its input. Hence, N must have a new state that will allow it to guess nondeterministically which of N 1 or N 2 accepts it Guessing is implemented by ɛ transitions from the new state to the start states of N 1 and N 2, as seen in Figure 1

An NFA recognizing A 1 A 2 N N 1 ɛ ɛ N 2 Figure 1: Construction of N to recognize A 1 A 2

Proof Let N 1 = (Q 1, Σ, δ 1, q 1 0, F 1), and N 2 = (Q 2, Σ, δ 2, q 2 0, F 2) Construct N = (Q, Σ, δ, q 0, F ) to recognize A 1 A 2 using the following procedure:

Construction procedure 1. Q = {q 0 } Q 1 Q 2 : That is, the states of N are all states on N 1 and N 2 with the addition of a new state q 0 2. The start state of N is q 0 3. The accept states of N are F = F 1 F 2 : That is, the accept states of N are all the accept states of N 1 and N 2 4. Define δ so that for any q Q and any a Σ ɛ : δ(q, a) = δ 1 (q, a), if q Q 1 δ 2 (q, a), if q Q 2 {q0, 1 q0}, 2 if q = q 0 and a = ɛ, if q = q 0 and a ɛ.

Application Consider the alphabet Σ = {0, 1} and the languages: A = {w w begins with 1 and ends with 0} B = {w w contains at least three 1} C = {w w = x0101y, x, y Σ } D = {w w does not contain the substring 110} Use the construction given in the proof of theorem 1.22 to give the state diagrams recognizing the languages A B and C D.

Theorem 1.23 The class of regular languages is closed under concatenation operation Proof idea: Assume two regular languages, A 1 and A 2 recognized by NFAs N 1 and N 2, respectively. Construct N as suggested in Figure 2

Construction of NFA N N 1 N 2 N ɛ ɛ ɛ Figure 2: Construction of N to recognize A 1 A 2

Construction procedure Combine N 1 and N 2 into a new automaton N that starts in the start state of N 1 Add ɛ transitions from the accept states of N 1 to the start state of N 2 Set accept states of N to be the accept states on N 2

Proof Let N 1 = (Q 1, Σ, δ 1, q 1 0, F 1) recognize A 1 and N 2 = (Q 2, Σ, δ 2, q 2 0, F 2) recognize A 2. Construct N = (Q, Σ, δ, q 1 0, F 2) by the following procedure:

Construction procedure 1. Q = Q 1 Q 2. The states of N are all states of N 1 and N 2 2. The start state is the state q0 1 of N 1 3. The accept states is the set F 2 of the accept states of N 2 4. Define δ so that for any q Q and any a Σ ɛ : δ 1 (q, a), if q Q 1 and q F 1 δ 1 (q, a), if q F 1 and a ɛ δ(q, a) = δ 1 (q, a) {q0}, 2 if q F 1 and a = ɛ δ 2 (q, a), if q Q 2.

Application Consider the alphabet Σ = {0, 1} and the languages: A = {w w 5} B = {w every odd position of w is 1} C = {w w contains at least three 1} D = {ɛ} Use the construction given in the proof of theorem 1.23 to give the state diagrams recognizing the languages A B and C D where is concatenation operator.

Theorem 1.24 The class of regular languages is closed under star operation Proof idea: we have a regular language A 1, recognized by the NFA N 1 and want to prove that A 1 is also a regular language. The procedure to prove this theorem is by construction of the NFA N that recognizes A 1 as shown in Figure 3

Procedure for the construction of N N N 1 ɛ ɛ ɛ Figure 3: Construction of N to recognize A 1

More on the proof idea N is like N 1 with a new start state and an ɛ transition from the new start state to q 1 Since ɛ A 1 the new start state is an accepts state We add ɛ transitions from the previous accept states of N 1 to the start state of N 1 allowing the machine to read and recognize strings of the form w 1... w k where w 1,..., w k A 1

Proof Let N 1 = (Q 1, Σ, δ 1, q 1 0, F 1) recognize A 1. Construct N = (Q, Σ, δ, q 0, F ) by the procedure:

Construction procedure 1. Q = {q 0 } Q 1 ; that is, states of N are the states of N 1 plus a new state q 0 2. Start state if N is q 0 3. F = {q 0 } F 1 ; that is, the accept states of N are the accept states of N 1 plus the new start state 4. Define δ so that for any q Q and a Σ ɛ : δ(q, a) = δ 1 (q, a), if q Q 1 and q F 1 δ 1 (q, a), δ 1 (q, a) {q0}, 1 if q F 1 and a ɛ if q F 1 and a = ɛ {q0}, 1 if q = q 0 and a = ɛ, if q = q 0 and a ɛ.

Application Consider the alphabet Σ = {0, 1} and the languages: A = {w w contains at least three 1s} B = {w w contains at least two 0s and at most one 1} C = {ɛ} Use the construction given in the proof of theorem 1.24 to give the state diagrams recognizing the languages A, B and C.

Closure under complementation We show here that class of regular languages is closed under complementation. For that we will first show that if M is a DFA that recognizes a language B, swapping the accept and non-accept states in M yields a new DFA that recognizes the complement of B.

Proof Let M be the DFA M with accept and non-accept states swapped. We will show that M recognizes the complement of B 1. Suppose M accept x, i.e., if we run M on x we end in an accept state of M 2. Because M and M have swapped accept/non-accept states, if we run M on x we would end in a non-accept state. Hence, x B 3. Similarly, if x is not accepted by M, it would be accepted by M Consequently, M accepts those strings that are not accepted by M and therefore M recognizes the complement of B.

Conclusion B has been an arbitrary regular language. Therefore, our construction shows how to build an automaton to recognize its complement Hence, the complement of any regular language is also regular Consequently the class of regular languages is closed under complementation

Interesting property If M is an NFA that recognizes language C, swapping its accept and non-accept states doesn t necessarily yield a new NFA that recognizes the complement of C.

Proof: We prove the interesting property by constructing a counter-example. Consider the construction in Figure 4, where both NFA-s, M and M, accept a a 1 a,b 2 a 1 a,b 2 b b Figure 4: NFAs M and M

Question Is the class of languages recognized by NFAs closed under complementation?

Note If we swap the accept and non-accept states of the NFA in Figure 4 the string a is still accepted.

Closure under complementation The class of languages recognized by NFA is still closed under complementation This follows from the fact that the class of languages recognized by NFAs is precisely the class of languages recognized by DFA The counter-example in Figure 4 shows the difference between the process of computations performed by DFAs and NFAs

Transducers

Transducers Transducers are DFA that produce output Since transducers have interesting applications in natural language processing I decided to present them to this class though they are not discussed by Sipser We follow Fleck s book to present transducers

Adding output Transducers regard the input to a DFA as being transformed by the machine into the output. This may be considered as a more realistic model of computation than simple acceptance or rejection. We will observe that adding output to the DFA amounts to extending the model of computation. However, the difference between DFAs and transducers is in fact quite small

Transition systems Definition: A deterministic transition system, DTS, is a triple T = (Q, Σ, δ), where Q is a finite set of states, Σ is an alphabet, and δ : Q Σ Q is the transition function Note: the set of states is regarded here as the memory of computation A DTS captures the way memory configurations of a computation device change when a single input symbol is presented to it The memory (states) permit the model to retain information about its past input, and this may affect the reaction to later input symbols Observation: in a real computer the states are mappings from variables to values while transitions are operators (instructions) mapping states to states

Extending δ If T = (Q, Σ, δ) is a DTS then δ : Q Σ Q is defined inductively for all q Q by: δ (q, ɛ) = q; For all w Σ and x Σ, δ (q, wx) = δ(δ (q, w), x)

Example 1: Take Q = {q 0, q 1, q 2 } and Σ = {0, 1}. Define δ by the Table: δ 0 1 q 0 q 0 q 1 q 1 q 2 q 1 q 2 q 2 q 2 That is: δ(q 0, 0) = q 0, δ(q 0, 1) = q 1, δ(q 1, 0) = q 2, δ(q 1, 1) = q 1, δ(q 2, 0) = q 2, δ(q 2, 1) = q 2. The transition diagram of this system is in Figure 1

Transition diagram 0 q 0 1 1 q 1 0 q 2 0, 1 Figure 1: Example transition system Essentials: Transition function show how states change. δ is described by edges and records the next state δ is described by paths, i.e., sequence of edges.

Deterministic finite acceptor The concept of a deterministic finite acceptor is the same as the concept of deterministic finite automaton, DFA. Using the notion of transition system, a DFA A is defined by the 5-tuple A = (Q, Σ, δ, q 0, F ) where 1. (Q, Σ, δ) is a DTS 2. q 0 Q is the start state 3. F Q is the set of accepting states

Using transition diagrams The transition diagram of a DFA differ from the transition diagram of a DTS, see Figure 2, by: 1. q 0 is marked by an arrow from nowhere; 2. states in F are double-circled. 0 q 0 1 1 q 1 0 q 2 0, 1 Figure 2: Example transition system

Transducers Definition: A transducer M is a 6-tuple M = (Q, Σ,, δ, ρ, q 0 ) where: 1. (Q, Σ, δ) is a deterministic transition system 2. is a finite non-empty set called the output alphabet 3. q 0 Q is the start state 4. ρ : Q Σ is the output function Note: termination occurs when all input has been consumed Note: Transducers are called by Fleck Deterministic Generalized Sequential Machines (DGSM)

Extending ρ Here we extend ρ : Q Σ to ρ : Q Σ by: ρ (q, ɛ) = ɛ, for each q Q ρ (q, wx) = ρ (q, w)ρ(δ (q, w), x) for all w Σ and x Σ Note: this allows us to regard M as defining a function M : Σ, namely, M(w) = ρ (q 0, w) and refer to it as DGSM function.

DGSM Computation Computation performed by a transducer parallels that of a DFA except that there is a sequence of outputs as well as a sequence of states Since ρ captures exactly this information we do not formalize this notion Note: a transducer terminates when all symbols of the output are consumed.

Example transducer Consider the transducer M = (Q, Σ,, δ, ρ, q 0 ) where Σ = = {a, b} which copies its input to its output while deleting the second occurrence (if any) of the symbol a. Note: The state diagram of this machine is in Figure 3 The arrows are labeled by y/x where y Σ is the input and x is the output

Transition diagram of M q 0 b/b a/a q 1 b/b a/ɛ a/a, b/b q 2 Figure 3: Example transition system

Note This machine copies b"s in state q 0 until first a"occurs. When first a" occurs, M copies it to the output and then goes to state q 1. In this state it copies b"s to output until first a" occurs. When first a" occurs in state q 1 the machine removes it and goes to state q 2 where it copies all input to output. Note: here we need output of length 0; this justifies the usage of ρ (the length of any symbol in the alphabet is 1)

Example 2: In this example Σ = = {0, 1, #} and the DGSM M 2 computes the odd parity, i.e., it transforms w# where w {0, 1} into wπ#, π {0, 1} such that the sequence wπ contains an odd numbers of 1s, Figure 4. 0/0, #/1# 1/1 q 0 1/1 0/0, #/0# q 1 Figure 4: DGSM M 2 computing odd parity

Interpretation M 2 is in state q 0 whenever input has even parity and it is in state q 1 whenever input has an odd parity When the output # (i.e., end of string) is encountered in state q 0 the machine adds 1 to the output thus making it of the odd parity When the output # is encountered in state q 1 the machine adds a 0 to the output thus maintaining the odd parity

Note With DFA our interest is in the language a DFA D recognizes With transducers our interest is in the function f : Σ a transducer M computes

Extensible functions Definition: A function f : Σ is called extendible if f(ɛ) = ɛ and for each x, y Σ, there is z so that f(xy) = f(x)z Note: For an extendible function, results of the function acting on prefixes of an argument occur as prefixes of the result of a longer argument This captures the DGSM characteristic of output accumulating as input is processed from left to right

Observations Functions realized by DGSMs are always extendible, i.e., x, y Σ M(xy) = ρ (q 0, xy) = ρ (q 0, x)ρ (δ (q 0, x), y) = M(x)z Consequently, if a string-to-string function is not extendible, it is not computable by a DGSM But not all extendible functions are computable by DGSM

Example 3: Consider the function : {a, b} {0} defined by: f(x) = 0 k where x contains k a"s Note: if f(xy) = 0 m then xy contains m a"s and so f(x) = 0 k, k m. Hence, f(xy) = 0 k 0 m k, i.e., f(xy) = f(x)0 m k and thus f is extendible

Example 4 Consider the function f : {a, b} {0, 1} defined by: 0 k, if x contains k more a"s than b"s f(x) = 1 k, if x contains k more b"s than a"s ɛ, if x contains the same number of a"s and b"s. Since f(a) = 0 while f(ab) = ɛ and ɛ f(a)z for every z, it results that f is not extendible

Note For a given extendible function f and string x, for each string y the string z (whose existence is guaranteed by the definition, f(xy) = f(x)z) is uniquely determined by y Hence: f(x) and f(xy) are uniquely determined

Conclusion There can be only one z that can satisfy the extensibility conditions. That is, with f and x fixed, z is a function of y.

Derived function Given an extendible function f : Σ and x Σ, the function f x : Σ defined by: y Σ [f x (y) = z if f(xy) = f(x)z] is the derived function associated to f Note: if f is extendible then: x, y Σ [f(xy) = f(x)f x (y)] Since Σ is infinite there is a potential for infinite many derived functions associated to f However, it may also be that f x1 = f x2 even though x1 x2

Definition An extendible function f : Σ is said to be of finite index if its set of distinct derived function {f x x Σ } is finite. Cardinality of {f x x Σ } is called the index of f; f is of infinite index if {f x x Σ } =

Example 1 Construct the derived function of the identity id : Σ Σ defined by x Σ [id(x) = x]. Since id(xy) = id(x)y, id is extendible. Since id x = id for all x Σ, i.e., id x (y) = y = id(y), the index of id is 1 That is, id is of finite index

Example 2 Construct the derived function of the unit delay function f : {0, 1} {0, 1} defined by: f(ɛ) = ɛ, f(w 1 w 2... w k ) = w 1 w 2... w k 1, for k 1 and w i Σ, 1 i k. f(w 1 ) = ɛ, f(w 1 w 2 ) = w 1, etc., and f is clearly extendible There are only three distinct derived functions for f: 1. f(0) = f(1) = ɛ and x, y Σ, and y ɛ, f(0y) = 0f(y) from the definition of f 2. f(0y) = f(0)f 0 (y) by extensibility condition, so f 0 (y) = 0f(y); 3. Since f(x0y) = x0f(y) and f(x0y) = f(x0)f x0 (y) = xf x0 (y) this implies f x0 (y) = 0f(y), i.e., x Σ [f x0 = f 0 ]; 4. Similarly, x Σ [f x1 = f 1 ] and f ɛ = f That is {f x x Σ } = {f ɛ, f 0, f 1 }

Fundamental results If f : Σ is extendible then f ɛ = f and x Σ [f x (ɛ) = ɛ] A function f : Σ is a DGSM function iff it is extendible and of finite index If M is a DGSM and L Σ is regular then M(L) is regular See proof in Fleck, pages 143 147