Top Banner
CS 454 Theory of Computation Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall Original slides by Vahid and Givargis, Mani Srivastava and others Extensive editing by Ravikumar
20

CS 454 Theory of Computation

Mar 20, 2016

Download

Documents

yaholo

CS 454 Theory of Computation. Sonoma State University, Fall 2011 Instructor: B. (Ravi) Ravikumar Office: 116 I Darwin Hall. Original slides by Vahid and Givargis, Mani Srivastava and others Extensive editing by Ravikumar. Lecture 2 Goals: - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS 454 Theory of Computation

CS 454 Theory of Computation

Sonoma State University, Fall 2011Instructor: B. (Ravi) Ravikumar

Office: 116 I Darwin HallOriginal slides by Vahid and Givargis, Mani Srivastava and othersExtensive editing by Ravikumar

Page 2: CS 454 Theory of Computation

Lecture 2 Goals:

• chapter 0 (45 minutes)• Quiz 1 (10 minutes)• Chapter 1 (rest of the class)

Page 3: CS 454 Theory of Computation

Chapter 0• Sets• Set operations and set relations

• union, intersection, complement• member, subset, equality• Venn diagrams

Problem: Show that (A U B) C = (A C)U (B C) Proof: Let x be in LHS set. Then, x is in both A U B and is in C. i.e., x is A and C, or x is in B and C. I.e., x is in A C or in B C. This means, x is in (A C)U (B C). Converse is similar.

Page 4: CS 454 Theory of Computation

Sequences and tuples

A sequence is a list of objects where order is important. Thus, <1, 2, 4, 10> is a sequence that is different than <2, 1, 4, 10>.

A finite sequence of length k is called a k-tuple. Thus, the above sequence is a 4-tuple.

• Power-set of a set A is the set of all its subsets.Ex: A = {1, 2} P(A) = {{1}, {2}, {1,2}, }

Page 5: CS 454 Theory of Computation

Cartesian product

A X B = {<i,j> | i is in A and j is in B }

Example: A = {a, b, c}, B = { 1, 2}

What is A X B?

Page 6: CS 454 Theory of Computation

Cartesian product

A X B = {<i,j> | i is in A and j is in B }

Example: A = {a, b, c}, B = { 1, 2}

What is A X B?

A x B = { <a, 1>, <a, 2>, <b, 1>, <b, 2>, <c, 1>, <c, 2>}

A X A X … X A is often denoted by Ak.

Page 7: CS 454 Theory of Computation

Relations A relation on a set A is a subset of A X A.Example 1: A = { 1, 2, …, 10}, relation R is defined as: (a, b) is in R if a – b = 3. R = { (4, 1), (5, 2), (6, 3), (7, 4), (8, 5), (9, 6), (10, 7)}

Example 2: Children’s game of Rock-Paper-Scissors. Relation could be “beats”. B = { (scissors, paper), (paper, rock), (rock, scissors)}

Page 8: CS 454 Theory of Computation

FunctionsA function (from A to B) is a relation R in which for every i, there is a unique j such that <i,j> is in R.

• onto: for any y in B, there is at least one x in A such that <x, y> is in R.• one-one: for any y in B, there is at most one x in A such that <x, y> is in R.• bijective: for any y in B, there is exactly one x in A such that <x, y> is in R.

Page 9: CS 454 Theory of Computation

Some special relations• equivalence relation• partial-order relation

Graphs:• Definition• Example

Strings and languages• Boolean logic• quantifiers

Summary of mathematical terms

Page 10: CS 454 Theory of Computation

Definitions, theorems and proofs• Definitions: A definition is the way to describe an object in a way that its characteristics are completely captured in the description.

• Assertions: Mathematical statement expresses some property of a set of defined objects. Assertions may or may not be true.

• Proof: is a convincing logical argument that a statement is true. The proofs are required to follow rigid rules and are not allowed any room for uncertainties or ambiguities.

• Theorem: is a proven assertion of some importance.

Page 11: CS 454 Theory of Computation

Rules for carrying out proof Usually assertions are compound statements that are connected using Boolean connectives and quantifiers. You can use theorems of Boolean logic in the proof.

Direct proof:

• For example, if the assertion is P or Q, you can show it as follows: Suppose P is not true. Then, Q must be true.

• Similarly, to show P Q, you assume P is true. From this, show Q is true. To show that P <-> Q, you should show P Q and Q P.

Page 12: CS 454 Theory of Computation

Example: Every positive integer is either a prime, or is a product of two integers both of which are strictly smaller than itself.

Is this a definition? Is it an assertion?

Page 13: CS 454 Theory of Computation

Example: Every positive integer is either a prime, or is a product of two integers both of which are strictly smaller than itself.

It is an assertion. Is it a true assertion?

Page 14: CS 454 Theory of Computation

Example: Every positive integer is either a prime, or is a product of two integers both of which are strictly smaller than itself.

Yes, it is a true assertion.

How to prove this assertion?

Page 15: CS 454 Theory of Computation

Example: Every positive integer is either a prime, or is a product of two integers both of which are strictly smaller than itself.

Yes, it is a true assertion.

How to prove this assertion?

This requires knowing the definition of a prime number.

Prime number: A number x is prime if it has exactly two divisors, namely 1 and x.

Page 16: CS 454 Theory of Computation

• Most of the theorems assert properties of a collection of objects.

• If the collection is finite, usually it is easy: • you can show it for every member one by one.

• Need for proof really arises when the assertion is of the form : “Every object in a set X has some property Y.” where X is an infinite set.

Now you can’t prove it one by one!

• Proof techniques: (not an exhaustive list!)• proof by construction• proof by contradiction• proof by induction

Page 17: CS 454 Theory of Computation

Proof by construction: Definition: A k-regular graph is a graph in which every node has degree k.

Theorem: For each even number n greater than 2, there exists a 3-regular graph with n nodes.

Although the construction below shows the claim for n = 14, it can be readily generalized.

Page 18: CS 454 Theory of Computation

Proof by contradictionTo show P Q, assume Q is not true, then show that P is false, which contradicts the hypothesis that P is true.

Theorem: is not rational, i.e., it can’t be written as a ratio of two integers.A proof by contradiction is presented in page 22.

Alternate proof: (This is not a proof by contradiction.) This proof is based on two lemmas.

Lemma 1: A positive integer n is a perfect square if and only if it has an odd number of divisors.

Lemma 2: If a positive odd integer n has d divisors, then 2n has 2d divisors.

2

Page 19: CS 454 Theory of Computation

Proof by inductionExample 1: Formula for mortgage calculation.

Page 24 of text.

Example 2: Show that the set of all binary strings of length n can be arranged in a way that every adjacent string differs in exactly one bit position, and further the first and the last string also differ in exactly one position. For n = 2, one such is 00, 01, 11, 10.

Page 20: CS 454 Theory of Computation

Assertion: Every integer is a sum of squares of two integers. This is not true. To disprove it, it is enough to find one integer (counter-example) that can’t be written as sum of two squares. Consider 3. Suppose x2 + y2 = 3 for some integers x and y. This means, x2 is either 0, 1 or 2. (Why not any other number?) Case 1: x2 is 0. Thus y2 is 3. But there is no integer y such that y2 = 3. (How can we show this?)Case 2: x2 is 1. Thus y2 is 2. But from previous slide, we know that there is no integer y such that y2 = 2.Case 3: x2 is 2. But from previous slide, we know that there is no integer x such that x2 = 2. End of proof.