HW6 Proofs, Numbers, and Cardinality

CSE20F21

Due: Tuesday, November 23, 2021 at 11:00PM on Gradescope

In this assignment,

You will practice determining and justifying whether statements are true in multiple contexts.

Instructions and academic integrity reminders for all homework assignments in CSE20 this quarter are on the class website and on the hw1-definitions-and-notations assignment.

You will submit this assignment via Gradescope (https://www.gradescope.com) in the assignment called “hw6-proofs-numbers-cardinality”.

Resources: To review the topics you are working with for this assignment, see the class material from Weeks 6 through 8. We will post frequently asked questions and our answers to them in a pinned Piazza post.

In your proofs and disproofs of statements below, justify each step by reference to a component of the following proof strategies we have discussed so far, and/or to relevant definitions and calculations.

Assigned questions

  1. Recall the definition of the set of linked lists from class, and some associated functions. \[\begin{array}{ll} \textrm{Basis Step: } & [] \in L \\ \textrm{Recursive Step: } & \textrm{If } l \in L\textrm{ and }n \in \mathbb{N} \textrm{, then } (n, l) \in L \end{array}\] The length function \(length: L \to \mathbb{N}\) is defined by \[\begin{array}{llll} \textrm{Basis Step:} & & length(~[]~) &= 0 \\ \textrm{Recursive Step:} & \textrm{If } l \in L\textrm{ and }n \in \mathbb{N}\textrm{, then } & length(~(n, l)~) &= 1+ length(l) \end{array}\] The function \(prepend : L \times \mathbb{N} \to L\) is defined by \[prepend(~(l, n)~) = (n, l)\] The function \(append : L \times \mathbb{N} \to L\) is defined by \[\hspace{-40pt}\begin{array}{llll} \textrm{Basis Step:} & \textrm{If } m \in \mathbb{N}\textrm{ then } & append(~([], m)~) & = (m, []) \\ \textrm{Recursive Step:} & \textrm{If } l \in L\textrm{ and }n \in \mathbb{N}\textrm{ and }m \in \mathbb{N}\textrm{, then } & append(~(~(n, l), m~)~) &= (n, append(~(l, m)~)~) \end{array}\]

    1. (Graded for fair effort completeness1) Fill in the blanks in the following proof of the statement \[\forall l\in L~ \forall m \in \mathbb{N} ~(~length(prepend(~(l,m)~)) = length(append(~(l,m)~))~)\] Proof: We proceed by structural induction on \(L\).

      Basis step: We need to show that \[\forall m \in \mathbb{N} ~(~length(prepend(~([],m)~)) = length(append(~([],m)~))~)\] Towards universal generalization, let \(m\) be an arbitrary natural number. Calculating: \[LHS = \underline{\text{BLANK~1}}\] \[RHS = \underline{\text{BLANK~2}}\] Since \(LHS = RHS\), the basis step is complete.

      Recursive step: Consider an arbitrary: \(l' \in L\), \(n \in \mathbb{N}\), and we assume as the induction hypothesis that: \[\underline{\text{BLANK~3}}\] Our goal is to show that \[\forall m \in \mathbb{N} ~(~length(prepend(~(~(n,l')~,m)~)) = length(append(~(~(n,l'),m)~))~)\] is also true. Let \(m\) be an arbitrary natural number. Calculating: \[LHS = \underline{\text{BLANK~4}}\] \[RHS = \underline{\text{BLANK~5}}\] Since \(LHS = RHS\), the recursive step is complete.

    2. (Graded for correctness2) Disprove the statement \[\forall l\in L~ \forall m \in \mathbb{N} ~(~prepend(~(l,m)~) = append(~(l,m)~)~)\]

    3. (Graded for correctness) Determine whether the statement \[\exists l\in L~ \exists m \in \mathbb{N} ~(~prepend(~(l,m)~) = append(~(l,m)~)~)\] is true or false, and justify your conclusion using valid proof strategies.

  2. Recall the definition of the set of rational numbers, \[Q = \left\{ \frac{p}{q} \mid p \in \mathbb{Z} \text{ and } q \in \mathbb{Z} \text{ and } q \neq 0 \right\}\] We define the set of irrational numbers \(\overline{\mathbb{Q}} = \mathbb{R} - \mathbb{Q} = \{ x \in \mathbb{R} \mid x \notin \mathbb{Q} \}\).

    1. (Translation graded for fair effort completeness; Witness graded for correctness) Translate the statement to English and then give a witness that could be used to prove the statement \[\exists x \in \mathbb{Q}~ \forall y \in \overline{\mathbb{Q}} ~(x\cdot y \in \mathbb{Q})\] You do not need to justify your answer. However, if you include clear explanations, we may be able to give partial credit for an answer with some imprecision.

    2. (Translation graded for fair effort completeness; Counterexample graded for correctness) Translate the statement to English and then give a counterexample that could be used to disprove the statement \[\forall x \in \overline{\mathbb{Q}} ~\left( x > 0 ~\to~ x \geq 1 \right)\] You do not need to justify your answer. However, if you include clear explanations, we may be able to give partial credit for an answer with some imprecision.

    3. (Translation graded for fair effort completeness; Witness graded for correctness) Translate the statement to English and then give a witness that could be used to prove the statement \[\exists (x,y,z) \in \overline{\mathbb{Q}}\times\mathbb{Q}\times \mathbb{Q} ~(y \neq z \land x^ y= z)\] You do not need to justify your answer. However, if you include clear explanations, we may be able to give partial credit for an answer with some imprecision.

    4. (Graded for fair effort completeness3) Fill in the blanks in the following argument.

      Claimed statement: \(\exists x \in \overline{\mathbb{Q}}~ \exists y \in \overline{\mathbb{Q}} ~\exists z\in \mathbb{Q} ~(x^y = z)\).

      Proof: We need to give a witness to prove this existential claim. We proceed in a proof by cases, since the disjunction (i)\(\underline{\phantom{\hspace{1.3in}}}\) is true.

      • Case 1: We need to show that \[(\sqrt{2}^{\sqrt{2}} \in \mathbb{Q}) \to \exists x \in \overline{\mathbb{Q}}~ \exists y \in \overline{\mathbb{Q}} ~\exists z\in \mathbb{Q} ~(x^y = z)\] Assume towards a direct proof that (ii)\(\underline{\phantom{\hspace{1.3in}}}\). We choose the witnesses \(x = \sqrt{2}\), \(y = \sqrt{2}\), \(z = \sqrt{2}^{\sqrt{2}}\). By the theorem we proved in class, \(\sqrt{2} \notin \mathbb{Q}\). Since \(x = y = \sqrt{2}\), \(x \in \overline{\mathbb{Q}}\) and \(y \in \overline{\mathbb{Q}}\). By the assumption of this direct proof, \(z \in \mathbb{Q}\). Thus, the witnesses we picked are in the required domains. Moreover, by definition, \(z = x^y\), as required. Thus, the existential claim is proved and we have completed the direct proof required for this case.

      • Case 2: We need to show that \[(\sqrt{2}^{\sqrt{2}} \in \overline{\mathbb{Q}}) \to \exists x \in \overline{\mathbb{Q}}~ \exists y \in \overline{\mathbb{Q}} ~\exists z\in \mathbb{Q} ~(x^y = z)\] Assume towards a direct proof that \((\sqrt{2}^{\sqrt{2}} \in \overline{\mathbb{Q}})\). We choose the witnesses \[x = \textbf{(iii)}\underline{\phantom{\hspace{1.3in}}}, ~y = \textbf{(iv)}\underline{\phantom{\hspace{1.3in}}}, ~z = \textbf{(v)}\underline{\phantom{\hspace{1.3in}}}\] By the assumption of this direct proof, \(x \in \overline{\mathbb{Q}}\). As we mentioned above, \(\sqrt{2} \notin \mathbb{Q}\) so \(y \in \overline{\mathbb{Q}}\). Picking \(p = 2, q = 1\), we observe that \(z = \frac{2}{1}\) and since (vi), \(z \in \mathbb{Q}\). Thus, the three witnesses we picked are in the required domains. Calculating: \[\left( \sqrt{2}^{\sqrt{2}}\right)^{\sqrt{2}} = \left( \sqrt{2} \right)^{\sqrt{2} \cdot \sqrt{2} } = \left(\sqrt{2} \right)^2 = \sqrt{2} \cdot \sqrt{2} = 2\] which proves that \(\textbf{(vii)}\underline{\phantom{\hspace{1.3in}}}\), and hence \(x,y,z\) are the required witnesses. Thus, the existential claim is proved and we have completed the direct proof required for this case.

      The proof by cases is now complete and the statement has been proved. QED

  3. Recall that A hex color is a nonnegative integer, \(n\), that has a base \(16\) fixed-width \(6\) expansion \[n = (r_1r_2g_1g_2b_1b_2)_{16,6}\] where \((r_1r_2)_{16,2}\) is the red component, \((g_1g_2)_{16,2}\) is the green component, and \((b_1b_2)_{16,2}\) is the blue component. For notational convenience, we define the set \(C = \{ x \in \mathbb{N} ~\mid~x < 16^6 \}\). This is the set of possible hex colors because these are all numbers that have hexadecimal fixed-width \(6\) expansions.

    1. (Graded for correctness) Determine and briefly justify whether \(C\) is finite, countably infinite, or uncountable.

    2. Consider the function \(red: C \to C\) given by \(red(~(r_1r_2g_1g_2b_1b_2)_{16,6}~) = (r_1r_20000)_{16,6}\).

      1. (Graded for correctness) Determine whether \(red\) is one-to-one, and justify your conclusion using valid proof strategies.

      2. (Graded for correctness) Determine whether \(red\) is onto, and justify your conclusion using valid proof strategies.

  4. Consider the set of ratings in a 3-movie database \(R = \{ -1,0,1\} \times \{-1,0,1\} \times \{-1,0,1\}\) and the set of bases of RNA strands \(B = \{\texttt{A}, \texttt{C}, \texttt{U}, \texttt{G}\}\).

    1. (Graded for fair effort completeness) Give a (well-defined) one-to-one function with domain \(R\) and codomain \(B\) or explain why there is no such function.

    2. (Graded for fair effort completeness) Give a (well-defined) one-to-one function with domain \(B\) and codomain \(R\) or explain why there is no such function.

    3. (Graded for fair effort completeness) Give a (well-defined) onto function with domain \(R\) and codomain \(B\) or explain why there is no such function.

    4. (Graded for fair effort completeness) Give a (well-defined) onto function with domain \(B\) and codomain \(R\) or explain why there is no such function.


    Sample calculation that can be used as reference for the detail expected in your answer when specifying functions and reasoning about their properties:

    We give a (well-defined) function with domain \(R\) and codomain \(B\) that is neither one-to-one nor onto.

    Define \(g: R \to B\) by, for \((x_1, x_2,x_3) \in R\), \[g(~(x_1, x_2, x_3)~) = \begin{cases} \texttt{A}\qquad &\text{if $x_1 = 1$} \\ \texttt{C}\qquad &\text{if $x_1 = 0$} \\ \texttt{G}\qquad &\text{if $x_1 = -1$} \end{cases}\] This function is well-defined because each ratings \(3\)-tuples is mapped to a unique base. However, this function is not one-to-one, as we can see from the counterexample: \(a = (1,1,1)\), \(b = (1, 0,0)\). These are ratings \(3\)-tuples (in the domain) which are distinct (they disagree about the second and third movies) but \[g(a) = g(~(1,1,1)~) = \texttt{A}= g(~(1,0,0)~) = g(b)\] because the two ratings agree on the first movie. Distinct domain elements getting mapped to the same codomain elements is a counterexample to injectivity.

    The function \(g\) is also not onto, as we can see from the counterexample \(\texttt{U}\). This is an element of the codomain which is not \(f(x)\) for any \(x\) in the domain, as we can see from the piecewise definition of \(g\), where in no case do we have the output value \(\texttt{U}\).



  1. Graded for fair effort completeness means you will get full credit so long as your submission demonstrates honest effort to answer the question. You will not be penalized for incorrect answers.↩︎

  2. Graded for correctness means your solution will be evaluated not only on the correctness of your answers, but on your ability to present your ideas clearly and logically. You should explain how you arrived at your conclusions, using mathematically sound reasoning. Whether you use formal proof techniques or write a more informal argument for why something is true, your answers should always be well-supported. Your goal should be to convince the reader that your results and methods are sound.↩︎

  3. Fair effort completeness for this question means either attempting to correctly answer each part or to write a sentence or two on where you get stuck in your attempt to correctly answer the question.↩︎