diff --git a/common/Common.lean b/common/Common.lean index fe57c61..9a4c831 100644 --- a/common/Common.lean +++ b/common/Common.lean @@ -1,4 +1,3 @@ -import Common.Data.Real.Geometry -import Common.Data.Real.Set -import Common.Data.Real.Sequence +import Common.List +import Common.Real import Common.Tuple diff --git a/common/Common/Data/Real/Geometry.lean b/common/Common/Data/Real/Geometry.lean deleted file mode 100644 index 1eb8d8c..0000000 --- a/common/Common/Data/Real/Geometry.lean +++ /dev/null @@ -1,2 +0,0 @@ -import Common.Data.Real.Geometry.Basic -import Common.Data.Real.Geometry.Rectangle \ No newline at end of file diff --git a/common/Common/Data/Real/Geometry/Rectangle.lean b/common/Common/Data/Real/Geometry/Rectangle.lean deleted file mode 100644 index ac754fc..0000000 --- a/common/Common/Data/Real/Geometry/Rectangle.lean +++ /dev/null @@ -1,39 +0,0 @@ -import Common.Data.Real.Geometry.Basic - -namespace Real - -/-- -A `Rectangle` is characterized by two points defining opposite corners. We -arbitrarily choose the bottom left and top right points to perform this -characterization. --/ -structure Rectangle (bottom_left : ℝ²) (top_right : ℝ²) - -namespace Rectangle - -/-- -A `Rectangle` is the locus of points making up its edges. --/ -def set_eq (r : Rectangle x y) : Set ℝ² := sorry - -/-- -Computes the bottom right corner of a `Rectangle`. --/ -def bottom_right (r : Rectangle x y) : ℝ² := sorry - -/-- -Computes the top left corner of a `Rectangle`. --/ -def top_left (r : Rectangle x y) : ℝ² := sorry - -/-- -Computes the width of a `Rectangle`. --/ -def width (r : Rectangle x y) : ℝ := sorry - -/-- -Computes the height of a `Rectangle`. --/ -def height (r : Rectangle x y) : ℝ := sorry - -end Real.Rectangle \ No newline at end of file diff --git a/common/Common/Data/Real/Sequence.lean b/common/Common/Data/Real/Sequence.lean deleted file mode 100644 index 1b0cdf5..0000000 --- a/common/Common/Data/Real/Sequence.lean +++ /dev/null @@ -1,2 +0,0 @@ -import Common.Data.Real.Sequence.Arithmetic -import Common.Data.Real.Sequence.Geometric \ No newline at end of file diff --git a/common/Common/List.lean b/common/Common/List.lean new file mode 100644 index 0000000..798f875 --- /dev/null +++ b/common/Common/List.lean @@ -0,0 +1 @@ +import Common.List.Basic \ No newline at end of file diff --git a/common/Common/List/Basic.lean b/common/Common/List/Basic.lean new file mode 100644 index 0000000..991fc83 --- /dev/null +++ b/common/Common/List/Basic.lean @@ -0,0 +1,31 @@ +import Mathlib.Logic.Basic + +namespace List + +/-- +The length of any empty list is definitionally zero. +-/ +theorem nil_length_eq_zero : @length α [] = 0 := rfl + +/-- +If the length of a list is greater than zero, it cannot be `List.nil`. +-/ +theorem length_gt_zero_imp_not_nil : xs.length > 0 → xs ≠ [] := by + intro h + by_contra nh + rw [nh] at h + have : 0 > 0 := calc 0 + _ = length [] := by rw [←nil_length_eq_zero] + _ > 0 := h + simp at this + +/-- +Given a list `xs` of length `k`, produces a list of length `k - 1` where the +`i`th member of the resulting list is `f xs[i] xs[i + 1]`. +-/ +def pairwise (xs : List α) (f : α → α → β) : List β := + match xs.tail? with + | none => [] + | some ys => zipWith f xs ys + +end List \ No newline at end of file diff --git a/common/Common/Real.lean b/common/Common/Real.lean new file mode 100644 index 0000000..2f95067 --- /dev/null +++ b/common/Common/Real.lean @@ -0,0 +1,5 @@ +import Common.Real.Basic +import Common.Real.Function +import Common.Real.Geometry +import Common.Real.Sequence +import Common.Real.Set \ No newline at end of file diff --git a/common/Common/Real/Basic.lean b/common/Common/Real/Basic.lean new file mode 100644 index 0000000..db92ca5 --- /dev/null +++ b/common/Common/Real/Basic.lean @@ -0,0 +1,5 @@ +import Mathlib.Data.Real.Basic + +notation "ℝ²" => ℝ × ℝ + +notation "ℝ³" => ℝ² × ℝ \ No newline at end of file diff --git a/common/Common/Real/Function.lean b/common/Common/Real/Function.lean new file mode 100644 index 0000000..c2a2a7a --- /dev/null +++ b/common/Common/Real/Function.lean @@ -0,0 +1 @@ +import Common.Real.Function.Step \ No newline at end of file diff --git a/common/Common/Real/Function/Step.lean b/common/Common/Real/Function/Step.lean new file mode 100644 index 0000000..55c49f2 --- /dev/null +++ b/common/Common/Real/Function/Step.lean @@ -0,0 +1,38 @@ +import Mathlib.Data.Fin.Basic +import Mathlib.Tactic.NormNum + +import Common.Real.Basic +import Common.Real.Set.Partition + +namespace Real.Function + +/-- +Any member of a subinterval of a partition `P` must also be a member of `P`. +-/ +lemma mem_open_subinterval_imp_mem_partition {p : Partition} + (hI : I ∈ p.xs.pairwise (fun x₁ x₂ => i(x₁, x₂))) + (hy : y ∈ I) : y ∈ p := by + unfold List.pairwise at hI + have ⟨ys, hys⟩ : ∃ ys, List.tail? p.xs = some ys := sorry + conv at hI => arg 2; rw [hys]; simp only + sorry + +/-- +A `Step` function is a function `f` along with a proof of the existence of some +partition `P` such that `f` is constant on every open subinterval of `P`. +-/ +structure Step where + p : Partition + f : ∀ x ∈ p, ℝ + const_open_subintervals : + ∀ (hI : I ∈ p.xs.pairwise (fun x₁ x₂ => i(x₁, x₂))), + ∃ c : ℝ, ∀ (hy : y ∈ I), + f y (mem_open_subinterval_imp_mem_partition hI hy) = c + +namespace Step + +def set_def (f : Step) : Set ℝ² := sorry + +-- TODO: Fill out + +end Real.Function.Step \ No newline at end of file diff --git a/common/Common/Real/Geometry.lean b/common/Common/Real/Geometry.lean new file mode 100644 index 0000000..220e9c6 --- /dev/null +++ b/common/Common/Real/Geometry.lean @@ -0,0 +1,2 @@ +import Common.Real.Geometry.Basic +import Common.Real.Geometry.Rectangle \ No newline at end of file diff --git a/common/Common/Data/Real/Geometry/Basic.lean b/common/Common/Real/Geometry/Basic.lean similarity index 81% rename from common/Common/Data/Real/Geometry/Basic.lean rename to common/Common/Real/Geometry/Basic.lean index b6756d6..c26299e 100644 --- a/common/Common/Data/Real/Geometry/Basic.lean +++ b/common/Common/Real/Geometry/Basic.lean @@ -1,9 +1,18 @@ import Mathlib.Data.Real.Sqrt -notation "ℝ²" => ℝ × ℝ +import Common.Real.Basic namespace Real +/-- +The undirected angle at `p2` between the line segments to `p1` and `p3`. + +PORT: `geometry.euclidean.angle` +-/ +axiom angle (p₁ p₂ p₃ : ℝ²) (h : p₁ ≠ p₂ ∧ p₂ ≠ p₃ ∧ p₃ ≠ p₁): ℝ + +notation "∠" => angle + /-- Determine the distance between two points in `ℝ²`. -/ diff --git a/common/Common/Real/Geometry/Rectangle.lean b/common/Common/Real/Geometry/Rectangle.lean new file mode 100644 index 0000000..b10efb0 --- /dev/null +++ b/common/Common/Real/Geometry/Rectangle.lean @@ -0,0 +1,44 @@ +import Common.Real.Geometry.Basic + +namespace Real + +/-- +A `Rectangle` is characterized by three distinct points and the angle formed +between line segments originating from the "bottom left" point. +-/ +structure Rectangle where + top_left : ℝ² + bottom_left : ℝ² + bottom_right : ℝ² + distinct_vertices : + top_left ≠ bottom_left ∧ bottom_left ≠ bottom_right ∧ bottom_right ≠ top_left + forms_right_angle : + ∠ top_left bottom_left bottom_right distinct_vertices = π / 2 + +namespace Rectangle + +/-- +A calculation of the missing point. +-/ +def top_right (r : Rectangle) : ℝ² := + sorry + +/-- +A `Rectangle` is the locus of points bounded by its edges. +-/ +def set_def (r : Rectangle) : Set ℝ² := + sorry + +/-- +Computes the width of a `Rectangle`. +-/ +noncomputable def width (r : Rectangle) : ℝ := + dist r.bottom_left r.top_left + +/-- +Computes the height of a `Rectangle`. +-/ +noncomputable def height (r : Rectangle) : ℝ := + dist r.bottom_left r.bottom_right + +end Real.Rectangle \ No newline at end of file diff --git a/common/Common/Real/Sequence.lean b/common/Common/Real/Sequence.lean new file mode 100644 index 0000000..b08da38 --- /dev/null +++ b/common/Common/Real/Sequence.lean @@ -0,0 +1,2 @@ +import Common.Real.Sequence.Arithmetic +import Common.Real.Sequence.Geometric \ No newline at end of file diff --git a/common/Common/Data/Real/Sequence.tex b/common/Common/Real/Sequence.tex similarity index 100% rename from common/Common/Data/Real/Sequence.tex rename to common/Common/Real/Sequence.tex diff --git a/common/Common/Data/Real/Sequence/Arithmetic.lean b/common/Common/Real/Sequence/Arithmetic.lean similarity index 100% rename from common/Common/Data/Real/Sequence/Arithmetic.lean rename to common/Common/Real/Sequence/Arithmetic.lean diff --git a/common/Common/Data/Real/Sequence/Geometric.lean b/common/Common/Real/Sequence/Geometric.lean similarity index 100% rename from common/Common/Data/Real/Sequence/Geometric.lean rename to common/Common/Real/Sequence/Geometric.lean diff --git a/common/Common/Real/Set.lean b/common/Common/Real/Set.lean new file mode 100644 index 0000000..e7b2fc3 --- /dev/null +++ b/common/Common/Real/Set.lean @@ -0,0 +1,3 @@ +import Common.Real.Set.Basic +import Common.Real.Set.Interval +import Common.Real.Set.Partition \ No newline at end of file diff --git a/common/Common/Data/Real/Set.lean b/common/Common/Real/Set/Basic.lean similarity index 100% rename from common/Common/Data/Real/Set.lean rename to common/Common/Real/Set/Basic.lean diff --git a/common/Common/Real/Set/Interval.lean b/common/Common/Real/Set/Interval.lean new file mode 100644 index 0000000..6f24d9c --- /dev/null +++ b/common/Common/Real/Set/Interval.lean @@ -0,0 +1,33 @@ +import Mathlib.Data.Real.Basic + +/-- +Representation of a closed interval. +-/ +syntax (priority := high) "i[" term "," term "]" : term + +macro_rules + | `(i[$a, $b]) => `({ z | $a ≤ z ∧ z ≤ $b }) + +/-- +Representation of an open interval. +-/ +syntax (priority := high) "i(" term "," term ")" : term + +macro_rules + | `(i($a, $b)) => `({ z | $a < z ∧ z < $b }) + +/-- +Representation of a left half-open interval. +-/ +syntax (priority := high) "i(" term "," term "]" : term + +macro_rules + | `(i($a, $b]) => `({ z | $a < z ∧ z ≤ $b }) + +/-- +Representation of a right half-open interval. +-/ +syntax (priority := high) "i[" term "," term ")" : term + +macro_rules + | `(i[$a, $b)) => `({ z | $a ≤ z ∧ z < $b }) \ No newline at end of file diff --git a/common/Common/Real/Set/Partition.lean b/common/Common/Real/Set/Partition.lean new file mode 100644 index 0000000..44cddbe --- /dev/null +++ b/common/Common/Real/Set/Partition.lean @@ -0,0 +1,45 @@ +import Common.List.Basic +import Common.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 \ No newline at end of file diff --git a/one-variable-calculus/Apostol.lean b/one-variable-calculus/Apostol.lean index d6b3cbf..5f2550f 100644 --- a/one-variable-calculus/Apostol.lean +++ b/one-variable-calculus/Apostol.lean @@ -1 +1,2 @@ import Apostol.Chapter_I_3 +import Apostol.Exercises \ No newline at end of file diff --git a/one-variable-calculus/Apostol/Chapter_1_6.lean b/one-variable-calculus/Apostol/Chapter_1_6.lean new file mode 100644 index 0000000..beee9cf --- /dev/null +++ b/one-variable-calculus/Apostol/Chapter_1_6.lean @@ -0,0 +1,157 @@ +/- +Chapter 1.6 + +The concept of area as a set function +-/ +import Common.Real.Function.Step +import Common.Real.Geometry.Rectangle + +namespace Real + +/-- +All *measurable sets*, i.e. sets in the plane to which an area can be assigned. + +The existence of such a class is assumed in the axiomatic definition of area +introduced by Apostol. He denotes this set of sets as `𝓜`. +-/ +axiom 𝓜 : Set (Set ℝ²) + +/-- +A set function mapping every *measurable set* to a value denoting its area. + +The existence of such a function is assumed in the axiomatic definition of area +introduced by Apostol. He denotes this function as `a`. +-/ +axiom area : ∀ ⦃x⦄, x ∈ 𝓜 → ℝ + +/-- +The nonnegative property. + +For each set `S` in `𝓜`, we have `a(S) ≥ 0`. +-/ +axiom area_ge_zero {S : Set ℝ²} (h : S ∈ 𝓜): area h ≥ 0 + +/-- +The additive property (i). + +If `S` and `T` are in `𝓜`, then `S ∪ T` in `𝓜`. +-/ +axiom measureable_imp_union_measurable {S T : Set ℝ²} (hS : S ∈ 𝓜) (hT : T ∈ 𝓜) + : S ∪ T ∈ 𝓜 + +/-- +The additive property (ii). + +If `S` and `T` are in `𝓜`, then `S ∩ T` in `𝓜`. +-/ +axiom measurable_imp_inter_measurable {S T : Set ℝ²} (hS : S ∈ 𝓜) (hT : T ∈ 𝓜) + : S ∩ T ∈ 𝓜 + +/-- +The additive property (iii). + +If `S` and `T` are in `𝓜`, then `a(S ∪ T) = a(S) + a(T) - a(S ∩ T)`. +-/ +axiom union_area_eq_area_add_area_sub_inter_area + {S T : Set ℝ²} (hS : S ∈ 𝓜) (hT : T ∈ 𝓜) + : area (measureable_imp_union_measurable hS hT) = + area hS + area hT - area (measurable_imp_inter_measurable hS hT) + +/-- +The difference property (i). + +If `S` and `T` are in `𝓜` with `S ⊆ T`, then `T - S` is in `𝓜`. +-/ +axiom measureable_imp_diff_measurable + {S T : Set ℝ²} (hS : S ∈ 𝓜) (hT : T ∈ 𝓜) (h : S ⊆ T) + : T \ S ∈ 𝓜 + +/-- +The difference property (ii). + +If `S` and `T` are in `𝓜` with `S ⊆ T`, then `a(T - S) = a(T) - a(S)`. +-/ +axiom diff_area_eq_area_sub_area + {S T : Set ℝ²} (hS : S ∈ 𝓜) (hT : T ∈ 𝓜) (h : S ⊆ T) + : area (measureable_imp_diff_measurable hS hT h) = area hT - area hS + +/-- +Invariance under congruence (i). + +If a set `S` is in `𝓜` and if `T` is congruent to `S`, then `T` is also in `𝓜`.. +-/ +axiom measurable_congruent_imp_measurable + {S T : Set ℝ²} (hS : S ∈ 𝓜) (h : congruent S T) + : T ∈ 𝓜 + +/-- +Invariance under congruence (ii). + +If a set `S` is in `𝓜` and if `T` is congruent to `S`, then `a(S) = a(T)`. +-/ +axiom congruent_imp_area_eq_area + {S T : Set ℝ²} (hS : S ∈ 𝓜) (h : congruent S T) + : area hS = area (measurable_congruent_imp_measurable hS h) + +/-- +Choice of scale (i). + +Every rectangle `R` is in `𝓜`. +-/ +axiom rectangle_measurable (R : Rectangle) + : R.set_def ∈ 𝓜 + +/-- +Choice of scale (ii). + +If the edges of rectangle `R` have lengths `h` and `k`, then `a(R) = hk`. +-/ +axiom rectangle_area_eq_mul_edge_lengths (R : Rectangle) + : area (rectangle_measurable R) = R.width * R.height + +/-- +Every step region is measurable. This follows from the choice of scale axiom, +and the fact all step regions are equivalent to the union of a collection of +rectangles. +-/ +theorem step_function_measurable (S : Function.Step) : S.set_def ∈ 𝓜 := by + sorry + +/-- +Exhaustion property. + +Let `Q` be a set that can be enclosed between two step regions `S` and `T`, so +that (1.1) `S ⊆ Q ⊆ T`. If there is one and only one number `k` which satisfies +the inequalities `a(S) ≤ k ≤ a(T)` for all step regions `S` and `T` satisfying +(1.1), then `Q` is measurable and `a(Q) = k`. +-/ +def forall_subset_between_step_imp_le_between_area (k : ℝ) (Q : Set ℝ²) := + ∀ S T : Function.Step, + (hS : S.set_def ⊆ Q) → + (hT : Q ⊆ T.set_def) → + area (step_function_measurable S) ≤ k ∧ k ≤ area (step_function_measurable T) + +/-- +Exhaustion property (i). + +If there exists some `k` satisfying the description in the above `def`, then `Q` +is measurable. +-/ +axiom exhaustion_exists_unique_imp_measurable (Q : Set ℝ²) + : (∃ k : ℝ, forall_subset_between_step_imp_le_between_area k Q ∧ + (∀ x : ℝ, forall_subset_between_step_imp_le_between_area x Q → x = k)) + → Q ∈ 𝓜 + +/-- +Exhaustion property (ii). + +If there exists some `k` satisfying the description in the above `def`, then `Q` +satisfies `a(Q) = k`. +-/ +axiom exhaustion_exists_unique_imp_area_eq (Q : Set ℝ²) + : ∃ k : ℝ, + (h : forall_subset_between_step_imp_le_between_area k Q ∧ + (∀ x : ℝ, forall_subset_between_step_imp_le_between_area x Q → x = k)) + → area (exhaustion_exists_unique_imp_measurable Q ⟨k, h⟩) = k + +end Real diff --git a/one-variable-calculus/Apostol/Chapter_I_3.lean b/one-variable-calculus/Apostol/Chapter_I_3.lean index ff742dd..bd43f34 100644 --- a/one-variable-calculus/Apostol/Chapter_I_3.lean +++ b/one-variable-calculus/Apostol/Chapter_I_3.lean @@ -3,7 +3,7 @@ Chapter I 3 A Set of Axioms for the Real-Number System -/ -import Common.Data.Real.Set +import Common.Real.Set #check Archimedean #check Real.exists_isLUB diff --git a/one-variable-calculus/Apostol/Exercises.lean b/one-variable-calculus/Apostol/Exercises.lean new file mode 100644 index 0000000..e0f7a10 --- /dev/null +++ b/one-variable-calculus/Apostol/Exercises.lean @@ -0,0 +1 @@ +import Apostol.Exercises.Exercises_I_3_12 \ No newline at end of file diff --git a/one-variable-calculus/Apostol/Exercises_I_3_12.lean b/one-variable-calculus/Apostol/Exercises/Exercises_I_3_12.lean similarity index 100% rename from one-variable-calculus/Apostol/Exercises_I_3_12.lean rename to one-variable-calculus/Apostol/Exercises/Exercises_I_3_12.lean