bookshelf/shared/Bookshelf/Real/Set/Partition.lean

46 lines
1.2 KiB
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 Bookshelf.List.Basic
import Bookshelf.Real.Set.Interval
namespace Real
/--
A `Partition` is some finite subset of `[a, b]` containing points `a` and `b`.
It is assumed that the points of the `Partition` are distinct and sorted. The
use of a `List` ensures finite-ness.
-/
structure Partition where
xs : List
has_min_length : xs.length ≥ 2
sorted : ∀ x ∈ xs.pairwise (fun x₁ x₂ => x₁ < x₂), x
namespace Partition
lemma length_partition_gt_zero (p : Partition) : p.xs.length > 0 :=
calc p.xs.length
_ ≥ 2 := p.has_min_length
_ > 0 := by simp
/--
The left-most subdivision point of the `Partition`.
-/
def a (p : Partition) : :=
p.xs.head (List.length_gt_zero_imp_not_nil (length_partition_gt_zero p))
/--
The right-most subdivision point of the `Partition`.
-/
def b (p : Partition) : :=
p.xs.getLast (List.length_gt_zero_imp_not_nil (length_partition_gt_zero p))
/--
Define `∈` syntax for a `Partition`. We say a real is a member of a partition
provided it lies somewhere in closed interval `[a, b]`.
-/
instance : Membership Partition where
mem (x : ) (p : Partition) := p.a ≤ x ∧ x ≤ p.b
end Partition
end Real