Fundamentele Informatica II



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

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

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

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

I. GROUPS: BASIC DEFINITIONS AND EXAMPLES

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

Regular Languages and Finite State Machines

Automata and Formal Languages

God created the integers and the rest is the work of man. (Leopold Kronecker, in an after-dinner speech at a conference, Berlin, 1886)

Local periods and binary partial words: An algorithm

C H A P T E R Regular Expressions regular expression

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

THEORY of COMPUTATION

k, then n = p2α 1 1 pα k

Math 312 Homework 1 Solutions

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

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

Mathematical Induction

Matrix Representations of Linear Transformations and Changes of Coordinates

(a) Write each of p and q as a polynomial in x with coefficients in Z[y, z]. deg(p) = 7 deg(q) = 9

THE BANACH CONTRACTION PRINCIPLE. Contents

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

Vector and Matrix Norms

Math 319 Problem Set #3 Solution 21 February 2002

Cartesian Products and Relations

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

Mathematical Induction

1 if 1 x 0 1 if 0 x 1

Handout #1: Mathematical Reasoning

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.

Reading 13 : Finite State Automata and Regular Expressions

Basic Proof Techniques

Solutions to TOPICS IN ALGEBRA I.N. HERSTEIN. Part II: Group Theory

3. Mathematical Induction

Mathematical Induction. Lecture 10-11

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

Regular Expressions with Nested Levels of Back Referencing Form a Hierarchy

CS 103X: Discrete Structures Homework Assignment 3 Solutions

Gröbner Bases and their Applications

SYSTEMS OF PYTHAGOREAN TRIPLES. Acknowledgements. I would like to thank Professor Laura Schueller for advising and guiding me

Set Theory Basic Concepts and Definitions

Chapter 17. Orthogonal Matrices and Symmetries of Space

INCIDENCE-BETWEENNESS GEOMETRY

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.

Automata on Infinite Words and Trees

6.2 Permutations continued

Solutions to Homework 6 Mathematics 503 Foundations of Mathematics Spring 2014

On the generation of elliptic curves with 16 rational torsion points by Pythagorean triples

Continued Fractions and the Euclidean Algorithm

CHAPTER 7 GENERAL PROOF SYSTEMS

CS 3719 (Theory of Computation and Algorithms) Lecture 4

INTRODUCTORY SET THEORY

Solutions for Practice problems on proofs

Lemma 5.2. Let S be a set. (1) Let f and g be two permutations of S. Then the composition of f and g is a permutation of S.

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

NOTES ON LINEAR TRANSFORMATIONS

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Regular Languages and Finite Automata

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

Mathematical Induction. Mary Barnes Sue Gordon

Solving Linear Systems, Continued and The Inverse of a Matrix

Practice with Proofs

8 Divisibility and prime numbers

Deterministic Finite Automata

The last three chapters introduced three major proof techniques: direct,

Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan

Collinear Points in Permutations

MATH 289 PROBLEM SET 4: NUMBER THEORY

Every Positive Integer is the Sum of Four Squares! (and other exciting problems)

SOLUTIONS TO ASSIGNMENT 1 MATH 576

On strong fairness in UNITY

MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.436J/15.085J Fall 2008 Lecture 5 9/17/2008 RANDOM VARIABLES

Linear Algebra. A vector space (over R) is an ordered quadruple. such that V is a set; 0 V ; and the following eight axioms hold:


E3: PROBABILITY AND STATISTICS lecture notes

SECOND DERIVATIVE TEST FOR CONSTRAINED EXTREMA

Matrix Algebra. Some Basic Matrix Laws. Before reading the text or the following notes glance at the following list of basic matrix algebra laws.

How To Compare A Markov Algorithm To A Turing Machine

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

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

FOUNDATIONS OF ALGEBRAIC GEOMETRY CLASS 22

MATH10040 Chapter 2: Prime and relatively prime numbers

n k=1 k=0 1/k! = e. Example 6.4. The series 1/k 2 converges in R. Indeed, if s n = n then k=1 1/k, then s 2n s n = 1 n

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Just the Factors, Ma am

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

Sample Induction Proofs

Math 4310 Handout - Quotient Vector Spaces

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Full and Complete Binary Trees

CHAPTER II THE LIMIT OF A SEQUENCE OF NUMBERS DEFINITION OF THE NUMBER e.

GROUPS WITH TWO EXTREME CHARACTER DEGREES AND THEIR NORMAL SUBGROUPS

Computability Theory

GREATEST COMMON DIVISOR

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

Discrete Structures. Lecture Notes

Automata and Computability. Solutions to Exercises

Transcription:

Fundamentele Informatica II Answer to selected exercises 1 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 Let L be a language. It is clear from the definition that L + L. Under which circumstances are they equal? By definition L = i 0 Li = L 0 i 1 Li = {Λ} L + for any language L. Hence, it is clear that L + L. Moreover, we see immediately that L = L + if and only if Λ L +. We claim that Λ L + if and only if Λ L. This can be proved as follows: Clearly, if Λ L, then Λ L +. Now assume that Λ L +. Thus there exists an i 1 such that Λ L i. Hence Λ is the shortest word in L i. Since the length of any shortest word in L is i times the length of a shortest word in L, it follows that Λ L. The claim being proved, we have L = L + if and only if Λ L. Find a language L over {a, b} that is neither {Λ} nor {a, b} and satisfies L = L. First of all observe that L = L implies that Λ L. Moreover, in combination with L {Λ} it follows that L must be an infinite language. A good example is {a}, because {a} {Λ} and ({a} ) = {a}, since {a} {a} = {a}. Another example is {x {a, b} x is even}. Find an infinite language L over { a,b} for which L L. Observe that each finite language such that L {Λ} has the property that L L, even = {Λ} =. This follows from the fact that Λ L whatever L. Similarly: for very infinite language L such that Λ L, we have L L. Consequently, example languages as requested are, e.g., {a} +, {a, b} +, and {x {a, b} x is odd}; observe that {x {a, b} x is odd} contains not only Λ, but actually all even words: {x {a, b} x is odd} = {a, b}. 1

Give examples of languages L 1 and L 2 such that L 1 L 2 = L 2 L 1 and a. L 1 {Λ} = L 2 and neither language contains the other one: Take L 1 = {a}, and L 2 = {aa}. b. = L 1 L 2 and L 1 {Λ}: Take L 1 = {a} and L 2 = {Λ, a}. Show that for any language L, L = (L ) = (L + ) = (L ) +. Whatever the language L, it always holds that L L + L, by the definition of + and. Then exercise 1.33 implies that L (L + ) (L ). Moreover, L (L ) + (L ). Now assume that the inclusion (L ) L is always true. Then L = (L ) and all inclusions above are equalities: L = (L + ) = (L ) + = (L ). Thus the only thing left to prove is that the inclusion (L ) L is always true. Consider w (L ). Thus there exist a k 0 and words v 1,..., v k L such that w = v 1 v k (note that w = Λ if k = 0). Thus w is a concatenation of 0 or more words from L, in other words: w L. 1.32 If L is a finite set, then L denotes the number of elements (the cardinality) of L. Let L 1 and L 2 be two finite languages. Then, clearly, L 1 L 2 L 1 L 2 because every element of L 1 L 2 is obtained by combining an element from L 1 with one from L 2 and there are L 1 L 2 ways to do this. It is however not necessarily the case that L 1 L 2 = L 1 L 2, because different choices may still yield the same result. Let L 1 = L 2 = {a, a 2 } then L 1 L 2 = {aa, aaa, aaaa} and L 1 L 2 = 3 4. Another example are L 1 = {a, ab}, L 2 = {a, ba}. Then L 1 L 2 = {aa, aba, abba}. 1.33 Let L 1, L 2 {a, b}. a. Assume L 1 L 2. Then L 2 1 = L 1L 1 L 1 L 2 L 2 2 and in general Lk 1 = Lk 1 1 L 1 L k 1 1 L 2 L k 1 2 L 2 = L k 2 for all k 1. Consequently, L 1 = {Λ} L 1 L 2 1... Lk 1... {Λ} L 2 L 2 2... Lk 2... = L 2. b. L 1 L 2 (L 1 L 2 ) always holds, since L 1 L 1 L 2 which implies that L 1 (L 1 L 2 ) (see item a. above) and similarly L 2 (L 1 L 2 ). c. The inclusion L 1 L 2 (L 1 L 2 ) may be strict: for L 1 = {0} and L 2 = {1} we have {0} {1} {0, 1}. d. If L 1 L 2 then L 1 L 2 = L 2 and since L 1 L 1 L 2 also (L 1 L 2 ) (L 2 L 2) = L 2. Similarly, L 2 L 1 implies that L 1 L 2 = L 1 = (L 1 L 2 ). Next consider L 1 = {0 2, 0 5 } and L 2 = {0 3, 0 5 }. Then L 1 = {Λ, 02, 0 4, 0 5,...} = {0} {0, 0 3 } and 2

L 2 = {Λ, 03, 0 5, 0 6, 0 8, 0 9,...} = {0} {0, 0 2, 0 4, 0 7 }. Thus neither L 1 L 2 nor L 2 L 1. However, L 1 L 2 = {0} {0} and also (L 1 L 2 ) = {0 2, 0 3, 0 5 } = {Λ, 0 2, 0 3, 0 4, 0 5,...} = {0} {0}. List some elements of {a, ab} and give a proposition describing all and only these elements. Further try to find a procedure to test if a word x satisfies your proposition. {a, ab} contains (among others) the following words: Λ, a, ab, aab, aba, aa, abab, aaa, aaab, aaba, etc. a. {a, ab} is precisely the set of strings in which every b is preceded by at least one a or alternatively {a, ab} is precisely the set of strings which do not start with b and do not have a subword bb. b. Hence a procedure to test whether a word belongs to {a, ab} is to simply go from left to right through the string, symbol by symbol: it should not begin with b and after every occurrence of b either the next letter is an a or the end of the string has been reached. 1.36 L consists of all strings from {a, b} that do not end with b and do not have a subword bb. a. L = {a, ba}. b. Consider now the language K consisting of all strings from {a, b} that do not have a subword bb. Assume that K = S for a finite set S. Then b K = S. Since S = S S, it follows that bb S S = S = K, a contradiction. Hence there cannot exist a finite S such that K = S. 1.37 Let L 1, L 2, L 3 Σ for some alphabet Σ. a. L 1 (L 2 L 3 ) L 1 L 2 L 1 L 3, because w L 1 (L 2 L 3 ) implies that w = xy with x L 1 and y L 2 L 3. Consequently, w L 1 L 2 and w L 1 L 3. Equality does not necessarily hold. Let L 1 = {a, ab}, L 2 = {ba}, and L 3 = {a}. Then L 1 (L 2 L 3 ) = {aba} = {aba, abba} {aa, aba} = L 1 L 2 L 1 L 3, b. L 1 L 2 (L 1 L 2 ), because w (L 1 L 2 ) implies that w is a concatenation of 0 or more words from L 1 L 2. Consequently, w L 1 and w L 2. Equality does not necessarily hold. Let L 1 = {a} and L 2 = {aa}. Then L 1 L 2 = {a} {aa} = {aa} {Λ} = = (L 1 L 2 ). c. L 1 L 2 and (L 1L 2 ) are not necessarily included in one another. Let L 1 = {a} and L 2 = {b}. Then L 1 L 2 = {a} {b} consisting of words with a number of a s followed by some number of b s and (L 1 L 2 ) = {ab} consisting of words with alternating a s and b s. These two languages are incomparable: aab L 1 L 2 (L 1L 2 ) and abab (L 1 L 2 ) L 1 L 2. 3

Let x, y Σ for some alphabet Σ. Whereas in general xy and yx are two different words, equality is possible, for instance if x = Λ or y = Λ. Can this still happen if x and y are both nonnull? Describe the precise conditions when this can happen. Assume that x Λ and y Λ and xy = yx holds. Before giving a characterization of the conditions allowing this situation, we first informally explore what is going on. If x = y, then it must be the case that x = y. If x = y we may assume that x > y ; the other case follows by symmetry. x > y in combination with xy = yx implies that there exists a non-empty word z such that x = yz = zy. Since y Λ, we have yz = x < yx and we may use induction to prove the following Claim For all s, t Σ such that s Λ t: st = ts if and only if there exists a word u and natural numbers p, q such that s = u p and t = u q. Proof of claimthe if-direction is obvious: st = u p u q = u p+q = u q u p = ts. For the only-if-direction we use induction on st : If s = 1 = t, then s = a and t = b for some a, b Σ. From st = st it follows that a = b. Hence we let u = a and p = q = 1 and we are done. Next assume that s > t 1. Then as argued above, there exists a word z such that s = tz = zt. Since tz = tz < st = ts we can apply the induction hypothesis: there exists a word u and natural numbers r, q such that z = u r and t = u q. Consequently, s = u r+q and we are done with p = r + q. Show that there is no language L so that L = {aa, bb} {ab, ba}. We prove by contradiction that exists no language L such that L = {aa, bb} {ab, ba}. Suppose that L is such that L = {aa, bb} {ab, ba}. Consequently, aa L and ab L which implies that abaa L. However, abaa is not an element of {aa, bb} {ab, ba}. Let L = {x {0, 1} x = yy for some string y}. Prove or disprove that there exist two languages L 1 {Λ} and L 2 {Λ} such that L 1 L 2 = L. We prove by contradiction that the statement is not true: Suppose L 1 and L 2 are such that L 1 L 2 = L. Observe that {00} and {11} are both subsets of L = L 1 L 2. If 0 i L 1 and 1 j L 2 for some i, j 1, then 0 i 1 j L 1 L 2 = L, a contradiction. Similarly, we arrive at a contradiction if 1 i L 1 and 0 j L 2 for some i, j 1. Hence it must be the case that either L 1 or L 2 contains only mixed strings with at least one occurrence of a 0 and at least one occurrence of a 1. We 4

only consider the case that L 1 has this property. The case that it would be L 2 is symmetrical. Let w = x 1 0x 2 1x 3 be such a word. Consider 1 j L 2 with j w. Then x 1 0x 2 1x 3 1 j L 1 L 2, but it cannot be an element of L, a contradiction. The remaining case (w = x 1 1x 2 0x 3 ) is dealt with in an analogous way. Hence we arrive in all cases at a contradiction and the assumed languaes L 1, L 2 cannot exist. version 2 September 2011 5