ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605



Similar documents
Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Automata and Formal Languages

Automata and Computability. Solutions to Exercises

Reading 13 : Finite State Automata and Regular Expressions

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

Regular Languages and Finite State Machines

C H A P T E R Regular Expressions regular expression

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

CS103B Handout 17 Winter 2007 February 26, 2007 Languages and Regular Expressions

Regular Expressions and Automata using Haskell

Fundamentele Informatica II

1. Prove that the empty set is a subset of every set.

Scanner. tokens scanner parser IR. source code. errors

Automata on Infinite Words and Trees

Deterministic Finite Automata

Finite Automata. Reading: Chapter 2

Finite Automata. Reading: Chapter 2

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Finite Automata and Regular Languages

CS5236 Advanced Automata Theory

Lights and Darks of the Star-Free Star

Lecture 17 : Equivalence and Order Relations DRAFT

Compiler Construction

SOLUTIONS TO ASSIGNMENT 1 MATH 576

Testing LTL Formula Translation into Büchi Automata

Lecture 2: Regular Languages [Fa 14]

THE BANACH CONTRACTION PRINCIPLE. Contents

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Baltic Way Västerås (Sweden), November 12, Problems and solutions

CS 3719 (Theory of Computation and Algorithms) Lecture 4

Regular Languages and Finite Automata

CMPSCI 250: Introduction to Computation. Lecture #19: Regular Expressions and Their Languages David Mix Barrington 11 April 2013

Informatique Fondamentale IMA S8

The Goldberg Rao Algorithm for the Maximum Flow Problem

The Halting Problem is Undecidable

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Sample Induction Proofs

Learning Analysis by Reduction from Positive Data

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Lecture I FINITE AUTOMATA

Solutions to In-Class Problems Week 4, Mon.

T Reactive Systems: Introduction and Finite State Automata

ω-automata Automata that accept (or reject) words of infinite length. Languages of infinite words appear:

NFAs with Tagged Transitions, their Conversion to Deterministic Automata and Application to Regular Expressions

Practice with Proofs

Hint 1. Answer (b) first. Make the set as simple as possible and try to generalize the phenomena it exhibits. [Caution: the next hint is an answer to

United States Naval Academy Electrical and Computer Engineering Department. EC262 Exam 1

Introduction to Finite Automata

Math 312 Homework 1 Solutions

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 15 april Master Edition

How To Compare A Markov Algorithm To A Turing Machine

Turing Machines: An Introduction

6.080/6.089 GITCS Feb 12, Lecture 3

Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

Modeling of Graph and Automaton in Database

Techniques algébriques en calcul quantique

Regular Languages and Finite Automata

On Recognizable Timed Languages FOSSACS 2004

Lecture 16 : Relations and Functions DRAFT

P. Jeyanthi and N. Angel Benseera

THEORY of COMPUTATION

On line construction of suffix trees 1

Composability of Infinite-State Activity Automata*

CH3 Boolean Algebra (cont d)

Models for Quantitative Distributed Systems and Multi-Valued Logics

E3: PROBABILITY AND STATISTICS lecture notes

Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

Automata and Formal Languages. Push Down Automata. Sipser pages Lecture 13. Tim Sheard 1

3515ICT Theory of Computation Turing Machines

Genetic programming with regular expressions

Omega Automata: Minimization and Learning 1

The Optimum One-Pass Strategy for Juliet

Section 1.1 Real Numbers

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.

Math Workshop October 2010 Fractions and Repeating Decimals

Math 319 Problem Set #3 Solution 21 February 2002

A First Investigation of Sturmian Trees


L 2 : x = s + 1, y = s, z = 4s Suppose that C has coordinates (x, y, z). Then from the vector equality AC = BD, one has

SOLUTIONS TO EXERCISES FOR. MATHEMATICS 205A Part 3. Spaces with special properties

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Lecture 24: Saccheri Quadrilaterals

CONTENTS 1. Peter Kahn. Spring 2007

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

So let us begin our quest to find the holy grail of real analysis.

SOLUTION Trial Test Grammar & Parsing Deficiency Course for the Master in Software Technology Programme Utrecht University

Index support for regular expression search. Alexander Korotkov PGCon 2012, Ottawa

Two Way F finite Automata and Three Ways to Solve Them

Computability Theory

MACM 101 Discrete Mathematics I

1 Approximating Set Cover

Projective Geometry - Part 2

Similarity and Diagonalization. Similar Matrices

INCIDENCE-BETWEENNESS GEOMETRY

How To Factorize Of Finite Abelian Groups By A Cyclic Subset Of A Finite Group

Transcription:

ASSIGNMENT ONE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605 (1) (a) (0 + 1) 010 (finite automata below). (b) First observe that the following regular expression generates the binary strings with an even number of 0s and an odd number of 1s r = (00 + 11 + (01 + 10)(00 + 11) (01 + 10)). Next observe that the following regular expression generates the binary strings with an even number of 0s and an odd number of 1s with the additional property that no prefix has even number of 0s and an odd number of 1s s = (1 + (01 + 10)(00 + 11) 0). Any string that has an even number of 0s and an odd number of 1s must have a longest prefix that has an even number of 0s and an even number of 1s, followed by a suffix that has an even number of 0s and an odd number of 1s. Therefore, a regular expression for the language is rs (finite automata below). (2) (a) Connect passwords Must be between 6 and 8 characters long so there are a finite number of possibilities. Thus, connect passwords are a finite language, and hence a recognizable language. (b) Consider the following languages that are recognizable (or equivalently, regular). The finite automaton below accepts strings that have length at least six. Given any a, b, c A the following regular expression generates strings that have the substring abc: A abca. Therefore, by the closure of regular languages under union, the strings containing a substring of length three in any fixed login name is a regular language. Therefore, by the closure 1

of regular language under complement, the strings that do not contain a substring of length three in any fixed login name is a regular language. The following regular expression generates strings that have a substring that is a postal code: A UDUDUDA. Therefore, by the closure of regular language under complement, the strings that do not contain a substring that is a postal code is a regular language. The following regular expression generates strings that have a substring that is a license plate: A UUUDDDA. Therefore, by the closure of regular language under complement, the strings that do not contain a substring that is a license plate is a regular language. In the previous three bullets, replace the initial regular expressions by (i) A cbaa, (ii) A DUDUDUA, and (iii) A DDDUUUA to prove that the strings whose reverse does not contain the given substrings is a regular language, respectively. Next we consider avoiding the desired substrings in ww instead of the reverse of w. In the previous three bullets, replace the initial regular expressions by (i) A abca +bca a+ca ab, (ii) A UDUDUDA +DA UDUDU+ UDA UDUD + DUDA UDU + UDUDA UD + DUDUDA U, and (iii) A UUUDDDA +DA UUUDD+DDA UUUD+DDDA UUU+UDDDA UU+ UUDDDA U to prove that the strings whose concatenation with themselves (ie ww) does not contain the given substrings is a regular language, respectively. Observe that if w is a string of length at least six (as per the first bullet) and s is a string of length at most six (as in the previous three bullets), then some string in w contains s as a substring if and only if ww contains s as a substring. Therefore, the strings of length at least six whose Kleene closure does not contain the given substrings is a regular language by using the same logic above. The following non-deterministic finite automaton accepts strings that contain a symbol in Q. Therefore, by the closure of regular language under complement, the strings that do not contain a symbol in Q is a regular language. Let a 1, a 2, a 3 A. The following regular expression generates strings that contain only these three symbols: (a 1 + a 2 + a 3 ). By considering all choices for a 1, a 2, and a 3 and by the closure of regular languages under union, the set of strings containing at most three distinct symbols is a regular language. By the closure of regular languages under complement, the set of strings that contain at least four distinct symbols is regular. The following regular expression generates strings whose first six symbols contain at least one symbol from L U, one symbol from D, and one symbol from P. In this regular expression, the terms are simply the permutations of the multiset {A, A, A, (L+U), D, P } (ensuring that the first six symbols contain the desired three types of symbols) followed by A. To be complete, 2

the full regular expression appears below. AAA(L + U)DP A + AAA(L + U)P DA + AAAD(L + U)P A + AAADP (L + U)A + AAAP (L + U)DA + AAAP D(L + U)A + AA(L + U)ADP A + AA(L + U)AP DA + AA(L + U)DAP A + AA(L + U)DP AA + AA(L + U)P ADA + AA(L + U)P DAA + AADA(L + U)P A + AADAP (L + U)A + AAD(L + U)AP A + AAD(L + U)P AA + AADP A(L + U)A + AADP (L + U)AA + AAP A(L + U)DA + AAP AD(L + U)A + AAP (L + U)ADA + AAP (L + U)DAA + AAP DA(L + U)A + AAP D(L + U)AA + A(L + U)AADP A + A(L + U)AAP DA + A(L + U)ADAP A + A(L + U)ADP AA + A(L + U)AP ADA + A(L + U)AP DAA + A(L + U)DAAP A + A(L + U)DAP AA + A(L + U)DP AAA + A(L + U)P AADA + A(L + U)P ADAA + A(L + U)P DAAA + ADAA(L + U)P A + ADAAP (L + U)A + ADA(L + U)AP A + ADA(L + U)P AA + ADAP A(L + U)A + ADAP (L + U)AA + AD(L + U)AAP A + AD(L + U)AP AA + AD(L + U)P AAA + ADP AA(L + U)A + ADP A(L + U)AA + ADP (L + U)AAA + AP AA(L + U)DA + AP AAD(L + U)A + AP A(L + U)ADA + AP A(L + U)DAA + AP ADA(L + U)A + AP AD(L + U)AA + AP (L + U)AADA + AP (L + U)ADAA + AP (L + U)DAAA + AP DAA(L + U)A + AP DA(L + U)AA + AP D(L + U)AAA + (L + U)AAADP A + (L + U)AAAP DA + (L + U)AADAP A + (L + U)AADP AA + (L + U)AAP ADA + (L + U)AAP DAA + (L + U)ADAAP A + (L + U)ADAP AA + (L + U)ADP AAA + (L + U)AP AADA + (L + U)AP ADAA + (L + U)AP DAAA + (L + U)DAAAP A + (L + U)DAAP AA + (L + U)DAP AAA + (L + U)DP AAAA + (L + U)P AAADA + (L + U)P AADAA + (L + U)P ADAAA + (L + U)P DAAAA + DAAA(L + U)P A + DAAAP (L + U)A + DAA(L + U)AP A + DAA(L + U)P AA + DAAP A(L + U)A + DAAP (L + U)AA + DA(L + U)AAP A + DA(L + U)AP AA + DA(L + U)P AAA + DAP AA(L + U)A + DAP A(L + U)AA + DAP (L + U)AAA + D(L + U)AAAP A + D(L + U)AAP AA + D(L + U)AP AAA + D(L + U)P AAAA + DP AAA(L + U)A + DP AA(L + U)AA + DP A(L + U)AAA + DP (L + U)AAAA + P AAA(L + U)DA + P AAAD(L + U)A + P AA(L + U)ADA + P AA(L + U)DAA + P AADA(L + U)A + P AAD(L + U)AA + P A(L + U)AADA + P A(L + U)ADAA + P A(L + U)DAAA + P ADAA(L + U)A + P ADA(L + U)AA + P AD(L + U)AAA + P (L + U)AAADA + P (L + U)AADAA + P (L + U)ADAAA + P (L + U)DAAAA + P DAAA(L + U)A + P DAA(L + U)AA + P DA(L + U)AAA + P D(L + U)AAAA For the overall proof, observe that each bullet above proves that certain languages are regular. Moreover, the intersection of these languages are precisely the passwords defined in the question. Therefore, passwords are a regular language by the closure of regular languages under intersection. (3) (a) No, L p is not recognizable. Consider the string w = 1 n 01 n, where n is the pumping constant for L p. Observe that w L p and w n. Consider any x, y, z {0, 1} such that (i) w = xyz, (ii) xy n, and (iii) y > 0. By these constraints, x = 1 a, y = 1 b, and z = 1 c 01 n where a 0, b > 0, and a + b + c = n. If i = 0, then xy i z = xz = 1 a+c 01 n = 1 a+c 01 a+b+c / L p since b > 0. Therefore, L p does not satisfy the pumping property, and hence L p is not regular. (b) Yes, L e is recognizable. Suppose w {0, 1} and let n 01 be its number of 01 substrings and let n 10 be its number of 10 substrings. Observe that n 10 + 1 if w begins with 0 and w ends with 1 n 01 = n 10 1 if w begins with 1 and w ends with 0 n 10 otherwise 3

where the final case includes (i) w = ɛ, (ii) w begins and ends with 0, and (iii) w begins and ends with 1. Therefore, L e is generated by the regular expression ɛ + 0 + 1 + 0(0 + 1) 0 + 1(0 + 1) 1. Therefore, L e is regular, and hence L e is recognizable. (4) (a) Consider an arbitrary w = w 1 w 2 w n L a, where each w i {0, 1}. Observe that w can be expressed as w = 0 r 1 s 2 t where r 0 = (s = t). Let x = ɛ, y = w 1, and z = w 2 w 3 w n. Observe that these choices ensure (i) w = xyz, (ii) xy n, and (iii) y > 0, where n is the pumping constant for L a. We wish to prove that (iv) xy i z L a for all i 0. There are two cases to consider. If r 0, then xy i z = 0 r 1+i 1 s 2 t for all i 0. In this case, s = t by the implication given above. Therefore, xy i z = 0 r 1+i 1 s 2 s L for all i 0. On the other and, if r = 0, then xy i z = 1 s 1+i 2 t. Therefore, xy i z L a for all i 0. Therefore, L a satisfies the pumping property. (b) The difference between the pumping property and the generalized pumping property is that the former gives conditions on a prefix of length at most n in each string, whereas the latter gives conditions on a substring of length at most n in each string. (c) Consider the string pws with p = 0, w = 1 n 2 n, and s = ɛ, where n is the generalized pumping constant. Observe that pws = 01 n 2 n L a and w n. Consider any x, y, z {0, 1, 2} such that (i) w = xyz, (ii) xy n, and (iii) y > 0. By these constraints, x = 1 a, y = 1 b, and z = 1 c 2 n where a 0, b > 0, and a + b + c = n. If i = 0, then pxy i zs = 0xz = 01 a+c 2 n = 01 a+c 2 a+b+c / L a since b > 0. Therefore, L a does not satisfy the generalized pumping property. (d) If L is a recognizable language, then there exists some finite automata M = (S, A, s, δ, F ) such that L(M) = L. Let n = S be the number of states in M. Consider a string pws L with w n. Let w = w 1 w 2 w m where each w i A and m n. Consider the states s j = δ (s, pw 1 w 2 w j ) for j = 0, 1,..., n. Since there are only S = n states, there must be a repetition among s 0, s 1,..., s n. Let r and t be chosen such that s r = s t and 0 r < t n. Now consider the strings x = w 0 w 1 w r, y = w r+1 w r+2 w + t, and z = w r+1 w r+2 w t. Observe that the repeated state implies that δ (s, pxy i zs) = δ (s t, zs) for all i 0. Furthermore, the state δ (s t, zs) F since pws = pxyzs L. Therefore, pxy i zs L for all i 0. (5) (a) The language L s = {w A w has suffix s} is recognizable. Therefore, if L is recognizable then so is L L s by the closure of recognizable languages under intersection. Observe that L L s contains all strings in L that have suffix s. Therefore, L L s = L/s, and so L/s is recognizable. (b) Let S = S 1 S 2, i = {(i i, i 2 )} 1, F = (F 1 (S 2 \F 2 )) (F 2 (S 1 \F 1 )), and define δ : S A P (S) by δ((x, y), a) = {(δ 1 (x, a), δ 2 (y, a))} for all (x, y) S and a A. Observe that M is essentially a (deterministic) finite-automata and that it accepts the desired language. 1 This i should have been stated as I in the question since it is a set of states. 4

(c) If L is recognizable, then there exists a finite automata M = (S, A, i, δ, F ) such that L(M) = L. We will construct an ɛ-finite automata M (S, B, I, δ, F ) as follows. S is a set of states that includes those in S as well as additional states to be defined, and the set of initial states I = {i} includes only the single initial state from M. The basic idea is to replace each arc labeled a in M by a path whose arcs are labeled with the symbols in f(a) Formally, define δ : S B P (S ) as follows. If f(a) = ɛ for a A, then for each s S let δ (s, ɛ) = {δ(s, a)}. If f(a) = b for a A and b B, then for each s S let δ (s, ɛ) = {δ(s, a)}. (6) (a) δ (s 1, 1) = s 0 / F and δ (s 2, 1) = s 1 F so s 1 M s 2. (b) See the tables below. Partition Table for S/ M s 1 s 2 s 3 s 4 s 5 s 6 x 0 x 0 x 0 x 0 x 0 s 0 x 1 x 0 x 1 s 1 x 1 x 0 x 1 s 2 x 0 x 1 s 3 x 0 x 0 s 4 x 1 s 5 Table 1 0 1 (0,4) (1,5) (4,0) (1,2) (3,1) (2,0) (1,3) (3,3) (2,6) (1,5) (3,1) (2,6) (1,6) (3,1) (2,4) (2,3) (1,3) (0,6) (2,5) (1,1) (0,6) (2,6) (1,1) (0,4) (3,5) (3,1) (6,6) (3,6) (3,1) (6,4) (5,6) (1,1) (6,4) Table 2 0 1 (0,4) (1,5) (4,0) (1,3) (3,3) (2,6) (1,5) (3,1) (2,6) (2,6) (1,1) (0,4) (3,5) (3,1) (6,6) (c) The language is {w {0, 1} w has suffix 0 or 01}. See the minimal automata below. (7) The finite automaton is given by the transition table below. (The shortest strings that distinguish between each pair of states are given in parentheses.) 5

0 1 {a} {b, d} {b} (ɛ) {b} {c} {b, c} (1) {b, d} {c} {a, b, c} (0) {c} {d} {a} (10) {b, c} {c, d} {a, b, c} (11) {a, b, c} {b, c, d} {a, b, c} (01) {d} {a} (100) {c, d} {d} {a} (110) {b, c, d} {c, d} {a, b, c} (010) (1000) In the above table and denote the start state and final states, respectively. (8) (a) See the table below. (b) See the table below. (c) See the table below. state x E(x) E(x) a E(x) b E(E(x) a) E(E(x) b) s 1 {s 1, s 2 } {s 4 } {s 1, s 2, s 3, s 4 } s 2 {s 2 } {s 4 } {s 1, s 2, s 3, s 4 } s 3 {s 1, s 2, s 3 } {s 2, s 4 } {s 1 } {s 1, s 2, s 3, s 4 } {s 1, s 2 } s 4 {s 1, s 2, s 3, s 4 } {s 2, s 4 } {s 1 } {s 1, s 2, s 3, s 4 } {s 1, s 2 } (d) See the NFA below. (9) Since L 1 and L 2 are recognizable languages there are finite automata that accept these languages. Let M 1 = (S 1, A 1, δ 1, F 1, i 1 ) and M 2 = (S 2, A 2, δ 2, F 2, i 2 ) be finite automata such that L(M 1 ) = L 1 and L(M 2 ) = L 2. Consider the non-deterministic finite automata M = (S, A, δ, F, i) such that S = S 1 S 2 {1, 2}, A = A 1 A 2, F = F 1 F 2 {1}, i = {(i 1, i 2, 1)} and δ is defined as follows. If a 1 A 1 then, and if a 2 A 2 then, δ((s 1, s 2, 1), a 1 ) = {(δ 1 (s 1, a 1 ), s 2, 2)} δ((s 1, s 2, 2), a 2 ) = {(s 1, δ 2 (s 2, a 2 ), 1)} and for all other inputs, δ returns the empty set. Observe that M accepts the shuffle of L 1 and L 2. Therefore, the shuffle of two regular languages is also a regular language. 6