To illustrate what is intended the following are three write ups by students. Diagonalization

Similar documents
University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

1. [5 points each] True or False. If the question is currently open, write O or Open.

Material from Recitation 1

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

CIT3130: Theory of Computation. Regular languages

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Infinity and Uncountability. Countable Countably infinite. Enumeration

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Problems, Languages, Machines, Computability, Complexity

CSE 20 DISCRETE MATH WINTER

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

CS3102 Theory of Computation Problem Set 2, Spring 2011 Department of Computer Science, University of Virginia

Chapter 3. Set Theory. 3.1 What is a Set?

DISCRETE MATHEMATICS

Computer Science 236 Fall Nov. 11, 2010

UNM - PNM STATEWIDE MATHEMATICS CONTEST XLI. February 7, 2009 Second Round Three Hours

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

Lecture 1. 1 Notation

Induction and Recursion. CMPS/MATH 2170: Discrete Mathematics

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

COT 3100 Spring 2010 Midterm 2

A B. bijection. injection. Section 2.4: Countability. a b c d e g

Lecture 2 Finite Automata

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Math 485, Graph Theory: Homework #3

Theory of Computation

CmpSci 187: Programming with Data Structures Spring 2015

CS402 - Theory of Automata Glossary By

Proof Techniques Alphabets, Strings, and Languages. Foundations of Computer Science Theory

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Basic Combinatorics. Math 40210, Section 01 Fall Homework 4 Solutions

THEORY OF COMPUTATION

Semantics via Syntax. f (4) = if define f (x) =2 x + 55.

Cantor s Diagonal Argument for Different Levels of Infinity

.Math 0450 Honors intro to analysis Spring, 2009 Notes #4 corrected (as of Monday evening, 1/12) some changes on page 6, as in .

Discrete Structures. Fall Homework3

The Further Mathematics Support Programme

A Random Walk through CS70

CS6160 Theory of Computation Problem Set 2 Department of Computer Science, University of Virginia

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

Final Exam 1, CS154. April 21, 2010

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

CSE 20 DISCRETE MATH. Winter

Reflection in the Chomsky Hierarchy

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

2. CONNECTIVITY Connectivity

Discrete Mathematics Exam File Fall Exam #1

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Cardinality of Sets. Washington University Math Circle 10/30/2016

Phil 320 Chapter 1: Sets, Functions and Enumerability I. Sets Informally: a set is a collection of objects. The objects are called members or

Ma/CS 6b Class 26: Art Galleries and Politicians

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

APCS-AB: Java. Recursion in Java December 12, week14 1

Today. Types of graphs. Complete Graphs. Trees. Hypercubes.

The Probabilistic Method

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

ELEC-270 Solutions to Assignment 5

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

EDAA40 At home exercises 1

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

CSE 20 DISCRETE MATH. Fall

Combinatorial Gems. Po-Shen Loh. June 2009

Infinity part I. High School Circle I. June 4, 2017

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

Math 170- Graph Theory Notes

Enumerations and Turing Machines

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

REGULAR GRAPHS OF GIVEN GIRTH. Contents

Technische Universität München Zentrum Mathematik

Cardinality of Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Cardinality of Sets Fall / 15

1. Chapter 1, # 1: Prove that for all sets A, B, C, the formula

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

SET DEFINITION 1 elements members

Recursive definition of sets and structural induction

Section 1.7 Sequences, Summations Cardinality of Infinite Sets

CS103 Spring 2018 Mathematical Vocabulary

Final Exam 2, CS154. April 25, 2010

2 Review of Set Theory

Recursion. Chapter 7. Copyright 2012 by Pearson Education, Inc. All rights reserved

Recursion and Structural Induction

Fall Recursion and induction. Stephen Brookes. Lecture 4

Foundations of Computer Science Spring Mathematical Preliminaries

Chapter 18 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal.

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

MITOCW watch?v=4dj1oguwtem

Ambiguous Grammars and Compactification

CpSc 421 Final Solutions

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

Euclid's Algorithm. MA/CSSE 473 Day 06. Student Questions Odd Pie Fight Euclid's algorithm (if there is time) extended Euclid's algorithm

Section 2.4 Sequences and Summations

CS525 Winter 2012 \ Class Assignment #2 Preparation

6 NFA and Regular Expressions

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

Introduction to Sets and Logic (MATH 1190)

SECTION 5.1. Sequences

Transcription:

General guidelines: You may work with other people, as long as you write up your solution in your own words and understand everything you turn in. Make sure to justify your answers they should be clear and concise, with no irrelevant information. Please put your name and net id on your homework! 1. Select a topic from the list of topics on the course website beyond finite automata. You may select any topic after the heading context-free languages. Write a half page explanation of your topic that should be understandable to any student in the class. Then create two problems on the topic and work out solutions. These might be used by someone teaching the course as examples. Then create eight more homework exercises that would help a student understand the topic. To illustrate what is intended the following are three write ups by students. Diagonalization If we want to compare the cardinalities of two finite sets, we can simply count the elements in each set and compare the number of elements. For infinite sets, such as the set of integers or the set of real numbers, we can compare the cardinalities of two sets by finding a one-to-one correspondence between the elements of the sets. A set is countably infinite if its elements can be put in one-to-one correspondence with integers. For example, we can create a one-to-one correspondence between the set of all even numbers and the set of all integers. Therefore, the set of all even numbers is countably infinite. Even numbers: 0 2 4 6 8 Integers: 0 1 2 3 4 If a set is countable, then we can list the elements of the set or, equivalently, we can put the elements of the set in a table. We can show that certain sets are not countably infinite by diagonalization. For example, diagonalization can be used to show that the set of all real numbers between 0 and 1 is not countably infinite. To do this, try to put all the elements in the following table:

0. 1 0 1 0 1 0 0. 0 1 0 1 0 1 0. 1 1 1 1 1 1 0. 0 0 1 0 0 1 0. 1 1 0 1 1 0 0. 0 0 0 0 0 1 By selecting all the elements along the diagonal beginning with the digit in the tenths place, namely 111011, we have selected an element that has not already been listed in the table. This shows that all the real numbers cannot be listed in a table. Thus, the set of real numbers is not countably infinite. There exist a countably infinite number of computer programs, or names, but there are too many sets, or functions to be counted. Thus, there exist functions that cannot be computed by a computer program. Exercises: 1. Write a short essay about diagonalization that would explain to a high school student the concepts of countably infinite, not countably infinite, and diagonalization. It should talk about how to compare the cardinality of two sets and it should give a convincing argument that there exists a non countably infinite set. 2. Prove that the set of all rational numbers is countably infinite. 3. Prove the following: (a) The set of strings {0,1}* is countably infinite. (b) The set of all subsets of {0,1}* is not countably infinite. 4. Compare the cardinalities of the following pairs of sets: (a) The set of all real numbers between 0 and 1 and the set of all integers.

(b) The set of all finite length strings over the alphabet {0,1} and the set of all finite length strings over the alphabet {0,1,2,3}. (c) The set of all odd numbers between 0 and 100 inclusive and the set of all negative numbers greater than -75. 5. Consider the set of all finite length strings over the alphabet {0,1} and the set of all finite length strings over the alphabet {0,1,2,3}. Give a one-to-one mapping between the elements of the two sets. 6. Compare the cardinalities of the set of all real numbers and the set of all perfect squares. 7. What is the cardinality of the set of all square integer matrices? The size of the matrix can be arbitrarily large as well as the value of any entry. Pumping Lemma Consider a deterministic finite automaton that accepts some language L. If L defines an infinite number of strings, such as 0*1*, there must be some string in the language that has more symbols than the number of states in the machine, because the machine has a finite number of states. If the string is processed by the machine, at least one of the states must be visited more than once due to the pigeonhole principle. Thus, there must be a loop in the DFA beginning and ending at that state. Let us denote by X the substring which sends the DFA through the loop. Clearly, the machine should then accept a string with as many contiguous copies of X as you want. So, for instance, if the machine accepted 0X1, then it should accept 0XX1, 0XXX1, or even 0XXXXXX1, because the machine will just loop over and over until it is time to continue on. Essentially the pumping lemma says is that if you have a regular language and a machine that accepts it, then for the strings in the language whose lengths exceed the number of states in the machine there must be some substring that can be looped as many times you want and still be an accepted string. This theorem can be used to prove that a language is not regular. The proof proceeds by contradiction. Assume that the language is regular and that we have some DFA which accepts it. If we can find a string in that language which, after duplicating any substring gives something not accepted by the DFA (and thus not in the language), then clearly the pumping lemma is not satisfied, and thus the string cannot have been regular to begin with. Example 1: L = {0 i 1 i i 1}

Assume that this language is regular, and that some DFA with n states accepts it. Consider the string 0 n 1 n. Clearly this string has 2n symbols. Because this exceeds the number of states in the machine, one state must be visited at least more than once somewhere in the first n symbols. In this case, that means the loop in the DFA must be some length substring consisting of all 0 s. Write the string as some string xyz, where x is the part of the string before the loop, y is the piece between the repeated state, and z is the piece of the string after the loop. It should be clear that if there are n states in the DFA, xy n. The pumping lemma states that for any string in the language, xy j z is also in the language, for any j 0. However, no matter how you cut 0 n 1 n up into xyz with xy n, y must necessarily be made up entirely of 0 s. Thus, if we considered the string xy 2 z we would get something where there are clearly more 0 s than 1 s (because all of the 1 s are in z), and thus is not a part of the language. This is a contradiction. Because the pumping lemma doesn t hold for all the strings in our language, the language is not regular. Example 2: L = {ww w (0+1)*} Assume that this language is regular, and that some DFA with n states accepts it. Consider the string 0 n 1 n 0 n 1 n. Clearly this string has 4n symbols. Because this exceeds the number of states in the machine, one state must be visited at least more than once somewhere in the first n symbols. In this case, that means the loop in the DFA must be some length substring consisting of all 0 s. Write the string as some string xyz, where x is the part of the string before the loop, y is the piece between the repeated state, and z is the piece of the string after the loop. It should be clear that if there are n states in the DFA, xy n. The pumping lemma states that for any string in the language, xy j z is also in the language, for any j 0. However, no matter how you cut 0 n 1 n 0 n 1 n up into xyz with xy n, y must necessarily be made up entirely of 0 s. Thus, if we considered the string xy 2 z we would get something where there are clearly more 0 s in the first block than in the second (because the second block of zeros are all in z), and thus is not a part of the language. This is a contradiction. Because the pumping lemma doesn t hold for all the strings in our language, the language is not regular. Exercises: Prove the following languages to be non-regular:

1.) {0 n n is a power of 2} 2.) The set of strings of the form w1 n, where w is a string of 0 s and 1 s of length n. 3.) The set of strings of balanced parentheses. These are the strings of characters ( and ) that can appear in a well-formed arithmetic expression. 4.) {0 p p is a prime number} 5.) {a n b n c n n 0} 6.) {a n b m c n d m n,m 0} 7.) {a i b j c k 0 i j k} Mathematical Induction Mathematical induction is a proof technique used to show that a statement involving a number n is true for any n k, where n and k are natural numbers. This proof is done by proving that 1) the statement is true for n = k (the base case), and that 2) if the statement is true for n, it is also true for n+1 (the inductive step). Example 1. Let s use dominos as an example to demonstrate this technique. In order to prove that all dominos will fall over, we must show two things: that the first one is knocked over (our base case), and that each domino will knock over its neighbor (our inductive step). Obviously, if we have shown these two facts true, than we have also shown that all the dominos will fall over. Example 2. Now let s move to a more formal example. Let s prove that = (that is, that the sum of natural numbers from 1 to n is ) for n 0. Induction Hypothesis (S n ): = Base Case (S 0 ): We must show that our induction hypothesis is true for n=0: = = 0.The sum of all natural numbers from 0 to 0 is indeed 0. Base Case is true. Inductive Step (S n => S n+1 ): We must now show that if S n is true, this implies that S n+1 is true as well. Let s assume that S n is true, that is, that =. Now let s show that this implies that =. = (The sum of all natural numbers from 0 to n+1 equals the sum all natural numbers from 0 to n and n+1.) = (By the induction hypothesis, we can replace with.) = = = (Using algebraic transformations, we get the expression we wanted.) We have thus shown that = implies that =. Conclusion: By induction, we have shown that our induction hypothesis, =, is true for all n 0. Induction is really useful in computer science because of its strong link to recursion. Its techniques can be used on recursively defined structures such as trees.

Once again, to prove a statement S n true for all n k using induction, we must 1) prove our base case, S k, and 2) prove that S n S n+1. Homework problems. #1 Prove that = for all natural numbers. #2 Prove that = for all natural numbers. #3 Prove that for all natural numbers. #4 Prove that for all natural numbers. #5 Let be the number of nodes and be the number of levels in a binary tree. Prove that. #6 The Towers of Hanoi is a puzzle involving three rods and a number of disks all of which are a different size and fit onto the rods. Initially, all the disks are on the first rod in order of increasing size from top to bottom. The point of the game is to move all the disks from one rod to another, without breaking the following two rules: 1) only one disk may be moved at a time; 2) a larger disk may never be on top of a smaller disk. Prove by induction that this may be done for any number of disks.