diff --git a/Bookshelf/Apostol/Chapter_1_11.lean b/Bookshelf/Apostol/Chapter_1_11.lean index 63d8813..515684d 100644 --- a/Bookshelf/Apostol/Chapter_1_11.lean +++ b/Bookshelf/Apostol/Chapter_1_11.lean @@ -1,8 +1,6 @@ -import Mathlib.Data.Real.Basic - import Common.Real.Floor -import Common.Geometry.StepFunction import Common.Set.Basic +import Mathlib.Data.Real.Basic /-! # Apostol.Chapter_1_11 -/ diff --git a/Bookshelf/Apostol/Chapter_I_03.lean b/Bookshelf/Apostol/Chapter_I_03.lean index c5f0b39..0c7da3e 100644 --- a/Bookshelf/Apostol/Chapter_I_03.lean +++ b/Bookshelf/Apostol/Chapter_I_03.lean @@ -1,6 +1,5 @@ -import Mathlib.Data.Real.Basic - import Common.Set +import Mathlib.Data.Real.Basic /-! # Apostol.Chapter_I_03 diff --git a/Common/Geometry/StepFunction.lean b/Common/Geometry/StepFunction.lean index fd3119b..907165f 100644 --- a/Common/Geometry/StepFunction.lean +++ b/Common/Geometry/StepFunction.lean @@ -1,7 +1,7 @@ import Common.Finset import Common.Geometry.Rectangle.Orthogonal import Common.List.Basic -import Common.Set.Partition +import Common.List.NonEmpty /-! # Common.Geometry.StepFunction @@ -10,19 +10,63 @@ Characterization of step functions. 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` -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`. 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 - p : Partition ℝ - toFun : Fin p.ivls.length → ℝ + ivls : List.NonEmpty (Interval ℝ) + connected : ∀ I ∈ ivls.toList.pairwise (·.right = ·.left), I + toFun : Fin ivls.length → ℝ namespace StepFunction @@ -30,8 +74,8 @@ namespace StepFunction The ordinate set of the `StepFunction`. -/ def toSet (sf : StepFunction) : Set Point := - ⋃ i ∈ Finset.finRange sf.p.ivls.length, - let I := sf.p.ivls[i] + ⋃ i ∈ Finset.finRange sf.ivls.length, + let I := sf.ivls[i] Rectangle.Orthogonal.toSet ⟨ { diff --git a/Common/Set.lean b/Common/Set.lean index 4be289c..44465b9 100644 --- a/Common/Set.lean +++ b/Common/Set.lean @@ -1,4 +1,2 @@ import Common.Set.Basic -import Common.Set.Interval -import Common.Set.Partition import Common.Set.Peano \ No newline at end of file diff --git a/Common/Set/Interval.lean b/Common/Set/Interval.lean deleted file mode 100644 index b698cb2..0000000 --- a/Common/Set/Interval.lean +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Common/Set/Partition.lean b/Common/Set/Partition.lean deleted file mode 100644 index 8b2ee8a..0000000 --- a/Common/Set/Partition.lean +++ /dev/null @@ -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 \ No newline at end of file