Exercise · Volume 1 · 2.3-7
Exercise 2.3-7
not stated yet in Lean solution written
| Rating | 23 |
|---|---|
| Kind | K1, prove: show that a stated fact is true from the written solution |
| Section | Section 2.3 of Volume 1 |
The task
Extend the definition of the previous exercise to all and all , so that any two nodes and of a tree have exactly one pair for which is an th cousin of , times removed.
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
The old condition says that and that . The new ranges let an exponent be , and the second condition then has an exponent .
Hint 2
Make the second condition true by convention when one of its exponents is . Then prove the claim with the nearest common ancestor of and .
Solution
Show the solution
Let and . The ranges and say exactly that and .
Definition. is an th cousin of , times removed, if (both defined), and in addition either or , or .
For this is the definition of exercise 2.3-6. For the first condition says . For it says . In these two cases the second condition is true by convention.
Let be the nearest common ancestor of and , where a node counts as an ancestor of itself. It exists because the root is a common ancestor, and it is unique because the ancestors of a node form a chain. Let be the number of steps from up to , and let be the number of steps from up to . If , the nodes and are children of , and they are different. Otherwise they would be equal, and this common child would be a common ancestor below .
Existence. Take and . Then . If the second condition holds by the remark above. If or it holds by convention. So the relation holds with and . These satisfy because , and because .
Uniqueness. Suppose the relation holds for some . Put . Then is a common ancestor, so is or an ancestor of . Suppose . If , then is an ancestor of , and the nearest common ancestor of and is then , which contradicts . The case is the same. If , both and are children of on the paths from down to and . Both paths pass through , which is below , so both nodes equal the child of on the path to . They are equal, and this contradicts the second condition. So . Then and , and is determined.
Check
Python3 built 200 random trees with up to 12 nodes. For every ordered pair it searched all from to and from to . Each pair satisfied the definition for exactly one . For example, in Fig. 19, and give .
Remarks
For the node is an ancestor of (or equal to it), and for it is the other way round. The pair means .
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.