### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# FoCS Week 3 CSCI 2200

RPI

### View Full Document

## 57

## 0

## Popular in Foundations of Computer Science

## Popular in ComputerScienence

This 66 page Class Notes was uploaded by thersh on Thursday February 11, 2016. The Class Notes belongs to CSCI 2200 at Rensselaer Polytechnic Institute taught by Petros Drineas in Spring 2016. Since its upload, it has received 57 views. For similar materials see Foundations of Computer Science in ComputerScienence at Rensselaer Polytechnic Institute.

## Reviews for FoCS Week 3

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/11/16

Basic Structures: Sets, Functions, Sequences, & Sums Introduction • Sets are one of the basic building blocks for the types of objects considered in discrete mathematics. • Important for counting. • Programming languages have set operations. • Set theory is an important branch of mathematics. • Many different systems of axioms have been used to develop set theory. • Here we are not concerned with a formal set of axioms for set theory. Instead, we will use what is called naïve set theory. Sets • A set is an unordered collection of objects. • the students in this class • the chairs in this room • The objects in a set are called the elements, or members of the set. A set is said to contain its elements. • The notation a ∈ A denotes that a is an element of the set A. • If a is not a member of A, write a ∉ A Describing a Set: Roster Method • S = {a,b,c,d} • Order not important S = {a,b,c,d} = {b,c,a,d} • Each distinct object is either a member or not; listing more than once does not change the set. S = {a,b,c,d} = {a,b,c,b,c,d} • Elipses (…) may be used to describe a set without listing all of the members when the pattern is clear. S = {a,b,c,d, ……,z } Roster Method • Set of all vowels in the English alphabet: V = {a,e,i,o,u} • Set of all odd positive integers less than 10: O = {1,3,5,7,9} • Set of all positive integers less than 100: S = {1,2,3,……..,99} • Set of all integers less than 0: S = {…., -3,-2,-1} Some Important Sets N = natural numbers = {0,1,2,3….} Z = integers = {…,-3,-2,-1,0,1,2,3,…} Z⁺ = positive integers = {1,2,3,…..} R = set of real numbers R = set of positive real numbers C = set of complex numbers. Q = set of rational numbers Set-Builder Notation • Specify the property or properties that all members must satisfy: S = {x | x is a positive integer less than 100} O = {x | x is an odd positive integer less than 10} O = {x ∈ Z⁺ | x is odd and x < 10} • A predicate may be used: S = {x | P(x)} • Example: S = {x | Prime(x)} • Positive rational numbers: Q = {x ∈ R | x = p/q, for some positive integers p,q} Interval Notation [a,b] = {x | a ≤ x ≤ b} [a,b) = {x | a ≤ x < b} (a,b] = {x | a < x ≤ b} (a,b) = {x | a < x < b} closed interval [a,b] open interval (a,b) Universal Set and Empty Set • The universal set U is the set containing everything currently under consideration. • Sometimes implicit • Sometimes explicitly stated. Venn Diagram • Contents depend on the context. • The empty set is the set with no U elements. Symbolized ∅, but {} also used. V a e i o u John Venn (1834-1923) Cambridge, UK Some things to remember • Sets can be elements of sets. {{1,2,3},a, {b,c}} {N,Z,Q,R} • The empty set is different from a set containing the empty set. ∅ ≠ { ∅ } Set Equality Definition: Two sets are equal if and only if they have the same elements. • Therefore if A and B are sets, then A and B are equal if and only if . • We write A = B if A and B are equal sets. {1,3,5} = {3, 5, 1} {1,5,5,5,3,3,1} = {1,3,5} Subsets Definition: The set A is a subset of B, if and only if every element of A is also an element of B. • The notation A ⊆ B is used to indicate that A is a subset of the set B. • A ⊆ B holds if is true. 1. Because a ∈ ∅ is always false, ∅ ⊆ S ,for every set S. 2. Because a ∈ S → a ∈ S, S ⊆ S, for every set S. Showing a Set is or is not a Subset of Another Set • Showing that A is a Subset of B: To show that A ⊆ B, show that if x belongs to A, then x also belongs to B. • Showing that A is not a Subset of B: To show that A is not a subset of B, A ⊈ B, find an element x ∈ A with x ∉ B. (Such an x is a counterexample to the claim that x ∈ A implies x ∈ B.) Examples: 1. The set of all computer science majors at your school is a subset of all students at your school. 2. The set of integers with squares less than 100 is not a subset of the set of nonnegativeintegers. Another look at Equality of Sets • Recall that two sets A and B are equal, denoted by A = B, iff • Using logical equivalences we have that A = B iff • This is equivalent to A ⊆ B and B ⊆ A Proper Subsets Definition: If A ⊆ B, but A ≠B, then we say A is a proper subset of B, denoted by A ⊂ B. If A ⊂ B, then is true. Venn Diagram U B A Set Cardinality Definition: If there are exactly n distinct elements in S where n is a nonnegative integer, we say that S is finite. Otherwise it is infinite. Definition: The cardinality of a finite set A, denoted by |A|, is the number of (distinct) elements of A. Examples: 1. |ø| = 0 2. Let S be the letters of the English alphabet. Then |S| = 26 3. |{1,2,3}| = 3 4. |{ø}| = 1 5. The set of integers is infinite. Power Sets Definition: The set of all subsets of a set A, denoted P(A), is called the power set of A. Example: If A = {a,b} then P(A) = {ø, {a},{b},{a,b}} • If a set has n elements, then the cardinality of the power set is 2ⁿ. Tuples • The ordered n-tuple (a ,1 ,2..,a n is the ordered collection that has a1as its first element and a 2s its second element and so on until a n as its last element. • Two n-tuples are equal if and only if their corresponding elements are equal. • 2-tuples are called ordered pairs. • The ordered pairs (a,b) and (c,d) are equal if and only if a = c and b = d. René Descartes Cartesian Product (1596-1650) sets A and B, denoted by A × B is the set of ordered pairs (a,b) where a ∈ A and b ∈ B . Example: A = {a,b} B = {1,2,3} A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)} Cartesian Product Definition: The cartesian products of the sets A ,A 1……,2 , denoned by A × A ×…… × A , is the set of ordered n-tuples 1 2 n (a1,a2,……,a n where a beloigs to A i for i = 1, … n. Example: What is A × B × C where A = {0,1}, B = {1,2} and C = {0,1,2} Solution: A × B × C = {(0,1,0), (0,1,1), (0,1,2),(0,2,0), (0,2,1), (0,2,2),(1,1,0), (1,1,1), (1,1,2), (1,2,0), (1,2,1), (1,1,2)} Truth Sets of Quantifiers • Given a predicate P and a domain D, we define the truth set of P to be the set of elements in D for which P(x) is true. The truth set of P(x) is denoted by • Example: The truth set of P(x) where the domain is the integers and P(x) is “|x| = 1” is the set {-1,1} Union • Definition: Let A and B be sets. The union of the sets A and B, denoted by A ∪ B, is the set: • Example: What is {1,2,3} ∪ {3, 4, 5}? Solution: {1,2,3,4,5} Venn Diagram for A ∪ B U A B Intersection • Definition: The intersection of sets A and B, denoted by A ∩ B, is • Note if the intersection is empty, then A and B are said to be disjoint. • Example: What is? {1,2,3} ∩ {3,4,5} ? Solution: {3} • Example:What is? {1,2,3} ∩ {4,5,6} ? Venn Diagram for A ∩B Solution:∅ U A B Complement Definition: If A is a set, then the complement of the A (with respect to U), denoted by Ā is the set U - A Ā = {x ∈ U | x ∉ A} (The complement of A is sometimes denoted by A .) Example: If U is the positive integers less than 100, what is the complement of {x | x > 70} Solution: {x | x ≤ 70} Venn Diagram for Complement U Ā A Difference • Definition: Let A and B be sets. The difference of A and B, denoted by A – B, is the set containing the elements of A that are not in B. The difference of A and B is also called the complement of B with respect to A. A – B = {x | x ∈ A x ∉ B} = A ∩B U Venn Diagram for A − B A B The Cardinality of the Union of Two Sets • Inclusion-Exclusion U |A ∪ B| = |A| + | B| - |A ∩ B| A B Venn Diagram for A, B, A ∩ B, A ∪ B Review Questions Example: U = {0,1,2,3,4,5,6,7,8,9,10} A = {1,2,3,4,5}, B ={4,5,6,7,8} 1. A ∪ B Solution: {1,2,3,4,5,6,7,8} 2. A ∩ B Solution: {4,5} 3. Ā Solution: {0,6,7,8,9,10} 4. Solution: {0,1,2,3,9,10} 5. A – B Solution: {1,2,3} 6. B – A Solution: {6,7,8} Set Identities • Identity laws • Domination laws • Idempotent laws • Complementation law Continued on next slide Set Identities • Commutative laws • Associative laws • Distributive laws Continued on next slide Set Identities • De Morgan’s laws • Absorption laws • Complement laws Proof of Second De Morgan Law Example: Prove that Solution: We prove this identity by showing that: 1) and 2) Continued on next slide Proof of Second De Morgan Law These steps show that: Continued on next slide Proof of Second De Morgan Law These steps show that: Set-Builder Notation: Second De Morgan Law Membership Table Example: Construct a membership table to show that the distributive law holds. Solution: A B C 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 Generalized Unions and Intersections • Let A1, 2 ,…, Anbe an indexed collection of sets. We define: These are well defined, since union and intersection are associative. Functions Definition: Let A and B be nonempty sets. A functionf from A to B, denoted f: A → B is an assignment of each element of A to exactly one element of B. We write f(a) = b if b is the unique element of B assigned by the function f to the element a of A. • Functions are sometimes called mappings or Students Grades transformations. A Carlota B Sandeep C Jalen D F Kathy Functions Given a function f: A → B: • We say f maps A to B or f is a mapping from A to B. • A is called the domain of f. • B is called the codomain of f. • If f(a) = b, • then b is called the image of a under f. • a is called the preimage of b. • The range of f is the set of all images of points in A under f. We denote it by f(A). •the same codomain and map each element of the domain to, the same element of the codomain. Representing Functions • Functions may be specified in different ways: • An explicit statement of the assignment. Students and grades example. • A formula. f(x) = x + 1 • A computer program. • A Java program that when given an integer n, produces the nth Fibonacci Number (covered in the next section and also inChapter 5). Questions f(a) = ? z A B The image of d is ? z a x The domain of f is ? A b y The codomain of f is ? B c d z The preimage of y is ? b f(A) = ? The preimage(s) of z is (are) ? {a,c,d} Injections Definition: A function f is said to be one-to-one , or injective, if and only if f(a) = f(b) implies that a = b for all a and b in the domain of f. A function is said to be an injection if it is one-to-one. A B a x b v y c z d w Surjections Definition: A function f from A to B is called onto or surjective, if and only if for every element there is an element with . A function f is called a surjection if it is onto. A B a x b y c z d Bijections Definition: A function f is a one-to-one correspondence, or a bijection, if it is both one-to-one and onto (surjective and injective). A B a x b y c d z w Showing that f is one-to-one or onto Showing that f is one-to-one or onto Example 1: Let f be the function from {a,b,c,d} to {1,2,3} defined by f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3. Is f an onto function? Solution: Yes, f is onto since all three elements of the codomain are images of elements in the domain. If the codomain were changed to {1,2,3,4}, f would not be onto. 2 Example 2: Is the function f(x) = x from the set of integers onto? Solution: No, f is not onto because there is no integer x with x = −1, for example. Inverse Functions Definition: Let f be a bijection from A to B. Then the inverse of f, denoted , is the function from B to A defined as No inverse exists unless f is a bijection. Why? Inverse Functions A B A B f a V V a b W b W c c d X X d Y Y Questions Example 2: Let f: Z Z be such that f(x) = x + 1. Is f invertible, and if so, what is its inverse? Solution: The function f is invertible because it is a one- to-one correspondence. The inverse function f -1 reverses the correspondence so f (y) = y – 1. Questions Example 3: Let f: R → R be such that . Is f invertible, and if so, what is its inverse? Solution: The function f is not invertible because it is not one-to-one . Factorial Function Definition: f: N → Z , denoted by f(n) = n! is the product of the first n positive integers when n is a nonnegative integer. f(n) = 1 ∙ 2 ∙∙∙ (n – 1) ∙ f(0) = 0! = 1 Examples: f(1) = 1! = 1 f(2) = 2! = 1 ∙ 2 = 2 Stirling’s Formula: f(6) = 6! = 1 ∙ 2 ∙ 3∙ 4∙ 5 ∙ 6 = 720 f(20) = 2,432,902,008,176,640,000. Introduction • Sequences are ordered lists of elements. • 1, 2, 3, 5, 8 • 1, 3, 9, 27, 81, ……. • Sequences arise throughout mathematics, computer science, and in many other disciplines, ranging from botany to music. • We will introduce the terminology to represent sequences and sums of the terms in the sequences. Sequences Definition: A sequence is a function from a subset of the integers (usually either the set {0, 1, 2, 3, 4, …..} or {1, 2, 3, 4, ….} ) to a set S. • The notation a is used to denote the image of the integer n. We n can think of n as the equivalent of f(n) where f is a function from {0,1,2,…..} to S. We callna a term of the sequence. Sequences Example: Consider the sequencwhere Geometric Progression Definition: A geometric progression is a sequence of the form: where the initial term a and the common ratio r are real numbers. Examples: 1. Let a = 1 and r = −1. Then: 2. Let a = 2 and r = 5. Then: 3. Let a = 6 and r = 1/3. Then: Arithmetic Progression Definition: A arithmetic progression is a sequence of the form: where the initial term a and the common difference d are real numbers. Examples: 1. Let a = −1 and d = 4: 2. Let a = 7 and d = −3: 3. Let a = 1 and d = 2: Recurrence Relations Definition: A recurrence relation for the sequence {a } isnan equation that expresses a in terms of one or more of the previous terms of the sequence, namely, a , 0 , 1, a , n-1 all integers n with n ≥ n , 0 where n i0 a nonnegative integer. • A sequence is called a solution of a recurrence relation if its terms satisfy the recurrence relation. • The initial conditions for a sequence specify the terms that precede the first term where the recurrence relation takes effect. Questions about Recurrence Relations Example 1: Let {a n be a sequence that satisfies the recurrence relation an= an-1+ 3 for n = 1,2,3,4,…. and suppose that a = 0. What are a , a and a ? 1 2 3 [Here a 0 2 is the initial condition.] Solution: We see from the recurrence relation that a 1 a + 0 = 2 + 3 = 5 a = 5 + 3 = 8 2 a 3 8 + 3 = 11 Questions about Recurrence Relations Example 2: Let {a n be a sequence that satisfies the recurrence relation an= a n-1– an-2for n = 2,3,4,…. and suppose that a =03 and a 1 = 5. What are a and a ? 2 3 [Here the initial conditions are a 0 3 and a =15. ] Solution: We see from the recurrence relation that a 2 a -1a =05 – 3 = 2 a3= a 2 a =12 – 5 = –3 Fibonacci Sequence Definition: Define the Fibonacci sequence, f ,f ,f ,…, by: 0 1 2 • Initial Conditions:0f = 01 f = 1 • Recurrence Relation: f = f + f n n-1 n-2 Example: Find f ,f 2f 3 4 an5 f . 6 Answer: 2 = f 1 f =01 + 0 = 1, f = f + f = 1 + 1 = 2, 3 2 1 f = f + f = 2 + 1 = 3, 4 3 2 f5= f 4 f =33 + 2 = 5, f6= f 5 f =45 + 3 = 8. Solving Recurrence Relations • Finding a formula for the nth term of the sequence generated by a recurrence relation is called solving the recurrence relation. • Such a formula is called a closed formula; such a formula may be found via the method of iteration, in which we need to guess the formula. The guess can be proved correct by the method of induction. Iterative Solution Example Method 1: Working upward, forward substitution Let {a } be a sequence that satisfies the recurrence relation a = a n n n-1 + 3 for n = 2,3,4,…. and suppose that a = 2. 1 a2= 2 + 3 a = (2 + 3) + 3 = 2 + 3 ∙ 2 3 a4= (2 + 2 ∙ 3) + 3 = 2 + 3 ∙ 3 . . . a = a + 3 = (2 + 3 ∙ (n – 2)) + 3 = 2 + 3(n – 1) n n-1 Iterative Solution Example Method 2: Working downward, backward substitution Let {n } be a sequence that satisfies the recurrence relation an= an-1 + 3 for n = 2,3,4,…. and suppose th1t a = 2. a = a + 3 n n-1 = (a n-2+ 3) + 3 = a n-2+ 3 ∙ 2 = (a n-3+ 3 )+ 3 ∙ 2 = a n-3 + 3 ∙ 3 . . . = a + 3(n – 2) = (a + 3) + 3(n – 2) = 2 + 3(n – 1) 2 1 Summations • Sum of the terms from the sequence • The notation: represents • The variable j is called the index of summation. It runs through all the integers starting with its lower limit m and ending with its upper limit n. Summations • More generally for a set S: • Examples: Product Notation • Product of the terms from the sequence • The notation: represents Some Useful Summation Formulae Later we will prove some of these by induction. Proof in text (optional)

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

#### "I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.