My solutions to Tao's Analysis I, formalized in Lean
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #252 from teorth:golf

some golf

authored by

teorth and committed by
GitHub
23af288b 5ed6ece8

+231 -398
+103 -172
analysis/Analysis/Section_11_1.lean
··· 121 121 | Ico _ b => b 122 122 123 123 theorem BoundedInterval.subset_Icc (I: BoundedInterval) : I ⊆ Icc I.a I.b := match I with 124 - | Ioo a b => by simp [Ioo, Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Icc_self] 125 - | Icc a b => by simp [Icc, BoundedInterval.a, BoundedInterval.b, subset_iff] 126 - | Ioc a b => by simp [Ioc, Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioc_subset_Icc_self] 127 - | Ico a b => by simp [Ico, Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ico_subset_Icc_self] 124 + | Ioo _ _ => by simp [Ioo, Icc, a, b, subset_iff, Set.Ioo_subset_Icc_self] 125 + | Icc _ _ => by simp [Icc, a, b, subset_iff] 126 + | Ioc _ _ => by simp [Ioc, Icc, a, b, subset_iff, Set.Ioc_subset_Icc_self] 127 + | Ico _ _ => by simp [Ico, Icc, a, b, subset_iff, Set.Ico_subset_Icc_self] 128 128 129 129 theorem BoundedInterval.Ioo_subset (I: BoundedInterval) : Ioo I.a I.b ⊆ I := match I with 130 - | Ioo a b => by simp [Ioo, BoundedInterval.a, BoundedInterval.b, subset_iff] 131 - | Icc a b => by simp [Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Icc_self] 132 - | Ioc a b => by simp [Ioc, Ioo, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Ioc_self] 133 - | Ico a b => by simp [Ico, Ioo, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Ico_self] 130 + | Ioo _ _ => by simp [Ioo, a, b, subset_iff] 131 + | Icc _ _ => by simp [Icc, a, b, subset_iff, Set.Ioo_subset_Icc_self] 132 + | Ioc _ _ => by simp [Ioc, Ioo, a, b, subset_iff, Set.Ioo_subset_Ioc_self] 133 + | Ico _ _ => by simp [Ico, Ioo, a, b, subset_iff, Set.Ioo_subset_Ico_self] 134 134 135 135 instance BoundedInterval.instTrans : IsTrans BoundedInterval (· ⊆ ·) where 136 - trans I J K hIJ hJK := by 137 - simp [subset_iff] at hIJ hJK ⊢ 138 - exact hIJ.trans hJK 136 + trans I J K hIJ hJK := by simp_all [subset_iff]; exact hIJ.trans hJK 139 137 140 138 @[simp] 141 139 theorem BoundedInterval.mem_inter (I J: BoundedInterval) (x:ℝ) : 142 - x ∈ (I ∩ J : BoundedInterval) ↔ x ∈ I ∧ x ∈ J := by 143 - simp [inter_eq, Set.mem_inter_iff, mem_iff, mem_iff] 140 + x ∈ (I ∩ J : BoundedInterval) ↔ x ∈ I ∧ x ∈ J := by simp [mem_iff] 144 141 145 142 abbrev BoundedInterval.length (I: BoundedInterval) : ℝ := max (I.b - I.a) 0 146 143 ··· 161 158 162 159 theorem BoundedInterval.empty_of_lt {I: BoundedInterval} (h: I.b < I.a) : (I:Set ℝ) = ∅ := by 163 160 cases I with 164 - | Ioo a b => simp [Ioo, le_of_lt h] 165 - | Icc a b => simp [Icc, h] 166 - | Ioc a b => simp [Ioc, le_of_lt h] 167 - | Ico a b => simp [Ico, le_of_lt h] 161 + | Ioo _ _ => simp [Ioo, le_of_lt h] 162 + | Icc _ _ => simp [Icc, h] 163 + | Ioc _ _ => simp [Ioc, le_of_lt h] 164 + | Ico _ _ => simp [Ico, le_of_lt h] 168 165 169 166 theorem BoundedInterval.length_of_empty {I: BoundedInterval} (hI: (I:Set ℝ) = ∅) : |I|ₗ = 0 := by 170 167 sorry ··· 175 172 theorem BoundedInterval.dist_le_length {I:BoundedInterval} {x y:ℝ} (hx: x ∈ I) (hy: y ∈ I) : |x - y| ≤ |I|ₗ := by 176 173 replace hx := subset_Icc I _ hx 177 174 replace hy := subset_Icc I _ hy 178 - simp [mem_iff, abs_le'] at hx hy ⊢ 179 - left; constructor <;> linarith 175 + simp_all [mem_iff, abs_le']; left; constructor <;> linarith 180 176 181 177 abbrev BoundedInterval.joins (K I J: BoundedInterval) : Prop := (I:Set ℝ) ∩ (J:Set ℝ) = ∅ 182 178 ∧ (K:Set ℝ) = (I:Set ℝ) ∪ (J:Set ℝ) ∧ |K|ₗ = |I|ₗ + |J|ₗ ··· 187 183 . ext x; simp; constructor 188 184 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b] 189 185 rintro (_ | _) <;> and_intros <;> linarith 190 - simp [length, BoundedInterval.a, BoundedInterval.b, 191 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 186 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 192 187 193 188 theorem BoundedInterval.join_Icc_Ioo {a b c:ℝ} (hab: a ≤ b) (hbc: b < c) : (Ico a c).joins (Icc a b) (Ioo b c) := by 194 189 and_intros ··· 196 191 . ext x; simp; constructor 197 192 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b] 198 193 rintro (_ | _) <;> and_intros <;> linarith 199 - simp [length, BoundedInterval.a, BoundedInterval.b, 200 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 194 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 201 195 202 196 theorem BoundedInterval.join_Ioc_Ioc {a b c:ℝ} (hab: a ≤ b) (hbc: b ≤ c) : (Ioc a c).joins (Ioc a b) (Ioc b c) := by 203 197 and_intros ··· 205 199 . ext x; simp; constructor 206 200 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b] 207 201 rintro (_ | _) <;> and_intros <;> linarith 208 - simp [length, BoundedInterval.a, BoundedInterval.b, 209 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 202 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 210 203 211 204 theorem BoundedInterval.join_Ioc_Ioo {a b c:ℝ} (hab: a ≤ b) (hbc: b < c) : (Ioo a c).joins (Ioc a b) (Ioo b c) := by 212 205 and_intros ··· 214 207 . ext x; simp; constructor 215 208 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b] 216 209 rintro (_ | _) <;> and_intros <;> linarith 217 - simp [length, BoundedInterval.a, BoundedInterval.b, 218 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 210 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 219 211 220 212 theorem BoundedInterval.join_Ico_Icc {a b c:ℝ} (hab: a ≤ b) (hbc: b ≤ c) : (Icc a c).joins (Ico a b) (Icc b c) := by 221 213 and_intros ··· 223 215 . ext x; simp; constructor 224 216 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b] 225 217 rintro (_ | _) <;> and_intros <;> linarith 226 - simp [length, BoundedInterval.a, BoundedInterval.b, 227 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 218 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 228 219 229 220 theorem BoundedInterval.join_Ico_Ico {a b c:ℝ} (hab: a ≤ b) (hbc: b ≤ c) : (Ico a c).joins (Ico a b) (Ico b c) := by 230 221 and_intros ··· 232 223 . ext x; simp; constructor 233 224 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b] 234 225 rintro (_ | _) <;> and_intros <;> linarith 235 - simp [length, BoundedInterval.a, BoundedInterval.b, 236 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 226 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 237 227 238 228 theorem BoundedInterval.join_Ioo_Icc {a b c:ℝ} (hab: a < b) (hbc: b ≤ c) : (Ioc a c).joins (Ioo a b) (Icc b c) := by 239 229 and_intros ··· 241 231 . ext x; simp; constructor 242 232 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b] 243 233 rintro (_ | _) <;> and_intros <;> linarith 244 - simp [length, BoundedInterval.a, BoundedInterval.b, 245 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 234 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 246 235 247 236 theorem BoundedInterval.join_Ioo_Ico {a b c:ℝ} (hab: a < b) (hbc: b ≤ c) : (Ioo a c).joins (Ioo a b) (Ico b c) := by 248 237 and_intros ··· 250 239 . ext x; simp; constructor 251 240 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b] 252 241 rintro (_ | _) <;> and_intros <;> linarith 253 - simp [length, BoundedInterval.a, BoundedInterval.b, 254 - show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 242 + simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith] 255 243 256 244 257 245 @[ext] ··· 269 257 bot := { 270 258 intervals := {I} 271 259 exists_unique x hx := by apply ExistsUnique.intro I <;> simp [hx] 272 - contains J hJ := by simp at hJ; rw [hJ, subset_iff] 260 + contains J hJ := by simp_all [subset_iff] 273 261 } 274 262 275 263 @[simp] ··· 281 269 { 282 270 intervals := P.intervals ∪ Q.intervals 283 271 exists_unique x hx := by 284 - simp [mem_iff, h.2] at hx 285 - rcases hx with hx | hx 286 - . obtain ⟨ L, hLP, hxL ⟩ := (P.exists_unique x hx).exists 272 + simp [mem_iff, h.2] at hx; rcases hx with hx | hx 273 + . obtain ⟨ L, hLP, hxL ⟩ := (P.exists_unique _ hx).exists 287 274 apply ExistsUnique.intro L (by aesop) 288 - intro K ⟨hK, hxK⟩ 289 - simp at hK; rcases hK with hKP | hKQ 290 - . exact (P.exists_unique x hx).unique ⟨ hKP, hxK ⟩ ⟨ hLP, hxL ⟩ 291 - replace hxK := (BoundedInterval.subset_iff _ _).mp (Q.contains K hKQ) hxK 292 - have := congr(x ∈ $(h.1)) 293 - simp [hx, hxK] at this 294 - obtain ⟨ L, hLQ, hxL ⟩ := (Q.exists_unique x hx).exists 275 + intro K ⟨hK, hxK⟩; simp at hK; rcases hK with hKP | hKQ 276 + . exact (P.exists_unique _ hx).unique ⟨ hKP, hxK ⟩ ⟨ hLP, hxL ⟩ 277 + replace hxK := (K.subset_iff _).mp (Q.contains _ hKQ) hxK 278 + have := congr(x ∈ $(h.1)); simp [hx, hxK] at this 279 + obtain ⟨ L, hLQ, hxL ⟩ := (Q.exists_unique _ hx).exists 295 280 apply ExistsUnique.intro L (by aesop) 296 - intro K ⟨hK, hxK⟩ 297 - simp at hK; rcases hK with hKP | hKQ 298 - . replace hxK := (BoundedInterval.subset_iff _ _).mp (P.contains K hKP) hxK 299 - have := congr(x ∈ $(h.1)) 300 - simp [hx, hxK] at this 281 + intro K ⟨hK, hxK⟩; simp at hK; rcases hK with hKP | hKQ 282 + . replace hxK := (K.subset_iff _).mp (P.contains _ hKP) hxK 283 + have := congr(x ∈ $(h.1)); simp [hx, hxK] at this 301 284 exact (Q.exists_unique x hx).unique ⟨ hKQ, hxK ⟩ ⟨ hLQ, hxL ⟩ 302 285 contains L hL := by 303 286 simp at hL; rcases hL with hLP | hLQ 304 - . apply (P.contains L hLP).trans 305 - simp [h, subset_iff] 306 - apply (Q.contains L hLQ).trans 307 - simp [h, subset_iff] 287 + . apply (P.contains _ hLP).trans; simp [h, subset_iff] 288 + apply (Q.contains _ hLQ).trans; simp [h, subset_iff] 308 289 } 309 290 310 291 @[simp] ··· 322 303 simp [mem_iff] at hxK 323 304 contains L hL := by 324 305 simp at hL; rcases hL with hL | rfl 325 - . exact P.contains L hL 306 + . exact P.contains _ hL 326 307 simp [subset_iff] 327 308 } 328 309 ··· 331 312 intervals := P.intervals.filter (fun J ↦ (J:Set ℝ).Nonempty) 332 313 exists_unique x hx := by 333 314 obtain ⟨ J, hJP, hxJ ⟩ := (P.exists_unique x hx).exists 334 - apply ExistsUnique.intro J (by 335 - simp [hxJ, hJP]; simp [mem_iff] at hxJ; exact Set.nonempty_of_mem hxJ ) 315 + apply ExistsUnique.intro J (by simp_all [mem_iff]; exact Set.nonempty_of_mem hxJ ) 336 316 intro K ⟨ hK, hxK ⟩; simp at hK 337 317 exact (P.exists_unique x hx).unique ⟨ hK.1, hxK ⟩ ⟨ hJP, hxJ ⟩ 338 - contains L hL := by 339 - simp at hL; exact P.contains L hL.1 318 + contains L hL := by simp at hL; exact P.contains _ hL.1 340 319 } 341 320 342 321 @[simp] ··· 344 323 simp [Partition.add_empty, Finset.union_empty] 345 324 346 325 example : ∃ P:Partition (Icc 1 8), 347 - P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5, 348 - Icc 5 5, Ioc 5 8, ∅} := by 326 + P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5, Icc 5 5, Ioc 5 8, ∅} := by 349 327 set P1 : Partition (Icc 1 1) := ⊥ 350 - set P2 : Partition (Ico 1 3) := P1.join (⊥:Partition (Ioo 1 3)) 351 - (BoundedInterval.join_Icc_Ioo (by norm_num) (by norm_num) ) 352 - set P3 : Partition (Ico 1 5) := P2.join (⊥:Partition (Ico 3 5)) 353 - (BoundedInterval.join_Ico_Ico (by norm_num) (by norm_num) ) 354 - set P4 : Partition (Icc 1 5) := P3.join (⊥:Partition (Icc 5 5)) 355 - (BoundedInterval.join_Ico_Icc (by norm_num) (by norm_num) ) 356 - set P5 : Partition (Icc 1 8) := P4.join (⊥:Partition (Ioc 5 8)) 357 - (BoundedInterval.join_Icc_Ioc (by norm_num) (by norm_num) ) 328 + set P2 : Partition (Ico 1 3) := P1.join (⊥:Partition (Ioo 1 3)) (join_Icc_Ioo (by norm_num) (by norm_num) ) 329 + set P3 : Partition (Ico 1 5) := P2.join (⊥:Partition (Ico 3 5)) (join_Ico_Ico (by norm_num) (by norm_num) ) 330 + set P4 : Partition (Icc 1 5) := P3.join (⊥:Partition (Icc 5 5)) (join_Ico_Icc (by norm_num) (by norm_num) ) 331 + set P5 : Partition (Icc 1 8) := P4.join (⊥:Partition (Ioc 5 8)) (join_Icc_Ioc (by norm_num) (by norm_num) ) 358 332 use P5.add_empty 359 333 simp [P5, P4, P3, P2, P1] 360 334 aesop 361 335 362 - example : ∃ P:Partition (Icc 1 8), 363 - P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5, 364 - Icc 5 5, Ioc 5 8} := by 336 + example : ∃ P:Partition (Icc 1 8), P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5, Icc 5 5, Ioc 5 8} := by 365 337 sorry 366 338 367 - example : ¬ ∃ P:Partition (Icc 1 5), 368 - P.intervals = {Icc 1 4, Icc 3 5} := by 339 + example : ¬ ∃ P:Partition (Icc 1 5), P.intervals = {Icc 1 4, Icc 3 5} := by 369 340 sorry 370 341 371 - example : ¬ ∃ P:Partition (Ioo 1 5), 372 - P.intervals = {Ioo 1 3, Ioo 3 5} := by 342 + example : ¬ ∃ P:Partition (Ioo 1 5), P.intervals = {Ioo 1 3, Ioo 3 5} := by 373 343 sorry 374 344 375 - example : ¬ ∃ P:Partition (Ioo 1 5), 376 - P.intervals = {Ioo 0 3, Ico 3 5} := by 345 + example : ¬ ∃ P:Partition (Ioo 1 5), P.intervals = {Ioo 0 3, Ico 3 5} := by 377 346 sorry 378 347 379 348 ··· 383 352 : ∃ c ∈ Set.Ico I.a I.b, Ioo c I.b ∈ P ∨ Ico c I.b ∈ P := by 384 353 sorry 385 354 386 - /-- Theorem 11.1.13 (Length is finitely additive). 387 - Due to the excessive case analysis, `simp only` is used in place of `simp` in some places 388 - to speed up elaboration. -/ 355 + /-- Theorem 11.1.13 (Length is finitely additive). -/ 389 356 theorem Partition.sum_of_length (I: BoundedInterval) (P: Partition I) : 390 357 ∑ J ∈ P.intervals, |J|ₗ = |I|ₗ := by 391 358 -- This proof is written to follow the structure of the original text. ··· 394 361 . rw [Finset.card_eq_zero] at hcard 395 362 have : (I:Set ℝ) = ∅ := by 396 363 sorry 397 - replace this := length_of_empty this 398 - simp only [hcard, Finset.sum_empty, this] 364 + simp [hcard, length_of_empty this] 399 365 -- the proof in the book treats the n=1 case separately, but this is unnecessary 400 366 by_cases h : Subsingleton (I:Set ℝ) 401 367 . have (J: BoundedInterval) (hJ: J ∈ P) : Subsingleton (J:Set ℝ) := by 402 368 sorry 403 369 simp_rw [length_of_subsingleton] at h this 404 - simp only [h] 405 - apply Finset.sum_eq_zero this 406 - simp only [length_of_subsingleton, length, sup_eq_right, tsub_le_iff_right, zero_add, not_le] at h 370 + convert Finset.sum_eq_zero this 371 + simp [length_of_subsingleton, length, -Set.subsingleton_coe] at h 407 372 have : ∃ K L : BoundedInterval, K ∈ P ∧ I.joins L K := by 408 373 by_cases hI' : I.b ∈ I 409 374 . obtain ⟨ K, hK, hbK ⟩ := (P.exists_unique I.b hI').exists 410 375 have hKI : K ⊆ I := P.contains K hK 411 376 by_cases hsub : Subsingleton (K:Set ℝ) 412 - . simp_all [mem_iff, Set.subsingleton_coe] 413 - replace hbK := Set.Subsingleton.eq_singleton_of_mem hsub hbK 377 + . simp_all [mem_iff] 378 + replace hbK := hsub.eq_singleton_of_mem hbK 414 379 have : K = Icc (I.b) (I.b) := by 415 380 sorry 416 381 subst this 417 382 cases I with 418 - | Ioo a b => simp [mem_iff, Set.mem_Ioo, lt_self_iff_false, and_false] at hI' 419 - | Icc a b => use (Icc b b), hK, Ico a b 420 - exact join_Ico_Icc (le_of_lt h) (le_refl _) 421 - | Ioc a b => use (Icc b b), hK, Ioo a b 422 - exact join_Ioo_Icc h (le_refl _) 423 - | Ico a b => simp [mem_iff, Set.mem_Ico, lt_self_iff_false, and_false] at hI' 424 - simp only [length_of_subsingleton, sup_eq_right, tsub_le_iff_right, zero_add, not_le] at hsub 383 + | Ioo _ _ => simp [mem_iff] at hI' 384 + | Icc a b => use (Icc b b), hK, Ico a b; apply join_Ico_Icc <;> order 385 + | Ioc a b => use (Icc b b), hK, Ioo a b; apply join_Ioo_Icc <;> order 386 + | Ico _ _ => simp [mem_iff] at hI' 387 + simp [length_of_subsingleton, -Set.subsingleton_coe] at hsub 425 388 have hKI' := (K.Ioo_subset.trans hKI).trans I.subset_Icc 426 389 simp only [subset_iff] at hKI' 427 390 have hKb : K.b = I.b := by 428 - rw [le_antisymm_iff] 429 - constructor 430 - . replace hKI' := csSup_le_csSup bddAbove_Icc ?_ hKI' 431 - . simp_all [csSup_Ioo hsub, csSup_Icc (le_of_lt h)] 432 - simp [Set.nonempty_Ioo, hsub] 433 - have := K.subset_Icc _ hbK 434 - simp only [mem_iff, Set.mem_Icc] at this 435 - exact this.2 391 + rw [le_antisymm_iff]; and_intros 392 + . replace hKI' := csSup_le_csSup bddAbove_Icc (by simp [hsub]) hKI' 393 + simp_all [csSup_Ioo hsub, csSup_Icc (le_of_lt h)] 394 + have := K.subset_Icc _ hbK; simp only [mem_iff, Set.mem_Icc] at this; exact this.2 436 395 have hKA : I.a ≤ K.a := by 437 - replace hKI' := csInf_le_csInf bddBelow_Icc ?_ hKI' 438 - . simp_all [csInf_Icc (le_of_lt h), csInf_Ioo] 439 - simp [Set.nonempty_Ioo, hsub] 396 + replace hKI' := csInf_le_csInf bddBelow_Icc (by simp [hsub]) hKI' 397 + simp_all [csInf_Icc (le_of_lt h), csInf_Ioo] 440 398 cases I with 441 - | Ioo a b => simp [mem_iff, Set.mem_Ioo, lt_self_iff_false, and_false] at hI' 442 - | Icc a b => 399 + | Ioo _ _ => simp [mem_iff] at hI' 400 + | Icc a₁ b₁ => 443 401 cases K with 444 - | Ioo c b' => 445 - simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b, Set.mem_Icc, Set.mem_Ioo] at * 446 - linarith 447 - | Icc c b' => 448 - use Icc c b', Ico a c, hK 449 - simp [BoundedInterval.b] at hKb; subst hKb 450 - exact join_Ico_Icc hKA (by linarith) 451 - | Ioc c b' => 452 - use Ioc c b', Icc a c, hK 453 - simp [BoundedInterval.b] at hKb; subst hKb 454 - exact join_Icc_Ioc hKA (by linarith) 455 - | Ico c b' => simp [BoundedInterval.a, BoundedInterval.b, mem_iff, Set.mem_Icc, 456 - le_refl, and_true, Set.mem_Ico, subset_iff] at *; linarith 457 - | Ioc a b => 402 + | Ioo _ _ => simp [mem_iff, subset_iff, a, b] at *; linarith 403 + | Icc c₂ b₂ => use Icc c₂ b₂, Ico a₁ c₂, hK; simp_all [b]; apply join_Ico_Icc <;> order 404 + | Ioc c₂ b₂ => use Ioc c₂ b₂, Icc a₁ c₂, hK; simp_all [b]; apply join_Icc_Ioc <;> order 405 + | Ico _ _ => simp [a, b, mem_iff] at *; linarith 406 + | Ioc a₁ b₁ => 458 407 cases K with 459 - | Ioo c b' => simp_all [mem_iff, subset_iff] 460 - | Icc c b' => 461 - use Icc c b', Ioo a c, hK 462 - simp [BoundedInterval.b] at hKb; subst hKb 463 - simp [subset_iff] at hKI 464 - have : c ∈ Set.Icc c b' := by simp; linarith 408 + | Ioo _ _ => simp_all [mem_iff, subset_iff] 409 + | Icc c₂ b₂ => 410 + use Icc c₂ b₂, Ioo a₁ c₂, hK 411 + simp_all [a,b,subset_iff] 412 + have : c₂ ∈ Set.Icc c₂ b₁ := by simp; linarith 465 413 replace this := hKI this; simp at this 466 - exact join_Ioo_Icc (by linarith) (by linarith) 467 - | Ioc c b' => 468 - use Ioc c b', Ioc a c, hK 469 - simp [BoundedInterval.b] at hKb; subst hKb 470 - exact join_Ioc_Ioc hKA (by linarith) 471 - | Ico c b' => 472 - simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b, Set.mem_Ioc, Set.mem_Ico] at *; linarith 473 - | Ico a b => simp [mem_iff, Set.mem_Ico, lt_self_iff_false, and_false] at hI' 414 + apply join_Ioo_Icc <;> tauto 415 + | Ioc c₂ b₂ => use Ioc c₂ b₂, Ioc a₁ c₂, hK; simp_all [b]; apply join_Ioc_Ioc <;> order 416 + | Ico _ _ => simp [mem_iff, subset_iff, a, b] at *; linarith 417 + | Ico _ _ => simp [mem_iff] at hI' 474 418 obtain ⟨ c, hc, hK ⟩ := P.exist_right h hI' 475 419 cases I with 476 - | Ioo a b => 420 + | Ioo a₁ b₁ => 477 421 rcases hK with hK | hK 478 - . simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] 479 - use Ioo c b, hK, Ioc a c 480 - exact join_Ioc_Ioo (hc.1) (hc.2) 481 - simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] 482 - use Ico c b, hK, Ioo a c 483 - replace hK := P.contains _ hK 484 - simp [subset_iff] at hK 485 - have : c ∈ Set.Ico c b := by simp; linarith 422 + . simp_all [mem_iff, subset_iff, a, b]; use Ioo c b₁, hK, Ioc a₁ c; apply join_Ioc_Ioo <;> tauto 423 + simp_all [mem_iff, subset_iff, a, b] 424 + use Ico c b₁, hK, Ioo a₁ c 425 + replace hK := P.contains _ hK; simp [subset_iff] at hK 426 + have : c ∈ Set.Ico c b₁ := by simp; linarith 486 427 replace this := hK this; simp at this 487 - exact join_Ioo_Ico (by linarith) (by linarith) 488 - | Icc a b => simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] at hI' h; linarith 489 - | Ioc a b => simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] at hI' h; linarith 490 - | Ico a b => 428 + apply join_Ioo_Ico <;> linarith 429 + | Icc _ _ => simp [mem_iff, subset_iff, a, b] at hI' h; order 430 + | Ioc _ _ => simp [mem_iff, subset_iff, a, b] at hI' h; order 431 + | Ico a₁ b₁ => 491 432 rcases hK with hK | hK 492 - . simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] 493 - use Ioo c b, hK, Icc a c 494 - exact join_Icc_Ioo (hc.1) (hc.2) 495 - simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] 496 - use Ico c b, hK, Ico a c 497 - exact join_Ico_Ico (by linarith) (by linarith) 433 + . simp_all [mem_iff, subset_iff, a, b]; use Ioo c b₁, hK, Icc a₁ c; apply join_Icc_Ioo <;> tauto 434 + simp_all [mem_iff, subset_iff, a, b]; use Ico c b₁, hK, Ico a₁ c; apply join_Ico_Ico <;> linarith 498 435 obtain ⟨ K, L, hK, ⟨ h1, h2, h3 ⟩ ⟩ := this 499 436 have : ∃ P' : Partition L, P'.intervals = P.intervals.erase K := by 500 437 sorry 501 438 obtain ⟨ P', hP' ⟩ := this 502 - rw [h3, ←Finset.add_sum_erase _ _ hK, ←hP', add_comm] 503 - congr 504 - apply hn _ _ _ 505 - simp only [hP', Finset.card_erase_of_mem hK, hcard, add_tsub_cancel_right] 439 + rw [h3, ←Finset.add_sum_erase _ _ hK, ←hP', add_comm]; congr 440 + apply hn; simp [hP', Finset.card_erase_of_mem hK, hcard] 506 441 507 442 /-- Definition 11.1.14 (Finer and coarser partitions) -/ 508 443 instance Partition.instLE (I: BoundedInterval) : LE (Partition I) where ··· 531 466 max P P' := { 532 467 intervals := Finset.image₂ (fun J K ↦ J ∩ K) P.intervals P'.intervals 533 468 exists_unique x hx := by 534 - obtain ⟨ J, ⟨ hJ1, hJ2⟩, hxJ ⟩ := P.exists_unique x hx 535 - obtain ⟨ K, ⟨ hK1, hK2⟩, hxK ⟩ := P'.exists_unique x hx 469 + obtain ⟨ J, ⟨ hJ1, hJ2⟩, hxJ ⟩ := P.exists_unique _ hx 470 + obtain ⟨ K, ⟨ hK1, hK2⟩, hxK ⟩ := P'.exists_unique _ hx 536 471 simp [hx] at hxJ hxK 537 472 apply ExistsUnique.intro (J ∩ K) 538 - . simp; exact ⟨ ⟨ J, hJ1, K, hK1, rfl ⟩, ⟨ hJ2, hK2 ⟩ ⟩ 539 - simp; rintro L J' hJ' K' hK' rfl hx'; simp at hx' 540 - specialize hxJ J' hJ' hx'.1 541 - specialize hxK K' hK' hx'.2 542 - simp [hxJ, hxK] 473 + . simp_all; exact ⟨ _, hJ1, _, hK1, rfl ⟩ 474 + simp; rintro _ J' hJ' K' hK' rfl hx'; simp at hx' 475 + simp [hxJ _ hJ' hx'.1, hxK _ hK' hx'.2] 543 476 contains L hL := by 544 477 simp at hL 545 478 obtain ⟨ J, hJ, K, hK, rfl ⟩ := hL 546 - replace hJ := P.contains J hJ 547 - replace hK := P'.contains K hK 479 + replace hJ := P.contains _ hJ 480 + replace hK := P'.contains _ hK 548 481 simp [subset_iff] at hJ hK ⊢ 549 482 exact Set.inter_subset_left.trans hJ 550 483 } 551 484 552 485 553 486 /-- Example 11.1.17 -/ 554 - example : ∃ P P' : Partition (Icc 1 4), 555 - P.intervals = {Ico 1 3, Icc 3 4} ∧ 556 - P'.intervals = {Icc 1 2, Ioc 2 4} ∧ 487 + example : ∃ P P' : Partition (Icc 1 4), P.intervals = {Ico 1 3, Icc 3 4} ∧ P'.intervals = {Icc 1 2, Ioc 2 4} ∧ 557 488 (P' ⊔ P).intervals = {Icc 1 2, Ioo 2 3, Icc 3 4, ∅} := by 558 489 sorry 559 490
+28 -43
analysis/Analysis/Section_11_2.lean
··· 27 27 if h: Constant f then h.choose else hY.some 28 28 29 29 theorem Constant.eq {X Y:Type} {f: X → Y} [Nonempty Y] (h: Constant f) (x:X) : 30 - f x = constant_value f := by 31 - rw [constant_value, dif_pos h] 32 - exact h.choose_spec x 30 + f x = constant_value f := by simp [constant_value, h]; apply h.choose_spec 33 31 34 32 theorem Constant.of_const {X Y:Type} {f:X → Y} {c:Y} (h: ∀ x, f x = c) : 35 33 Constant f := by use c 36 34 37 35 theorem Constant.const_eq {X Y:Type} {f:X → Y} [hX: Nonempty X] [Nonempty Y] {c:Y} (h: ∀ x, f x = c) : 38 - constant_value f = c := by 39 - rw [←eq (of_const h) hX.some, h hX.some] 36 + constant_value f = c := by rw [←eq (of_const h) hX.some, h hX.some] 40 37 41 - theorem Constant.of_subsingleton {X Y:Type} [Subsingleton X] [hY: Nonempty Y] {f:X → Y} : 38 + theorem Constant.of_subsingleton {X Y:Type} [hs: Subsingleton X] [hY: Nonempty Y] {f:X → Y} : 42 39 Constant f := by 43 40 by_cases h:Nonempty X 44 - . use f (h.some : X); intro x; congr; exact Subsingleton.elim x h.some 45 - use hY.some; intro x; simp at h; exact IsEmpty.elim h x 41 + . use f h.some; intros; congr; exact hs.elim _ h.some 42 + use hY.some; intro x; simp at h; exact h.elim x 46 43 47 44 abbrev ConstantOn (f: ℝ → ℝ) (X: Set ℝ) : Prop := Constant (fun x : X ↦ f ↑x) 48 45 ··· 50 47 51 48 theorem ConstantOn.eq {f: ℝ → ℝ} {X: Set ℝ} (h: ConstantOn f X) {x:ℝ} (hx: x ∈ X) : 52 49 f x = constant_value_on f X := by 53 - convert Constant.eq h ⟨ x, hx ⟩ 50 + convert Constant.eq h ⟨ _, hx ⟩ 54 51 55 52 theorem ConstantOn.of_const {f:ℝ → ℝ} {X: Set ℝ} {c:ℝ} (h: ∀ x ∈ X, f x = c) : 56 53 ConstantOn f X := by use c; rintro ⟨ x, hx ⟩; simp [h x hx] 57 54 58 55 theorem ConstantOn.of_const' (c:ℝ) (X:Set ℝ): ConstantOn (fun _ ↦ c) X := by 59 - apply ConstantOn.of_const (c := c) 60 - simp 56 + apply of_const (c := c); simp 61 57 62 58 theorem ConstantOn.const_eq {f:ℝ → ℝ} {X: Set ℝ} (hX: X.Nonempty) {c:ℝ} (h: ∀ x ∈ X, f x = c) : 63 59 constant_value_on f X = c := by 64 60 rw [←eq (of_const h) hX.some_mem, h _ hX.some_mem] 65 61 66 62 theorem ConstantOn.congr {f g: ℝ → ℝ} {X: Set ℝ} (h: ∀ x ∈ X, f x = g x) : ConstantOn f X ↔ ConstantOn g X := by 67 - simp [ConstantOn]; rw [iff_iff_eq] 68 - congr; ext ⟨ x, hx ⟩; simp [h x hx] 63 + simp [ConstantOn]; rw [iff_iff_eq]; congr; ext ⟨ _, hx ⟩; simp [h _ hx] 69 64 70 65 theorem ConstantOn.of_subsingleton {f: ℝ → ℝ} {X: Set ℝ} [Subsingleton X] : 71 66 ConstantOn f X := Constant.of_subsingleton 72 67 73 68 theorem constant_value_on_congr {f g: ℝ → ℝ} {X: Set ℝ} (h: ∀ x ∈ X, f x = g x) : 74 69 constant_value_on f X = constant_value_on g X := by 75 - simp [constant_value_on] 76 - congr; ext ⟨ x, hx ⟩; simp [h x hx] 70 + simp [constant_value_on]; congr; ext ⟨ _, hx ⟩; simp [h _ hx] 77 71 78 72 /-- Definition 11.2.3 (Piecewise constant functions I) -/ 79 73 abbrev PiecewiseConstantWith (f:ℝ → ℝ) {I: BoundedInterval} (P: Partition I) : Prop := ∀ J ∈ P, ConstantOn f (J:Set ℝ) ··· 85 79 theorem PiecewiseConstantWith.congr {f g:ℝ → ℝ} {I: BoundedInterval} {P: Partition I} 86 80 (h: ∀ x ∈ (I:Set ℝ), f x = g x) : 87 81 PiecewiseConstantWith f P ↔ PiecewiseConstantWith g P := by 88 - simp [PiecewiseConstantWith] 89 - peel with J hJ 90 - apply ConstantOn.congr; intro x hx 91 - have := P.contains _ hJ; rw [subset_iff] at this 92 - solve_by_elim 82 + simp [PiecewiseConstantWith]; peel with J hJ 83 + apply ConstantOn.congr; intros; have := P.contains _ hJ; rw [subset_iff] at this; solve_by_elim 93 84 94 85 /-- Definition 11.2.5 (Piecewise constant functions I) -/ 95 86 abbrev PiecewiseConstantOn (f:ℝ → ℝ) (I: BoundedInterval) : Prop := ∃ P : Partition I, PiecewiseConstantWith f P ··· 173 164 theorem PiecewiseConstantWith.integ_congr {f g:ℝ → ℝ} {I: BoundedInterval} {P: Partition I} 174 165 (h: ∀ x ∈ (I:Set ℝ), f x = g x) : PiecewiseConstantWith.integ f P = PiecewiseConstantWith.integ g P := by 175 166 simp only [integ, Subtype.forall] 176 - apply Finset.sum_congr rfl; intro J hJ; congr 1 177 - apply constant_value_on_congr; intro x hx 167 + apply Finset.sum_congr rfl; intro J hJ; congr 1; apply constant_value_on_congr; intros 178 168 have := P.contains _ hJ; rw [subset_iff] at this 179 169 aesop 180 170 ··· 212 202 213 203 /-- Proposition 11.2.13 (Piecewise constant integral is independent of partition) / Exercise 11.2.3 -/ 214 204 theorem PiecewiseConstantWith.integ_eq {f:ℝ → ℝ} {I: BoundedInterval} {P P': Partition I} 215 - (hP: PiecewiseConstantWith f P) (hP': PiecewiseConstantWith f P') : PiecewiseConstantWith.integ f P = PiecewiseConstantWith.integ f P' := by 205 + (hP: PiecewiseConstantWith f P) (hP': PiecewiseConstantWith f P') : integ f P = integ f P' := by 216 206 sorry 217 207 218 208 open Classical in ··· 221 211 ℝ := if h: PiecewiseConstantOn f I then PiecewiseConstantWith.integ f h.choose else 0 222 212 223 213 theorem PiecewiseConstantOn.integ_def {f:ℝ → ℝ} {I: BoundedInterval} {P: Partition I} 224 - (h: PiecewiseConstantWith f P) : PiecewiseConstantOn.integ f I = PiecewiseConstantWith.integ f P := by 214 + (h: PiecewiseConstantWith f P) : integ f I = PiecewiseConstantWith.integ f P := by 225 215 have h' : PiecewiseConstantOn f I := by use P 226 - simp [PiecewiseConstantOn.integ, h'] 227 - exact PiecewiseConstantWith.integ_eq h'.choose_spec h 216 + simp [integ, h']; exact PiecewiseConstantWith.integ_eq h'.choose_spec h 228 217 229 218 theorem PiecewiseConstantOn.integ_congr {f g:ℝ → ℝ} {I: BoundedInterval} 230 219 (h: ∀ x ∈ (I:Set ℝ), f x = g x) : PiecewiseConstantOn.integ f I = PiecewiseConstantOn.integ g I := by 231 220 by_cases hf : PiecewiseConstantOn f I 232 - <;> have hg := hf <;> rw [PiecewiseConstantOn.congr h] at hg <;> simp [integ, hf, hg] 233 - rw [PiecewiseConstantWith.integ_congr h, ←integ_def ?_, ←integ_def ?_] 234 - . exact hg.choose_spec 235 - rw [←PiecewiseConstantWith.congr h] 236 - exact hf.choose_spec 221 + <;> have hg := hf <;> rw [congr h] at hg <;> simp [integ, hf, hg] 222 + rw [PiecewiseConstantWith.integ_congr h, ←integ_def hg.choose_spec, ←integ_def ?_] 223 + rw [←PiecewiseConstantWith.congr h]; exact hf.choose_spec 237 224 238 225 /-- Example 11.2.15 -/ 239 226 example : PiecewiseConstantOn.integ f_11_2_4 (Icc 1 6) = 10 := by ··· 242 229 /-- Theorem 11.2.16 (a) (Laws of integration) / Exercise 11.2.4 -/ 243 230 theorem PiecewiseConstantOn.integ_add {f g: ℝ → ℝ} {I: BoundedInterval} 244 231 (hf: PiecewiseConstantOn f I) (hg: PiecewiseConstantOn g I) : 245 - PiecewiseConstantOn.integ (f + g) I = PiecewiseConstantOn.integ f I + PiecewiseConstantOn.integ g I := by 232 + integ (f + g) I = integ f I + integ g I := by 246 233 sorry 247 234 248 235 /-- Theorem 11.2.16 (b) (Laws of integration) / Exercise 11.2.4 -/ 249 - theorem PiecewiseConstantOn.integ_smul {f: ℝ → ℝ} {I: BoundedInterval} (c:ℝ) 250 - (hf: PiecewiseConstantOn f I) : 251 - PiecewiseConstantOn.integ (c • f) I = c * PiecewiseConstantOn.integ f I 236 + theorem PiecewiseConstantOn.integ_smul {f: ℝ → ℝ} {I: BoundedInterval} (c:ℝ) (hf: PiecewiseConstantOn f I) : 237 + integ (c • f) I = c * integ f I 252 238 := by 253 239 sorry 254 240 255 241 /-- Theorem 11.2.16 (c) (Laws of integration) / Exercise 11.2.4 -/ 256 242 theorem PiecewiseConstantOn.integ_sub {f g: ℝ → ℝ} {I: BoundedInterval} 257 243 (hf: PiecewiseConstantOn f I) (hg: PiecewiseConstantOn g I) : 258 - PiecewiseConstantOn.integ (f - g) I = PiecewiseConstantOn.integ f I - PiecewiseConstantOn.integ g I 259 - := by 244 + integ (f - g) I = integ f I - integ g I := by 260 245 sorry 261 246 262 247 /-- Theorem 11.2.16 (d) (Laws of integration) / Exercise 11.2.4 -/ 263 248 theorem PiecewiseConstantOn.integ_of_nonneg {f: ℝ → ℝ} {I: BoundedInterval} (h: ∀ x ∈ I, 0 ≤ f x) 264 249 (hf: PiecewiseConstantOn f I) : 265 - 0 ≤ PiecewiseConstantOn.integ f I := by 250 + 0 ≤ integ f I := by 266 251 sorry 267 252 268 253 /-- Theorem 11.2.16 (e) (Laws of integration) / Exercise 11.2.4 -/ 269 254 theorem PiecewiseConstantOn.integ_mono {f g: ℝ → ℝ} {I: BoundedInterval} (h: ∀ x ∈ I, f x ≤ g x) 270 255 (hf: PiecewiseConstantOn f I) (hg: PiecewiseConstantOn g I) : 271 - PiecewiseConstantOn.integ f I ≤ PiecewiseConstantOn.integ g I := by 256 + integ f I ≤ integ g I := by 272 257 sorry 273 258 274 259 275 260 /-- Theorem 11.2.16 (f) (Laws of integration) / Exercise 11.2.4 -/ 276 261 theorem PiecewiseConstantOn.integ_const (c: ℝ) (I: BoundedInterval) : 277 - PiecewiseConstantOn.integ (fun _ ↦ c) I = c * |I|ₗ := by 262 + integ (fun _ ↦ c) I = c * |I|ₗ := by 278 263 sorry 279 264 280 265 /-- Theorem 11.2.16 (f) (Laws of integration) / Exercise 11.2.4 -/ 281 266 theorem PiecewiseConstantOn.integ_const' {f:ℝ → ℝ} {I: BoundedInterval} (h: ConstantOn f I) : 282 - PiecewiseConstantOn.integ f I = (constant_value_on f I) * |I|ₗ := by 267 + integ f I = (constant_value_on f I) * |I|ₗ := by 283 268 sorry 284 269 285 270 open Classical in ··· 293 278 /-- Theorem 11.2.16 (g) (Laws of integration) / Exercise 11.2.4 -/ 294 279 theorem PiecewiseConstantOn.integ_of_extend {I J: BoundedInterval} (hIJ: I ⊆ J) 295 280 {f: ℝ → ℝ} (h: PiecewiseConstantOn f I) : 296 - PiecewiseConstantOn.integ (fun x ↦ if x ∈ I then f x else 0) J = PiecewiseConstantOn.integ f I := by 281 + integ (fun x ↦ if x ∈ I then f x else 0) J = integ f I := by 297 282 sorry 298 283 299 284 /-- Theorem 11.2.16 (h) (Laws of integration) / Exercise 11.2.4 -/ ··· 304 289 /-- Theorem 11.2.16 (h) (Laws of integration) / Exercise 11.2.4 -/ 305 290 theorem PiecewiseConstantOn.integ_of_join {I J K: BoundedInterval} (hIJK: K.joins I J) 306 291 {f: ℝ → ℝ} (h: PiecewiseConstantOn f K) : 307 - PiecewiseConstantOn.integ f K = PiecewiseConstantOn.integ f I + PiecewiseConstantOn.integ f J := by 292 + integ f K = integ f I + integ f J := by 308 293 sorry 309 294 310 295 end Chapter11
+22 -49
analysis/Analysis/Section_11_3.lean
··· 44 44 45 45 lemma integral_bound_upper_of_bounded {f:ℝ → ℝ} {M:ℝ} {I: BoundedInterval} (h: ∀ x ∈ (I:Set ℝ), |f x| ≤ M) : M * |I|ₗ ∈ (fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MajorizesOn g f I ∧ PiecewiseConstantOn g I} := by 46 46 simp 47 - refine ⟨ fun _ ↦ M , ⟨ ⟨ ?_, ?_, ⟩, ?_ ⟩ ⟩ 48 - . peel h with x hx h' 49 - simp [abs_le'] at h' 50 - simp [h'.1] 51 - . apply PiecewiseConstantOn.of_const (ConstantOn.of_const (c := M) _) 52 - simp 53 - exact PiecewiseConstantOn.integ_const M I 47 + refine ⟨ fun _ ↦ M , ⟨ ⟨ ?_, ?_, ⟩, PiecewiseConstantOn.integ_const M I ⟩ ⟩ 48 + . peel h with _ _ h'; simp [abs_le'] at h'; simp [h'.1] 49 + exact PiecewiseConstantOn.of_const (ConstantOn.of_const (c := M) (by simp)) 54 50 55 51 lemma integral_bound_lower_of_bounded {f:ℝ → ℝ} {M:ℝ} {I: BoundedInterval} (h: ∀ x ∈ (I:Set ℝ), |f x| ≤ M) : -M * |I|ₗ ∈ (fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MinorizesOn g f I ∧ PiecewiseConstantOn g I} := by 56 52 simp 57 - refine ⟨ fun _ ↦ -M , ⟨ ⟨ ?_, ?_, ⟩, ?_ ⟩ ⟩ 58 - . peel h with x hx h' 59 - simp [abs_le'] at h' 60 - simp; linarith 61 - . apply PiecewiseConstantOn.of_const (ConstantOn.of_const (c := -M) _) 62 - simp 63 - convert PiecewiseConstantOn.integ_const (-M) I using 1 64 - simp 53 + refine ⟨ fun _ ↦ -M , ⟨ ⟨ ?_, ?_, ⟩, by convert PiecewiseConstantOn.integ_const (-M) I using 1; simp ⟩ ⟩ 54 + . peel h with _ _ h'; simp [abs_le'] at h'; simp; linarith 55 + exact PiecewiseConstantOn.of_const (ConstantOn.of_const (c := -M) (by simp)) 65 56 66 57 lemma integral_bound_upper_nonempty {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) : ((fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MajorizesOn g f I ∧ PiecewiseConstantOn g I}).Nonempty := by 67 - obtain ⟨ _, h ⟩ := h 68 - apply Set.nonempty_of_mem 69 - exact integral_bound_upper_of_bounded h 58 + obtain ⟨ _, h ⟩ := h; exact Set.nonempty_of_mem (integral_bound_upper_of_bounded h) 70 59 71 60 lemma integral_bound_lower_nonempty {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) : ((fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MinorizesOn g f I ∧ PiecewiseConstantOn g I}).Nonempty := by 72 - obtain ⟨ _, h ⟩ := h 73 - apply Set.nonempty_of_mem 74 - exact integral_bound_lower_of_bounded h 61 + obtain ⟨ _, h ⟩ := h; exact Set.nonempty_of_mem (integral_bound_lower_of_bounded h) 75 62 76 63 lemma integral_bound_lower_le_upper {f:ℝ → ℝ} {I: BoundedInterval} {a b:ℝ} 77 64 (ha: a ∈ (fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MajorizesOn g f I ∧ PiecewiseConstantOn g I}) ··· 79 66 : b ≤ a:= by 80 67 obtain ⟨ g, ⟨ ⟨ hmaj, hgp⟩, hgi ⟩ ⟩ := ha 81 68 obtain ⟨ h, ⟨ ⟨ hmin, hhp⟩, hhi ⟩ ⟩ := hb 82 - rw [←hgi, ←hhi] 83 - apply PiecewiseConstantOn.integ_mono _ hhp hgp 84 - intro x hx 85 - have := hmaj x hx 86 - apply (ge_iff_le.mp (hmin x hx)).trans (hmaj x hx) 69 + rw [←hgi, ←hhi]; apply PiecewiseConstantOn.integ_mono _ hhp hgp 70 + intro x hx; exact (ge_iff_le.mp (hmin x hx)).trans (hmaj x hx) 87 71 88 72 lemma integral_bound_below {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) : 89 73 BddBelow ((fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MajorizesOn g f I ∧ PiecewiseConstantOn g I}) := by 90 - rw [bddBelow_def] 91 - use (integral_bound_lower_nonempty h).some 74 + rw [bddBelow_def]; use (integral_bound_lower_nonempty h).some 92 75 intro a ha; exact integral_bound_lower_le_upper ha (integral_bound_lower_nonempty h).some_mem 93 76 94 77 lemma integral_bound_above {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) : 95 78 BddAbove ((fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MinorizesOn g f I ∧ PiecewiseConstantOn g I}) := by 96 - rw [bddAbove_def] 97 - use (integral_bound_upper_nonempty h).some 79 + rw [bddAbove_def]; use (integral_bound_upper_nonempty h).some 98 80 intro b hb; exact integral_bound_lower_le_upper (integral_bound_upper_nonempty h).some_mem hb 99 81 100 82 /-- Lemma 11.3.3. The proof has been reorganized somewhat from the textbook. -/ ··· 106 88 lemma lower_integral_le_upper {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) : 107 89 lower_integral f I ≤ upper_integral f I := by 108 90 apply ConditionallyCompleteLattice.csSup_le _ _ (integral_bound_lower_nonempty h) _ 109 - rw [mem_upperBounds] 110 - intro b hb 91 + rw [mem_upperBounds]; intro b hb 111 92 apply ConditionallyCompleteLattice.le_csInf _ _ (integral_bound_upper_nonempty h) _ 112 - rw [mem_lowerBounds] 113 - intro a ha 93 + rw [mem_lowerBounds]; intro a ha 114 94 exact integral_bound_lower_le_upper ha hb 115 95 116 96 lemma upper_integral_le {f:ℝ → ℝ} {I: BoundedInterval} {M:ℝ} (h: ∀ x ∈ (I:Set ℝ), |f x| ≤ M) : ··· 134 114 {X:ℝ} (hX: upper_integral f I < X ) : 135 115 ∃ g, MajorizesOn g f I ∧ PiecewiseConstantOn g I ∧ PiecewiseConstantOn.integ g I < X := by 136 116 obtain ⟨ Y, hY, hYX ⟩ := exists_lt_of_csInf_lt (integral_bound_upper_nonempty hf) hX 137 - simp at hY 138 - peel hY with h hY 139 - simp [hY, hYX]; tauto 117 + simp at hY; peel hY with h hY; simp_all; tauto 140 118 141 119 lemma gt_of_lt_lower_integral {f:ℝ → ℝ} {I: BoundedInterval} (hf: BddOn f I) 142 120 {X:ℝ} (hX: X < lower_integral f I) : 143 121 ∃ h, MinorizesOn h f I ∧ PiecewiseConstantOn h I ∧ X < PiecewiseConstantOn.integ h I := by 144 122 obtain ⟨ Y, hY, hYX ⟩ := exists_lt_of_lt_csSup (integral_bound_lower_nonempty hf) hX 145 - simp at hY 146 - peel hY with h hY 147 - simp [hY, hYX]; tauto 123 + simp at hY; peel hY with h hY; simp_all; tauto 148 124 149 125 /-- Definition 11.3.4 (Riemann integral) 150 126 As we permit junk values, the simplest definition for the Riemann integral is the upper integral.-/ 151 - noncomputable abbrev integ (f:ℝ → ℝ) (I: BoundedInterval) : ℝ := 152 - upper_integral f I 127 + noncomputable abbrev integ (f:ℝ → ℝ) (I: BoundedInterval) : ℝ := upper_integral f I 153 128 154 129 theorem integ_congr {f g:ℝ → ℝ} {I: BoundedInterval} (h: Set.EqOn f g I) : 155 130 integ f I = integ g I := upper_integral_congr h ··· 165 140 /-- Remark 11.3.8 -/ 166 141 theorem integ_on_subsingleton {f:ℝ → ℝ} {I: BoundedInterval} (hI: |I|ₗ = 0) : 167 142 IntegrableOn f I ∧ integ f I = 0 := by 168 - have hI' := hI 169 - rw [←length_of_subsingleton] at hI' 143 + have _ := length_of_subsingleton.mpr hI 170 144 have hconst : ConstantOn f I := ConstantOn.of_subsingleton 171 - convert integ_of_piecewise_const _ 172 - . simp [PiecewiseConstantOn.integ_const' hconst, hI] 173 - exact PiecewiseConstantOn.of_const hconst 145 + convert integ_of_piecewise_const (PiecewiseConstantOn.of_const hconst) 146 + simp [PiecewiseConstantOn.integ_const' hconst, hI] 174 147 175 148 /-- Definition 11.3.9 (Riemann sums). The restriction to positive length J is not needed thanks to various junk value conventions. -/ 176 149 noncomputable abbrev upper_riemann_sum (f:ℝ → ℝ) {I: BoundedInterval} (P: Partition I) : ℝ := ··· 196 169 sorry 197 170 198 171 theorem upper_integ_eq_inf_upper_sum {f:ℝ → ℝ} {I:BoundedInterval} (hf: BddOn f I) : 199 - upper_integral f I = sInf (Set.range (fun P : Partition I ↦ upper_riemann_sum f P)) := by 172 + upper_integral f I = sInf (.range (fun P : Partition I ↦ upper_riemann_sum f P)) := by 200 173 sorry 201 174 202 175 theorem lower_integ_ge_lower_sum {f:ℝ → ℝ} {I:BoundedInterval} (hf: BddOn f I) ··· 204 177 sorry 205 178 206 179 theorem lower_integ_eq_sup_lower_sum {f:ℝ → ℝ} {I:BoundedInterval} (hf: BddOn f I) : 207 - lower_integral f I = sSup (Set.range (fun P : Partition I ↦ lower_riemann_sum f P)) := by 180 + lower_integral f I = sSup (.range (fun P : Partition I ↦ lower_riemann_sum f P)) := by 208 181 sorry 209 182 210 183 /-- Exercise 11.3.1 -/
+78 -134
analysis/Analysis/Section_11_4.lean
··· 96 96 lemma nonneg_of_le_const_mul_eps {x C:ℝ} (h: ∀ ε>0, x ≤ C * ε) : x ≤ 0 := by 97 97 by_cases hC: C > 0 98 98 . by_contra! 99 - specialize h (x/(2*C)) ( by positivity) 100 - convert_to x ≤ x/2 at h 99 + specialize h (x/(2*C)) ( by positivity); convert_to x ≤ x/2 at h 101 100 . field_simp; ring 102 101 linarith 103 - specialize h 1 (by norm_num) 104 - simp at h hC; linarith 102 + specialize h 1 (by norm_num); simp at h hC; linarith 105 103 106 104 /-- Theorem 11.4.3 (Max and min preserve integrability)-/ 107 105 theorem integ_of_max {I: BoundedInterval} {f g:ℝ → ℝ} (hf: IntegrableOn f I) (hg: IntegrableOn g I) : ··· 109 107 -- This proof is written to follow the structure of the original text. 110 108 unfold IntegrableOn at hf hg 111 109 have hmax_bound : BddOn (max f g) I := by 112 - obtain ⟨ M, hM ⟩ := hf.1 113 - obtain ⟨ M', hM' ⟩ := hg.1 114 - use max M M'; intro x hx 115 - specialize hM x hx 116 - specialize hM' x hx 110 + obtain ⟨ M, hM ⟩ := hf.1; obtain ⟨ M', hM' ⟩ := hg.1 111 + use max M M'; peel hM with x hx hM; specialize hM' _ hx 117 112 simp only [Pi.sup_apply] 118 113 apply abs_max_le_max_abs_abs.trans 119 114 exact sup_le_sup hM hM' ··· 122 117 obtain ⟨ f', hf'min, hf'const, hf'int ⟩ := gt_of_lt_lower_integral hf.1 (show integ f I - ε < lower_integral f I 123 118 by linarith) 124 119 obtain ⟨ g', hg'min, hg'const, hg'int ⟩ := gt_of_lt_lower_integral hg.1 (show integ g I - ε < lower_integral g I by linarith) 125 - obtain ⟨ f'', hf''max, hf''const, hf''int ⟩ := lt_of_gt_upper_integral hf.1 (show upper_integral f I < integ f I + ε by linarith) 126 - obtain ⟨ g'', hg''max, hg''const, hg''int ⟩ := lt_of_gt_upper_integral hg.1 (show upper_integral g I < integ g I + ε by linarith) 120 + obtain ⟨ f'', hf''max, hf''const, hf''int ⟩ := lt_of_gt_upper_integral hf.1 (show upper_integral f I < integ f I + ε by linarith) 121 + obtain ⟨ g'', hg''max, hg''const, hg''int ⟩ := lt_of_gt_upper_integral hg.1 (show upper_integral g I < integ g I + ε by linarith) 127 122 set h := (f'' - f') + (g'' - g') 128 123 have hf'_integ := integ_of_piecewise_const hf'const 129 124 have hg'_integ := integ_of_piecewise_const hg'const ··· 133 128 have hg''g'_integ := integ_of_sub hg''_integ.1 hg'_integ.1 134 129 have hh_integ_eq := integ_of_add hf''f'_integ.1 hg''g'_integ.1 135 130 have hinteg_le : integ h I ≤ 4 * ε := by linarith 136 - have hf''g''_const := PiecewiseConstantOn.max hf''const hg''const 131 + have hf''g''_const := hf''const.max hg''const 137 132 have hf''g''_maj : MajorizesOn (max f'' g'') (max f g) I := by 138 133 sorry 139 - have hf'g'_const := PiecewiseConstantOn.max hf'const hg'const 134 + have hf'g'_const := hf'const.max hg'const 140 135 have hf'g'_maj : MinorizesOn (max f' g') (max f g) I := by 141 136 sorry 142 137 have hff'g''_ge := upper_integral_le_integ hmax_bound hf''g''_maj hf''g''_const 143 138 have hf'g'_le := integ_le_lower_integral hmax_bound hf'g'_maj hf'g'_const 144 139 have : MinorizesOn (max f'' g'') (max f' g' + h) I := by 145 - intro x hx 146 - specialize hf'min x hx 147 - specialize hg'min x hx 148 - specialize hf''max x hx 149 - specialize hg''max x hx 150 - have hmaxl := le_max_left (f' x) (g' x) 151 - have hmaxr := le_max_right (f' x) (g' x) 152 - simp [h]; constructor <;> linarith 140 + peel hf'min with x hx hf'min; specialize hg'min _ hx; specialize hf''max _ hx; specialize hg''max _ hx 141 + simp [h]; and_intros <;> linarith [le_max_left (f' x) (g' x), le_max_right (f' x) (g' x)] 153 142 have hf'g'_integ := integ_of_piecewise_const hf'g'_const 154 143 have hf''g''_integ := integ_of_piecewise_const hf''g''_const 155 144 have hf'g'h_integ := integ_of_add hf'g'_integ.1 hh_integ_eq.1 156 145 rw [MinorizesOn.iff] at this 157 - replace this := integ_mono hf''g''_integ.1 hf'g'h_integ.1 this 158 - linarith 159 - refine ⟨ hmax_bound, ?_ ⟩ 160 - replace := nonneg_of_le_const_mul_eps this 161 - linarith 146 + linarith [integ_mono hf''g''_integ.1 hf'g'h_integ.1 this] 147 + exact ⟨ hmax_bound, by linarith [nonneg_of_le_const_mul_eps this] ⟩ 148 + 149 + 162 150 163 151 /-- Theorem 11.4.5 / Exercise 11.4.3. The objective here is to create a shorter proof than the one above.-/ 164 152 theorem integ_of_min {I: BoundedInterval} {f g:ℝ → ℝ} (hf: IntegrableOn f I) (hg: IntegrableOn g I) : ··· 168 156 /-- Corollary 11.4.4 -/ 169 157 theorem integ_of_abs {I: BoundedInterval} {f:ℝ → ℝ} (hf: IntegrableOn f I) : 170 158 IntegrableOn (abs f) I := by 171 - have f_plus := integ_of_max hf (integ_of_const 0 I).1 172 - have f_minus := integ_of_min hf (integ_of_const 0 I).1 173 - convert (integ_of_sub f_plus f_minus).1 using 1 174 - ext x 175 - rcases le_or_gt (f x) 0 with h | h 159 + have := (integ_of_const 0 I).1 160 + convert (integ_of_sub (integ_of_max hf this) (integ_of_min hf this)).1 using 1 161 + ext x; rcases le_or_gt (f x) 0 with h | h 176 162 . simp [h] 177 163 simp [le_of_lt h] 178 164 ··· 186 172 swap 187 173 . apply (integ_on_subsingleton _).1 188 174 rw [←BoundedInterval.length_of_subsingleton] 189 - rw [Set.not_nonempty_iff_eq_empty] at hI 190 - simp [hI] 175 + simp_all [Set.not_nonempty_iff_eq_empty] 191 176 unfold IntegrableOn at hf hg 192 177 obtain ⟨ M₁, hM₁ ⟩ := hf.1 193 178 obtain ⟨ M₂, hM₂ ⟩ := hg.1 194 - have hM₁pos : 0 ≤ M₁ := by 195 - specialize hM₁ hI.some hI.some_mem 196 - apply (abs_nonneg _).trans hM₁ 197 - have hM₂pos : 0 ≤ M₂ := by 198 - specialize hM₂ hI.some hI.some_mem 199 - apply (abs_nonneg _).trans hM₂ 179 + have hM₁pos : 0 ≤ M₁ := (abs_nonneg _).trans (hM₁ hI.some hI.some_mem) 180 + have hM₂pos : 0 ≤ M₂ := (abs_nonneg _).trans (hM₂ hI.some hI.some_mem) 200 181 have hmul_bound : BddOn (f * g) I := by 201 - use M₁ * M₂ 202 - intro x hx 203 - specialize hM₁ x hx 204 - specialize hM₂ x hx 205 - simp [abs_mul] 206 - exact mul_le_mul hM₁ hM₂ (by positivity) (by positivity) 182 + use M₁ * M₂; peel hM₁ with x hx hM₁; specialize hM₂ _ hx 183 + simp [abs_mul]; apply mul_le_mul hM₁ hM₂ <;> positivity 207 184 have lower_le_upper : 0 ≤ upper_integral (f * g) I - lower_integral (f * g) I := by 208 185 linarith [lower_integral_le_upper hmul_bound] 209 186 have (ε:ℝ) (hε: 0 < ε) : upper_integral (f * g) I - lower_integral (f * g) I ≤ 2*(M₁+M₂)*ε := by ··· 211 188 obtain ⟨ f', hf'min, hf'const, hf'int ⟩ := gt_of_lt_lower_integral hf.1 (show integ f I - ε < lower_integral f I by linarith) 212 189 use max f' 0 213 190 have hzero := PiecewiseConstantOn.of_const (ConstantOn.of_const' 0 I) 214 - refine ⟨ ?_, ?_, ?_, ?_ ⟩ 215 - . intro x hx 216 - specialize hf_nonneg x hx 217 - specialize hf'min x hx 218 - aesop 219 - . exact PiecewiseConstantOn.max hf'const hzero 220 - . apply lt_of_lt_of_le hf'int (PiecewiseConstantOn.integ_mono _ hf'const _) 221 - . intro x hx; simp 222 - exact PiecewiseConstantOn.max hf'const hzero 223 - intro x hx; simp 191 + and_intros 192 + . peel hf_nonneg with x hx _; specialize hf'min _ hx; aesop 193 + . exact hf'const.max hzero 194 + . exact lt_of_lt_of_le hf'int (hf'const.integ_mono (by intros; simp) (hf'const.max hzero)) 195 + intro _ _; simp 224 196 obtain ⟨ f', hf'min, hf'const, hf'int, hf'_nonneg ⟩ := this 225 197 have : ∃ g', MinorizesOn g' g I ∧ PiecewiseConstantOn g' I ∧ integ g I - ε < PiecewiseConstantOn.integ g' I ∧ MajorizesOn g' 0 I := by 226 198 obtain ⟨ g', hg'min, hg'const, hg'int ⟩ := gt_of_lt_lower_integral hg.1 (show integ g I - ε < lower_integral g I by linarith) 227 199 use max g' 0 228 200 have hzero := PiecewiseConstantOn.of_const (ConstantOn.of_const' 0 I) 229 - refine ⟨ ?_, ?_, ?_, ?_ ⟩ 230 - . intro x hx 231 - specialize hg_nonneg x hx 232 - specialize hg'min x hx 233 - aesop 234 - . exact PiecewiseConstantOn.max hg'const hzero 235 - . apply lt_of_lt_of_le hg'int (PiecewiseConstantOn.integ_mono _ hg'const _) 236 - . intro x hx; simp 237 - exact PiecewiseConstantOn.max hg'const hzero 238 - intro x hx; simp 201 + and_intros 202 + . peel hg_nonneg with x hx _; specialize hg'min _ hx; aesop 203 + . exact hg'const.max hzero 204 + . apply lt_of_lt_of_le hg'int (hg'const.integ_mono (by intros; simp) (hg'const.max hzero)) 205 + intro _ _; simp 239 206 obtain ⟨ g', hg'min, hg'const, hg'int, hg'_nonneg ⟩ := this 240 207 have : ∃ f'', MajorizesOn f'' f I ∧ PiecewiseConstantOn f'' I ∧ PiecewiseConstantOn.integ f'' I < integ f I + ε ∧ MinorizesOn f'' (fun _ ↦ M₁) I := by 241 208 obtain ⟨ f'', hf''maj, hf''const, hf''int ⟩ := lt_of_gt_upper_integral hf.1 (show upper_integral f I < integ f I + ε by linarith) 242 209 use min f'' (fun _ ↦ M₁) 243 210 have hM₁_piece := PiecewiseConstantOn.of_const (ConstantOn.of_const' M₁ I) 244 - refine ⟨ ?_, ?_, ?_, ?_ ⟩ 245 - . intro x hx 246 - specialize hM₁ x hx; rw [abs_le'] at hM₁ 247 - specialize hf''maj x hx 248 - simp [hf''maj, hM₁.1] 249 - . exact PiecewiseConstantOn.min hf''const hM₁_piece 250 - . apply lt_of_le_of_lt (PiecewiseConstantOn.integ_mono _ _ hf''const) hf''int 251 - . intro x hx; simp [hf''maj, hM₁_piece] 252 - exact PiecewiseConstantOn.min hf''const hM₁_piece 253 - intro x hx; simp 211 + and_intros 212 + . peel hM₁ with x hx hM₁; rw [abs_le'] at hM₁ 213 + specialize hf''maj _ hx; simp [hf''maj, hM₁.1] 214 + . exact hf''const.min hM₁_piece 215 + . apply lt_of_le_of_lt ((hf''const.min hM₁_piece).integ_mono _ hf''const) hf''int 216 + intros; simp [hf''maj, hM₁_piece] 217 + intro _ _; simp 254 218 obtain ⟨ f'', hf''maj, hf''const, hf''int, hf''bound ⟩ := this 255 219 have : ∃ g'', MajorizesOn g'' g I ∧ PiecewiseConstantOn g'' I ∧ PiecewiseConstantOn.integ g'' I < integ g I + ε ∧ MinorizesOn g'' (fun _ ↦ M₂) I := by 256 220 obtain ⟨ g'', hg''maj, hg''const, hg''int ⟩ := lt_of_gt_upper_integral hg.1 (show upper_integral g I < integ g I + ε by linarith) 257 221 use min g'' (fun _ ↦ M₂) 258 222 have hM₂_piece := PiecewiseConstantOn.of_const (ConstantOn.of_const' M₂ I) 259 - refine ⟨ ?_, ?_, ?_, ?_ ⟩ 260 - . intro x hx 261 - specialize hM₂ x hx; rw [abs_le'] at hM₂ 262 - specialize hg''maj x hx 263 - simp [hg''maj, hM₂.1] 264 - . exact PiecewiseConstantOn.min hg''const hM₂_piece 265 - . apply lt_of_le_of_lt (PiecewiseConstantOn.integ_mono _ _ hg''const) hg''int 266 - . intro x hx; simp [hg''maj, hM₂_piece] 267 - exact PiecewiseConstantOn.min hg''const hM₂_piece 268 - intro x hx; simp 223 + and_intros 224 + . peel hM₂ with x hx hM₂; rw [abs_le'] at hM₂ 225 + specialize hg''maj _ hx; simp [hg''maj, hM₂.1] 226 + . exact hg''const.min hM₂_piece 227 + . apply lt_of_le_of_lt ((hg''const.min hM₂_piece).integ_mono _ hg''const) hg''int 228 + intros; simp [hg''maj, hM₂_piece] 229 + intro _ _; simp 269 230 obtain ⟨ g'', hg''maj, hg''const, hg''int, hg''bound ⟩ := this 270 231 have hf'g'_const := PiecewiseConstantOn.mul hf'const hg'const 271 232 have hf'g'_maj : MinorizesOn (f' * g') (f * g) I := by 272 - intro x hx 273 - specialize hf'min x hx 274 - specialize hg'min x hx 275 - specialize hf'_nonneg x hx 276 - specialize hg'_nonneg x hx 277 - simp at hf'_nonneg hg'_nonneg ⊢ 278 - exact mul_le_mul hf'min hg'min (by positivity) (by linarith) 233 + peel hf'min with x hx hf'min; specialize hg'min _ hx; specialize hf'_nonneg _ hx; specialize hg'_nonneg _ hx 234 + simp at *; exact mul_le_mul hf'min hg'min (by positivity) (by linarith) 279 235 have hf''g''_const := PiecewiseConstantOn.mul hf''const hg''const 280 236 have hf''g''_maj : MajorizesOn (f'' * g'') (f * g) I := by 281 - intro x hx 282 - specialize hf''maj x hx 283 - specialize hg''maj x hx 284 - specialize hf''bound x hx 285 - specialize hg_nonneg x hx 286 - specialize hf_nonneg x hx 287 - simp at hf''bound hf_nonneg hg_nonneg ⊢ 288 - exact mul_le_mul hf''maj hg''maj (by positivity) (by linarith) 237 + peel hf''maj with x hx hf''maj; specialize hg''maj _ hx; specialize hf''bound _ hx 238 + specialize hg_nonneg _ hx; specialize hf_nonneg _ hx 239 + simp at *; exact mul_le_mul hf''maj hg''maj (by positivity) (by linarith) 289 240 have hupper_le := upper_integral_le_integ hmul_bound hf''g''_maj hf''g''_const 290 241 have hlower_ge := integ_le_lower_integral hmul_bound hf'g'_maj hf'g'_const 291 - have hh_const := PiecewiseConstantOn.sub hf''g''_const hf'g'_const 292 - have hh_integ := PiecewiseConstantOn.integ_sub hf''g''_const hf'g'_const 242 + have hh_const := hf''g''_const.sub hf'g'_const 243 + have hh_integ := hf''g''_const.integ_sub hf'g'_const 293 244 have hhmin : MinorizesOn (f'' * g'' - f' * g') (M₁ • (g''-g') + M₂ • (f''-f')) I := by 294 245 intro x hx 295 246 simp only [Pi.sub_apply, Pi.mul_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul] 296 247 calc 297 248 _ = (f'' x) * (g'' x - g' x) + (g' x) * (f'' x - f' x) := by ring 298 249 _ ≤ _ := by 299 - specialize hg'min x hx 300 - specialize hg''maj x hx 301 - specialize hf''bound x hx 302 - specialize hf'min x hx 303 - specialize hf''maj x hx 304 - specialize hg''bound x hx 305 - gcongr 306 - . linarith 307 - . linarith 308 - simp at hg''bound; linarith 309 - have hg''g'_const := PiecewiseConstantOn.sub hg''const hg'const 310 - have hg''g'_integ := PiecewiseConstantOn.integ_sub hg''const hg'const 311 - have hM₁g''g'_const := PiecewiseConstantOn.smul M₁ hg''g'_const 312 - have hM₁g''g_integ := PiecewiseConstantOn.integ_smul M₁ hg''g'_const 313 - have hf''f'_const := PiecewiseConstantOn.sub hf''const hf'const 314 - have hf''f_integ := PiecewiseConstantOn.integ_sub hf''const hf'const 315 - have hM₂f''f'_const := PiecewiseConstantOn.smul M₂ hf''f'_const 316 - have hM₂f''f_integ := PiecewiseConstantOn.integ_smul M₂ hf''f'_const 317 - have hsum_const := PiecewiseConstantOn.add hM₁g''g'_const hM₂f''f'_const 318 - have hsum_integ := PiecewiseConstantOn.integ_add hM₁g''g'_const hM₂f''f'_const 319 - have hsum_bound := PiecewiseConstantOn.integ_mono hhmin hh_const hsum_const 250 + specialize hg'min x hx; specialize hg''maj x hx; specialize hf''bound x hx 251 + specialize hf'min x hx; specialize hf''maj x hx; specialize hg''bound x hx 252 + simp at hg''bound; gcongr <;> linarith 253 + have hg''g'_const := hg''const.sub hg'const 254 + have hg''g'_integ := hg''const.integ_sub hg'const 255 + have hM₁g''g'_const := hg''g'_const.smul M₁ 256 + have hM₁g''g_integ := hg''g'_const.integ_smul M₁ 257 + have hf''f'_const := hf''const.sub hf'const 258 + have hf''f_integ := hf''const.integ_sub hf'const 259 + have hM₂f''f'_const := hf''f'_const.smul M₂ 260 + have hM₂f''f_integ := hf''f'_const.integ_smul M₂ 261 + have hsum_const := hM₁g''g'_const.add hM₂f''f'_const 262 + have hsum_integ := hM₁g''g'_const.integ_add hM₂f''f'_const 263 + have hsum_bound := hh_const.integ_mono hhmin hsum_const 320 264 calc 321 265 _ ≤ M₁ * PiecewiseConstantOn.integ (g'' - g') I + M₂ * PiecewiseConstantOn.integ (f'' - f') I := by linarith 322 266 _ ≤ M₁ * (2*ε) + M₂ * (2*ε) := by gcongr <;> linarith 323 267 _ = _ := by ring 324 - refine ⟨ hmul_bound, ?_ ⟩ 325 - replace := nonneg_of_le_const_mul_eps this 326 - linarith 268 + exact ⟨ hmul_bound, by linarith [nonneg_of_le_const_mul_eps this] ⟩ 269 + 327 270 328 271 theorem integ_of_mul {I: BoundedInterval} {f g:ℝ → ℝ} (hf: IntegrableOn f I) (hg: IntegrableOn g I) : 329 272 IntegrableOn (f * g) I := by ··· 332 275 set fminus := -min f (fun _ ↦ 0) 333 276 set gplus := max g (fun _ ↦ 0) 334 277 set gminus := -min g (fun _ ↦ 0) 335 - have hfplus_integ : IntegrableOn fplus I := integ_of_max hf (integ_of_const 0 I).1 336 - have hfminus_integ : IntegrableOn fminus I := (integ_of_neg (integ_of_min hf (integ_of_const 0 I).1)).1 337 - have hgplus_integ : IntegrableOn gplus I := integ_of_max hg (integ_of_const 0 I).1 338 - have hgminus_integ : IntegrableOn gminus I := (integ_of_neg (integ_of_min hg (integ_of_const 0 I).1)).1 339 - have hfplus_nonneg : MajorizesOn fplus 0 I := by intro x hx; simp [fplus] 340 - have hfminus_nonneg : MajorizesOn fminus 0 I := by intro x hx; simp [fminus] 341 - have hgplus_nonneg : MajorizesOn gplus 0 I := by intro x hx; simp [gplus] 342 - have hgminus_nonneg : MajorizesOn gminus 0 I := by intro x hx; simp [gminus] 278 + have := (integ_of_const 0 I).1 279 + have hfplus_integ : IntegrableOn fplus I := integ_of_max hf this 280 + have hfminus_integ : IntegrableOn fminus I := (integ_of_neg (integ_of_min hf this)).1 281 + have hgplus_integ : IntegrableOn gplus I := integ_of_max hg this 282 + have hgminus_integ : IntegrableOn gminus I := (integ_of_neg (integ_of_min hg this)).1 283 + have hfplus_nonneg : MajorizesOn fplus 0 I := by intro _ _; simp [fplus] 284 + have hfminus_nonneg : MajorizesOn fminus 0 I := by intro _ _; simp [fminus] 285 + have hgplus_nonneg : MajorizesOn gplus 0 I := by intro _ _; simp [gplus] 286 + have hgminus_nonneg : MajorizesOn gminus 0 I := by intro _ _; simp [gminus] 343 287 have hfplusgplus := integ_of_mul_nonneg hfplus_integ hgplus_integ hfplus_nonneg hgplus_nonneg 344 288 have hfplusgminus := integ_of_mul_nonneg hfplus_integ hgminus_integ hfplus_nonneg hgminus_nonneg 345 289 have hfminusgplus := integ_of_mul_nonneg hfminus_integ hgplus_integ hfminus_nonneg hgplus_nonneg