Basic Structures: Sets, Functions, Sequences, Sums, and Matrices

Sets

  • Sets are fundamental building blocks in discrete mathematics, crucial for counting and implemented in programming languages through set operations.

  • Set theory is a significant branch of mathematics with various axiomatic systems, employing a naïve approach in this context.

Definition

  • A set is an unordered collection of objects, referred to as elements or members.

  • Notation:

    • aAa ∈ A denotes that aa is an element of set AA.

    • aAa \notin A indicates aa is not a member of AA.

Describing Sets

Roster Method
  • Listing elements within braces: e.g., S=a,b,c,dS = {a, b, c, d}.

  • Order is not important: a,b,c,d=b,c,a,d{a, b, c, d} = {b, c, a, d}.

  • Duplicate elements do not change the set: a,b,c,d=a,b,c,b,c,d{a, b, c, d} = {a, b, c, b, c, d}.

  • Ellipses can represent clear patterns: S=a,b,c,d,,zS = {a, b, c, d, …, z}.

Examples
  • Vowels: V=a,e,i,o,uV = {a, e, i, o, u}.

  • Odd positive integers less than 10: O=1,3,5,7,9O = {1, 3, 5, 7, 9}.

  • Positive integers less than 100: S=1,2,3,,99S = {1, 2, 3, …, 99}.

  • Integers less than 0: S=,3,2,1S = {…, -3, -2, -1}.

Important Sets

  • N\mathbb{N} = Natural numbers = 0,1,2,3,{0, 1, 2, 3, …}

  • Z\mathbb{Z} = Integers = ,3,2,1,0,1,2,3,{…, -3, -2, -1, 0, 1, 2, 3, …}

  • Z+\mathbb{Z^+} = Positive integers = 1,2,3,{1, 2, 3, …}

  • R\mathbb{R} = Real numbers

  • R+\mathbb{R^+} = Positive real numbers

  • C\mathbb{C} = Complex numbers

  • Q\mathbb{Q} = Rational numbers

Set-Builder Notation

  • Specifies properties members must satisfy:

    • S=xx is a positive integer less than 100S = {x | x \text{ is a positive integer less than 100} }

    • O=xx is an odd positive integer less than 10O = {x | x \text{ is an odd positive integer less than 10} }

    • O = {x ∈ \mathbb{Z^+} | x \text{ is odd and } x < 10}

  • Using a predicate: S=xP(x)S = {x | P(x)} (e.g., xPrime(x){x | Prime(x)}).

  • Positive rational numbers: Q+=xRx=p/q, for some positive integers p,q\mathbb{Q^+} = {x ∈ \mathbb{R} | x = p/q, \text{ for some positive integers } p, q}

Interval Notation

  • Closed interval: [a,b]=xaxb[a, b] = {x | a ≤ x ≤ b}

  • Half-open interval: [a, b) = {x | a ≤ x < b}

  • Half-open interval: (a, b] = {x | a < x ≤ b}

  • Open interval: (a, b) = {x | a < x < b}

Universal and Empty Sets

  • Universal set UU contains everything under consideration, either implicit or explicitly stated, depending on context.

  • Empty set contains no elements, also represented as {}.

Russell’s Paradox

  • If SS is the set of all sets not members of themselves, the question "Is SS a member of itself?" leads to a paradox.

  • Related to the barber paradox: Henry shaves all who don't shave themselves. Does Henry shave himself?

Key Reminders

  • Sets can contain sets: 1,2,3,a,b,c{{1, 2, 3}, a, {b, c}}, N,Z,Q,R{N, Z, Q, R}.

  • Empty set vs. set containing the empty set: ∅ ≠ {∅}.

Set Equality

  • Two sets are equal if they contain the same elements: A=Bx(xAxB)A = B ↔ ∀x(x ∈ A ↔ x ∈ B).

  • Examples: 1,3,5=3,5,1{1, 3, 5} = {3, 5, 1}, 1,5,5,5,3,3,1=1,3,5{1, 5, 5, 5, 3, 3, 1} = {1, 3, 5}.

Subsets

  • Set AA is a subset of BB if every element of AA is also in BB: ABx(xAxB)A ⊆ B ↔ ∀x(x ∈ A → x ∈ B).

  • S∅ ⊆ S for every set SS.

  • SSS ⊆ S for every set SS.

Showing Subsets

  • To prove ABA ⊆ B, show if xAx ∈ A, then xBx ∈ B.

  • To prove ABA \nsubseteq B, find an xAx ∈ A such that xBx \notin B.

Equality of Sets Revisited

  • A=BA = B if and only if x(xAxB)\forall x (x \in A \leftrightarrow x \in B).

  • Equivalently, A=BA = B if and only if ABA ⊆ B and BAB ⊆ A.

Proper Subsets

  • If ABA ⊆ B but ABA ≠ B, then AA is a proper subset of BB, denoted by ABA ⊂ B.

  • ABA ⊂ B if and only if x(xAxB)x(xBxA)\forall x (x \in A \rightarrow x \in B) \land \exists x (x \in B \land x \notin A).

Set Cardinality

  • If SS has exactly nn distinct elements, it is finite. Otherwise, it is infinite.

  • Cardinality of a finite set AA, denoted by A|A|, is the number of distinct elements in AA.

  • Examples: =0|∅| = 0, alphabet S=26|S| = 26, 1,2,3=3|{1, 2, 3}| = 3, =1|{∅}| = 1.

Power Sets

  • Power set P(A)P(A) is the set of all subsets of AA.

  • Example: If A=a,bA = {a, b}, then P(A)=,a,b,a,bP(A) = {∅, {a}, {b}, {a, b}}.

  • If A=n|A| = n, then P(A)=2n|P(A)| = 2^n.

Tuples

  • Ordered nn-tuple (a<em>1,a</em>2,,an)(a<em>1, a</em>2, …, a_n) is an ordered collection.

  • Two nn-tuples are equal if corresponding elements are equal.

  • 2-tuples are ordered pairs: (a,b)=(c,d)(a, b) = (c, d) if and only if a=ca = c and b=db = d.

Cartesian Product

  • Cartesian product of AA and BB is A×B=(a,b)aA and bBA × B = {(a, b) | a ∈ A \text{ and } b ∈ B}.

  • Example: If A=a,bA = {a, b} and B=1,2,3B = {1, 2, 3}, then A×B=(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)A × B = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}.

  • A relation from AA to BB is a subset of A×BA × B.

Cartesian Product of Multiple Sets

  • A<em>1×A</em>2××A<em>n=(a</em>1,a<em>2,,a</em>n)a<em>iA</em>i for i=1,,nA<em>1 × A</em>2 × … × A<em>n = {(a</em>1, a<em>2, …, a</em>n) | a<em>i ∈ A</em>i \text{ for } i = 1, …, n}.

  • Example: If A=0,1A = {0, 1}, B=1,2B = {1, 2}, C=0,1,2C = {0, 1, 2}, then 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)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

  • Truth set of predicate P(x)P(x) over domain DD is the set of elements in DD for which P(x)P(x) is true.

  • Example: If P(x)P(x) is x=1|x| = 1 and the domain is integers, the truth set is 1,1{-1, 1}.

Set Operations

  • Set operations include union, intersection, complementation, and difference.

Boolean Algebra

  • Both propositional calculus and set theory are instances of Boolean Algebra.

  • Set theory operators are analogous to propositional calculus operators within a universal set UU.

Union

  • The union of sets AA and BB, denoted by ABA ∪ B, is xxA or xB{x | x ∈ A \text{ or } x ∈ B}.

  • Example: 1,2,33,4,5=1,2,3,4,5{1, 2, 3} ∪ {3, 4, 5} = {1, 2, 3, 4, 5}.

Intersection

  • The intersection of sets AA and BB, denoted by ABA ∩ B, is xxA and xB{x | x ∈ A \text{ and } x ∈ B}.

  • If the intersection is empty, AA and BB are disjoint.

  • Example: 1,2,33,4,5=3{1, 2, 3} ∩ {3, 4, 5} = {3}, 1,2,34,5,6={1, 2, 3} ∩ {4, 5, 6} = ∅.

Complement

  • The complement of set AA, denoted by A\overline{A}, is xUxA{x ∈ U | x \notin A}.

  • Example: If UU is positive integers less than 100, then the complement of {x | x > 70} is xx70{x | x ≤ 70}.

Difference

  • The difference of AA and BB, denoted by ABA – B, is xxA and xB=AB{x | x ∈ A \text{ and } x \notin B} = A ∩ \overline{B}.

Cardinality of Union

  • Inclusion-Exclusion Principle: AB=A+BAB|A ∪ B| = |A| + |B| - |A ∩ B|.

  • To count students in math or CS, add math majors and CS majors, then subtract joint majors.

Review Questions

  • Given U=0,1,2,3,4,5,6,7,8,9,10U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, A=1,2,3,4,5A = {1, 2, 3, 4, 5}, B=4,5,6,7,8B = {4, 5, 6, 7, 8}:

    • AB=1,2,3,4,5,6,7,8A ∪ B = {1, 2, 3, 4, 5, 6, 7, 8}

    • AB=4,5A ∩ B = {4, 5}

    • A=0,6,7,8,9,10\overline{A} = {0, 6, 7, 8, 9, 10}

    • B=0,1,2,3,9,10\overline{B} = {0, 1, 2, 3, 9, 10}

    • AB=1,2,3A – B = {1, 2, 3}

    • BA=6,7,8B – A = {6, 7, 8}

Symmetric Difference (Optional)

  • The symmetric difference of AA and BB, denoted by ABA \oplus B, is (AB)(BA)(A - B) ∪ (B - A).

  • Example: With the same AA and BB as above, AB=1,2,3,6,7,8A \oplus B = {1, 2, 3, 6, 7, 8}.

Set Identities

  • Identity laws, domination laws, idempotent laws, complementation law, commutative laws, associative laws, distributive laws, De Morgan's laws, absorption laws, complement laws.

  • Examples:

    • A=AA \cup \emptyset = A (Identity Law)

    • AU=AA \cap U = A (Identity Law)

    • AU=UA \cup U = U (Domination Law)

    • A=A \cap \emptyset = \emptyset (Domination Law)

    • AA=AA \cup A = A (Idempotent Law)

    • AA=AA \cap A = A (Idempotent Law)

    • (A)=A\overline{(\overline{A})} = A (Complementation Law)

    • AB=BAA \cup B = B \cup A (Commutative Law)

    • AB=BAA \cap B = B \cap A (Commutative Law)

    • A(BC)=(AB)CA \cup (B \cup C) = (A \cup B) \cup C (Associative Law)

    • A(BC)=(AB)CA \cap (B \cap C) = (A \cap B) \cap C (Associative Law)

    • A(BC)=(AB)(AC)A \cup (B \cap C) = (A \cup B) \cap (A \cup C) (Distributive Law)

    • A(BC)=(AB)(AC)A \cap (B \cup C) = (A \cap B) \cup (A \cap C) (Distributive Law)

    • AB=AB\overline{A \cup B} = \overline{A} \cap \overline{B} (De Morgan's Law)

    • AB=AB\overline{A \cap B} = \overline{A} \cup \overline{B} (De Morgan's Law)

    • A(AB)=AA \cup (A \cap B) = A (Absorption Law)

    • A(AB)=AA \cap (A \cup B) = A (Absorption Law)

    • AA=UA \cup \overline{A} = U (Complement Law)

    • AA=A \cap \overline{A} = \emptyset (Complement Law)

Proving Set Identities

  • Methods: Prove each side is a subset of the other, use set-builder notation and propositional logic, or use membership tables.

Proof of De Morgan's Law

  • To prove AB=AB\overline{A \cap B} = \overline{A} \cup \overline{B}, show that ABAB\overline{A \cap B} \subseteq \overline{A} \cup \overline{B} and ABAB\overline{A} \cup \overline{B} \subseteq \overline{A \cap B}.

Set-Builder Notation Example: Second De Morgan Law

  • AB=xxAB=x¬(xAB)=x¬(xAxB)=x¬(xA)¬(xB)=xxAxB=xxAB=AB\overline{A \cap B} = {x | x \notin A \cap B} = {x | \neg (x \in A \cap B)} = {x | \neg (x \in A \land x \in B)} = {x | \neg (x \in A) \lor \neg (x \in B)} = {x | x \notin A \lor x \notin B} = {x | x \in \overline{A} \cup \overline{B}} = \overline{A} \cup \overline{B}.

Membership Tables

  • Use 1 to indicate membership, 0 to indicate non-membership. Useful to verify identities.

Generalized Unions and Intersections

  • For indexed collection of sets A<em>1,A</em>2,,AnA<em>1, A</em>2, …, A_n:

    • <em>i=1nA</em>i=A<em>1A</em>2An\bigcup<em>{i=1}^{n} A</em>i = A<em>1 \cup A</em>2 \cup … \cup A_n

    • <em>i=1nA</em>i=A<em>1A</em>2An\bigcap<em>{i=1}^{n} A</em>i = A<em>1 \cap A</em>2 \cap … \cap A_n

  • For A<em>i=i,i+1,i+2,A<em>i = {i, i+1, i+2, …}, </em>i=1A<em>i=1,2,3,\bigcup</em>{i=1}^{\infty} A<em>i = {1, 2, 3, …} and </em>i=1Ai=\bigcap</em>{i=1}^{\infty} A_i = \emptyset.

Functions

  • A function f:ABf: A → B assigns each element of AA to exactly one element of BB. If f(a)=bf(a) = b, bb is the image of aa and aa is the preimage of bb.

Terminology

  • ff maps AA to BB.

  • AA is the domain, BB is the codomain.

  • The range of ff is the set of all images of points in AA, denoted by f(A)f(A).

  • Two functions are equal if they have the same domain, codomain, and mapping.

Representing Functions

  • Explicit statement, formula, computer program.

  • Examples: f(x)=x+1f(x) = x + 1, a program to generate Fibonacci numbers.

Questions on Functions

  • Given f:ABf: A → B where A=a,b,c,dA = {a, b, c, d} and B=x,y,zB = {x, y, z} with assignments.

Functions and Sets

  • If f:ABf: A → B and SAS ⊆ A, then f(S)=f(s)sSf(S) = {f(s) | s \in S}.

Injections (One-to-One)

  • A function ff is injective if f(a)=f(b)f(a) = f(b) implies a=ba = b for all a,ba, b in the domain of ff.

Surjections (Onto)

  • A function f:ABf: A → B is surjective if for every element bb in BB, there is an element aa in AA with f(a)=bf(a) = b.

Bijections

  • A function is a bijection if it is both injective (one-to-one) and surjective (onto).

Showing Injective and Surjective Properties

  • To show ff is injective, prove if f(x)=f(y)f(x) = f(y) then x=yx = y.

  • To show ff is not injective, find xyx ≠ y such that f(x)=f(y)f(x) = f(y).

  • To show ff is surjective, find an xx in AA for arbitrary yy in BB such that f(x)=yf(x) = y.

  • To show ff is not surjective, find a yy in BB such that f(x)yf(x) ≠ y for all xx in AA.

Inverse Functions

  • If ff is a bijection from AA to BB, the inverse of ff, denoted f1f^{-1}, is the function from BB to AA such that f1(b)=af^{-1}(b) = a when f(a)=bf(a) = b.

  • Inverses only exist for bijections.

Composition

  • Let f:BCf: B → C and g:ABg: A → B.

  • The composition of ff with gg, denoted fgf ∘ g, is the function from AA to CC defined by (fg)(a)=f(g(a))(f ∘ g)(a) = f(g(a)).

Graphs of Functions

  • The graph of f:ABf: A → B is the set of ordered pairs (a,baA and f(a)=b)({a, b} | a ∈ A \text{ and } f(a) = b).

Important Functions

  • Floor function: x\lfloor x \rfloor is the largest integer less than or equal to xx.

  • Ceiling function: x\lceil x \rceil is the smallest integer greater than or equal to xx.

Properties of Floor and Ceiling Functions

  • (1a) x=n\lfloor x \rfloor = n if and only if n ≤ x < n + 1

Factorial Function

  • f:NZ+f: N → Z^+, f(n)=n!=12(n1)nf(n) = n! = 1 ∙ 2 ∙ … ∙ (n – 1) ∙ n, f(0)=0!=1f(0) = 0! = 1.

Partial Functions (Optional)

  • A partial function ff from AA to BB assigns each element in a subset of AA to a unique element in BB.

  • The subset of AA is the domain of definition.

  • If the domain of definition is AA, ff is a total function.

Sequences and Summations

  • Sequences are ordered lists of elements that appear throughout mathematics and computer science.

Sequences Definition

  • A sequence is a function from a subset of integers to a set SS.

  • The notation ana_n denotes the image of the integer nn.

Geometric Progression

  • A sequence of the form a,ar,ar2,ar3,,arn{a, ar, ar^2, ar^3, …, ar^n}, where aa is the initial term and rr is the common ratio.

Arithmetic Progression

  • A sequence of the form a,a+d,a+2d,a+3d,,a+nd{a, a+d, a+2d, a+3d, …, a+nd}, where aa is the initial term and dd is the common difference.

Strings

  • A finite sequence of characters from a finite set (alphabet).

  • The empty string is represented by λλ.

Recurrence Relations

  • An equation that expresses a<em>na<em>n in terms of previous terms a</em>0,a<em>1,,a</em>n1a</em>0, a<em>1, …, a</em>{n-1} for nn0n ≥ n_0.

  • Initial conditions specify terms preceding the first term.

Fibonacci Sequence

  • Initial Conditions: f<em>0=0f<em>0 = 0, f</em>1=1f</em>1 = 1. Recurrence Relation: f<em>n=f</em>n1+fn2f<em>n = f</em>{n-1} + f_{n-2}.

Solving Recurrence Relations

  • Finding a formula for the nnth term is called solving the recurrence relation; such a formula is called a closed formula.

Useful Sequences

  • Examples: n2,n3,n4,2n,3n,n!,fnn^2, n^3, n^4, 2^n, 3^n, n!, f_n

Summations

  • The sum of terms from a sequence is represented using summation notation.

  • <em>j=mna</em>j=a<em>m+a</em>m+1++an\sum<em>{j=m}^{n} a</em>j = a<em>m + a</em>{m+1} + … + a_n

Product Notation (Optional)

  • <em>j=mna</em>j=a<em>ma</em>m+1an\prod<em>{j=m}^{n} a</em>j = a<em>m * a</em>{m+1} * … * a_n

Useful Summation Formulas

  • Geometric Series, etc.

Matrices

  • Matrices are rectangular arrays of numbers used in linear transformations, graph representations, and models of various systems.

Definition

  • An m×nm × n matrix has mm rows and nn columns.

  • A square matrix has the same number of rows and columns.

  • Two matrices are equal if they have the same dimensions and corresponding entries are equal.

Notation

  • A=[a<em>ij]A = [a<em>{ij}], where a</em>ija</em>{ij} is the element in the iith row and jjth column.

Matrix Arithmetic: Addition

  • A+B=[a<em>ij+b</em>ij]A + B = [a<em>{ij} + b</em>{ij}] for m×nm × n matrices AA and BB. Matrices must have the same dimensions to be added.

Matrix Multiplication

  • If AA is an m×km × k matrix and BB is a k×nk × n matrix, then AB=[c<em>ij]AB = [c<em>{ij}] is an m×nm × n matrix with c</em>ij=<em>r=1ka</em>irbrjc</em>{ij} = \sum<em>{r=1}^{k} a</em>{ir}b_{rj}.

  • The product is undefined if the number of columns in the first matrix doesn't match the number of rows in the second matrix.

Identity Matrix and Powers of Matrices

  • The identity matrix of order nn is I<em>n=[δ</em>ij]I<em>n = [δ</em>{ij}], where δ<em>ij=1δ<em>{ij} = 1 if i=ji = j and δ</em>ij=0δ</em>{ij} = 0 if iji ≠ j.

  • AI<em>n=I</em>mA=AAI<em>n = I</em>mA = A when AA is an m×nm × n matrix.

  • A0=InA^0 = I_n, Ar=AAAAA^r = AAA…A (rr times) for a square matrix AA.

Transposes of Matrices

  • The transpose of A=[a<em>ij]A = [a<em>{ij}] is At=[b</em>ij]A^t = [b</em>{ij}] where b<em>ij=a</em>jib<em>{ij} = a</em>{ji}.

Symmetric Matrices

  • A square matrix AA is symmetric if A=AtA = A^t, i.e., a<em>ij=a</em>jia<em>{ij} = a</em>{ji}.

Zero-One Matrices

  • Matrices with entries either 0 or 1, used in Boolean arithmetic.

Joins and Meets

  • The join of AA and BB is AB=[a<em>ijb</em>ij]A ∨ B = [a<em>{ij} ∨ b</em>{ij}]

  • The meet of AA and BB is AB=[a<em>ijb</em>ij]A ∧ B = [a<em>{ij} ∧ b</em>{ij}].

Boolean Product

  • For m×km × k matrix AA and k×nk × n matrix BB, the Boolean product AB=[c<em>ij]A ⊙ B = [c<em>{ij}] has cij=(a</em>i1b<em>1j)(a</em>i2b<em>2j)(a</em>ikbkj)\text{cij} = (a</em>{i1} ∧ b<em>{1j}) ∨ (a</em>{i2} ∧ b<em>{2j}) ∨ … ∨ (a</em>{ik} ∧ b_{kj}).

Boolean Powers

  • A[r]A^{[r]} is the Boolean product of rr factors of AA; A[0]=In\text{A}^{[0]} = I_n.