This file contains auxiliary results about lists that do not have anything to do with Formale Systeme.
Eliminates duplicates from a list, keeping the rightmost occurrence. (Implementation copied from https://github.com/monsterkrampe/Basic-Lean-Datastructures/blob/main/BasicLeanDatastructures/List/EraseDupsKeepRight.lean)
Equations
- [].removeDups = []
- (hd :: tl).removeDups = if hd ∈ tl then tl.removeDups else hd :: tl.removeDups
Instances For
Removing duplicates from a list does not change the elements contained in it.
theorem
List.removeDups_count
{α : Type u_1}
[DecidableEq α]
(l : List α)
(a : α)
:
a ∈ l → count a l.removeDups = 1
In a list with removed duplicates, each element has count 1.
@[implicit_reducible]
Infix is decidable for Lists whose elements have decidable equality. (The proof is essentially the expanded version of the one from mathlib)
Equations
- [].decidableInfix x✝ = isTrue ⋯
- (a :: k).decidableInfix [] = isFalse ⋯
- x✝.decidableInfix (b :: l) = decidable_of_decidable_of_iff ⋯