Bracketings of a list #
A bracketing of a nonempty list is a way of grouping its entries by nested pairs of brackets: a
binary tree whose leaves, read from left to right, are the entries of the list
(Cslib.Bracketing). Every nonempty list of length n has a bracketing of height at most
⌈lg n⌉ (Cslib.Bracketing.exists_leaves_eq), obtained by halving. Divide-and-conquer
arguments over a product of n factors in a fixed order go by induction on the height of the
subtrees of such a bracketing (Cslib.Bracketing.subtrees).
Main definitions #
Cslib.Bracketing: binary trees with labelled leaves.Cslib.Bracketing.leaves,Cslib.Bracketing.height,Cslib.Bracketing.subtrees.
Main results #
Cslib.Bracketing.exists_leaves_eq: a bracketing of height at most⌈lg n⌉of a list of lengthn.Cslib.Bracketing.length_subtrees: a bracketing ofnentries has2 n - 1subtrees.Cslib.Bracketing.sublist_leaves_of_mem_subtrees: the leaves of a subtree form a sublist.
A bracketing: a binary tree with leaves labelled in σ.
- leaf {σ : Type u_1} (i : σ) : Bracketing σ
A single entry.
- node {σ : Type u_1} (l r : Bracketing σ) : Bracketing σ
Two bracketings side by side.
The entries of a bracketing, from left to right.
The height of a bracketing: the largest number of brackets around an entry.
The subtrees of a bracketing, itself included.
The subtrees of a subtree are subtrees.
The entries of a subtree form a sublist of the entries of the bracketing.