bookshelf/Common/Set/Partition.lean

37 lines
918 B
Plaintext
Raw Normal View History

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.
2023-05-13 01:31:44 +00:00
-/
structure Partition (α : Type _) [LT α] where
ivls : List.NonEmpty (Interval α)
connected : ∀ I ∈ ivls.toList.pairwise (·.right = ·.left), I
2023-05-13 01:31:44 +00:00
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