Drop `Common.Set.Interval` and `Common.Set.Partition`.

finite-set-exercises
Joshua Potter 2023-07-25 07:28:00 -06:00
parent 1260c493bc
commit 7fe780e72f
6 changed files with 54 additions and 108 deletions

View File

@ -1,8 +1,6 @@
import Mathlib.Data.Real.Basic
import Common.Real.Floor import Common.Real.Floor
import Common.Geometry.StepFunction
import Common.Set.Basic import Common.Set.Basic
import Mathlib.Data.Real.Basic
/-! # Apostol.Chapter_1_11 -/ /-! # Apostol.Chapter_1_11 -/

View File

@ -1,6 +1,5 @@
import Mathlib.Data.Real.Basic
import Common.Set import Common.Set
import Mathlib.Data.Real.Basic
/-! # Apostol.Chapter_I_03 /-! # Apostol.Chapter_I_03

View File

@ -1,7 +1,7 @@
import Common.Finset import Common.Finset
import Common.Geometry.Rectangle.Orthogonal import Common.Geometry.Rectangle.Orthogonal
import Common.List.Basic import Common.List.Basic
import Common.Set.Partition import Common.List.NonEmpty
/-! # Common.Geometry.StepFunction /-! # Common.Geometry.StepFunction
@ -10,19 +10,63 @@ Characterization of step functions.
namespace Geometry namespace Geometry
open Set Partition /--
An interval defines a range of values, characterized by a "left" value and a
"right" value. We require these values to be distinct; we do not support the
notion of an empty interval.
-/
structure Interval (α : Type _) [LT α] where
left : α
right : α
h : left < right
namespace Interval
/--
Computes the size of the interval.
-/
def size [LT α] [Sub α] (i : Interval α) : α := i.right - i.left
/--
Computes the midpoint of the interval.
-/
def midpoint [LT α] [Add α] [HDiv α α] (i : Interval α) : α :=
(i.left + i.right) / (2 : )
/--
Convert an `Interval` into a `Set.Ico`.
-/
def toIco [Preorder α] (i : Interval α) : Set α := Set.Ico i.left i.right
/--
Convert an `Interval` into a `Set.Ioc`.
-/
def toIoc [Preorder α] (i : Interval α) : Set α := Set.Ioc i.left i.right
/--
Convert an `Interval` into a `Set.Icc`.
-/
def toIcc [Preorder α] (i : Interval α) : Set α := Set.Icc i.left i.right
/--
Convert an `Interval` into a `Set.Ioo`.
-/
def toIoo [Preorder α] (i : Interval α) : Set α := Set.Ioo i.left i.right
end Interval
/-- /--
A function `f`, whose domain is a closed interval `[a, b]`, is a `StepFunction` A function `f`, whose domain is a closed interval `[a, b]`, is a `StepFunction`
if there exists a `Partition` `P = {x₀, x₁, …, xₙ}` of `[a, b]` such that `f` is if there exists a partition `P = {x₀, x₁, …, xₙ}` of `[a, b]` such that `f` is
constant on each open subinterval of `P`. constant on each open subinterval of `P`.
Instead of maintaining a function from `[a, b]` to ``, we instead maintain a Instead of maintaining a function from `[a, b]` to ``, we instead maintain a
function that maps each `Partition` index to some constant value. function that maps each partition index to some constant value.
-/ -/
structure StepFunction where structure StepFunction where
p : Partition ivls : List.NonEmpty (Interval )
toFun : Fin p.ivls.length → connected : ∀ I ∈ ivls.toList.pairwise (·.right = ·.left), I
toFun : Fin ivls.length →
namespace StepFunction namespace StepFunction
@ -30,8 +74,8 @@ namespace StepFunction
The ordinate set of the `StepFunction`. The ordinate set of the `StepFunction`.
-/ -/
def toSet (sf : StepFunction) : Set Point := def toSet (sf : StepFunction) : Set Point :=
i ∈ Finset.finRange sf.p.ivls.length, i ∈ Finset.finRange sf.ivls.length,
let I := sf.p.ivls[i] let I := sf.ivls[i]
Rectangle.Orthogonal.toSet Rectangle.Orthogonal.toSet
{ {

View File

@ -1,4 +1,2 @@
import Common.Set.Basic import Common.Set.Basic
import Common.Set.Interval
import Common.Set.Partition
import Common.Set.Peano import Common.Set.Peano

View File

@ -1,56 +0,0 @@
import Mathlib.Data.Real.Basic
import Mathlib.Data.Set.Intervals.Basic
/-! # Common.Set.Interval
A representation of a range of values.
-/
namespace Set
/--
An interval defines a range of values, characterized by a "left" value and a
"right" value. We require these values to be distinct; we do not support the
notion of an empty interval.
-/
structure Interval (α : Type _) [LT α] where
left : α
right : α
h : left < right
namespace Interval
/--
Computes the size of the interval.
-/
def size [LT α] [Sub α] (i : Interval α) : α := i.right - i.left
/--
Computes the midpoint of the interval.
-/
def midpoint [LT α] [Add α] [HDiv α α] (i : Interval α) : α :=
(i.left + i.right) / (2 : )
/--
Convert an `Interval` into a `Set.Ico`.
-/
def toIco [Preorder α] (i : Interval α) : Set α := Set.Ico i.left i.right
/--
Convert an `Interval` into a `Set.Ioc`.
-/
def toIoc [Preorder α] (i : Interval α) : Set α := Set.Ioc i.left i.right
/--
Convert an `Interval` into a `Set.Icc`.
-/
def toIcc [Preorder α] (i : Interval α) : Set α := Set.Icc i.left i.right
/--
Convert an `Interval` into a `Set.Ioo`.
-/
def toIoo [Preorder α] (i : Interval α) : Set α := Set.Ioo i.left i.right
end Interval
end Set

View File

@ -1,37 +0,0 @@
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