Destuttering of Lists #
This file proves theorems about List.destutter
(in Data.List.Defs
), which greedily removes all
non-related items that are adjacent in a list, e.g. [2, 2, 3, 3, 2].destutter (≠) = [2, 3, 2]
.
Note that we make no guarantees of being the longest sublist with this property; e.g.,
[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]
, but a longer ascending chain could be
[1, 2, 5, 543, 1000]
.
Main statements #
List.destutter_sublist
:l.destutter
is a sublist ofl
.List.destutter_is_chain'
:l.destutter
satisfiesChain' R
.- Analogies of these theorems for
List.destutter'
, which is thedestutter
equivalent ofChain
.
Tags #
adjacent, chain, duplicates, remove, list, stutter, destutter
For a relation-preserving map, destutter
commutes with map
.
For a injective function f
, destutter' (·≠·)
commutes with map f
.
destutter'
on a relation like ≠ or <, whose negation is transitive, has length monotone
under a ¬R
changing of the first element.
List.destutter'
on a relation like ≠
, whose negation is an equivalence, gives the same
length if the first elements are not related.
List.destutter'
on a relation like ≠, whose negation is an equivalence, has length
monotonic under List.cons
List.destutter
on a relation like ≠, whose negation is an equivalence, has length
monotone under List.cons
destutter ≠
has length monotone under List.cons
.
destutter
of relations like ≠
, whose negation is an equivalence relation,
gives a list of maximal length over any chain.
In other words, l.destutter R
is an R
-chain sublist of l
, and is at least as long as any other
R
-chain sublist.
destutter
of ≠
gives a list of maximal length over any chain.
In other words, l.destutter (· ≠ ·)
is a ≠
-chain sublist of l
, and is at least as long as any
other ≠
-chain sublist.