2023-05-12 19:17:34 +00:00
|
|
|
|
import Common.List.Basic
|
2023-05-15 14:00:01 +00:00
|
|
|
|
import Common.List.NonEmpty
|
|
|
|
|
import Common.Set.Interval
|
2023-05-12 19:17:34 +00:00
|
|
|
|
|
2023-05-15 01:32:18 +00:00
|
|
|
|
/-! # Common.Set.Partition
|
2023-05-12 19:17:34 +00:00
|
|
|
|
|
|
|
|
|
Additional theorems and definitions useful in the context of sets.
|
|
|
|
|
-/
|
|
|
|
|
|
2023-05-15 01:32:18 +00:00
|
|
|
|
namespace Set
|
2023-05-12 19:17:34 +00:00
|
|
|
|
|
|
|
|
|
/--
|
|
|
|
|
A `Partition` is a finite subset of `[a, b]` containing points `a` and `b`.
|
|
|
|
|
|
2023-05-15 14:00:01 +00:00
|
|
|
|
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
|
|
|
|
-/
|
2023-05-15 14:00:01 +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
|
|
|
|
|
2023-05-15 14:00:01 +00:00
|
|
|
|
namespace Partition
|
2023-05-12 19:17:34 +00:00
|
|
|
|
|
|
|
|
|
/--
|
2023-05-15 14:00:01 +00:00
|
|
|
|
Return the left-most endpoint of the `Partition`.
|
2023-05-12 19:17:34 +00:00
|
|
|
|
-/
|
2023-05-15 14:00:01 +00:00
|
|
|
|
def left [LT α] (p : Partition α) := p.ivls.head.left
|
2023-05-12 19:17:34 +00:00
|
|
|
|
|
|
|
|
|
/--
|
2023-05-15 14:00:01 +00:00
|
|
|
|
Return the right-most endpoint of the `Partition`.
|
2023-05-12 19:17:34 +00:00
|
|
|
|
-/
|
2023-05-15 14:00:01 +00:00
|
|
|
|
def right [LT α] (p : Partition α) := p.ivls.last.right
|
2023-05-12 19:17:34 +00:00
|
|
|
|
|
|
|
|
|
end Partition
|
|
|
|
|
|
2023-05-15 01:32:18 +00:00
|
|
|
|
end Set
|