22
Chapter 2 - Basics Structures 2.1 - Sets Definitions and Notation Definition 1 (Set). A set is an of . These are called the or of the set. We’ll typically use uppercase letters to denote sets: S, A, B,. . . When listing out the elements in a set (what the book calls the “roster method”) we’ll use braces, e.g., S = {2, red, water, {1}} Membership: x S means x/ S means Note: and do not matter when listing the elements of a set. For example, {5, 3, 2, 7, 3, 8, 2, 2, 2} is the same set as {2, 3, 5, 7, 8}. Examples Let S be the set of people in this room. Some standard sets of numbers: N is the set of , {0, 1, 2, 3,... }. Note: Some books define N to be {1, 2, 3,... } (the “counting numbers”). Z is the set of all . Q is the set of all . R is the set of all . C is the set of all . Z + is the set of all (sometimes written Z + ). You may also see this sort of notation to denote other subset of certain sets of numbers, such as Z <0 , Z 0 , R + (or R + ), Q + , etc. Note: “positive” does not include 0, but saying “nonnegative” does include 0. Set-Builder Notation Often we will write sets using “set-builder” notation; the general form is {x | P (x)} or {x : P (x)} for some predicate P (x). The | or : is read “such that”. 1

Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

  • Upload
    others

  • View
    16

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Chapter 2 - Basics Structures

2.1 - Sets

Definitions and Notation

Definition 1 (Set). A set is an of . These are called theor of the set.

• We’ll typically use uppercase letters to denote sets: S, A, B,. . .

• When listing out the elements in a set (what the book calls the “roster method”) we’ll use braces, e.g., S ={2, red,water, {1}}

• Membership:

– x ∈ S means

– x /∈ S means

• Note: and do not matter when listing the elements of a set. For example,{5, 3, 2, 7, 3, 8, 2, 2, 2} is the same set as {2, 3, 5, 7, 8}.

Examples

• Let S be the set of people in this room.

• Some standard sets of numbers:

– N is the set of , {0, 1, 2, 3, . . . }. Note: Some books define N to be {1, 2, 3, . . . } (the“counting numbers”).

– Z is the set of all .

– Q is the set of all .

– R is the set of all .

– C is the set of all .

– Z+ is the set of all (sometimes written Z+). You may also see this sort of notationto denote other subset of certain sets of numbers, such as Z<0, Z≤0, R+ (or R+), Q+, etc. Note: “positive”does not include 0, but saying “nonnegative” does include 0.

Set-Builder Notation

Often we will write sets using “set-builder” notation; the general form is {x | P (x)} or {x : P (x)} for some predicateP (x). The | or : is read “such that”.

1

Page 2: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Example 1.

1. {x | x is a left-handed guitar player}

2. {x | x ∈ R and 1 ≤ x ≤ 2}

We can also use set-builder notation to make the domain(s) explicit:

Example 2.

• {x ∈ R : x2 < 10}

• {x ∈ N : x2 < 10}

• {x ∈ Z : x2 < 10}

Examples

1. The set of all integers that are perfect squares.

2. {2, 4, 6}

Venn Diagrams

The is the set of all objects under consideration (similar to domain in the previous chapter).We denote it by U and draw a rectangle in the Venn Diagram.

In a Venn Diagram we picture a set, say A, as a restricted portion of the universal set:

The Empty Set

Definition 2. Empty Set The empty set is the set that contains .

Example 3. Is ∅ = {∅}?

2

Page 3: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Subsets

Notation:

Predicate Definition: We can define “subset” using predicates.

Example 4. For all sets S,

1. Is ∅ ⊆ S?

2. Is S ⊆ S?

Subsets and Equality

• To show that A ⊆ B, we show that if then .

• To show that A * B, we find at least one such that .

• Two set A and B are equal if and only if (TFAE):

– They both contain

Sundry Definitions

Proper subsets:

3

Page 4: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Finite sets:

Infinite sets:

Cardinality of a set: |A| is denotes the of A.

If A is then we can just count them all and |A| =(some number).

If A is , then we can still have .

New Sets From Old

The Power Set: P(S) denotes the set of . It is a .

Cartesian Products: The ofA andB is a set of / .We write this as

A×B =

In general,A1 ×A2 × · · · ×An =

Example 5. Let B = {1, 2} and C = {a, b, c}. Find the following:

1. P(∅)

2. P ({∅})

3. P(B)

4. B × C

5. |B × C|

6. B ×B

7. P(C)

8. P (P({∅})).

Note: |P(A)| =

4

Page 5: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

2.2 - Set Operations

Union of Sets

Definition 3 (Union). The union of two setsA andB is the set of all elements which are

Notation

Venn Diagram

Intersection of Sets

Definition 4 (Intersection). The intersection of two sets A and B is the set of all elements which are in both A andB.

Notation

Venn Diagram

Generalized Unions and Intersections

Both unions and intersections are associative, so their generalizations are well-defined.

Notation:

5

Page 6: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

More Definitions

• Disjoint Sets:

• Mutually Disjoint Collections of Sets:

• Principle of Inclusion/Exclusion:

• Set Difference

Set Complement

Definition 5 (Complement of a Set).

Venn Diagram

6

Page 7: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Set Identities

Identity Name

A ∩U = AA ∪∅ = A

Identity Laws

A ∪U = UA ∩∅ = ∅

Domination Laws

A ∪A = AA ∩A = A

Idempotent Laws

(A) = A Complementation Law

A ∪B = B ∪AA ∩B = B ∩A

Commutative Laws

A ∪ (B ∪ C) = (A ∪B) ∪ CA ∩ (B ∩ C) = (A ∩B) ∩ C

Associative Laws

A ∪ (B ∩ C) = (A ∪B) ∩ (A ∪ C)A ∩ (B ∪ C) = (A ∩B) ∪ (A ∩ C)

Distributive Laws

A ∩B = A ∪ BA ∪B = A ∩ B

De Morgan’s Laws

A ∪ (A ∩B) = AA ∩ (A ∪B) = A

Absorption Laws

A ∪ A = UA ∩ A = ∅

Complement Laws

Proving Set Identities

Example 6. Prove the Second Absorption Law:

A ∩ (A ∪B)

Proof.

Q.E.D.

7

Page 8: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Example 7. Prove the first part of De Morgan’s Law:

A ∪B = (A ∩ B)

Proof.

Q.E.D.

8

Page 9: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

2.3 - Functions

Definition 6 (Function). Given nonempty sets A and B, a function f from A to B is an assignment of exactly oneelement of B to each element of A. We write f(a) = b where b is the unique element of the set B to which f maps theelement a of the set A.

Functions are also called mappings, transformations, or assignments.

Example 8.

1. Each student in this room is assigned to exactly one seat.

2. Each person is assigned to exactly one birth mother.

3. Each nonnegative real number is assigned exactly one square root.

Notation

If f is a function from A to B, we write this as f : A→ B.

If A and B are relatively small sets, we can draw the function:

More terminology

Given a function f : A→ B,

• Domain and Codomain:

• Range:

• Image:

• Pre-Image:

• Arithmetic on Functions: If f1 and f2 are functions whose codomain is the real numbers, then we can definef1 + f2 and f1 · f2 as. . .

9

Page 10: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Image of a Set

Suppose f : A→ B and S ⊆ A. Then

f(S) =

Example 9. Let A = {1, 2, 3, 4, 5} and B = {a, b, c, d}, and S = {2, 3, 4} and T = {1, 5}, and let f(1) = b, f(2) = c,f(3) = a, f(4) = d, and f(5) = b. Find

1. f(∅)

2. f(S)

3. f(T )

One-to-One and Onto

Definition 7 (One-to-One). A function f : A→ B is said to be one-to-one (abbreviated “1-1”) or injective if and onlyif. . .

Definition 8 (Onto). A function f : A→ B is said to be onto or surjective if and only if. . .

10

Page 11: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Bijection and Inverse

Definition 9 (Bijection). A function f : A→ B is said to be a bijection or one-to-one correspondence if and only if itis both injective and surjective.

Definition 10 (Inverse). The inverse (when it exists) of a function f : A→ B is the function. . .

Cardinality and Functions

• If f : A→ B is 1-1, then |A| |B|.

• If f : A→ B is onto, then |A| |B|.

• If f : A→ B is a bijection, then |A| |B|.

Monotonic Functions

• A function f is said to be increasing if and only if x < y implies that. . .

• A function f is said to be decreasing if and only if x < y implies that. . .

• A function f is said to be strictly increasing if and only if x < y implies that. . .

• A function f is said to be strictly decreasing if and only if x < y implies that. . .

11

Page 12: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Proofs Involving Functions

Example 10. Show that f : R→ R defined by f(x) = −3x+ 4 is a bijection.

Proof.

Q.E.D.

Example 11. Let A be the set of even integers and B be the set of odd integers. Define f : A → B as f(x) = x+ 1.Determine whether f is a bijection.

Proof.

Q.E.D.

12

Page 13: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Compositions of Functions

Definition 11. Given two functions f : B → C and g : A→ B, we define the composition of f and g to be. . .

The ‘Graph’ of a Function

Definition 12. The graph of a function f : A→ B is the set of all ordered pairs (a, b) for which f(a) = b.

One last thing. . .

Definition 13 (Floor and Ceiling Functions).

• bxc

• dxe

Example 12.

13

Page 14: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

2.4 - Sequences and Summations

Sequences

Definition 14 (Sequence). A sequence is a function from some subset of the integers (usually N or Z+) into R. Insteadof writing f(i) for the function value, we instead use subscripts to denote the ith function value and write ai.

Notation: The notation for an infinite sequence looks like

a0, a1, a2, . . .or= {ai}

or= {ai}∞i=0

Note: Although we use braces as our delimiters, a sequence is not the same as a set because the order of a sequencematters! Unless otherwise noted: if the function is defined at 0 then we assume our sequence starts at the index 0; ifthe function is not defined at 0 then we assume the sequence starts at the index 1.

Progessions

Definition 15 (Geometric Progression). A geometric progression is a sequence of the form

a, ar, ar2, . . . , arn, . . .

where a, r ∈ R. a is called the initial term and r is called the common ratio.

Definition 16 (Arithmetic Progression). An arithmetic progression is a sequence of the form

a, a+ d, a+ 2d, . . . , a+ nd, . . .

where a, d ∈ R. a is called the initial term and d is called the common difference.

Example 13. Find the pattern in each of the following:

1. 3, 10, 31, 94, . . .

2. 12 ,

14 ,

18 ,

116 , . . .

3. 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, . . .

Definition 17 (Strings). Finite sequences of the form a1, a2, . . . , an are sometimes viewed and written as strings:

a1a2 . . . an

The empty string is denoted by λ.

14

Page 15: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Summations and Summation Notation

The sum of the first n terms of a sequence {an} is denoted by. . .

Reindexing: Suppose we want to change the starting index of a sum. . .

Theorem 1 (Finite Geometric Series). The sum of a finite geometric series (finite geometric progression) is

n∑i=0

ari =

a− arn+1

1− rif r 6= 1

(n+ 1)a if r = 1

Other Useful Sums

•n∑

k=1

k =n(n+ 1)

2

•∞∑k=0

ark =a

1− rfor |r| < 1

• (See the book for other summation formulae.)

Summation Over Members of a Set

Example 14. Let A = {0, 2, 4}, f :A→ R given by f(i) = ai = 3i. Then∑i∈A

ai =

15

Page 16: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Double Summation3∑

i=1

4∑j=1

(i− j)

Recurrence Relations

Definition 18 (Recurrence Relation). A recurrence relation for the sequence {an} is a recursive definition for the termsof the sequence which expresses an in terms of one or more of the previous terms of the sequence.

Definition 19 (Solution). A solution of a recurrence relation is a sequence whose terms satisfy the recurrence relation.A closed formula solution of a recurrence relation is a non-recursive solution of the recurrence relation.

Definition 20 (Initial Conditions). The initial conditions of a recursively defined sequence specify the terms thatprecede the first terms where the recurrence relation takes effect.

Example 15. Let a0 = 1, an = 3an−1 + 1. Find the first 5 terms in the sequence, and show that an = 3n+1−12 is a

closed formula solution.

16

Page 17: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Example 16. Determine whether the sequences an = 2n and an = n · 4n are solutions of the recurrence relation

an = 8an−1 − 16an−2

The Towers of Hanoi

Suppose we have n disks of different sizes and three pegs, and the disks are stacked on one of the pegs1 in order of sizewith the largest at the bottom of the peg. If we are only allowed to move one disk at a time and cannot put a largerdisk on a smaller one, then how many moves are needed to move the entire tower to a new peg?

1Drill a hole in each disk, if needed.

17

Page 18: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

2.5 - Cardinality

Definition 21. Two sets A and B have the same cardinality if and only if there exists a bijection between them. Whenthis is the case, we write |A|=|B|.

(Note: This definition holds for any sets A and B – not just finite sets.)

Definition 22. If there is a 1-1 function from A to B, then the cardinality of A is less than or equal to the cardinalityof B, and we write |A| ≤ |B|. When |A| ≤ |B| and A and B have different cardinality, then the cardinality of A is lessthan the cardinality of B, and we write |A| < |B|.

Definition 23. A set is countable if it is finite or there exists a bijection between the set and Z+. A set that is notcountable is uncountable. When an infinite set S is countable, we denote the cardinality of S by ℵ0 (read “aleph-null”or “aleph-nought”) and write |S| = ℵ0.

Example

A graphical proof that Q has cardinality ℵ0:

18

Page 19: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

2.6 - Matrices

Definitions

Definition 24 (Matrix, pl. Matrices). A matrix is a rectangular array of numbers. A matrix with m rows and ncolumns is called an m × n (read “m by n”) matrix; if m = n then we say that the matrix is a square matrix. Twomatrices are equal if and only if the corresponding entries in every position are equal.

Example 17.

Notation: The book uses boldface uppercase letters to denote matrices; normal font uppercase letters are typicallyused in handwritten work and also in some textbooks. The book uses brackets as delimiters, but parentheses are alsocommonly used.

Definition 25. Let

A =

a11 a12 . . . a1na21 a22 . . . a2n...

......

am1 am2 . . . amn

The ith row of A is the 1×n row matrix[ai1 ai2 . . . ain

]; the jth column of A is the m× 1 column matrix

a1ja2j...

amj

The ijth element of A is denoted by aij , and we may write A = [aij ].

Matrix Addition

Definition 26. Let A = [aij ] and B = [bij ] both bem×nmatrices. The sum of A and B is the matrix A+B = [aij+bij ].So, we simply add corresponding elements of each matrix.

Note: If the matrices are different sizes, then the sum is undefined!

Example 18. Let A =

[1 2 34 5 6

], B =

[1 0 −12 3 −2

], C =

1 0−1 23 −2

.

19

Page 20: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Matrix Scalar Multiplication

Definition 27. Let A = [aij ] and α ∈ R. ThenαA = [αaij ],

i.e., we multiply each element of the matrix by α.

Example 19. Let α = −2, C =

1 0−1 23 −2

.

Matrix Multiplication

Definition 28. Let A = [aij ] be an m × k matrix and B = [bij ] be a k × n matrix. The product of A and B isAB = [cij ], where

cij = ai1b1j + ai2b2j + · · ·+ aikbkj2

Note: Matrix multiplication is not commutative!

Example 20. Let A =

[1 2 34 5 6

], B =

[1 0 −12 3 −2

], C =

1 0−1 23 −2

.

Definition 29 (Identity). The identity matrix is the n× n matrix In which has 1s on the diagonal and 0s everywhereelse:

In =

1 0 . . . 00 1 . . . 0...

......

0 0 . . . 1

If we multiply a matrix A by an appropriately sized identity matrix, then the product is still A.

2This is the dot product of the ith row of A with the jth column of B.

20

Page 21: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Definition 30 (Inverse). The inverse of a square n× n matrix is the n× n matrix A−1 such that

AA−1 = A−1A = In

For 2× 2 matrices we have the following formula for the inverse:[a bc d

]−1=

1

ad− bc

[d −b−c a

]

Example 21.

Transpose of a Matrix

Definition 31 (Transpose). Let A = [aij ] be an m× n matrix. The transpose of A is the n×m matrix

At = [aji]

This means that the rows of A become the columns of At (this also means that the columns of A become the rows ofAt).

Example 22.

Definition 32 (Symmetric). A matrix A is said to be symmetric if

A = At

Note: If A is symmetric then it must be square.

Example 23.

Zero-One Matrices

A zero-one matrix is one whose entries are all either zeros or ones. We can combine zero-one matrices using Booleanoperations:

• Meet: A ∧B

• Join: A ∨B

• Boolean product: A�B

21

Page 22: Chapter 2 - Basics Structures€¦ · Chapter 2 - Basics Structures 2.1 - Sets De nitions and Notation De nition 1 (Set). A set is an of . These are called the or of the set. •

Powers of a Matrix

If A is a square matrix, then we can define

Ar =

In if r = 0

AA . . .A︸ ︷︷ ︸r times

if r ∈ Z+

If A is a square zero-one matrix, then we can define the rth Boolean power of A as

A[r] =

In if r = 0

A�A� · · · �A︸ ︷︷ ︸r times

if r ∈ Z+

Example 24.

A =

1 0 11 1 00 0 1

22