HW7 Function and Relations

CSE20F21

Due: Tuesday, November 30, 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 “hw7-functions-and-relations”.

Resources: To review the topics you are working with for this assignment, see the class material from Weeks 8 and 9. 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. Consider the set \(U = \mathcal{P}(\mathbb{R})\).

    1. (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. 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.

      Note: your counterexample should specify a value for \(A\) and a value for \(B\). \[\forall A \in U ~\forall B \in U~(~( A \subseteq B \to \lnot (~|A| \geq |B|~)~)\]

    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. 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.

      Note: your counterexample should specify a value for \(X\) and a value for \(Y\). \[\forall X \in U~\forall Y \in U~( ~X \subseteq \mathbb{Z}~\land~ Y \subseteq \mathbb{Z} ~\to~ |X| = |Y| ~)\]

    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. 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.

      Note: your witness should specify a value for \(X\) and a value for \(Y\). \[\exists X \in U~ \exists Y \in U (~(~\mathbb{Z} \subseteq X~) \land (~\mathbb{Z} \subseteq Y~) \land \neg ( |X| = |Y|)~)\]

  2. (Graded for correctness1) The diagonalization argument constructs, for each function \(f: \mathbb{N} \to \mathcal{P}(\mathbb{N})\), a set \(D_f\) defined as \[D_f = \{ x \in \mathbb{N} ~|~ x \notin f(x) \}\]

    1. Define a function \(g\) such that \(D_g\) is a finite nonempty set, or explain why no such function exists.

    2. Define a function \(h\) such that \(D_h\) is an infinite set that is a proper subset of \(\mathbb{N}\), or explain why no such function exists.

    3. Define a function \(k\) such that \(D_k\) is a proper superset of \(\mathbb{N}\) (in other words, \(\mathbb{N}\) is a proper subset of \(D_k\)), or explain why no such function exists.2

  3. (Graded for correctness) For each part of this question, 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.

    1. Recall that in a movie recommendation system, each user’s ratings of movies is represented as a \(n\)-tuple (with the positive integer \(n\) being the number of movies in the database), and each component of the \(n\)-tuple is an element of the collection \(\{-1,0,1\}\). Assume there are five movies in the database, so that each user’s ratings can be represented as a \(5\)-tuple. We call \(Rt_5\) the set of all ratings \(5\)-tuples. Consider the binary relation on the set of all \(5\)-tuples where each component of the \(5\)-tuple is an element of the collection \(\{-1,0,1\}\): \[G = \{ (u,v) \in Rt_5 \times Rt_5 \mid \text{the number of $0$s in $u$ is the same as the number of $0$s in $v$} \}\] This is an equivalence relation (you do not need to prove this).

      Recall that the equivalence class of an element \(x \in X\) for an equivalence relation \(\sim\) on the set \(X\) is the set \(\{s \in X | (x, s) \in \sim \}\). We write this as \([x]_\sim\).

      1. Find a ratings \(5\)-tuple \(v\) such that \([v]_{G} = \{v \}\).

      2. Find distinct ratings \(5\)-tuples \(u_1, u_2\) (\(u_1 \neq u_2\)) whose equivalence classes \([u_1]_{G}\) and \([u_2]_{G}\) have the same size.

      3. Find distinct ratings \(5\)-tuples \(w_1, w_2\) (\(w_1 \neq w_2\)) whose equivalence classes \([w_1]_{G}\) and \([w_2]_{G}\) have different sizes.

    2. Let \(S_{1,2}\) be the set of RNA strands of length \(1\) or \(2\), formally \[S_{1,2} = \{ s \in S \mid ( rnalen(s) = 1) \lor (rnalen(s) = 2)\}\] Consider the binary relation on \(S_{1,2}\) given by \[\begin{aligned} P = \{ (s, s') \in S_{1,2} \times S_{1,2} \mid &\text{$s$ is a prefix of $s'$, }\\ &\text{namely either $s = s'$ or there is some base $b$ such that $sb=s'$} \} \end{aligned}\] This is a partial ordering (you do not need to prove this).

      Draw the Hasse diagram of \(P\).

    3. Consider the set \(CP\) of compound propositions that use propositional variables from the set \(\{p,q\}\). We define the logical equivalence binary relation on this set by \[LE = \{ (x, y) \in CP \times CP \mid x \equiv y \}\] This is an equivalence relation (you do not need to prove this).

      1. Give two distinct examples of elements in \([~(p \land \lnot p)~]_{LE}\)

      2. Give two distinct examples of elements in \([~(p \to q)~]_{LE}\)

      Bonus - not for credit; do not hand in: Prove that \(G\) is an equivalence relation on the set of ratings \(5\)-tuples. Prove that \(P\) is a partial ordering on \(S_{1,2}\). Prove that \(LE\) is an equivalence relation on the set of compound propostions that use propositional variables from the set \(\{p,q\}\).

  4. Imagine you are playing the role of Alice in the Diffie Hellman key agreement (exchange) protocol. You and Bob have agreed to use the prime \(p = 7\) and its primitive root \(a = 3\). Your secret integer is \(k_1 = 3\).

    1. (Graded for fair effort completeness3) Calculate the number you send to Bob, \(a^{k_1} \textrm{\bf ~mod~} p\). Use the modular exponentiation algorithm for the calculation. Include a trace of the algorithm in your solution.

      procedure \(modular~exponentiation\)(\(b\): integer; \(n = (a_{k-1}a_{k-2} \ldots a_1 a_0)_2\), \(m\): positive integers) \(x\) := \(1\) \(power\) := \(b\) mod \(m\) for \(i\):= \(0\) to \(k-1\) if \(a_i = 1\) then \(x\):= \((x \cdot power)\) mod \(m\) \(power\) := \((power \cdot power)\) mod \(m\) return \(x\) \(\{x~\textrm{equals}~b^n \textbf{ mod } m\}\)

    2. (Graded for fair effort completeness) Bob sends you the number \(5\). Compute your shared key, \(\left(a^{k_2}\right)^{k_1} \textrm{\bf ~mod~} p\). Hint: \(a^{k_2} \textrm{\bf ~mod~} p\) is what Bob sent you. Include all relevant calculations, annotated with explanations, for full credit.

    3. (Graded for fair effort completeness) What are some possible values for Bob’s secret integer? What algorithm are you using to compute them?


  1. This 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.↩︎

  2. For sets \(A\) and \(B\), when the relation \(A\subseteq B\) holds we say that \(A\) is a subset of \(B\) and that \(B\) is a superset of \(A\). Similarly, when the relation \(A\subsetneq B\) holds we say that \(A\) is a proper subset of \(B\) and that \(B\) is a proper superset of \(A\).↩︎

  3. This 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.↩︎