Order statistics of a list #
List.IsOrderStatistic r xs k y says that y is an element of xs of rank k (counting from
0) for a total preorder r: at most k elements of xs lie strictly below y, and more than
k lie at or below it. With ties, several elements of xs can have rank k; they are all
r-equivalent, and under an antisymmetric order the order statistic is unique and equals the
k-th entry of the sorted list.
Main definitions #
List.IsOrderStatistic:yis an element ofxsof rankkforr.
Main results #
List.Pairwise.length_sub_le_countP,List.Pairwise.add_one_le_countP: in a sorted list, an element at or below (at or above) thei-th entry is at or below (at or above) at leastlength - i(i + 1) entries.List.isOrderStatistic_getElem_of_perm: thek-th entry of a sorted permutation ofxsis an order statistic of rankk.List.IsOrderStatistic.rel,List.IsOrderStatistic.unique: order statistics of the same rank are equivalent, and equal under an antisymmetric order.List.isOrderStatistic_iff_mergeSort: in a linear order, the rank-korder statistic is(xs.mergeSort)[k].
References #
y is an element of xs of rank k (counting from 0) for the relation r: at most k
elements of xs lie strictly below y, and more than k lie at or below it. For a total
preorder r, "strictly below y" means ¬ r y x.
- mem : y ∈ xs
The order statistic is an element of the list.
At most
kelements lie strictly belowy.More than
kelements lie at or belowy.
An order statistic has rank below the length of the list.
In a list sorted by a transitive relation, an element p below the i-th entry is below
all of the last length - i entries.
In a list sorted by a transitive relation, an element p above the i-th entry is above
all of the first i + 1 entries.
Two order statistics of the same rank are related, so under a total preorder they are equivalent.
Under an antisymmetric transitive relation, order statistics are unique.
An order statistic of xs.filter q is an order statistic of xs of the same rank when every
element of xs strictly below it satisfies q.
An order statistic of xs.filter q is an order statistic of xs whose rank is shifted by
the number of rejected elements, when every rejected element is at or below it.
In a linear order, the rank-k order statistic of xs is the k-th entry of
xs.mergeSort.