Edit this page Backlinks This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== Structural Induction ===== Recall the ADTs defined in the [[aa:lab:11|previous lab]] and lecture (together with their operators): * Binary Tree * List * Nat And the following definition of ''reverse'': $math[reverse : List \rightarrow List] $math[reverse(Empty) = Empty] $math[reverse(Cons(x, xs)) = append(reverse(xs), Cons(x, Empty))] 1. Prove the following properties are true, using structural induction: * $math[\forall t \in \texttt{Tree}. size(t) = size(mirror(t))] * $math[\forall t \in \texttt{Tree}. size(t) = length(flatten(t))] * $math[\forall t \in \texttt{Tree}. flatten(mirror(t)) = reverse(flatten(t))] * $math[\forall a, b, c \in \texttt{Nat}. add(a, add(b, c)) = add(add(a, b), c)] * $math[\forall l \in \texttt{List}. append(l, Empty) = l] * $math[\forall l1, l2, l3 \in \texttt{List}. append(l1, append(l2, l3)) = append(append(l1, l2), l3))] * $math[\forall l1, l2 \in \texttt{List}. length(append(l1, l2)) = length(append(l2, l1))] * $math[\forall l1, l2 \in \texttt{List}. reverse(append(l1, l2)) = append(reverse(l2), reverse(l1))].