hw4-proofs-sets-recursion

CSE020F26

Due: 11/17/26 at 5pm (no penalty late submission until 8am next morning)

In this assignment, you will analyze statements and determine if they are true or false using valid proof strategies. You will also determine if candidate arguments are valid. You will work with recursively defined sets and functions and prove properties about them, practicing induction and other proof strategies.

Relevant class material: Weeks 5, 6, and 7.

You will submit this assignment via Gradescope (https://www.gradescope.com) in the assignment called “hw4-proofs-sets-recursion”.

For all HW assignments: These homework assignments must be done in groups of three students. Please ensure your name(s) and TSN(s) are clearly visible on the first page of your homework submission, start each question on a new page, and upload the PDF to Gradescope. If you’re working in a group, submit only one submission per group: one partner uploads the submission through their Gradescope account and then adds the other group members to the Gradescope submission by selecting their name(s) in the “Add Group Members” dialog box. You will need to re-add your group member(s) every time you resubmit a new version of your assignment.

All submitted homework for this class must be typed. You can use a word processing editor if you like (Microsoft Word, Open Office, Notepad, Vim, Google Docs, etc.) but you might find it useful to take this opportunity to learn LaTeX. LaTeX is a markup language used widely in computer science and mathematics. The homework assignments are typed using LaTeX and you can use the source files as templates for typesetting your solutions.

After you submit the PDF of the homework, you will meet with a TA for a Homework Q&A session. This session is a primary component of your homework score. All group members must be present and able to fully participate in discussions of each question.

Integrity reminders

When discussing your homework solutions, you should be prepared to describe

A rule of thumb for the level of detail to include is to imagine someone who is taking the class alongside you but missed about a week’s worth of content: does your writeup have enough detail for them to learn from it?

To demonstrate your honest effort in answering homework questions, we expect you to include your attempt to answer *each* part of the question. If you get stuck with your attempt, you can still demonstrate your effort by explaining where you got stuck and what you did to try to get unstuck (e.g. reviewing annotated notes from class, checking the relevant textbook sections, looking up comparable questions on the relevant weekly review quizzes, asking questions on Piazza, attending (instructor/TA/tutor) office hours, consulting generative AI tools, etc.).

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. Number properties. Consider the predicate \(F(~(a,b)~) = ``a \text{ is a factor of } b"\) over the domain \(\mathbb{Z}^{\neq 0} \times \mathbb{Z}\). Consider the following quantified statements

    2

    1. \(\forall x \in \mathbb{Z} ~(F(~(1,x~)))\)

    2. \(\forall x \in \mathbb{Z}^{\neq 0} ~(F(~(x,1)~))\)

    3. \(\exists x \in \mathbb{Z} ~(F(~(1,x)~))\)

    4. \(\exists x \in \mathbb{Z}^{\neq 0} ~(F(~(x,1)~))\)

    5. \(\forall x \in \mathbb{Z}^{\neq 0} ~\exists y \in \mathbb{Z} ~(F(~(x,y)~))\)

    6. \(\exists x \in \mathbb{Z}^{\neq 0} ~\forall y \in \mathbb{Z} ~(F(~(x,y)~))\)

    7. \(\forall y \in \mathbb{Z} ~\exists x \in \mathbb{Z}^{\neq 0} ~(F(~(x,y)~))\)

    8. \(\exists y \in \mathbb{Z} ~\forall x \in \mathbb{Z}^{\neq 0} ~(F(~(x,y)~))\)

    1. Which of the statements (i) - (viii) is being proved by the following proof:

      By universal generalization, choose \(e\) to be an arbitrary integer. We need to show that \(F(~(1,e)~)\). By definition of the predicate \(F\), we can rewrite this goal as \(\exists c \in \mathbb{Z}~(e = c \cdot 1)\). We pick the witness \(c = e\), which is an integer and therefore in the domain. Calculating, \(c \cdot 1 = e \cdot 1 = e\), as required. Since the predicate \(F(1,e)\) evaluates to true for the arbitrary integer \(e\), the claim has been proved. \(\square\)

      Hint: it may be useful to identify the key words in the proof that indicate proof strategies.

    2. Which of the statements (i) - (viii) is being disproved by the following proof:

      To disprove the statement, we need to find a counterexample. We choose \(2\), a nonzero integer so in the domain. We need to show that \(\lnot F(~(2,1)~)\). By definition of the predicate \(F\), we can rewrite this goal as \(1 \textbf{ mod } 2 \neq 0\). By definition of integer division, since \(1 = 0 \cdot 2 + 1\) (and \(0 \leq 1 < 2\)), \(1 \textbf { mod } 2 = 1\) which is nonzero so the counterexample works to disprove the original statement. \(\square\)

      Hint: it may be useful to identify the key words in the proof that indicate proof strategies.

    3. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation).

      \[\exists x \in \mathbb{Z}^{\neq 0}~ \exists y \in \mathbb{Z}^{\neq 0} ~(~\lnot(x = y) \land F(~(x,y)~) \land F(~(y,x)~)~)\]

    4. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation). \[\forall x \in \mathbb{Z}^{\neq 0}~ \forall y \in \mathbb{Z}^{\neq 0} ~(~F(~(x,y)~) \to \lnot F(~(y,x)~)~)\]

    5. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation) \[\exists x \in \mathbb{Z}^{\neq 0}~ \exists y \in \mathbb{Z}~(~F(~(x,y)~) \land F(~(x+1, y)~) \land F(~(x+2, y)~)~)\]

    6. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation).

      \[\forall x \in \mathbb{Z}^{\neq 0}~ (~F(~(x,x^2)~) \land F(~(x,x^3)~)~)\]

  2. Structural induction. Recall that we define the set of bases as \(B = \{ \texttt{A}, \texttt{C}, \texttt{U}, \texttt{G}\}\). The set of RNA strands \(S\) is defined (recursively) by: \[\begin{array}{ll} \textrm{Basis Step: } & \texttt{A}\in S, \texttt{C}\in S, \texttt{U}\in S, \texttt{G}\in S \\ \textrm{Recursive Step: } & \textrm{If } s \in S\textrm{ and }b \in B \textrm{, then }sb \in S \end{array}\] where \(sb\) is string concatenation. The function rnalen that computes the length of RNA strands in \(S\) is defined recursively by \(rnalen: S \to \mathbb{Z}^+\)

    Basis step: If \(b \in B\) then \(rnalen(b) = 1\)

    Recursive step: If \(s \in S\) and \(b \in B\), then \(rnalen(sb) = 1 + rnalen(s)\)

    The function basecount that computes the number of a given base \(b\) appearing in a RNA strand \(s\) is defined recursively:

    \[\begin{array}{llll} & & \textit{basecount} : S \times B & \to \mathbb{N} \\ \textrm{Basis Step:} & \textrm{If } b_1 \in B, b_2 \in B & \textit{basecount}(~(b_1, b_2)~) & = \begin{cases} 1 & \textrm{when } b_1 = b_2 \\ 0 & \textrm{when } b_1 \neq b_2 \\ \end{cases} \\ \textrm{Recursive Step:} & \textrm{If } s \in S, b_1 \in B, b_2 \in B &\textit{basecount}(~(s b_1, b_2)~) & = \begin{cases} 1 + \textit{basecount}(~(s, b_2)~) & \textrm{when } b_1 = b_2 \\ \textit{basecount}(~(s, b_2)~) & \textrm{when } b_1 \neq b_2 \\ \end{cases} \end{array}\]

    1. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation). \[\forall b \in B ~\exists s \in S ~(~rnalen(s) = basecount(~(s,b)~)~)\]

    2. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation). \[\forall s \in S~ (rnalen(s) > basecount( ~(s,\texttt{A})~))\]

    3. Translate the statement to English, state whether is it true or false, and then justify your answer (by proving the statement or its negation). \[\forall s \in S~ \forall b \in B ~( basecount( ~(s,b)~) > 0)\]

  3. Games and induction. The game of Nim-Var is a two-player game (which is a variant of Nim). At the start of the game, there are two piles, each containing \(n\) jelly beans (\(n\) is a positive integer). On a player’s turn, that player picks one of the two piles and does one of the following: either

    The player to take the last jelly bean wins. Use strong induction to prove that the second player always has a winning strategy in Nim-Move. A complete and correct solution will first identify what the strategy is, and then prove that following this strategy will lead the second player to win the game (no matter what the first player chooses to do at each turn).

  4. Linked Lists. Recall the recursive definition of the set of linked lists of natural numbers (from class) \[\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}\] and the definitions of the function which gives the length of a linked list of natural numbers \(length: L \to \mathbb{N}\) \[\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 \(append : L \times \mathbb{N} \to L\) that adds an element at the end of a linked list \[\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}\] and the function \(prepend : L \times \mathbb{N} \to L\) that adds an element at the front of a linked list \[prepend(~(l, n)~) = (n, l)\]


    Sample response that can be used as reference for the detail expected in your answer: To evaluate the result of \(length(~(4,(2,(7,[])))~)\) we calculate: \[\begin{align*} length(~(4,(2,(7,[])))~) &= 1 + length ( ~(2,(7,[]))~) \\ & \qquad \qquad \text{using recursive step of definition of $length$, with $n=4, l=(2,(7,[]))$} \\ &= 1 + 1 + length ( ~(7,[])~) \\ & \qquad \qquad \text{using recursive step of definition of $length$, with $n=2, l=(7,[])$} \\ &= 1 + 1 + 1+ length ( ~[]~) \\ & \qquad \qquad \text{using recursive step of definition of $length$, with $n=7, l=[]$} \\ &= 1 + 1 + 1 + 0\\ & \qquad \qquad \text{using basis step of definition of $length$, since input to $length$ is $[]$} \\ \end{align*}\]


    In this question, we’ll consider the combination of these functions with a new function, one that removes the element at the front of the list (if there is any). We define \(remove: L \to L\) by \[\begin{array}{ll} \textrm{Basis Step: } & remove([]) = [] \\ \textrm{Recursive Step: } & \textrm{If } l \in L\textrm{ and }n \in \mathbb{N} \textrm{, then } remove(~(n, l)~) = l \end{array}\]

    1. What is the result of \(remove(~append(~(prepend~(~(~(10,[]), 5~)~), 20)~)~)\)? For full credit, include all intermediate steps with brief justifications for each.

    2. Prove the statement \[\forall l \in L \left(~ remove( prepend(~(l,0)~)) = l ~\right)\]

    3. Disprove the statement \[\forall l \in L \left(~ remove( append(~(l,0)~)) = l ~\right)\]

  5. Primes, divisors, and proof strategies. For each statement below, identify the main logical structure or connective of the statement, list the proof strategies that could be used to prove and to disprove a statement with that structure, then identify whether the statement is true or false and justify with a proof of the statement or its negation.


    Sample response that can be used as reference for the detail expected in your answer:

    Consider the statement: There is a greatest negative integer.

    The main logical structure for this statement is that it is an existential statement, as we can see by translating it to symbols: \[\exists g \in \mathbb{Z}^{-} \forall x \in \mathbb{Z}^{-} ( g \geq x)\] To prove an existential statement, the main proof strategy we could use is to find a witness. Proof by cases and proof by contradiction could also be used, because both can be used to prove any statement (no matter its logical structure).

    To disprove an existential statement, we would need to prove its negation, which (using DeMorgan’s Laws) can be written as a universal statement. Therefore, to disprove this statement the strategies we could use are universal generalization or structural induction (because \(\mathbb{Z}^{-}\) is a recursively defined set) or proof by cases or proof by contradiction. Notice that proof by exhaustion is not possible because the domain is not finite.

    The statement is true, as we can see from the witness \(g = -1\), since it is in the domain \(\mathbb{Z}^{-}\) and when we evaluate \[\forall x \in \mathbb{Z}^{-} ( -1 \geq x)\] we can proceed by universal generalization and take an arbitrary negative integer \(x\), which by definition means \(x < 0\), and since \(x\) is an integer, guarantees \(x \leq -1 = g\), as required.


    1. The quotient of any even number with any nonzero even number is even.

    2. There are two odd numbers (not necessarily distinct) whose sum is even.

    3. The greatest common divisor of 5 and 23 is 1 and the greatest common divisior of 7 and 19 is 1.

    4. There are two positive integers greater than 20 that have the same greatest common divisor with 20.