Chapter2 - Basic Structures Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices - Chapter 2
Chapter Summary
- Sets
- The Language of Sets
- Set Operations
- Set Identities
- Functions
- Types of Functions
- Operations on Functions
- Computability
- Sequences and Summations
- Types of Sequences
- Summation Formulae
- Set Cardinality
- Countable Sets
- Matrices
- Matrix Arithmetic
Sets - Section 2.1
Section Summary
- Definition of sets
- Describing Sets
- Roster Method
- Set-Builder Notation
- Some Important Sets in Mathematics
- Empty Set and Universal Set
- Subsets and Set Equality
- Cardinality of Sets
- Tuples
- Cartesian Product
Introduction
- Sets are basic building blocks for objects in discrete mathematics.
- Important for counting.
- Programming languages have set operations.
- Set theory is an important branch of mathematics.
- Many different systems of axioms are used to develop set theory.
- Using "naïve set theory" instead of formal axioms.
Sets
- A set is an unordered collection of objects.
- Examples:
- Students in this class
- Chairs in this room
- Objects in a set are called elements or members.
- A set is said to contain its elements.
- Notation:
- a∈A denotes that a is an element of set A.
- a∈/A denotes that a is not a member of set A.
Describing a Set: Roster Method
- S=a,b,c,d
- Order is 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
- Ellipses (…) may be used to describe a set without listing all members when the pattern is clear: S=a,b,c,d,……,z
Roster Method Examples
- 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 ∈ \mathbb{Z^+} | x \text{ 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 (closed interval)
- [a,b) = {x | a ≤ x < b}
- (a,b] = {x | a < x ≤ b}
- (a,b) = {x | a < x < b} (open interval)
Universal Set and Empty Set
- The universal set U is the set containing everything currently under consideration.
- Sometimes implicit.
- Sometimes explicitly stated.
- Contents depend on the context.
- The empty set is the set with no elements. Symbolized ∅, but also used.
- Venn Diagram illustrates sets within the Universal set.
Russell’s Paradox
- Let S be the set of all sets which are not members of themselves. A paradox results from trying to answer the question “Is S a member of itself?”
- Related Paradox:
- Henry is a barber who shaves all people who do not shave themselves. A paradox results from trying to answer the question “Does Henry shave himself?”
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 every element of A is an element of B and every element of B is an element of A.
- 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 and only if ∀x(x∈A→x∈B) is true.
- Because a∈∅ is always false, ∅⊆S, for every set S.
- 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:
- The set of all computer science majors at your school is a subset of all students at your school.
- The set of integers with squares less than 100 is not a subset of the set of nonnegative integers.
Another Look at Equality of Sets
- Recall that two sets A and B are equal, denoted by A=B, iff ∀x(x∈A↔x∈B).
- Using logical equivalences we have that A=B iff ∀x[(x∈A→x∈B)∧(x∈B→x∈A)].
- 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 ∀x(x∈A→x∈B)∧∃x(x∈B∧x∈/A) is true.
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:
- ∣∅∣=0
- Let S be the letters of the English alphabet. Then ∣S∣=26
- ∣1,2,3∣=3
- ∣∅∣=1
- 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 2n.
Tuples
- The ordered n-tuple (a<em>1,a</em>2,…..,a<em>n) is the ordered collection that has a</em>1 as its first element and a<em>2 as its second element and so on until a</em>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.
Cartesian Product
- Definition: The Cartesian Product of two 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)
- Definition: A subset R of the Cartesian product A×B is called a relation from the set A to the set B.
Cartesian Product of n Sets
- Definition: The cartesian products of the sets A<em>1,A</em>2,……,A<em>n, denoted by A</em>1×A<em>2×……×A</em>n, is the set of ordered n-tuples (a<em>1,a</em>2,……,a<em>n) where a</em>i belongs to Ai 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,2,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 x∈D∣P(x)
- Example: The truth set of P(x) where the domain is the integers and P(x) is “∣x∣=1” is the set −1,1
Set Operations - Section 2.2
Section Summary
- Set Operations
- Union
- Intersection
- Complementation
- Difference
- More on Set Cardinality
- Set Identities
- Proving Identities
- Membership Tables
Boolean Algebra
- Propositional calculus and set theory are both instances of an algebraic system called a Boolean Algebra. This is discussed in Chapter 12.
- The operators in set theory are analogous to the corresponding operator in propositional calculus.
- As always there must be a universal set U. All sets are assumed to be subsets of U.
Union
- Definition: Let A and B be sets. The union of the sets A and B, denoted by A∪B, is the set: A∪B=x∣x∈A∨x∈B
- Example: What is 1,2,3∪3,4,5?
- Solution: 1,2,3,4,5
Intersection
- Definition: The intersection of sets A and B, denoted by A∩B, is A∩B=x∣x∈A∧x∈B
- 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 ?
- Solution : ∅
Complement
- Definition: If A is a set, then the complement of the A (with respect to U), denoted by Aˉ is the set Aˉ=x∈U∣x∈/A
- (The complement of A is sometimes denoted by Ac .)
- Example: If U is the positive integers less than 100, what is the complement of {x | x > 70}
- Solution: x∣x≤70
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ˉ
The Cardinality of the Union of Two Sets
- Inclusion-Exclusion: ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣
- Example: Let A be the math majors in your class and B be the CS majors. To count the number of students who are either math majors or CS majors, add the number of math majors and the number of CS majors, and subtract the number of joint CS/math majors.
- We will return to this principle in Chapter 6 and Chapter 8 where we will derive a formula for the cardinality of the union of n sets, where n is a positive integer.
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
- A∪B
- Solution: 1,2,3,4,5,6,7,8
- A∩B
- Aˉ
- Solution: 0,6,7,8,9,10
- Bˉ
- Solution: 0,1,2,3,9,10
- A–B
- Solution: 1,2,3
- B–A
- Solution: 6,7,8
Symmetric Difference (optional)
- Definition: The symmetric difference of A and B, denoted by A⊕B, is the set A⊕B=(A−B)∪(B−A)
- 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
- What is A⊕B:
- Solution: 1,2,3,6,7,8
Set Identities
- Identity laws:
- A∪∅=A
- A∩U=A
- Domination laws:
- A∪U=U
- A∩∅=∅
- Idempotent laws:
- A∪A=A
- A∩A=A
- Complementation law:
- Aˉˉ=A
- Commutative laws:
- A∪B=B∪A
- A∩B=B∩A
- Associative laws:
- A∪(B∪C)=(A∪B)∪C
- A∩(B∩C)=(A∩B)∩C
- Distributive laws:
- A∪(A∩B)=A
- A∩(A∪B)=A
- De Morgan's laws:
- A∪B=Aˉ∩Bˉ
- A∩B=Aˉ∪Bˉ
- Absorption laws:
- A∪(A∩B)=A
- A∩(A∪B)=A
- Complement laws:
- A∪A=U
- A∩A=∅
Proving Set Identities
- Different ways to prove set identities:
- Prove that each set (side of the identity) is a subset of the other.
- Use set builder notation and propositional logic.
- Membership Tables: Verify that elements in the same combination of sets always either belong or do not belong to the same side of the identity. Use 1 to indicate it is in the set and a 0 to indicate that it is not.
Proof of Second De Morgan Law Example
- Example: Prove that A∩B=Aˉ∪Bˉ
- Solution: We prove this identity by showing that:
- A∩B⊆Aˉ∪Bˉ
- Aˉ∪Bˉ⊆A∩B
Proof of Second De Morgan Law Steps
- These steps show that: A∩B⊆Aˉ∪Bˉ
- x∈A∩B - by assumption
- x∈/A∩B - defn. of complement
- ¬((x∈A)∧(x∈B)) - defn. of intersection
- ¬(x∈A)∨¬(x∈B) - 1st De Morgan Law for Prop Logic
- x∈/A∨x∈/B - defn. of negation
- x∈Aˉ∨x∈Bˉ - defn. of complement
- x∈Aˉ∪Bˉ - defn. of union
- These steps show that: Aˉ∪Bˉ⊆A∩B
- x∈Aˉ∪Bˉ - by assumption
- (x∈Aˉ)∨(x∈Bˉ) - defn. of union
- (x∈/A)∨(x∈/B) - defn. of complement
- ¬(x∈A)∨¬(x∈B) - defn. of negation
- ¬((x∈A)∧(x∈B)) - by 1st De Morgan Law for Prop Logic
- ¬(x∈A∩B) - defn. of intersection
- x∈/A∩B - defn. of complement
Set-Builder Notation: Second De Morgan Law
- A∩B=x∣x∈/A∩B
- =x∣¬(x∈(A∩B))
- =x∣¬(x∈A∧x∈B)
- =x∣¬(x∈A)∨¬(x∈B)
- =x∣x∈/A∨x∈/B
- =x∣x∈Aˉ∨x∈Bˉ
- =x∣x∈Aˉ∪Bˉ=Aˉ∪Bˉ
Membership Table
- Construct a membership table to show that the distributive law holds.
| A | B | C | B ∪ C | A ∩ (B ∪ C) | A ∩ B | A ∩ C | (A ∩ B) ∪ (A ∩ C) |
|---|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Generalized Unions and Intersections
- Let A<em>1,A</em>2,…,An be an indexed collection of sets. We define:
- ⋃<em>i=1nA</em>i=A<em>1∪A</em>2∪…∪An
- ⋂<em>i=1nA</em>i=A<em>1∩A</em>2∩…∩An
- These are well defined, since union and intersection are associative.
- For i=1,2,…,, let Ai=i,i+1,i+2,….. Then,
- ⋃<em>i=1∞A</em>i=1,2,3,….
- ⋂<em>i=1∞A</em>i=∅
Functions - Section 2.3
Section Summary
- Definition of a Function.
- Domain, Codomain
- Image, Preimage
- Injection, Surjection, Bijection
- Inverse Function
- Function Composition
- Graphing Functions
- Floor, Ceiling, Factorial
- Partial Functions (optional)
Functions Definition
- Definition: Let A and B be nonempty sets. A function f 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 transformations.
Functions as Relations
- A function f:A→B can also be defined as a subset of A×B (a relation). This subset is restricted to be a relation where no two elements of the relation have the same first element.
- Specifically, a function f from A to B contains one, and only one ordered pair (a,b) for every element a∈A.
- ∀a∈A∃b∈B((a,b)∈f)
- ∀a∈A∀b∈B∀c∈B(((a,b)∈f)∧((a,c)∈f)→b=c)
Functions Terminology
- 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).
- Two functions are equal when they have the same domain, 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
- The image of d is ? - z
- The domain of f is ? - A
- The codomain of f is ? - B
- The preimage of y is ? - b
- f(A)=? - {y,z}
- The preimage(s) of z is (are) ? - {a,c,d}
Question on Functions and Sets
- If f:A→B and S is a subset of A, then f(S)=f(s)∣s∈S
- f(c,d) is ? - {z}
- f(a,b,c,) is ? - {y,z}
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.
Surjections
- Definition: A function f from A to B is called onto or surjective, if and only if for every element b∈B there is an element a∈A with f(a)=b. A function f is called a surjection if it is onto.
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).
Showing that f is one-to-one or onto
- Suppose that f:A→B.
- To show that f is injective Show that if f(x)=f(y) for arbitrary x,y∈A with x=y, then x=y.
- To show that f is not injective Find particular elements x,y∈A such that x=y and f(x)=f(y).
- To show that f is surjective Consider an arbitrary element y∈B and find an element x∈A such that f(x)=y.
- To show that f is not surjective Find a particular y∈B such that f(x)=y for all x∈A.
Showing that f is one-to-one or onto Examples
- 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.
- Example 2: Is the function f(x)=x2 from the set of integers to the set of integers onto?
- Solution: No, f is not onto because there is no integer x with x2=−1, for example.
Inverse Functions
- Definition: Let f be a bijection from A to B. Then the inverse of f, denoted f−1, is the function from B to A defined as f−1(b)=a when f(a)=b.
- No inverse exists unless f is a bijection. Why?
Inverse Functions Examples
Questions on Inverse Functions
- Example 1: Let f be the function from a,b,c to 1,2,3 such that f(a)=2, f(b)=3, and f(c)=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 given by f, so f−1(1)=c, f−1(2)=a, and f−1(3)=b.
- 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−1(y)=y–1.
- Example 3: Let f:R→R be such that f(x)=x2. Is f invertible, and if so, what is its inverse?
- Solution: The function f is not invertible because it is not one-to-one .
Composition
- Definition: Let f:B→C, g:A→B. The composition of $$f