Recall the definition of linked lists from class. Consider this (incomplete) definition: Definition The function \(\textit{increment} : \underline{\hspace{6em}}\) that adds 1 to the data in each node of a linked list is defined by: \[\begin{array}{llll} & & \textit{increment} : \underline{\hspace{3em}} & \to \underline{\hspace{3em}} \\ \textrm{Basis Step:} & & \textit{increment}([]) & = [] \\ \textrm{Recursive Step:} & \textrm{If } l \in L, n \in \mathbb{N} & \textit{increment}((n, l)) & = (1 + n, \textit{increment}(l)) \end{array}\] Consider this (incomplete) definition: Definition The function \(\textit{sum} : L \to \mathbb{N}\) that adds together all the data in nodes of the list is defined by: \[\begin{array}{llll} & & \textit{sum} : L & \to \mathbb{N} \\ \textrm{Basis Step:} & & \textit{sum}([]) & = 0 \\ \textrm{Recursive Step:} & \textrm{If } l \in L, n \in \mathbb{N} & \textit{sum}((n, l)) & = \underline{\hspace{8em}} \end{array}\] You will compute a sample function application and then fill in the blanks for the domain and codomain of each of these functions.
Based on the definition, what is the result of \(\textit{increment}((4, (2, (7, []))))\)? Write your answer directly with no spaces.
Which of the following describes the domain and codomain of increment?
2
The domain is \(L\) and the codomain is \(\mathbb{N}\)
The domain is \(L\) and the codomain is \(\mathbb{N} \times L\)
The domain is \(L \times \mathbb{N}\) and the codomain is \(L\)
The domain is \(L \times \mathbb{N}\) and the codomain is \(\mathbb{N}\)
The domain is \(L\) and the codomain is \(L\)
None of the above
Assuming we would like \(sum((5, (6, [])))\) to evaluate to \(11\) and \(sum((3, (1, (8, []))))\) to evaluate to \(12\), which of the following could be used to fill in the definition of the recursive case of sum?
2
\(\begin{cases} 1 + \textit{sum}(l) & \textrm{when } n \neq 0 \\ \textit{sum}(l) & \textrm{when } n = 0 \\ \end{cases}\)
\(1 + \textit{sum}(l)\)
\(n + \textit{increment}(l)\)
\(n + \textit{sum}(l)\)
None of the above
Choose only and all of the following statements that are well-defined; that is, they correctly reflect the domains and codomains of the functions and quantifiers, and respect the notational conventions we use in this class. Note that a well-defined statement may be true or false.
2
\(\forall l \in L \, (\textit{sum}(l))\)
\(\exists l \in L \, (\textit{sum}(l) \land \textit{length}(l))\)
\(\forall l \in L \, (\textit{sum}(\textit{increment}(l)) = 10)\)
\(\exists l \in L \, (\textit{sum}(\textit{increment}(l)) = 10)\)
\(\forall l \in L \, \forall n \in \mathbb{N} \, ((n \times l) \subseteq L)\)
\(\forall l_1 \in L \, \exists l_2 \in L \, (\textit{increment}(\textit{sum}(l_1)) = l_2)\)
\(\forall l \in L \, (\textit{length}(\textit{increment}(l)) = \textit{length}(l))\)
Choose only and all of the statements in the previous part that are both well-defined and true.