Exercise · Volume 1 · 2.3-3
Exercise 2.3-3
not stated yet in Lean solution written
| Rating | M20 |
|---|---|
| Markers | M (mathematical) |
| Kind | K1, prove: show that a stated fact is true from the written solution |
| Section | Section 2.3 of Volume 1 |
The task
Prove from the definition of a tree that for each node there is exactly one path with the root, and the parent of .
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
Use induction on the number of nodes of the tree. Split off the root and the subtrees.
Hint 2
Prove two facts: a path exists, and each node other than the root has exactly one parent.
Solution
Show the solution
Recall the definition. A tree is a finite nonempty set of nodes. One node is the root. The other nodes are split into disjoint sets, and each set is a tree, the subtrees. The root of each subtree has the root of the whole tree as its parent. Inside a subtree, the parent relation is the one of that subtree.
Claim 1 (a path exists). Induction on the number of nodes. For the only node is the root, and the path is . Let . If is the root, the path is again . Otherwise lies in one subtree , which has fewer than nodes. By the induction hypothesis has a path with the root of . The root of the whole tree is the parent of . So is a path in the whole tree.
Claim 2 (each node except the root has one parent). Induction on again. For there is nothing to prove. Let and let be a node other than the root . Then lies in exactly one subtree , because the subtrees are disjoint. If is the root of , its parent is , and no other node is its parent, because parents link nodes of the same subtree or link to a subtree root, and the root of has no parent inside . If is not the root of , then has one parent in by induction, and no node outside is a parent of .
Now take two paths and that both end in and both start at the root. The root has no parent. If , a path with would give the root a parent, so both paths are the one-element path. If , then and are both parents of . By Claim 2 they are equal. Repeat the argument for , and so on. The two paths agree in every position, and because both end when the root is reached.
Check
For the tree of Fig. 19 in the text (root , with and below it), a python3 program listed the path from the root to each of the 9 nodes by following parents upward. Each node gave one path. For the path is .
Remarks
The same two-part induction proves most of the elementary facts about trees, so it is worth learning well.
This solution is drafted, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.