···121121 | Ico _ b => b
122122123123theorem BoundedInterval.subset_Icc (I: BoundedInterval) : I ⊆ Icc I.a I.b := match I with
124124- | Ioo a b => by simp [Ioo, Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Icc_self]
125125- | Icc a b => by simp [Icc, BoundedInterval.a, BoundedInterval.b, subset_iff]
126126- | Ioc a b => by simp [Ioc, Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioc_subset_Icc_self]
127127- | Ico a b => by simp [Ico, Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ico_subset_Icc_self]
124124+ | Ioo _ _ => by simp [Ioo, Icc, a, b, subset_iff, Set.Ioo_subset_Icc_self]
125125+ | Icc _ _ => by simp [Icc, a, b, subset_iff]
126126+ | Ioc _ _ => by simp [Ioc, Icc, a, b, subset_iff, Set.Ioc_subset_Icc_self]
127127+ | Ico _ _ => by simp [Ico, Icc, a, b, subset_iff, Set.Ico_subset_Icc_self]
128128129129theorem BoundedInterval.Ioo_subset (I: BoundedInterval) : Ioo I.a I.b ⊆ I := match I with
130130- | Ioo a b => by simp [Ioo, BoundedInterval.a, BoundedInterval.b, subset_iff]
131131- | Icc a b => by simp [Icc, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Icc_self]
132132- | Ioc a b => by simp [Ioc, Ioo, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Ioc_self]
133133- | Ico a b => by simp [Ico, Ioo, BoundedInterval.a, BoundedInterval.b, subset_iff, Set.Ioo_subset_Ico_self]
130130+ | Ioo _ _ => by simp [Ioo, a, b, subset_iff]
131131+ | Icc _ _ => by simp [Icc, a, b, subset_iff, Set.Ioo_subset_Icc_self]
132132+ | Ioc _ _ => by simp [Ioc, Ioo, a, b, subset_iff, Set.Ioo_subset_Ioc_self]
133133+ | Ico _ _ => by simp [Ico, Ioo, a, b, subset_iff, Set.Ioo_subset_Ico_self]
134134135135instance BoundedInterval.instTrans : IsTrans BoundedInterval (· ⊆ ·) where
136136- trans I J K hIJ hJK := by
137137- simp [subset_iff] at hIJ hJK ⊢
138138- exact hIJ.trans hJK
136136+ trans I J K hIJ hJK := by simp_all [subset_iff]; exact hIJ.trans hJK
139137140138@[simp]
141139theorem BoundedInterval.mem_inter (I J: BoundedInterval) (x:ℝ) :
142142- x ∈ (I ∩ J : BoundedInterval) ↔ x ∈ I ∧ x ∈ J := by
143143- simp [inter_eq, Set.mem_inter_iff, mem_iff, mem_iff]
140140+ x ∈ (I ∩ J : BoundedInterval) ↔ x ∈ I ∧ x ∈ J := by simp [mem_iff]
144141145142abbrev BoundedInterval.length (I: BoundedInterval) : ℝ := max (I.b - I.a) 0
146143···161158162159theorem BoundedInterval.empty_of_lt {I: BoundedInterval} (h: I.b < I.a) : (I:Set ℝ) = ∅ := by
163160 cases I with
164164- | Ioo a b => simp [Ioo, le_of_lt h]
165165- | Icc a b => simp [Icc, h]
166166- | Ioc a b => simp [Ioc, le_of_lt h]
167167- | Ico a b => simp [Ico, le_of_lt h]
161161+ | Ioo _ _ => simp [Ioo, le_of_lt h]
162162+ | Icc _ _ => simp [Icc, h]
163163+ | Ioc _ _ => simp [Ioc, le_of_lt h]
164164+ | Ico _ _ => simp [Ico, le_of_lt h]
168165169166theorem BoundedInterval.length_of_empty {I: BoundedInterval} (hI: (I:Set ℝ) = ∅) : |I|ₗ = 0 := by
170167 sorry
···175172theorem BoundedInterval.dist_le_length {I:BoundedInterval} {x y:ℝ} (hx: x ∈ I) (hy: y ∈ I) : |x - y| ≤ |I|ₗ := by
176173 replace hx := subset_Icc I _ hx
177174 replace hy := subset_Icc I _ hy
178178- simp [mem_iff, abs_le'] at hx hy ⊢
179179- left; constructor <;> linarith
175175+ simp_all [mem_iff, abs_le']; left; constructor <;> linarith
180176181177abbrev BoundedInterval.joins (K I J: BoundedInterval) : Prop := (I:Set ℝ) ∩ (J:Set ℝ) = ∅
182178 ∧ (K:Set ℝ) = (I:Set ℝ) ∪ (J:Set ℝ) ∧ |K|ₗ = |I|ₗ + |J|ₗ
···187183 . ext x; simp; constructor
188184 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b]
189185 rintro (_ | _) <;> and_intros <;> linarith
190190- simp [length, BoundedInterval.a, BoundedInterval.b,
191191- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
186186+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
192187193188theorem BoundedInterval.join_Icc_Ioo {a b c:ℝ} (hab: a ≤ b) (hbc: b < c) : (Ico a c).joins (Icc a b) (Ioo b c) := by
194189 and_intros
···196191 . ext x; simp; constructor
197192 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b]
198193 rintro (_ | _) <;> and_intros <;> linarith
199199- simp [length, BoundedInterval.a, BoundedInterval.b,
200200- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
194194+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
201195202196theorem BoundedInterval.join_Ioc_Ioc {a b c:ℝ} (hab: a ≤ b) (hbc: b ≤ c) : (Ioc a c).joins (Ioc a b) (Ioc b c) := by
203197 and_intros
···205199 . ext x; simp; constructor
206200 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b]
207201 rintro (_ | _) <;> and_intros <;> linarith
208208- simp [length, BoundedInterval.a, BoundedInterval.b,
209209- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
202202+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
210203211204theorem BoundedInterval.join_Ioc_Ioo {a b c:ℝ} (hab: a ≤ b) (hbc: b < c) : (Ioo a c).joins (Ioc a b) (Ioo b c) := by
212205 and_intros
···214207 . ext x; simp; constructor
215208 . intro ⟨ _, _ ⟩; simp_all [le_or_lt x b]
216209 rintro (_ | _) <;> and_intros <;> linarith
217217- simp [length, BoundedInterval.a, BoundedInterval.b,
218218- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
210210+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
219211220212theorem BoundedInterval.join_Ico_Icc {a b c:ℝ} (hab: a ≤ b) (hbc: b ≤ c) : (Icc a c).joins (Ico a b) (Icc b c) := by
221213 and_intros
···223215 . ext x; simp; constructor
224216 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b]
225217 rintro (_ | _) <;> and_intros <;> linarith
226226- simp [length, BoundedInterval.a, BoundedInterval.b,
227227- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
218218+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
228219229220theorem BoundedInterval.join_Ico_Ico {a b c:ℝ} (hab: a ≤ b) (hbc: b ≤ c) : (Ico a c).joins (Ico a b) (Ico b c) := by
230221 and_intros
···232223 . ext x; simp; constructor
233224 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b]
234225 rintro (_ | _) <;> and_intros <;> linarith
235235- simp [length, BoundedInterval.a, BoundedInterval.b,
236236- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
226226+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
237227238228theorem BoundedInterval.join_Ioo_Icc {a b c:ℝ} (hab: a < b) (hbc: b ≤ c) : (Ioc a c).joins (Ioo a b) (Icc b c) := by
239229 and_intros
···241231 . ext x; simp; constructor
242232 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b]
243233 rintro (_ | _) <;> and_intros <;> linarith
244244- simp [length, BoundedInterval.a, BoundedInterval.b,
245245- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
234234+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
246235247236theorem BoundedInterval.join_Ioo_Ico {a b c:ℝ} (hab: a < b) (hbc: b ≤ c) : (Ioo a c).joins (Ioo a b) (Ico b c) := by
248237 and_intros
···250239 . ext x; simp; constructor
251240 . intro ⟨ _, _ ⟩; simp_all [lt_or_le x b]
252241 rintro (_ | _) <;> and_intros <;> linarith
253253- simp [length, BoundedInterval.a, BoundedInterval.b,
254254- show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
242242+ simp [length, show a ≤ b by linarith, show b ≤ c by linarith, show a ≤ c by linarith]
255243256244257245@[ext]
···269257 bot := {
270258 intervals := {I}
271259 exists_unique x hx := by apply ExistsUnique.intro I <;> simp [hx]
272272- contains J hJ := by simp at hJ; rw [hJ, subset_iff]
260260+ contains J hJ := by simp_all [subset_iff]
273261 }
274262275263@[simp]
···281269{
282270 intervals := P.intervals ∪ Q.intervals
283271 exists_unique x hx := by
284284- simp [mem_iff, h.2] at hx
285285- rcases hx with hx | hx
286286- . obtain ⟨ L, hLP, hxL ⟩ := (P.exists_unique x hx).exists
272272+ simp [mem_iff, h.2] at hx; rcases hx with hx | hx
273273+ . obtain ⟨ L, hLP, hxL ⟩ := (P.exists_unique _ hx).exists
287274 apply ExistsUnique.intro L (by aesop)
288288- intro K ⟨hK, hxK⟩
289289- simp at hK; rcases hK with hKP | hKQ
290290- . exact (P.exists_unique x hx).unique ⟨ hKP, hxK ⟩ ⟨ hLP, hxL ⟩
291291- replace hxK := (BoundedInterval.subset_iff _ _).mp (Q.contains K hKQ) hxK
292292- have := congr(x ∈ $(h.1))
293293- simp [hx, hxK] at this
294294- obtain ⟨ L, hLQ, hxL ⟩ := (Q.exists_unique x hx).exists
275275+ intro K ⟨hK, hxK⟩; simp at hK; rcases hK with hKP | hKQ
276276+ . exact (P.exists_unique _ hx).unique ⟨ hKP, hxK ⟩ ⟨ hLP, hxL ⟩
277277+ replace hxK := (K.subset_iff _).mp (Q.contains _ hKQ) hxK
278278+ have := congr(x ∈ $(h.1)); simp [hx, hxK] at this
279279+ obtain ⟨ L, hLQ, hxL ⟩ := (Q.exists_unique _ hx).exists
295280 apply ExistsUnique.intro L (by aesop)
296296- intro K ⟨hK, hxK⟩
297297- simp at hK; rcases hK with hKP | hKQ
298298- . replace hxK := (BoundedInterval.subset_iff _ _).mp (P.contains K hKP) hxK
299299- have := congr(x ∈ $(h.1))
300300- simp [hx, hxK] at this
281281+ intro K ⟨hK, hxK⟩; simp at hK; rcases hK with hKP | hKQ
282282+ . replace hxK := (K.subset_iff _).mp (P.contains _ hKP) hxK
283283+ have := congr(x ∈ $(h.1)); simp [hx, hxK] at this
301284 exact (Q.exists_unique x hx).unique ⟨ hKQ, hxK ⟩ ⟨ hLQ, hxL ⟩
302285 contains L hL := by
303286 simp at hL; rcases hL with hLP | hLQ
304304- . apply (P.contains L hLP).trans
305305- simp [h, subset_iff]
306306- apply (Q.contains L hLQ).trans
307307- simp [h, subset_iff]
287287+ . apply (P.contains _ hLP).trans; simp [h, subset_iff]
288288+ apply (Q.contains _ hLQ).trans; simp [h, subset_iff]
308289}
309290310291@[simp]
···322303 simp [mem_iff] at hxK
323304 contains L hL := by
324305 simp at hL; rcases hL with hL | rfl
325325- . exact P.contains L hL
306306+ . exact P.contains _ hL
326307 simp [subset_iff]
327308}
328309···331312 intervals := P.intervals.filter (fun J ↦ (J:Set ℝ).Nonempty)
332313 exists_unique x hx := by
333314 obtain ⟨ J, hJP, hxJ ⟩ := (P.exists_unique x hx).exists
334334- apply ExistsUnique.intro J (by
335335- simp [hxJ, hJP]; simp [mem_iff] at hxJ; exact Set.nonempty_of_mem hxJ )
315315+ apply ExistsUnique.intro J (by simp_all [mem_iff]; exact Set.nonempty_of_mem hxJ )
336316 intro K ⟨ hK, hxK ⟩; simp at hK
337317 exact (P.exists_unique x hx).unique ⟨ hK.1, hxK ⟩ ⟨ hJP, hxJ ⟩
338338- contains L hL := by
339339- simp at hL; exact P.contains L hL.1
318318+ contains L hL := by simp at hL; exact P.contains _ hL.1
340319}
341320342321@[simp]
···344323 simp [Partition.add_empty, Finset.union_empty]
345324346325example : ∃ P:Partition (Icc 1 8),
347347- P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5,
348348- Icc 5 5, Ioc 5 8, ∅} := by
326326+ P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5, Icc 5 5, Ioc 5 8, ∅} := by
349327 set P1 : Partition (Icc 1 1) := ⊥
350350- set P2 : Partition (Ico 1 3) := P1.join (⊥:Partition (Ioo 1 3))
351351- (BoundedInterval.join_Icc_Ioo (by norm_num) (by norm_num) )
352352- set P3 : Partition (Ico 1 5) := P2.join (⊥:Partition (Ico 3 5))
353353- (BoundedInterval.join_Ico_Ico (by norm_num) (by norm_num) )
354354- set P4 : Partition (Icc 1 5) := P3.join (⊥:Partition (Icc 5 5))
355355- (BoundedInterval.join_Ico_Icc (by norm_num) (by norm_num) )
356356- set P5 : Partition (Icc 1 8) := P4.join (⊥:Partition (Ioc 5 8))
357357- (BoundedInterval.join_Icc_Ioc (by norm_num) (by norm_num) )
328328+ set P2 : Partition (Ico 1 3) := P1.join (⊥:Partition (Ioo 1 3)) (join_Icc_Ioo (by norm_num) (by norm_num) )
329329+ set P3 : Partition (Ico 1 5) := P2.join (⊥:Partition (Ico 3 5)) (join_Ico_Ico (by norm_num) (by norm_num) )
330330+ set P4 : Partition (Icc 1 5) := P3.join (⊥:Partition (Icc 5 5)) (join_Ico_Icc (by norm_num) (by norm_num) )
331331+ set P5 : Partition (Icc 1 8) := P4.join (⊥:Partition (Ioc 5 8)) (join_Icc_Ioc (by norm_num) (by norm_num) )
358332 use P5.add_empty
359333 simp [P5, P4, P3, P2, P1]
360334 aesop
361335362362-example : ∃ P:Partition (Icc 1 8),
363363- P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5,
364364- Icc 5 5, Ioc 5 8} := by
336336+example : ∃ P:Partition (Icc 1 8), P.intervals = {Icc 1 1, Ioo 1 3, Ico 3 5, Icc 5 5, Ioc 5 8} := by
365337 sorry
366338367367-example : ¬ ∃ P:Partition (Icc 1 5),
368368- P.intervals = {Icc 1 4, Icc 3 5} := by
339339+example : ¬ ∃ P:Partition (Icc 1 5), P.intervals = {Icc 1 4, Icc 3 5} := by
369340 sorry
370341371371-example : ¬ ∃ P:Partition (Ioo 1 5),
372372- P.intervals = {Ioo 1 3, Ioo 3 5} := by
342342+example : ¬ ∃ P:Partition (Ioo 1 5), P.intervals = {Ioo 1 3, Ioo 3 5} := by
373343 sorry
374344375375-example : ¬ ∃ P:Partition (Ioo 1 5),
376376- P.intervals = {Ioo 0 3, Ico 3 5} := by
345345+example : ¬ ∃ P:Partition (Ioo 1 5), P.intervals = {Ioo 0 3, Ico 3 5} := by
377346 sorry
378347379348···383352 : ∃ c ∈ Set.Ico I.a I.b, Ioo c I.b ∈ P ∨ Ico c I.b ∈ P := by
384353 sorry
385354386386-/-- Theorem 11.1.13 (Length is finitely additive).
387387-Due to the excessive case analysis, `simp only` is used in place of `simp` in some places
388388-to speed up elaboration. -/
355355+/-- Theorem 11.1.13 (Length is finitely additive). -/
389356theorem Partition.sum_of_length (I: BoundedInterval) (P: Partition I) :
390357 ∑ J ∈ P.intervals, |J|ₗ = |I|ₗ := by
391358 -- This proof is written to follow the structure of the original text.
···394361 . rw [Finset.card_eq_zero] at hcard
395362 have : (I:Set ℝ) = ∅ := by
396363 sorry
397397- replace this := length_of_empty this
398398- simp only [hcard, Finset.sum_empty, this]
364364+ simp [hcard, length_of_empty this]
399365 -- the proof in the book treats the n=1 case separately, but this is unnecessary
400366 by_cases h : Subsingleton (I:Set ℝ)
401367 . have (J: BoundedInterval) (hJ: J ∈ P) : Subsingleton (J:Set ℝ) := by
402368 sorry
403369 simp_rw [length_of_subsingleton] at h this
404404- simp only [h]
405405- apply Finset.sum_eq_zero this
406406- simp only [length_of_subsingleton, length, sup_eq_right, tsub_le_iff_right, zero_add, not_le] at h
370370+ convert Finset.sum_eq_zero this
371371+ simp [length_of_subsingleton, length, -Set.subsingleton_coe] at h
407372 have : ∃ K L : BoundedInterval, K ∈ P ∧ I.joins L K := by
408373 by_cases hI' : I.b ∈ I
409374 . obtain ⟨ K, hK, hbK ⟩ := (P.exists_unique I.b hI').exists
410375 have hKI : K ⊆ I := P.contains K hK
411376 by_cases hsub : Subsingleton (K:Set ℝ)
412412- . simp_all [mem_iff, Set.subsingleton_coe]
413413- replace hbK := Set.Subsingleton.eq_singleton_of_mem hsub hbK
377377+ . simp_all [mem_iff]
378378+ replace hbK := hsub.eq_singleton_of_mem hbK
414379 have : K = Icc (I.b) (I.b) := by
415380 sorry
416381 subst this
417382 cases I with
418418- | Ioo a b => simp [mem_iff, Set.mem_Ioo, lt_self_iff_false, and_false] at hI'
419419- | Icc a b => use (Icc b b), hK, Ico a b
420420- exact join_Ico_Icc (le_of_lt h) (le_refl _)
421421- | Ioc a b => use (Icc b b), hK, Ioo a b
422422- exact join_Ioo_Icc h (le_refl _)
423423- | Ico a b => simp [mem_iff, Set.mem_Ico, lt_self_iff_false, and_false] at hI'
424424- simp only [length_of_subsingleton, sup_eq_right, tsub_le_iff_right, zero_add, not_le] at hsub
383383+ | Ioo _ _ => simp [mem_iff] at hI'
384384+ | Icc a b => use (Icc b b), hK, Ico a b; apply join_Ico_Icc <;> order
385385+ | Ioc a b => use (Icc b b), hK, Ioo a b; apply join_Ioo_Icc <;> order
386386+ | Ico _ _ => simp [mem_iff] at hI'
387387+ simp [length_of_subsingleton, -Set.subsingleton_coe] at hsub
425388 have hKI' := (K.Ioo_subset.trans hKI).trans I.subset_Icc
426389 simp only [subset_iff] at hKI'
427390 have hKb : K.b = I.b := by
428428- rw [le_antisymm_iff]
429429- constructor
430430- . replace hKI' := csSup_le_csSup bddAbove_Icc ?_ hKI'
431431- . simp_all [csSup_Ioo hsub, csSup_Icc (le_of_lt h)]
432432- simp [Set.nonempty_Ioo, hsub]
433433- have := K.subset_Icc _ hbK
434434- simp only [mem_iff, Set.mem_Icc] at this
435435- exact this.2
391391+ rw [le_antisymm_iff]; and_intros
392392+ . replace hKI' := csSup_le_csSup bddAbove_Icc (by simp [hsub]) hKI'
393393+ simp_all [csSup_Ioo hsub, csSup_Icc (le_of_lt h)]
394394+ have := K.subset_Icc _ hbK; simp only [mem_iff, Set.mem_Icc] at this; exact this.2
436395 have hKA : I.a ≤ K.a := by
437437- replace hKI' := csInf_le_csInf bddBelow_Icc ?_ hKI'
438438- . simp_all [csInf_Icc (le_of_lt h), csInf_Ioo]
439439- simp [Set.nonempty_Ioo, hsub]
396396+ replace hKI' := csInf_le_csInf bddBelow_Icc (by simp [hsub]) hKI'
397397+ simp_all [csInf_Icc (le_of_lt h), csInf_Ioo]
440398 cases I with
441441- | Ioo a b => simp [mem_iff, Set.mem_Ioo, lt_self_iff_false, and_false] at hI'
442442- | Icc a b =>
399399+ | Ioo _ _ => simp [mem_iff] at hI'
400400+ | Icc a₁ b₁ =>
443401 cases K with
444444- | Ioo c b' =>
445445- simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b, Set.mem_Icc, Set.mem_Ioo] at *
446446- linarith
447447- | Icc c b' =>
448448- use Icc c b', Ico a c, hK
449449- simp [BoundedInterval.b] at hKb; subst hKb
450450- exact join_Ico_Icc hKA (by linarith)
451451- | Ioc c b' =>
452452- use Ioc c b', Icc a c, hK
453453- simp [BoundedInterval.b] at hKb; subst hKb
454454- exact join_Icc_Ioc hKA (by linarith)
455455- | Ico c b' => simp [BoundedInterval.a, BoundedInterval.b, mem_iff, Set.mem_Icc,
456456- le_refl, and_true, Set.mem_Ico, subset_iff] at *; linarith
457457- | Ioc a b =>
402402+ | Ioo _ _ => simp [mem_iff, subset_iff, a, b] at *; linarith
403403+ | Icc c₂ b₂ => use Icc c₂ b₂, Ico a₁ c₂, hK; simp_all [b]; apply join_Ico_Icc <;> order
404404+ | Ioc c₂ b₂ => use Ioc c₂ b₂, Icc a₁ c₂, hK; simp_all [b]; apply join_Icc_Ioc <;> order
405405+ | Ico _ _ => simp [a, b, mem_iff] at *; linarith
406406+ | Ioc a₁ b₁ =>
458407 cases K with
459459- | Ioo c b' => simp_all [mem_iff, subset_iff]
460460- | Icc c b' =>
461461- use Icc c b', Ioo a c, hK
462462- simp [BoundedInterval.b] at hKb; subst hKb
463463- simp [subset_iff] at hKI
464464- have : c ∈ Set.Icc c b' := by simp; linarith
408408+ | Ioo _ _ => simp_all [mem_iff, subset_iff]
409409+ | Icc c₂ b₂ =>
410410+ use Icc c₂ b₂, Ioo a₁ c₂, hK
411411+ simp_all [a,b,subset_iff]
412412+ have : c₂ ∈ Set.Icc c₂ b₁ := by simp; linarith
465413 replace this := hKI this; simp at this
466466- exact join_Ioo_Icc (by linarith) (by linarith)
467467- | Ioc c b' =>
468468- use Ioc c b', Ioc a c, hK
469469- simp [BoundedInterval.b] at hKb; subst hKb
470470- exact join_Ioc_Ioc hKA (by linarith)
471471- | Ico c b' =>
472472- simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b, Set.mem_Ioc, Set.mem_Ico] at *; linarith
473473- | Ico a b => simp [mem_iff, Set.mem_Ico, lt_self_iff_false, and_false] at hI'
414414+ apply join_Ioo_Icc <;> tauto
415415+ | Ioc c₂ b₂ => use Ioc c₂ b₂, Ioc a₁ c₂, hK; simp_all [b]; apply join_Ioc_Ioc <;> order
416416+ | Ico _ _ => simp [mem_iff, subset_iff, a, b] at *; linarith
417417+ | Ico _ _ => simp [mem_iff] at hI'
474418 obtain ⟨ c, hc, hK ⟩ := P.exist_right h hI'
475419 cases I with
476476- | Ioo a b =>
420420+ | Ioo a₁ b₁ =>
477421 rcases hK with hK | hK
478478- . simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b]
479479- use Ioo c b, hK, Ioc a c
480480- exact join_Ioc_Ioo (hc.1) (hc.2)
481481- simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b]
482482- use Ico c b, hK, Ioo a c
483483- replace hK := P.contains _ hK
484484- simp [subset_iff] at hK
485485- have : c ∈ Set.Ico c b := by simp; linarith
422422+ . simp_all [mem_iff, subset_iff, a, b]; use Ioo c b₁, hK, Ioc a₁ c; apply join_Ioc_Ioo <;> tauto
423423+ simp_all [mem_iff, subset_iff, a, b]
424424+ use Ico c b₁, hK, Ioo a₁ c
425425+ replace hK := P.contains _ hK; simp [subset_iff] at hK
426426+ have : c ∈ Set.Ico c b₁ := by simp; linarith
486427 replace this := hK this; simp at this
487487- exact join_Ioo_Ico (by linarith) (by linarith)
488488- | Icc a b => simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] at hI' h; linarith
489489- | Ioc a b => simp [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b] at hI' h; linarith
490490- | Ico a b =>
428428+ apply join_Ioo_Ico <;> linarith
429429+ | Icc _ _ => simp [mem_iff, subset_iff, a, b] at hI' h; order
430430+ | Ioc _ _ => simp [mem_iff, subset_iff, a, b] at hI' h; order
431431+ | Ico a₁ b₁ =>
491432 rcases hK with hK | hK
492492- . simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b]
493493- use Ioo c b, hK, Icc a c
494494- exact join_Icc_Ioo (hc.1) (hc.2)
495495- simp_all [mem_iff, subset_iff, BoundedInterval.a, BoundedInterval.b]
496496- use Ico c b, hK, Ico a c
497497- exact join_Ico_Ico (by linarith) (by linarith)
433433+ . simp_all [mem_iff, subset_iff, a, b]; use Ioo c b₁, hK, Icc a₁ c; apply join_Icc_Ioo <;> tauto
434434+ simp_all [mem_iff, subset_iff, a, b]; use Ico c b₁, hK, Ico a₁ c; apply join_Ico_Ico <;> linarith
498435 obtain ⟨ K, L, hK, ⟨ h1, h2, h3 ⟩ ⟩ := this
499436 have : ∃ P' : Partition L, P'.intervals = P.intervals.erase K := by
500437 sorry
501438 obtain ⟨ P', hP' ⟩ := this
502502- rw [h3, ←Finset.add_sum_erase _ _ hK, ←hP', add_comm]
503503- congr
504504- apply hn _ _ _
505505- simp only [hP', Finset.card_erase_of_mem hK, hcard, add_tsub_cancel_right]
439439+ rw [h3, ←Finset.add_sum_erase _ _ hK, ←hP', add_comm]; congr
440440+ apply hn; simp [hP', Finset.card_erase_of_mem hK, hcard]
506441507442/-- Definition 11.1.14 (Finer and coarser partitions) -/
508443instance Partition.instLE (I: BoundedInterval) : LE (Partition I) where
···531466 max P P' := {
532467 intervals := Finset.image₂ (fun J K ↦ J ∩ K) P.intervals P'.intervals
533468 exists_unique x hx := by
534534- obtain ⟨ J, ⟨ hJ1, hJ2⟩, hxJ ⟩ := P.exists_unique x hx
535535- obtain ⟨ K, ⟨ hK1, hK2⟩, hxK ⟩ := P'.exists_unique x hx
469469+ obtain ⟨ J, ⟨ hJ1, hJ2⟩, hxJ ⟩ := P.exists_unique _ hx
470470+ obtain ⟨ K, ⟨ hK1, hK2⟩, hxK ⟩ := P'.exists_unique _ hx
536471 simp [hx] at hxJ hxK
537472 apply ExistsUnique.intro (J ∩ K)
538538- . simp; exact ⟨ ⟨ J, hJ1, K, hK1, rfl ⟩, ⟨ hJ2, hK2 ⟩ ⟩
539539- simp; rintro L J' hJ' K' hK' rfl hx'; simp at hx'
540540- specialize hxJ J' hJ' hx'.1
541541- specialize hxK K' hK' hx'.2
542542- simp [hxJ, hxK]
473473+ . simp_all; exact ⟨ _, hJ1, _, hK1, rfl ⟩
474474+ simp; rintro _ J' hJ' K' hK' rfl hx'; simp at hx'
475475+ simp [hxJ _ hJ' hx'.1, hxK _ hK' hx'.2]
543476 contains L hL := by
544477 simp at hL
545478 obtain ⟨ J, hJ, K, hK, rfl ⟩ := hL
546546- replace hJ := P.contains J hJ
547547- replace hK := P'.contains K hK
479479+ replace hJ := P.contains _ hJ
480480+ replace hK := P'.contains _ hK
548481 simp [subset_iff] at hJ hK ⊢
549482 exact Set.inter_subset_left.trans hJ
550483 }
551484552485553486/-- Example 11.1.17 -/
554554-example : ∃ P P' : Partition (Icc 1 4),
555555- P.intervals = {Ico 1 3, Icc 3 4} ∧
556556- P'.intervals = {Icc 1 2, Ioc 2 4} ∧
487487+example : ∃ P P' : Partition (Icc 1 4), P.intervals = {Ico 1 3, Icc 3 4} ∧ P'.intervals = {Icc 1 2, Ioc 2 4} ∧
557488 (P' ⊔ P).intervals = {Icc 1 2, Ioo 2 3, Icc 3 4, ∅} := by
558489 sorry
559490
+28-43
analysis/Analysis/Section_11_2.lean
···2727 if h: Constant f then h.choose else hY.some
28282929theorem Constant.eq {X Y:Type} {f: X → Y} [Nonempty Y] (h: Constant f) (x:X) :
3030- f x = constant_value f := by
3131- rw [constant_value, dif_pos h]
3232- exact h.choose_spec x
3030+ f x = constant_value f := by simp [constant_value, h]; apply h.choose_spec
33313432theorem Constant.of_const {X Y:Type} {f:X → Y} {c:Y} (h: ∀ x, f x = c) :
3533 Constant f := by use c
36343735theorem Constant.const_eq {X Y:Type} {f:X → Y} [hX: Nonempty X] [Nonempty Y] {c:Y} (h: ∀ x, f x = c) :
3838- constant_value f = c := by
3939- rw [←eq (of_const h) hX.some, h hX.some]
3636+ constant_value f = c := by rw [←eq (of_const h) hX.some, h hX.some]
40374141-theorem Constant.of_subsingleton {X Y:Type} [Subsingleton X] [hY: Nonempty Y] {f:X → Y} :
3838+theorem Constant.of_subsingleton {X Y:Type} [hs: Subsingleton X] [hY: Nonempty Y] {f:X → Y} :
4239 Constant f := by
4340 by_cases h:Nonempty X
4444- . use f (h.some : X); intro x; congr; exact Subsingleton.elim x h.some
4545- use hY.some; intro x; simp at h; exact IsEmpty.elim h x
4141+ . use f h.some; intros; congr; exact hs.elim _ h.some
4242+ use hY.some; intro x; simp at h; exact h.elim x
46434744abbrev ConstantOn (f: ℝ → ℝ) (X: Set ℝ) : Prop := Constant (fun x : X ↦ f ↑x)
4845···50475148theorem ConstantOn.eq {f: ℝ → ℝ} {X: Set ℝ} (h: ConstantOn f X) {x:ℝ} (hx: x ∈ X) :
5249 f x = constant_value_on f X := by
5353- convert Constant.eq h ⟨ x, hx ⟩
5050+ convert Constant.eq h ⟨ _, hx ⟩
54515552theorem ConstantOn.of_const {f:ℝ → ℝ} {X: Set ℝ} {c:ℝ} (h: ∀ x ∈ X, f x = c) :
5653 ConstantOn f X := by use c; rintro ⟨ x, hx ⟩; simp [h x hx]
57545855theorem ConstantOn.of_const' (c:ℝ) (X:Set ℝ): ConstantOn (fun _ ↦ c) X := by
5959- apply ConstantOn.of_const (c := c)
6060- simp
5656+ apply of_const (c := c); simp
61576258theorem ConstantOn.const_eq {f:ℝ → ℝ} {X: Set ℝ} (hX: X.Nonempty) {c:ℝ} (h: ∀ x ∈ X, f x = c) :
6359 constant_value_on f X = c := by
6460 rw [←eq (of_const h) hX.some_mem, h _ hX.some_mem]
65616662theorem ConstantOn.congr {f g: ℝ → ℝ} {X: Set ℝ} (h: ∀ x ∈ X, f x = g x) : ConstantOn f X ↔ ConstantOn g X := by
6767- simp [ConstantOn]; rw [iff_iff_eq]
6868- congr; ext ⟨ x, hx ⟩; simp [h x hx]
6363+ simp [ConstantOn]; rw [iff_iff_eq]; congr; ext ⟨ _, hx ⟩; simp [h _ hx]
69647065theorem ConstantOn.of_subsingleton {f: ℝ → ℝ} {X: Set ℝ} [Subsingleton X] :
7166 ConstantOn f X := Constant.of_subsingleton
72677368theorem constant_value_on_congr {f g: ℝ → ℝ} {X: Set ℝ} (h: ∀ x ∈ X, f x = g x) :
7469 constant_value_on f X = constant_value_on g X := by
7575- simp [constant_value_on]
7676- congr; ext ⟨ x, hx ⟩; simp [h x hx]
7070+ simp [constant_value_on]; congr; ext ⟨ _, hx ⟩; simp [h _ hx]
77717872/-- Definition 11.2.3 (Piecewise constant functions I) -/
7973abbrev PiecewiseConstantWith (f:ℝ → ℝ) {I: BoundedInterval} (P: Partition I) : Prop := ∀ J ∈ P, ConstantOn f (J:Set ℝ)
···8579theorem PiecewiseConstantWith.congr {f g:ℝ → ℝ} {I: BoundedInterval} {P: Partition I}
8680 (h: ∀ x ∈ (I:Set ℝ), f x = g x) :
8781 PiecewiseConstantWith f P ↔ PiecewiseConstantWith g P := by
8888- simp [PiecewiseConstantWith]
8989- peel with J hJ
9090- apply ConstantOn.congr; intro x hx
9191- have := P.contains _ hJ; rw [subset_iff] at this
9292- solve_by_elim
8282+ simp [PiecewiseConstantWith]; peel with J hJ
8383+ apply ConstantOn.congr; intros; have := P.contains _ hJ; rw [subset_iff] at this; solve_by_elim
93849485/-- Definition 11.2.5 (Piecewise constant functions I) -/
9586abbrev PiecewiseConstantOn (f:ℝ → ℝ) (I: BoundedInterval) : Prop := ∃ P : Partition I, PiecewiseConstantWith f P
···173164theorem PiecewiseConstantWith.integ_congr {f g:ℝ → ℝ} {I: BoundedInterval} {P: Partition I}
174165 (h: ∀ x ∈ (I:Set ℝ), f x = g x) : PiecewiseConstantWith.integ f P = PiecewiseConstantWith.integ g P := by
175166 simp only [integ, Subtype.forall]
176176- apply Finset.sum_congr rfl; intro J hJ; congr 1
177177- apply constant_value_on_congr; intro x hx
167167+ apply Finset.sum_congr rfl; intro J hJ; congr 1; apply constant_value_on_congr; intros
178168 have := P.contains _ hJ; rw [subset_iff] at this
179169 aesop
180170···212202213203/-- Proposition 11.2.13 (Piecewise constant integral is independent of partition) / Exercise 11.2.3 -/
214204theorem PiecewiseConstantWith.integ_eq {f:ℝ → ℝ} {I: BoundedInterval} {P P': Partition I}
215215- (hP: PiecewiseConstantWith f P) (hP': PiecewiseConstantWith f P') : PiecewiseConstantWith.integ f P = PiecewiseConstantWith.integ f P' := by
205205+ (hP: PiecewiseConstantWith f P) (hP': PiecewiseConstantWith f P') : integ f P = integ f P' := by
216206 sorry
217207218208open Classical in
···221211 ℝ := if h: PiecewiseConstantOn f I then PiecewiseConstantWith.integ f h.choose else 0
222212223213theorem PiecewiseConstantOn.integ_def {f:ℝ → ℝ} {I: BoundedInterval} {P: Partition I}
224224- (h: PiecewiseConstantWith f P) : PiecewiseConstantOn.integ f I = PiecewiseConstantWith.integ f P := by
214214+ (h: PiecewiseConstantWith f P) : integ f I = PiecewiseConstantWith.integ f P := by
225215 have h' : PiecewiseConstantOn f I := by use P
226226- simp [PiecewiseConstantOn.integ, h']
227227- exact PiecewiseConstantWith.integ_eq h'.choose_spec h
216216+ simp [integ, h']; exact PiecewiseConstantWith.integ_eq h'.choose_spec h
228217229218theorem PiecewiseConstantOn.integ_congr {f g:ℝ → ℝ} {I: BoundedInterval}
230219 (h: ∀ x ∈ (I:Set ℝ), f x = g x) : PiecewiseConstantOn.integ f I = PiecewiseConstantOn.integ g I := by
231220 by_cases hf : PiecewiseConstantOn f I
232232- <;> have hg := hf <;> rw [PiecewiseConstantOn.congr h] at hg <;> simp [integ, hf, hg]
233233- rw [PiecewiseConstantWith.integ_congr h, ←integ_def ?_, ←integ_def ?_]
234234- . exact hg.choose_spec
235235- rw [←PiecewiseConstantWith.congr h]
236236- exact hf.choose_spec
221221+ <;> have hg := hf <;> rw [congr h] at hg <;> simp [integ, hf, hg]
222222+ rw [PiecewiseConstantWith.integ_congr h, ←integ_def hg.choose_spec, ←integ_def ?_]
223223+ rw [←PiecewiseConstantWith.congr h]; exact hf.choose_spec
237224238225/-- Example 11.2.15 -/
239226example : PiecewiseConstantOn.integ f_11_2_4 (Icc 1 6) = 10 := by
···242229/-- Theorem 11.2.16 (a) (Laws of integration) / Exercise 11.2.4 -/
243230theorem PiecewiseConstantOn.integ_add {f g: ℝ → ℝ} {I: BoundedInterval}
244231 (hf: PiecewiseConstantOn f I) (hg: PiecewiseConstantOn g I) :
245245- PiecewiseConstantOn.integ (f + g) I = PiecewiseConstantOn.integ f I + PiecewiseConstantOn.integ g I := by
232232+ integ (f + g) I = integ f I + integ g I := by
246233 sorry
247234248235/-- Theorem 11.2.16 (b) (Laws of integration) / Exercise 11.2.4 -/
249249-theorem PiecewiseConstantOn.integ_smul {f: ℝ → ℝ} {I: BoundedInterval} (c:ℝ)
250250- (hf: PiecewiseConstantOn f I) :
251251- PiecewiseConstantOn.integ (c • f) I = c * PiecewiseConstantOn.integ f I
236236+theorem PiecewiseConstantOn.integ_smul {f: ℝ → ℝ} {I: BoundedInterval} (c:ℝ) (hf: PiecewiseConstantOn f I) :
237237+ integ (c • f) I = c * integ f I
252238 := by
253239 sorry
254240255241/-- Theorem 11.2.16 (c) (Laws of integration) / Exercise 11.2.4 -/
256242theorem PiecewiseConstantOn.integ_sub {f g: ℝ → ℝ} {I: BoundedInterval}
257243 (hf: PiecewiseConstantOn f I) (hg: PiecewiseConstantOn g I) :
258258- PiecewiseConstantOn.integ (f - g) I = PiecewiseConstantOn.integ f I - PiecewiseConstantOn.integ g I
259259- := by
244244+ integ (f - g) I = integ f I - integ g I := by
260245 sorry
261246262247/-- Theorem 11.2.16 (d) (Laws of integration) / Exercise 11.2.4 -/
263248theorem PiecewiseConstantOn.integ_of_nonneg {f: ℝ → ℝ} {I: BoundedInterval} (h: ∀ x ∈ I, 0 ≤ f x)
264249 (hf: PiecewiseConstantOn f I) :
265265- 0 ≤ PiecewiseConstantOn.integ f I := by
250250+ 0 ≤ integ f I := by
266251 sorry
267252268253/-- Theorem 11.2.16 (e) (Laws of integration) / Exercise 11.2.4 -/
269254theorem PiecewiseConstantOn.integ_mono {f g: ℝ → ℝ} {I: BoundedInterval} (h: ∀ x ∈ I, f x ≤ g x)
270255 (hf: PiecewiseConstantOn f I) (hg: PiecewiseConstantOn g I) :
271271- PiecewiseConstantOn.integ f I ≤ PiecewiseConstantOn.integ g I := by
256256+ integ f I ≤ integ g I := by
272257 sorry
273258274259275260/-- Theorem 11.2.16 (f) (Laws of integration) / Exercise 11.2.4 -/
276261theorem PiecewiseConstantOn.integ_const (c: ℝ) (I: BoundedInterval) :
277277- PiecewiseConstantOn.integ (fun _ ↦ c) I = c * |I|ₗ := by
262262+ integ (fun _ ↦ c) I = c * |I|ₗ := by
278263 sorry
279264280265/-- Theorem 11.2.16 (f) (Laws of integration) / Exercise 11.2.4 -/
281266theorem PiecewiseConstantOn.integ_const' {f:ℝ → ℝ} {I: BoundedInterval} (h: ConstantOn f I) :
282282- PiecewiseConstantOn.integ f I = (constant_value_on f I) * |I|ₗ := by
267267+ integ f I = (constant_value_on f I) * |I|ₗ := by
283268 sorry
284269285270open Classical in
···293278/-- Theorem 11.2.16 (g) (Laws of integration) / Exercise 11.2.4 -/
294279theorem PiecewiseConstantOn.integ_of_extend {I J: BoundedInterval} (hIJ: I ⊆ J)
295280 {f: ℝ → ℝ} (h: PiecewiseConstantOn f I) :
296296- PiecewiseConstantOn.integ (fun x ↦ if x ∈ I then f x else 0) J = PiecewiseConstantOn.integ f I := by
281281+ integ (fun x ↦ if x ∈ I then f x else 0) J = integ f I := by
297282 sorry
298283299284/-- Theorem 11.2.16 (h) (Laws of integration) / Exercise 11.2.4 -/
···304289/-- Theorem 11.2.16 (h) (Laws of integration) / Exercise 11.2.4 -/
305290theorem PiecewiseConstantOn.integ_of_join {I J K: BoundedInterval} (hIJK: K.joins I J)
306291 {f: ℝ → ℝ} (h: PiecewiseConstantOn f K) :
307307- PiecewiseConstantOn.integ f K = PiecewiseConstantOn.integ f I + PiecewiseConstantOn.integ f J := by
292292+ integ f K = integ f I + integ f J := by
308293 sorry
309294310295end Chapter11
+22-49
analysis/Analysis/Section_11_3.lean
···44444545lemma 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
4646 simp
4747- refine ⟨ fun _ ↦ M , ⟨ ⟨ ?_, ?_, ⟩, ?_ ⟩ ⟩
4848- . peel h with x hx h'
4949- simp [abs_le'] at h'
5050- simp [h'.1]
5151- . apply PiecewiseConstantOn.of_const (ConstantOn.of_const (c := M) _)
5252- simp
5353- exact PiecewiseConstantOn.integ_const M I
4747+ refine ⟨ fun _ ↦ M , ⟨ ⟨ ?_, ?_, ⟩, PiecewiseConstantOn.integ_const M I ⟩ ⟩
4848+ . peel h with _ _ h'; simp [abs_le'] at h'; simp [h'.1]
4949+ exact PiecewiseConstantOn.of_const (ConstantOn.of_const (c := M) (by simp))
54505551lemma 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
5652 simp
5757- refine ⟨ fun _ ↦ -M , ⟨ ⟨ ?_, ?_, ⟩, ?_ ⟩ ⟩
5858- . peel h with x hx h'
5959- simp [abs_le'] at h'
6060- simp; linarith
6161- . apply PiecewiseConstantOn.of_const (ConstantOn.of_const (c := -M) _)
6262- simp
6363- convert PiecewiseConstantOn.integ_const (-M) I using 1
6464- simp
5353+ refine ⟨ fun _ ↦ -M , ⟨ ⟨ ?_, ?_, ⟩, by convert PiecewiseConstantOn.integ_const (-M) I using 1; simp ⟩ ⟩
5454+ . peel h with _ _ h'; simp [abs_le'] at h'; simp; linarith
5555+ exact PiecewiseConstantOn.of_const (ConstantOn.of_const (c := -M) (by simp))
65566657lemma 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
6767- obtain ⟨ _, h ⟩ := h
6868- apply Set.nonempty_of_mem
6969- exact integral_bound_upper_of_bounded h
5858+ obtain ⟨ _, h ⟩ := h; exact Set.nonempty_of_mem (integral_bound_upper_of_bounded h)
70597160lemma 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
7272- obtain ⟨ _, h ⟩ := h
7373- apply Set.nonempty_of_mem
7474- exact integral_bound_lower_of_bounded h
6161+ obtain ⟨ _, h ⟩ := h; exact Set.nonempty_of_mem (integral_bound_lower_of_bounded h)
75627663lemma integral_bound_lower_le_upper {f:ℝ → ℝ} {I: BoundedInterval} {a b:ℝ}
7764 (ha: a ∈ (fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MajorizesOn g f I ∧ PiecewiseConstantOn g I})
···7966 : b ≤ a:= by
8067 obtain ⟨ g, ⟨ ⟨ hmaj, hgp⟩, hgi ⟩ ⟩ := ha
8168 obtain ⟨ h, ⟨ ⟨ hmin, hhp⟩, hhi ⟩ ⟩ := hb
8282- rw [←hgi, ←hhi]
8383- apply PiecewiseConstantOn.integ_mono _ hhp hgp
8484- intro x hx
8585- have := hmaj x hx
8686- apply (ge_iff_le.mp (hmin x hx)).trans (hmaj x hx)
6969+ rw [←hgi, ←hhi]; apply PiecewiseConstantOn.integ_mono _ hhp hgp
7070+ intro x hx; exact (ge_iff_le.mp (hmin x hx)).trans (hmaj x hx)
87718872lemma integral_bound_below {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) :
8973 BddBelow ((fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MajorizesOn g f I ∧ PiecewiseConstantOn g I}) := by
9090- rw [bddBelow_def]
9191- use (integral_bound_lower_nonempty h).some
7474+ rw [bddBelow_def]; use (integral_bound_lower_nonempty h).some
9275 intro a ha; exact integral_bound_lower_le_upper ha (integral_bound_lower_nonempty h).some_mem
93769477lemma integral_bound_above {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) :
9578 BddAbove ((fun g ↦ PiecewiseConstantOn.integ g I) '' {g | MinorizesOn g f I ∧ PiecewiseConstantOn g I}) := by
9696- rw [bddAbove_def]
9797- use (integral_bound_upper_nonempty h).some
7979+ rw [bddAbove_def]; use (integral_bound_upper_nonempty h).some
9880 intro b hb; exact integral_bound_lower_le_upper (integral_bound_upper_nonempty h).some_mem hb
998110082/-- Lemma 11.3.3. The proof has been reorganized somewhat from the textbook. -/
···10688lemma lower_integral_le_upper {f:ℝ → ℝ} {I: BoundedInterval} (h: BddOn f I) :
10789 lower_integral f I ≤ upper_integral f I := by
10890 apply ConditionallyCompleteLattice.csSup_le _ _ (integral_bound_lower_nonempty h) _
109109- rw [mem_upperBounds]
110110- intro b hb
9191+ rw [mem_upperBounds]; intro b hb
11192 apply ConditionallyCompleteLattice.le_csInf _ _ (integral_bound_upper_nonempty h) _
112112- rw [mem_lowerBounds]
113113- intro a ha
9393+ rw [mem_lowerBounds]; intro a ha
11494 exact integral_bound_lower_le_upper ha hb
1159511696lemma upper_integral_le {f:ℝ → ℝ} {I: BoundedInterval} {M:ℝ} (h: ∀ x ∈ (I:Set ℝ), |f x| ≤ M) :
···134114 {X:ℝ} (hX: upper_integral f I < X ) :
135115 ∃ g, MajorizesOn g f I ∧ PiecewiseConstantOn g I ∧ PiecewiseConstantOn.integ g I < X := by
136116 obtain ⟨ Y, hY, hYX ⟩ := exists_lt_of_csInf_lt (integral_bound_upper_nonempty hf) hX
137137- simp at hY
138138- peel hY with h hY
139139- simp [hY, hYX]; tauto
117117+ simp at hY; peel hY with h hY; simp_all; tauto
140118141119lemma gt_of_lt_lower_integral {f:ℝ → ℝ} {I: BoundedInterval} (hf: BddOn f I)
142120 {X:ℝ} (hX: X < lower_integral f I) :
143121 ∃ h, MinorizesOn h f I ∧ PiecewiseConstantOn h I ∧ X < PiecewiseConstantOn.integ h I := by
144122 obtain ⟨ Y, hY, hYX ⟩ := exists_lt_of_lt_csSup (integral_bound_lower_nonempty hf) hX
145145- simp at hY
146146- peel hY with h hY
147147- simp [hY, hYX]; tauto
123123+ simp at hY; peel hY with h hY; simp_all; tauto
148124149125/-- Definition 11.3.4 (Riemann integral)
150126As we permit junk values, the simplest definition for the Riemann integral is the upper integral.-/
151151-noncomputable abbrev integ (f:ℝ → ℝ) (I: BoundedInterval) : ℝ :=
152152-upper_integral f I
127127+noncomputable abbrev integ (f:ℝ → ℝ) (I: BoundedInterval) : ℝ := upper_integral f I
153128154129theorem integ_congr {f g:ℝ → ℝ} {I: BoundedInterval} (h: Set.EqOn f g I) :
155130 integ f I = integ g I := upper_integral_congr h
···165140/-- Remark 11.3.8 -/
166141theorem integ_on_subsingleton {f:ℝ → ℝ} {I: BoundedInterval} (hI: |I|ₗ = 0) :
167142 IntegrableOn f I ∧ integ f I = 0 := by
168168- have hI' := hI
169169- rw [←length_of_subsingleton] at hI'
143143+ have _ := length_of_subsingleton.mpr hI
170144 have hconst : ConstantOn f I := ConstantOn.of_subsingleton
171171- convert integ_of_piecewise_const _
172172- . simp [PiecewiseConstantOn.integ_const' hconst, hI]
173173- exact PiecewiseConstantOn.of_const hconst
145145+ convert integ_of_piecewise_const (PiecewiseConstantOn.of_const hconst)
146146+ simp [PiecewiseConstantOn.integ_const' hconst, hI]
174147175148/-- Definition 11.3.9 (Riemann sums). The restriction to positive length J is not needed thanks to various junk value conventions. -/
176149noncomputable abbrev upper_riemann_sum (f:ℝ → ℝ) {I: BoundedInterval} (P: Partition I) : ℝ :=
···196169 sorry
197170198171theorem upper_integ_eq_inf_upper_sum {f:ℝ → ℝ} {I:BoundedInterval} (hf: BddOn f I) :
199199- upper_integral f I = sInf (Set.range (fun P : Partition I ↦ upper_riemann_sum f P)) := by
172172+ upper_integral f I = sInf (.range (fun P : Partition I ↦ upper_riemann_sum f P)) := by
200173 sorry
201174202175theorem lower_integ_ge_lower_sum {f:ℝ → ℝ} {I:BoundedInterval} (hf: BddOn f I)
···204177 sorry
205178206179theorem lower_integ_eq_sup_lower_sum {f:ℝ → ℝ} {I:BoundedInterval} (hf: BddOn f I) :
207207- lower_integral f I = sSup (Set.range (fun P : Partition I ↦ lower_riemann_sum f P)) := by
180180+ lower_integral f I = sSup (.range (fun P : Partition I ↦ lower_riemann_sum f P)) := by
208181 sorry
209182210183/-- Exercise 11.3.1 -/
+78-134
analysis/Analysis/Section_11_4.lean
···9696lemma nonneg_of_le_const_mul_eps {x C:ℝ} (h: ∀ ε>0, x ≤ C * ε) : x ≤ 0 := by
9797 by_cases hC: C > 0
9898 . by_contra!
9999- specialize h (x/(2*C)) ( by positivity)
100100- convert_to x ≤ x/2 at h
9999+ specialize h (x/(2*C)) ( by positivity); convert_to x ≤ x/2 at h
101100 . field_simp; ring
102101 linarith
103103- specialize h 1 (by norm_num)
104104- simp at h hC; linarith
102102+ specialize h 1 (by norm_num); simp at h hC; linarith
105103106104/-- Theorem 11.4.3 (Max and min preserve integrability)-/
107105theorem integ_of_max {I: BoundedInterval} {f g:ℝ → ℝ} (hf: IntegrableOn f I) (hg: IntegrableOn g I) :
···109107 -- This proof is written to follow the structure of the original text.
110108 unfold IntegrableOn at hf hg
111109 have hmax_bound : BddOn (max f g) I := by
112112- obtain ⟨ M, hM ⟩ := hf.1
113113- obtain ⟨ M', hM' ⟩ := hg.1
114114- use max M M'; intro x hx
115115- specialize hM x hx
116116- specialize hM' x hx
110110+ obtain ⟨ M, hM ⟩ := hf.1; obtain ⟨ M', hM' ⟩ := hg.1
111111+ use max M M'; peel hM with x hx hM; specialize hM' _ hx
117112 simp only [Pi.sup_apply]
118113 apply abs_max_le_max_abs_abs.trans
119114 exact sup_le_sup hM hM'
···122117 obtain ⟨ f', hf'min, hf'const, hf'int ⟩ := gt_of_lt_lower_integral hf.1 (show integ f I - ε < lower_integral f I
123118 by linarith)
124119 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)
125125- 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)
126126- 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)
120120+ 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)
121121+ 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)
127122 set h := (f'' - f') + (g'' - g')
128123 have hf'_integ := integ_of_piecewise_const hf'const
129124 have hg'_integ := integ_of_piecewise_const hg'const
···133128 have hg''g'_integ := integ_of_sub hg''_integ.1 hg'_integ.1
134129 have hh_integ_eq := integ_of_add hf''f'_integ.1 hg''g'_integ.1
135130 have hinteg_le : integ h I ≤ 4 * ε := by linarith
136136- have hf''g''_const := PiecewiseConstantOn.max hf''const hg''const
131131+ have hf''g''_const := hf''const.max hg''const
137132 have hf''g''_maj : MajorizesOn (max f'' g'') (max f g) I := by
138133 sorry
139139- have hf'g'_const := PiecewiseConstantOn.max hf'const hg'const
134134+ have hf'g'_const := hf'const.max hg'const
140135 have hf'g'_maj : MinorizesOn (max f' g') (max f g) I := by
141136 sorry
142137 have hff'g''_ge := upper_integral_le_integ hmax_bound hf''g''_maj hf''g''_const
143138 have hf'g'_le := integ_le_lower_integral hmax_bound hf'g'_maj hf'g'_const
144139 have : MinorizesOn (max f'' g'') (max f' g' + h) I := by
145145- intro x hx
146146- specialize hf'min x hx
147147- specialize hg'min x hx
148148- specialize hf''max x hx
149149- specialize hg''max x hx
150150- have hmaxl := le_max_left (f' x) (g' x)
151151- have hmaxr := le_max_right (f' x) (g' x)
152152- simp [h]; constructor <;> linarith
140140+ peel hf'min with x hx hf'min; specialize hg'min _ hx; specialize hf''max _ hx; specialize hg''max _ hx
141141+ simp [h]; and_intros <;> linarith [le_max_left (f' x) (g' x), le_max_right (f' x) (g' x)]
153142 have hf'g'_integ := integ_of_piecewise_const hf'g'_const
154143 have hf''g''_integ := integ_of_piecewise_const hf''g''_const
155144 have hf'g'h_integ := integ_of_add hf'g'_integ.1 hh_integ_eq.1
156145 rw [MinorizesOn.iff] at this
157157- replace this := integ_mono hf''g''_integ.1 hf'g'h_integ.1 this
158158- linarith
159159- refine ⟨ hmax_bound, ?_ ⟩
160160- replace := nonneg_of_le_const_mul_eps this
161161- linarith
146146+ linarith [integ_mono hf''g''_integ.1 hf'g'h_integ.1 this]
147147+ exact ⟨ hmax_bound, by linarith [nonneg_of_le_const_mul_eps this] ⟩
148148+149149+162150163151/-- Theorem 11.4.5 / Exercise 11.4.3. The objective here is to create a shorter proof than the one above.-/
164152theorem integ_of_min {I: BoundedInterval} {f g:ℝ → ℝ} (hf: IntegrableOn f I) (hg: IntegrableOn g I) :
···168156/-- Corollary 11.4.4 -/
169157theorem integ_of_abs {I: BoundedInterval} {f:ℝ → ℝ} (hf: IntegrableOn f I) :
170158 IntegrableOn (abs f) I := by
171171- have f_plus := integ_of_max hf (integ_of_const 0 I).1
172172- have f_minus := integ_of_min hf (integ_of_const 0 I).1
173173- convert (integ_of_sub f_plus f_minus).1 using 1
174174- ext x
175175- rcases le_or_gt (f x) 0 with h | h
159159+ have := (integ_of_const 0 I).1
160160+ convert (integ_of_sub (integ_of_max hf this) (integ_of_min hf this)).1 using 1
161161+ ext x; rcases le_or_gt (f x) 0 with h | h
176162 . simp [h]
177163 simp [le_of_lt h]
178164···186172 swap
187173 . apply (integ_on_subsingleton _).1
188174 rw [←BoundedInterval.length_of_subsingleton]
189189- rw [Set.not_nonempty_iff_eq_empty] at hI
190190- simp [hI]
175175+ simp_all [Set.not_nonempty_iff_eq_empty]
191176 unfold IntegrableOn at hf hg
192177 obtain ⟨ M₁, hM₁ ⟩ := hf.1
193178 obtain ⟨ M₂, hM₂ ⟩ := hg.1
194194- have hM₁pos : 0 ≤ M₁ := by
195195- specialize hM₁ hI.some hI.some_mem
196196- apply (abs_nonneg _).trans hM₁
197197- have hM₂pos : 0 ≤ M₂ := by
198198- specialize hM₂ hI.some hI.some_mem
199199- apply (abs_nonneg _).trans hM₂
179179+ have hM₁pos : 0 ≤ M₁ := (abs_nonneg _).trans (hM₁ hI.some hI.some_mem)
180180+ have hM₂pos : 0 ≤ M₂ := (abs_nonneg _).trans (hM₂ hI.some hI.some_mem)
200181 have hmul_bound : BddOn (f * g) I := by
201201- use M₁ * M₂
202202- intro x hx
203203- specialize hM₁ x hx
204204- specialize hM₂ x hx
205205- simp [abs_mul]
206206- exact mul_le_mul hM₁ hM₂ (by positivity) (by positivity)
182182+ use M₁ * M₂; peel hM₁ with x hx hM₁; specialize hM₂ _ hx
183183+ simp [abs_mul]; apply mul_le_mul hM₁ hM₂ <;> positivity
207184 have lower_le_upper : 0 ≤ upper_integral (f * g) I - lower_integral (f * g) I := by
208185 linarith [lower_integral_le_upper hmul_bound]
209186 have (ε:ℝ) (hε: 0 < ε) : upper_integral (f * g) I - lower_integral (f * g) I ≤ 2*(M₁+M₂)*ε := by
···211188 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)
212189 use max f' 0
213190 have hzero := PiecewiseConstantOn.of_const (ConstantOn.of_const' 0 I)
214214- refine ⟨ ?_, ?_, ?_, ?_ ⟩
215215- . intro x hx
216216- specialize hf_nonneg x hx
217217- specialize hf'min x hx
218218- aesop
219219- . exact PiecewiseConstantOn.max hf'const hzero
220220- . apply lt_of_lt_of_le hf'int (PiecewiseConstantOn.integ_mono _ hf'const _)
221221- . intro x hx; simp
222222- exact PiecewiseConstantOn.max hf'const hzero
223223- intro x hx; simp
191191+ and_intros
192192+ . peel hf_nonneg with x hx _; specialize hf'min _ hx; aesop
193193+ . exact hf'const.max hzero
194194+ . exact lt_of_lt_of_le hf'int (hf'const.integ_mono (by intros; simp) (hf'const.max hzero))
195195+ intro _ _; simp
224196 obtain ⟨ f', hf'min, hf'const, hf'int, hf'_nonneg ⟩ := this
225197 have : ∃ g', MinorizesOn g' g I ∧ PiecewiseConstantOn g' I ∧ integ g I - ε < PiecewiseConstantOn.integ g' I ∧ MajorizesOn g' 0 I := by
226198 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)
227199 use max g' 0
228200 have hzero := PiecewiseConstantOn.of_const (ConstantOn.of_const' 0 I)
229229- refine ⟨ ?_, ?_, ?_, ?_ ⟩
230230- . intro x hx
231231- specialize hg_nonneg x hx
232232- specialize hg'min x hx
233233- aesop
234234- . exact PiecewiseConstantOn.max hg'const hzero
235235- . apply lt_of_lt_of_le hg'int (PiecewiseConstantOn.integ_mono _ hg'const _)
236236- . intro x hx; simp
237237- exact PiecewiseConstantOn.max hg'const hzero
238238- intro x hx; simp
201201+ and_intros
202202+ . peel hg_nonneg with x hx _; specialize hg'min _ hx; aesop
203203+ . exact hg'const.max hzero
204204+ . apply lt_of_lt_of_le hg'int (hg'const.integ_mono (by intros; simp) (hg'const.max hzero))
205205+ intro _ _; simp
239206 obtain ⟨ g', hg'min, hg'const, hg'int, hg'_nonneg ⟩ := this
240207 have : ∃ f'', MajorizesOn f'' f I ∧ PiecewiseConstantOn f'' I ∧ PiecewiseConstantOn.integ f'' I < integ f I + ε ∧ MinorizesOn f'' (fun _ ↦ M₁) I := by
241208 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)
242209 use min f'' (fun _ ↦ M₁)
243210 have hM₁_piece := PiecewiseConstantOn.of_const (ConstantOn.of_const' M₁ I)
244244- refine ⟨ ?_, ?_, ?_, ?_ ⟩
245245- . intro x hx
246246- specialize hM₁ x hx; rw [abs_le'] at hM₁
247247- specialize hf''maj x hx
248248- simp [hf''maj, hM₁.1]
249249- . exact PiecewiseConstantOn.min hf''const hM₁_piece
250250- . apply lt_of_le_of_lt (PiecewiseConstantOn.integ_mono _ _ hf''const) hf''int
251251- . intro x hx; simp [hf''maj, hM₁_piece]
252252- exact PiecewiseConstantOn.min hf''const hM₁_piece
253253- intro x hx; simp
211211+ and_intros
212212+ . peel hM₁ with x hx hM₁; rw [abs_le'] at hM₁
213213+ specialize hf''maj _ hx; simp [hf''maj, hM₁.1]
214214+ . exact hf''const.min hM₁_piece
215215+ . apply lt_of_le_of_lt ((hf''const.min hM₁_piece).integ_mono _ hf''const) hf''int
216216+ intros; simp [hf''maj, hM₁_piece]
217217+ intro _ _; simp
254218 obtain ⟨ f'', hf''maj, hf''const, hf''int, hf''bound ⟩ := this
255219 have : ∃ g'', MajorizesOn g'' g I ∧ PiecewiseConstantOn g'' I ∧ PiecewiseConstantOn.integ g'' I < integ g I + ε ∧ MinorizesOn g'' (fun _ ↦ M₂) I := by
256220 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)
257221 use min g'' (fun _ ↦ M₂)
258222 have hM₂_piece := PiecewiseConstantOn.of_const (ConstantOn.of_const' M₂ I)
259259- refine ⟨ ?_, ?_, ?_, ?_ ⟩
260260- . intro x hx
261261- specialize hM₂ x hx; rw [abs_le'] at hM₂
262262- specialize hg''maj x hx
263263- simp [hg''maj, hM₂.1]
264264- . exact PiecewiseConstantOn.min hg''const hM₂_piece
265265- . apply lt_of_le_of_lt (PiecewiseConstantOn.integ_mono _ _ hg''const) hg''int
266266- . intro x hx; simp [hg''maj, hM₂_piece]
267267- exact PiecewiseConstantOn.min hg''const hM₂_piece
268268- intro x hx; simp
223223+ and_intros
224224+ . peel hM₂ with x hx hM₂; rw [abs_le'] at hM₂
225225+ specialize hg''maj _ hx; simp [hg''maj, hM₂.1]
226226+ . exact hg''const.min hM₂_piece
227227+ . apply lt_of_le_of_lt ((hg''const.min hM₂_piece).integ_mono _ hg''const) hg''int
228228+ intros; simp [hg''maj, hM₂_piece]
229229+ intro _ _; simp
269230 obtain ⟨ g'', hg''maj, hg''const, hg''int, hg''bound ⟩ := this
270231 have hf'g'_const := PiecewiseConstantOn.mul hf'const hg'const
271232 have hf'g'_maj : MinorizesOn (f' * g') (f * g) I := by
272272- intro x hx
273273- specialize hf'min x hx
274274- specialize hg'min x hx
275275- specialize hf'_nonneg x hx
276276- specialize hg'_nonneg x hx
277277- simp at hf'_nonneg hg'_nonneg ⊢
278278- exact mul_le_mul hf'min hg'min (by positivity) (by linarith)
233233+ peel hf'min with x hx hf'min; specialize hg'min _ hx; specialize hf'_nonneg _ hx; specialize hg'_nonneg _ hx
234234+ simp at *; exact mul_le_mul hf'min hg'min (by positivity) (by linarith)
279235 have hf''g''_const := PiecewiseConstantOn.mul hf''const hg''const
280236 have hf''g''_maj : MajorizesOn (f'' * g'') (f * g) I := by
281281- intro x hx
282282- specialize hf''maj x hx
283283- specialize hg''maj x hx
284284- specialize hf''bound x hx
285285- specialize hg_nonneg x hx
286286- specialize hf_nonneg x hx
287287- simp at hf''bound hf_nonneg hg_nonneg ⊢
288288- exact mul_le_mul hf''maj hg''maj (by positivity) (by linarith)
237237+ peel hf''maj with x hx hf''maj; specialize hg''maj _ hx; specialize hf''bound _ hx
238238+ specialize hg_nonneg _ hx; specialize hf_nonneg _ hx
239239+ simp at *; exact mul_le_mul hf''maj hg''maj (by positivity) (by linarith)
289240 have hupper_le := upper_integral_le_integ hmul_bound hf''g''_maj hf''g''_const
290241 have hlower_ge := integ_le_lower_integral hmul_bound hf'g'_maj hf'g'_const
291291- have hh_const := PiecewiseConstantOn.sub hf''g''_const hf'g'_const
292292- have hh_integ := PiecewiseConstantOn.integ_sub hf''g''_const hf'g'_const
242242+ have hh_const := hf''g''_const.sub hf'g'_const
243243+ have hh_integ := hf''g''_const.integ_sub hf'g'_const
293244 have hhmin : MinorizesOn (f'' * g'' - f' * g') (M₁ • (g''-g') + M₂ • (f''-f')) I := by
294245 intro x hx
295246 simp only [Pi.sub_apply, Pi.mul_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul]
296247 calc
297248 _ = (f'' x) * (g'' x - g' x) + (g' x) * (f'' x - f' x) := by ring
298249 _ ≤ _ := by
299299- specialize hg'min x hx
300300- specialize hg''maj x hx
301301- specialize hf''bound x hx
302302- specialize hf'min x hx
303303- specialize hf''maj x hx
304304- specialize hg''bound x hx
305305- gcongr
306306- . linarith
307307- . linarith
308308- simp at hg''bound; linarith
309309- have hg''g'_const := PiecewiseConstantOn.sub hg''const hg'const
310310- have hg''g'_integ := PiecewiseConstantOn.integ_sub hg''const hg'const
311311- have hM₁g''g'_const := PiecewiseConstantOn.smul M₁ hg''g'_const
312312- have hM₁g''g_integ := PiecewiseConstantOn.integ_smul M₁ hg''g'_const
313313- have hf''f'_const := PiecewiseConstantOn.sub hf''const hf'const
314314- have hf''f_integ := PiecewiseConstantOn.integ_sub hf''const hf'const
315315- have hM₂f''f'_const := PiecewiseConstantOn.smul M₂ hf''f'_const
316316- have hM₂f''f_integ := PiecewiseConstantOn.integ_smul M₂ hf''f'_const
317317- have hsum_const := PiecewiseConstantOn.add hM₁g''g'_const hM₂f''f'_const
318318- have hsum_integ := PiecewiseConstantOn.integ_add hM₁g''g'_const hM₂f''f'_const
319319- have hsum_bound := PiecewiseConstantOn.integ_mono hhmin hh_const hsum_const
250250+ specialize hg'min x hx; specialize hg''maj x hx; specialize hf''bound x hx
251251+ specialize hf'min x hx; specialize hf''maj x hx; specialize hg''bound x hx
252252+ simp at hg''bound; gcongr <;> linarith
253253+ have hg''g'_const := hg''const.sub hg'const
254254+ have hg''g'_integ := hg''const.integ_sub hg'const
255255+ have hM₁g''g'_const := hg''g'_const.smul M₁
256256+ have hM₁g''g_integ := hg''g'_const.integ_smul M₁
257257+ have hf''f'_const := hf''const.sub hf'const
258258+ have hf''f_integ := hf''const.integ_sub hf'const
259259+ have hM₂f''f'_const := hf''f'_const.smul M₂
260260+ have hM₂f''f_integ := hf''f'_const.integ_smul M₂
261261+ have hsum_const := hM₁g''g'_const.add hM₂f''f'_const
262262+ have hsum_integ := hM₁g''g'_const.integ_add hM₂f''f'_const
263263+ have hsum_bound := hh_const.integ_mono hhmin hsum_const
320264 calc
321265 _ ≤ M₁ * PiecewiseConstantOn.integ (g'' - g') I + M₂ * PiecewiseConstantOn.integ (f'' - f') I := by linarith
322266 _ ≤ M₁ * (2*ε) + M₂ * (2*ε) := by gcongr <;> linarith
323267 _ = _ := by ring
324324- refine ⟨ hmul_bound, ?_ ⟩
325325- replace := nonneg_of_le_const_mul_eps this
326326- linarith
268268+ exact ⟨ hmul_bound, by linarith [nonneg_of_le_const_mul_eps this] ⟩
269269+327270328271theorem integ_of_mul {I: BoundedInterval} {f g:ℝ → ℝ} (hf: IntegrableOn f I) (hg: IntegrableOn g I) :
329272 IntegrableOn (f * g) I := by
···332275 set fminus := -min f (fun _ ↦ 0)
333276 set gplus := max g (fun _ ↦ 0)
334277 set gminus := -min g (fun _ ↦ 0)
335335- have hfplus_integ : IntegrableOn fplus I := integ_of_max hf (integ_of_const 0 I).1
336336- have hfminus_integ : IntegrableOn fminus I := (integ_of_neg (integ_of_min hf (integ_of_const 0 I).1)).1
337337- have hgplus_integ : IntegrableOn gplus I := integ_of_max hg (integ_of_const 0 I).1
338338- have hgminus_integ : IntegrableOn gminus I := (integ_of_neg (integ_of_min hg (integ_of_const 0 I).1)).1
339339- have hfplus_nonneg : MajorizesOn fplus 0 I := by intro x hx; simp [fplus]
340340- have hfminus_nonneg : MajorizesOn fminus 0 I := by intro x hx; simp [fminus]
341341- have hgplus_nonneg : MajorizesOn gplus 0 I := by intro x hx; simp [gplus]
342342- have hgminus_nonneg : MajorizesOn gminus 0 I := by intro x hx; simp [gminus]
278278+ have := (integ_of_const 0 I).1
279279+ have hfplus_integ : IntegrableOn fplus I := integ_of_max hf this
280280+ have hfminus_integ : IntegrableOn fminus I := (integ_of_neg (integ_of_min hf this)).1
281281+ have hgplus_integ : IntegrableOn gplus I := integ_of_max hg this
282282+ have hgminus_integ : IntegrableOn gminus I := (integ_of_neg (integ_of_min hg this)).1
283283+ have hfplus_nonneg : MajorizesOn fplus 0 I := by intro _ _; simp [fplus]
284284+ have hfminus_nonneg : MajorizesOn fminus 0 I := by intro _ _; simp [fminus]
285285+ have hgplus_nonneg : MajorizesOn gplus 0 I := by intro _ _; simp [gplus]
286286+ have hgminus_nonneg : MajorizesOn gminus 0 I := by intro _ _; simp [gminus]
343287 have hfplusgplus := integ_of_mul_nonneg hfplus_integ hgplus_integ hfplus_nonneg hgplus_nonneg
344288 have hfplusgminus := integ_of_mul_nonneg hfplus_integ hgminus_integ hfplus_nonneg hgminus_nonneg
345289 have hfminusgplus := integ_of_mul_nonneg hfminus_integ hgplus_integ hfminus_nonneg hgplus_nonneg