bookshelf/Common/Set/Partition.lean

41 lines
1022 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import Mathlib.Data.Finset.Basic
import Mathlib.Data.List.Sort
import Mathlib.Data.Set.Intervals.Basic
import Common.List.Basic
import Common.List.NonEmpty
import Common.Set.Interval
/-! # Common.Set.Partition
Additional theorems and definitions useful in the context of sets.
-/
namespace Set
/--
A `Partition` is a finite subset of `[a, b]` containing points `a` and `b`.
We use a `List.NonEmpty` internally to ensure the existence of at least one
`Interval`, which cannot be empty. Thus our `Partition` can never be empty.
The intervals are sorted via the `connected` proposition.
-/
structure Partition (α : Type _) [LT α] where
ivls : List.NonEmpty (Interval α)
connected : ∀ I ∈ ivls.toList.pairwise (·.right = ·.left), I
namespace Partition
/--
Return the left-most endpoint of the `Partition`.
-/
def left [LT α] (p : Partition α) := p.ivls.head.left
/--
Return the right-most endpoint of the `Partition`.
-/
def right [LT α] (p : Partition α) := p.ivls.last.right
end Partition
end Set