Model systems with tools from discrete mathematics and reason about implications of modelling choices. Explore applications in CS through multiple perspectives, including software, hardware, and theory.
Defining important sets of numbers, e.g. set of integers, set of rational numbers
Defining functions using multiple representations
Determining whether a given function is one-to-one, onto, and/or invertible
Using functions to compare cardinality of sets
Clearly and unambiguously communicate computational ideas using appropriate formalism. Translate across levels of abstraction.
Using appropriate signpost words to improve readability of proofs, including ‘arbitrary’ and ‘assume’
Know, select and apply appropriate computing knowledge and problem-solving techniques. Reason about computation and systems. Use mathematical techniques to solve problems. Determine appropriate conceptual tools to apply to new situations. Know when tools do not apply and try different approaches. Critically analyze and evaluate candidate solutions.
Determining what evidence is required to establish that a quantified statement is true or false
Evaluating quantified statements about finite and infinite domains
Apply proof strategies, including direct proofs and proofs by contradiction, and determine whether a proposed argument is valid or not.
Identifying the proof strategies used in a given proof
Identifying which proof strategies are applicable to prove a given compound proposition based on its logical structure
Carrying out a given proof strategy to prove a given statement
Tracing and/or modifying a proof by contradiction
Using proofs as knowledge discovery tools to decide whether a statement is true or false
Review quiz based on Week 6 class material (due Monday)
No class Wednesday of Week 7 in observance of UCSD holiday.
Midquarter feedback: please let us know what’s working well for you and what isn’t. https://canvas.ucsd.edu/courses/71479/quizzes
For a set of numbers \(X\), how do you formalize “there is a greatest \(X\)” or “there is a least \(X\)”?
Prove or disprove: There is a least prime number.
Prove or disprove: There is a greatest integer.
Approach 1, De Morgan’s and universal generalization:
Approach 2, proof by contradiction:
Extra examples: Prove or disprove that \(\mathbb{N}\), \(\mathbb{Q}\) each have a least and a greatest element.
Definition: Greatest common divisor Let \(a\) and \(b\) be integers, not both zero. The largest integer \(d\) such that \(d\) is a factor of \(a\) and \(d\) is a factor of \(b\) is called the greatest common divisor of \(a\) and \(b\) and is denoted by \(gcd(~(a, b)~)\).
Why do we restrict to the situation where \(a\) and \(b\) are not both zero?
Calculate \(gcd(~(10,15)~)\)
Calculate \(gcd(~(10,20)~)\)
Claim: For any integers \(a,b\) (not both zero), \(gcd(~(a,b)~) \geq 1\).
Proof: Show that \(1\) is a common factor of any two integers, so since the gcd is the greatest common factor it is greater than or equal to any common factor.
Claim: For any positive integers \(a,b\), \(gcd(~(a,b)~) \leq a\) and \(gcd( ~(a,b)~) \leq b\).
Proof Using the definition of gcd and the fact that factors of a positive integer are less than or equal to that integer.
Claim: For any positive integers \(a,b\), if \(a\) divides \(b\) then \(gcd(~(a,b)~) = a\).
Proof Using previous claim and definition of gcd.
Claim: For any positive integers \(a,b,c\), if there is some integer \(q\) such that \(a = bq + c\), \[gcd(~(a,b)~) = gcd (~(b,c)~)\] Proof Prove that any common divisor of \(a,b\) divides \(c\) and that any common divisor of \(b,c\) divides \(a\).
Lemma: For any integers \(p, q\) (not both zero), \(gcd \left(~ \left(~\frac{p}{gcd(~(p,q)~)}, \frac{q}{gcd(~(p,q)~)} ~\right) ~\right) = 1\) . In other words, can reduce to relatively prime integers by dividing by gcd.
Proof:
Let \(x\) be arbitrary positive integer and assume that \(x\) is a factor of each of \(\frac{p}{gcd(~(p,q)~)}\) and \(\frac{q}{gcd(~(p,q)~)}\). This gives integers \(\alpha\), \(\beta\) such that \[\alpha x = \frac{p}{gcd(~(p,q)~)} \qquad \qquad \beta x = \frac{q}{gcd(~(p,q)~)}\] Multiplying both sides by the denominator in the RHS: \[\alpha x \cdot gcd(~(p,q)~)= p \qquad \qquad \beta x \cdot gcd(~(p,q)~)= q\] In other words, \(x \cdot gcd(~(p,q)~)\) is a common divisor of \(p, q\). By definition of \(gcd\), this means \[x \cdot gcd (~(p,q)~) \leq gcd (~(p,q)~)\] and since \(gcd(~(p,q)~)\) is positive, this means, \(x \leq 1\).
We’ve seen multiple representations of the set of positive integers (using base expansions and using prime factorization). Now we’re going to expand our attention to other sets of numbers as well.
The set of rational numbers, \(\mathbb{Q}\) is defined as \[\left\{ \frac{p}{q} \mid p \in \mathbb{Z} \text{ and } q \in \mathbb{Z} \text{ and } q \neq 0 \right\} \text{~~~~or, equivalently,~~~~} \{ x \in \mathbb{R} \mid \exists p \in \mathbb{Z} \exists q \in \mathbb{Z}^+ ( p = x \cdot q) \}\]
Extra practice: Use the definition of set equality to prove that the definitions above give the same set.
We have the following subset relationships between sets of numbers:
\[\mathbb{Z}^{+} \subsetneq \mathbb{N} \subsetneq \mathbb{Z} \subsetneq \mathbb{Q} \subsetneq \mathbb{R}\]
Which of the proper subset inclusions above can you prove?
Goal: The square root of \(2\) is not a rational number. In other words: \(\neg \exists x \in \mathbb{Q} ( x^2 - 2 = 0)\)
Attempted proof: The definition of the set of rational numbers is the collection of fractions \(p/q\) where \(p\) is an integer and \(q\) is a nonzero integer. Looking for a witness \(p\) and \(q\), we can write the square root of \(2\) as the fraction \(\sqrt{2 }/1\), where \(1\) is a nonzero integer. Since the numerator is not in the domain, this witness is not allowed, and we have shown that the square root of \(2\) is not a fraction of integers (with nonzero denominator). Thus, the square root of \(2\) is not rational.
The problem in the above attempted proof is that
Lemma 1: For every two integers \(a\) and \(b\), not both zero, with \(gcd(~(a,b)~) = 1\), it is not the case that both \(a\) is even and \(b\) is even.
Lemma 2: For every integer \(x\), \(x\) is even if and only if \(x^2\) is even.
Proof: Towards a proof by contradiction, we will define a statement \(r\) such that \(\sqrt{2} \in \mathbb{Q} \to (r \land \lnot r)\).
Assume that \(\sqrt{2} \in \mathbb{Q}\). Namely, there are positive integers \(p, q\) such that \[\sqrt{2} = \frac{p}{q}\] Let \(a= \frac{p}{gcd( ~(p,q)~)}\), \(b = \frac{q}{gcd(~(p,q)~)}\), then \[\sqrt{2} = \frac{a}{b} \qquad \text{and} \qquad gcd(~(a,b)~) = 1\]
By Lemma 1, \(a\) and \(b\) are not both even. We define \(r\) to be the statement “\(a\) is even and \(b\) is even”, and we have proved \(\lnot r\).
Squaring both sides and clearing denominator: \(2b^2 = a^2\).
By definition of even, since \(b^2\) is an integer\(, a^2\) is even.
By Lemma 2, this guarantees that \(a\) is even too. So, by definition of even, there is some integer (call it \(c\)), such that \(a = 2c\).
Plugging into the equation: \[2b^2 = a^2 = (2c)^2 = 4c^2\] and dividing both sides by \(2\) \[b^2 = 2c^2\] and since \(c^2\) is an integer, \(b^2\) is even. By Lemma 2, \(b\) is even too. Thus, \(a\) is even and \(b\) is even and we have proved \(r\).
In other words, assuming that \(\sqrt{2} \in \mathbb{Q}\) guarantees \(r \land \lnot r\), which is impossible, so \(\sqrt{2} \notin \mathbb{Q}\). QED
Definition: A finite set is one whose distinct elements can be counted by a natural number.
Motivating question: when can we say one set is bigger than another?
Does the definition change when we’re comparing finite sets? infinite sets?
Which is bigger?
The set \(\{1,2,3\}\) or the set \(\{0,1,2,3\}\)?
The set \(\{0, \pi, \sqrt{2} \}\) or the set \(\{\mathbb{N}, \mathbb{R}, \emptyset\}\)?
The set \(\mathbb{N}\) or the set \(\mathbb{Q}\)?
The set \(\mathbb{Q}\) or the set \(\mathbb{R}\)?
The set \(\mathbb{N}\) or the set \(\mathbb{R}^+\)?
Key idea for cardinality: Counting distinct elements is a way of labelling elements with natural numbers. This is a function! In general, functions let us associate elements of one set with those of another. If the association is “good", we get a correspondence between the elements of the sets which can relate the sizes of the sets.
Analogy: Musical chairs
2 
People try to sit down when the music stops
Person sits in Chair 1, Person sits in Chair 2,
Person is left standing!
What does this say about the number of chairs and the number of people?
Recall that a function is defined by its (1) domain, (2) codomain, and (3) rule assigning each element in the domain exactly one element in the codomain. The domain and codomain are nonempty sets. The rule can be depicted as a table, formula, English description, etc.
A function can fail to be well-defined if there is some domain element where the function rule doesn’t give a unique codomain element. For example, the function rule might lead to more than one potential image, or to an image outside of the codomain.
Example: \(f_A: \mathbb{R}^+ \to \mathbb{Q}\) with \(f_A(x) = x\) is not a well-defined function because
Example: \(f_B: \mathbb{Q} \to \mathbb{Z}\) with \(f_B\left(\frac{p}{q}\right) = p+q\) is not a well-defined function because
Example: \(f_C: \mathbb{Z} \to \mathbb{R}\) with \(f_C(x) = \frac{x}{|x|}\) is not a well-defined function because
Definition : A function \(f: D \to C\) is one-to-one (or injective) means for every \(a,b\) in the domain \(D\), if \(f(a) = f(b)\) then \(a=b\).
Formally, \(f: D \to C\) is one-to-one means \(\underline{\phantom{\forall a \in D \forall b \in D ~(f(a) = f(b) \to a = b)}}\).
Informally, a function being one-to-one means “no duplicate images”.
Definition: For nonempty sets \(A, B\), we say that the cardinality of \(A\) is no bigger than the cardinality of \(B\), and write \(|A| \leq |B|\), to mean there is a one-to-one function with domain \(A\) and codomain \(B\). Also, we define \(|\emptyset| \leq |B|\) for all sets \(B\).
In the analogy: The function \(sitter: \{ Chair1, Chair2\} \to \{ Person\sun, Person\smiley, Person\frownie \}\) given by \(sitter(Chair1) = Person\sun\), \(sitter(Chair2) = Person\smiley\), is one-to-one and witnesses that \[| \{ Chair1, Chair2\} | \leq |\{ Person\sun, Person\smiley, Person\frownie \}|\]
Definition: A function \(f: D \to C\) is onto (or surjective) means for every \(b\) in the codomain, there is an element \(a\) in the domain with \(f(a) = b\).
Formally, \(f: D \to C\) is onto means \(\underline{\phantom{\forall b \in C \exists a \in D ( f(a) = b)}}\).
Informally, a function being onto means “every potential image is an actual image”.
Definition: For nonempty sets \(A, B\), we say that the cardinality of \(A\) is no smaller than the cardinality of \(B\), and write \(|A| \geq |B|\), to mean there is an onto function with domain \(A\) and codomain \(B\). Also, we define \(|A| \geq |\emptyset|\) for all sets \(A\).
In the analogy: The function \(triedToSit: \{ Person\sun, Person\smiley, Person\frownie \} \to \{ Chair1, Chair2\}\) given by \(triedToSit(Person\sun) = Chair1\), \(triedToSit(Person\smiley) = Chair2\), \(triedToSit(Person\frownie) = Chair2\), is onto and witnesses that \[|\{ Person\sun, Person\smiley, Person\frownie \}| \geq | \{ Chair1, Chair2\} |\]
Definition : A function \(f: D \to C\) is a bijection means that it is both one-to-one and onto. The inverse of a bijection \(f: D \to C\) is the function \(g: C \to D\) such that \(g(b) = a\) iff \(f(a) = b\).
For nonempty sets \(A, B\) we say \[\begin{align*} |A| \leq |B| &\text{ means there is a one-to-one function with domain $A$, codomain $B$} \\ |A| \geq |B| &\text{ means there is an onto function with domain $A$, codomain $B$} \\ |A| = |B| &\text{ means there is a bijection with domain $A$, codomain $B$} \end{align*}\]
For all sets \(A\), we say \(|A| = |\emptyset|\), \(|\emptyset| = |A|\) if and only if \(A = \emptyset\).