|
| 1 | +/- |
| 2 | +Copyright (c) 2020 Yury Kudryashov. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Yury Kudryashov |
| 5 | +
|
| 6 | +! This file was ported from Lean 3 source module data.set.intervals.pi |
| 7 | +! leanprover-community/mathlib commit 207cfac9fcd06138865b5d04f7091e46d9320432 |
| 8 | +! Please do not edit these lines, except to modify the commit id |
| 9 | +! if you have ported upstream changes. |
| 10 | +-/ |
| 11 | +import Mathlib.Data.Set.Intervals.Basic |
| 12 | +import Mathlib.Data.Set.Lattice |
| 13 | + |
| 14 | +/-! |
| 15 | +# Intervals in `pi`-space |
| 16 | +
|
| 17 | +In this we prove various simple lemmas about intervals in `Π i, α i`. Closed intervals (`Ici x`, |
| 18 | +`Iic x`, `Icc x y`) are equal to products of their projections to `α i`, while (semi-)open intervals |
| 19 | +usually include the corresponding products as proper subsets. |
| 20 | +-/ |
| 21 | + |
| 22 | +variable {ι : Type _} {α : ι → Type _} |
| 23 | + |
| 24 | +namespace Set |
| 25 | + |
| 26 | +section PiPreorder |
| 27 | + |
| 28 | +variable [∀ i, Preorder (α i)] (x y : ∀ i, α i) |
| 29 | + |
| 30 | +@[simp] |
| 31 | +theorem pi_univ_Ici : (pi univ fun i ↦ Ici (x i)) = Ici x := |
| 32 | + ext fun y ↦ by simp [Pi.le_def] |
| 33 | +#align set.pi_univ_Ici Set.pi_univ_Ici |
| 34 | + |
| 35 | +@[simp] |
| 36 | +theorem pi_univ_Iic : (pi univ fun i ↦ Iic (x i)) = Iic x := |
| 37 | + ext fun y ↦ by simp [Pi.le_def] |
| 38 | +#align set.pi_univ_Iic Set.pi_univ_Iic |
| 39 | + |
| 40 | +@[simp] |
| 41 | +theorem pi_univ_Icc : (pi univ fun i ↦ Icc (x i) (y i)) = Icc x y := |
| 42 | + ext fun y ↦ by simp [Pi.le_def, forall_and] |
| 43 | +#align set.pi_univ_Icc Set.pi_univ_Icc |
| 44 | + |
| 45 | +theorem piecewise_mem_Icc {s : Set ι} [∀ j, Decidable (j ∈ s)] {f₁ f₂ g₁ g₂ : ∀ i, α i} |
| 46 | + (h₁ : ∀ i ∈ s, f₁ i ∈ Icc (g₁ i) (g₂ i)) (h₂ : ∀ (i) (_ : i ∉ s), f₂ i ∈ Icc (g₁ i) (g₂ i)) : |
| 47 | + s.piecewise f₁ f₂ ∈ Icc g₁ g₂ := |
| 48 | + ⟨le_piecewise (fun i hi ↦ (h₁ i hi).1) fun i hi ↦ (h₂ i hi).1, |
| 49 | + piecewise_le (fun i hi ↦ (h₁ i hi).2) fun i hi ↦ (h₂ i hi).2⟩ |
| 50 | +#align set.piecewise_mem_Icc Set.piecewise_mem_Icc |
| 51 | + |
| 52 | +theorem piecewise_mem_Icc' {s : Set ι} [∀ j, Decidable (j ∈ s)] {f₁ f₂ g₁ g₂ : ∀ i, α i} |
| 53 | + (h₁ : f₁ ∈ Icc g₁ g₂) (h₂ : f₂ ∈ Icc g₁ g₂) : s.piecewise f₁ f₂ ∈ Icc g₁ g₂ := |
| 54 | + piecewise_mem_Icc (fun _ _ ↦ ⟨h₁.1 _, h₁.2 _⟩) fun _ _ ↦ ⟨h₂.1 _, h₂.2 _⟩ |
| 55 | +#align set.piecewise_mem_Icc' Set.piecewise_mem_Icc' |
| 56 | + |
| 57 | +section Nonempty |
| 58 | + |
| 59 | +variable [Nonempty ι] |
| 60 | + |
| 61 | +theorem pi_univ_Ioi_subset : (pi univ fun i ↦ Ioi (x i)) ⊆ Ioi x := fun z hz ↦ |
| 62 | + ⟨fun i ↦ le_of_lt <| hz i trivial, fun h ↦ |
| 63 | + (Nonempty.elim ‹Nonempty ι›) fun i ↦ not_lt_of_le (h i) (hz i trivial)⟩ |
| 64 | +#align set.pi_univ_Ioi_subset Set.pi_univ_Ioi_subset |
| 65 | + |
| 66 | +theorem pi_univ_Iio_subset : (pi univ fun i ↦ Iio (x i)) ⊆ Iio x := |
| 67 | + @pi_univ_Ioi_subset ι (fun i ↦ (α i)ᵒᵈ) _ x _ |
| 68 | +#align set.pi_univ_Iio_subset Set.pi_univ_Iio_subset |
| 69 | + |
| 70 | +theorem pi_univ_Ioo_subset : (pi univ fun i ↦ Ioo (x i) (y i)) ⊆ Ioo x y := fun _ hx ↦ |
| 71 | + ⟨(pi_univ_Ioi_subset _) fun i hi ↦ (hx i hi).1, (pi_univ_Iio_subset _) fun i hi ↦ (hx i hi).2⟩ |
| 72 | +#align set.pi_univ_Ioo_subset Set.pi_univ_Ioo_subset |
| 73 | + |
| 74 | +theorem pi_univ_Ioc_subset : (pi univ fun i ↦ Ioc (x i) (y i)) ⊆ Ioc x y := fun _ hx ↦ |
| 75 | + ⟨(pi_univ_Ioi_subset _) fun i hi ↦ (hx i hi).1, fun i ↦ (hx i trivial).2⟩ |
| 76 | +#align set.pi_univ_Ioc_subset Set.pi_univ_Ioc_subset |
| 77 | + |
| 78 | +theorem pi_univ_Ico_subset : (pi univ fun i ↦ Ico (x i) (y i)) ⊆ Ico x y := fun _ hx ↦ |
| 79 | + ⟨fun i ↦ (hx i trivial).1, (pi_univ_Iio_subset _) fun i hi ↦ (hx i hi).2⟩ |
| 80 | +#align set.pi_univ_Ico_subset Set.pi_univ_Ico_subset |
| 81 | + |
| 82 | +end Nonempty |
| 83 | + |
| 84 | +variable [DecidableEq ι] |
| 85 | + |
| 86 | +open Function (update) |
| 87 | + |
| 88 | +theorem pi_univ_Ioc_update_left {x y : ∀ i, α i} {i₀ : ι} {m : α i₀} (hm : x i₀ ≤ m) : |
| 89 | + (pi univ fun i ↦ Ioc (update x i₀ m i) (y i)) = |
| 90 | + { z | m < z i₀ } ∩ pi univ fun i ↦ Ioc (x i) (y i) := |
| 91 | + by |
| 92 | + have : Ioc m (y i₀) = Ioi m ∩ Ioc (x i₀) (y i₀) := by |
| 93 | + rw [← Ioi_inter_Iic, ← Ioi_inter_Iic, ← inter_assoc, |
| 94 | + inter_eq_self_of_subset_left (Ioi_subset_Ioi hm)] |
| 95 | + simp_rw [univ_pi_update i₀ _ _ fun i z ↦ Ioc z (y i), ← pi_inter_compl ({i₀} : Set ι), |
| 96 | + singleton_pi', ← inter_assoc, this] |
| 97 | + rfl |
| 98 | +#align set.pi_univ_Ioc_update_left Set.pi_univ_Ioc_update_left |
| 99 | + |
| 100 | +theorem pi_univ_Ioc_update_right {x y : ∀ i, α i} {i₀ : ι} {m : α i₀} (hm : m ≤ y i₀) : |
| 101 | + (pi univ fun i ↦ Ioc (x i) (update y i₀ m i)) = |
| 102 | + { z | z i₀ ≤ m } ∩ pi univ fun i ↦ Ioc (x i) (y i) := |
| 103 | + by |
| 104 | + have : Ioc (x i₀) m = Iic m ∩ Ioc (x i₀) (y i₀) := by |
| 105 | + rw [← Ioi_inter_Iic, ← Ioi_inter_Iic, inter_left_comm, |
| 106 | + inter_eq_self_of_subset_left (Iic_subset_Iic.2 hm)] |
| 107 | + simp_rw [univ_pi_update i₀ y m fun i z ↦ Ioc (x i) z, ← pi_inter_compl ({i₀} : Set ι), |
| 108 | + singleton_pi', ← inter_assoc, this] |
| 109 | + rfl |
| 110 | +#align set.pi_univ_Ioc_update_right Set.pi_univ_Ioc_update_right |
| 111 | + |
| 112 | +theorem disjoint_pi_univ_Ioc_update_left_right {x y : ∀ i, α i} {i₀ : ι} {m : α i₀} : |
| 113 | + Disjoint (pi univ fun i ↦ Ioc (x i) (update y i₀ m i)) |
| 114 | + (pi univ fun i ↦ Ioc (update x i₀ m i) (y i)) := |
| 115 | + by |
| 116 | + rw [disjoint_left] |
| 117 | + rintro z h₁ h₂ |
| 118 | + refine' (h₁ i₀ (mem_univ _)).2.not_lt _ |
| 119 | + simpa only [Function.update_same] using (h₂ i₀ (mem_univ _)).1 |
| 120 | +#align set.disjoint_pi_univ_Ioc_update_left_right Set.disjoint_pi_univ_Ioc_update_left_right |
| 121 | + |
| 122 | +end PiPreorder |
| 123 | + |
| 124 | +variable [DecidableEq ι] [∀ i, LinearOrder (α i)] |
| 125 | + |
| 126 | +open Function (update) |
| 127 | + |
| 128 | +theorem pi_univ_Ioc_update_union (x y : ∀ i, α i) (i₀ : ι) (m : α i₀) (hm : m ∈ Icc (x i₀) (y i₀)) : |
| 129 | + ((pi univ fun i ↦ Ioc (x i) (update y i₀ m i)) ∪ |
| 130 | + pi univ fun i ↦ Ioc (update x i₀ m i) (y i)) = |
| 131 | + pi univ fun i ↦ Ioc (x i) (y i) := |
| 132 | + by |
| 133 | + simp_rw [pi_univ_Ioc_update_left hm.1, pi_univ_Ioc_update_right hm.2, ← union_inter_distrib_right, |
| 134 | + ← setOf_or, le_or_lt, setOf_true, univ_inter] |
| 135 | +#align set.pi_univ_Ioc_update_union Set.pi_univ_Ioc_update_union |
| 136 | + |
| 137 | +/-- If `x`, `y`, `x'`, and `y'` are functions `Π i : ι, α i`, then |
| 138 | +the set difference between the box `[x, y]` and the product of the open intervals `(x' i, y' i)` |
| 139 | +is covered by the union of the following boxes: for each `i : ι`, we take |
| 140 | +`[x, update y i (x' i)]` and `[update x i (y' i), y]`. |
| 141 | +
|
| 142 | +E.g., if `x' = x` and `y' = y`, then this lemma states that the difference between a closed box |
| 143 | +`[x, y]` and the corresponding open box `{z | ∀ i, x i < z i < y i}` is covered by the union |
| 144 | +of the faces of `[x, y]`. -/ |
| 145 | +theorem Icc_diff_pi_univ_Ioo_subset (x y x' y' : ∀ i, α i) : |
| 146 | + (Icc x y \ pi univ fun i ↦ Ioo (x' i) (y' i)) ⊆ |
| 147 | + (⋃ i : ι, Icc x (update y i (x' i))) ∪ ⋃ i : ι, Icc (update x i (y' i)) y := |
| 148 | + by |
| 149 | + rintro a ⟨⟨hxa, hay⟩, ha'⟩ |
| 150 | + simp at ha' |
| 151 | + simp [le_update_iff, update_le_iff, hxa, hay, hxa _, hay _, ← exists_or] |
| 152 | + rcases ha' with ⟨w, hw⟩ |
| 153 | + apply Exists.intro w |
| 154 | + cases lt_or_le (x' w) (a w) <;> simp_all |
| 155 | + |
| 156 | +#align set.Icc_diff_pi_univ_Ioo_subset Set.Icc_diff_pi_univ_Ioo_subset |
| 157 | + |
| 158 | +/-- If `x`, `y`, `z` are functions `Π i : ι, α i`, then |
| 159 | +the set difference between the box `[x, z]` and the product of the intervals `(y i, z i]` |
| 160 | +is covered by the union of the boxes `[x, update z i (y i)]`. |
| 161 | +
|
| 162 | +E.g., if `x = y`, then this lemma states that the difference between a closed box |
| 163 | +`[x, y]` and the product of half-open intervals `{z | ∀ i, x i < z i ≤ y i}` is covered by the union |
| 164 | +of the faces of `[x, y]` adjacent to `x`. -/ |
| 165 | +theorem Icc_diff_pi_univ_Ioc_subset (x y z : ∀ i, α i) : |
| 166 | + (Icc x z \ pi univ fun i ↦ Ioc (y i) (z i)) ⊆ ⋃ i : ι, Icc x (update z i (y i)) := by |
| 167 | + rintro a ⟨⟨hax, haz⟩, hay⟩ |
| 168 | + simpa [not_and_or, hax, le_update_iff, haz _] using hay |
| 169 | +#align set.Icc_diff_pi_univ_Ioc_subset Set.Icc_diff_pi_univ_Ioc_subset |
| 170 | + |
| 171 | +end Set |
0 commit comments