Skip to content

Commit 56cf38f

Browse files
committed
Converted some automations to more manual proof for compilation speedup
1 parent 4c6d4bf commit 56cf38f

File tree

1 file changed

+64
-25
lines changed

1 file changed

+64
-25
lines changed

analysis/Analysis/MeasureTheory/Section_1_1_2.lean

Lines changed: 64 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ theorem JordanMeasurable.union {d:ℕ} {E F : Set (EuclideanSpace' d)}
273273
have h_inner_outer_eq : ∀ ε > 0, ∃ A B : Set (EuclideanSpace' d), ∃ hA : IsElementary A, ∃ hB : IsElementary B, A ⊆ E ∪ F ∧ E ∪ F ⊆ B ∧ (IsElementary.measure (hB.sdiff hA)) ≤ ε := by
274274
intro ε hε_pos
275275
obtain ⟨A₁, B₁, hA₁, hB₁, hA₁_subset_E, hE_subset_B₁, hB₁_minus_A₁⟩ : ∃ A₁ B₁ : Set (EuclideanSpace' d), ∃ hA₁ : IsElementary A₁, ∃ hB₁ : IsElementary B₁, A₁ ⊆ E ∧ E ⊆ B₁ ∧ (IsElementary.measure (hB₁.sdiff hA₁)) ≤ ε / 2 := by
276-
have := JordanMeasurable.equiv hE_bounded |>.out 0 1 ; aesop
276+
have := JordanMeasurable.equiv hE_bounded |>.out 0 1 ; simp_all only [gt_iff_lt, exists_and_left, implies_true,
277+
iff_true, div_pos_iff_of_pos_left, Nat.ofNat_pos]
277278
obtain ⟨A₂, B₂, hA₂, hB₂, hA₂_subset_F, hF_subset_B₂, hB₂_minus_A₂⟩ : ∃ A₂ B₂ : Set (EuclideanSpace' d), ∃ hA₂ : IsElementary A₂, ∃ hB₂ : IsElementary B₂, A₂ ⊆ F ∧ F ⊆ B₂ ∧ (IsElementary.measure (hB₂.sdiff hA₂)) ≤ ε / 2 := by
278279
have := JordanMeasurable.equiv hF_bounded |>.out 0 1;
279280
exact this.mp hF ( ε / 2 ) ( half_pos hε_pos ) |> fun ⟨ A₂, B₂, hA₂, hB₂, hA₂_subset_F, hF_subset_B₂, hB₂_minus_A₂ ⟩ => ⟨ A₂, B₂, hA₂, hB₂, hA₂_subset_F, hF_subset_B₂, by linarith ⟩;
@@ -285,7 +286,7 @@ theorem JordanMeasurable.union {d:ℕ} {E F : Set (EuclideanSpace' d)}
285286
exact hB₁.sdiff hA₁
286287
exact hB₂.sdiff hA₂
287288
exact by linarith! [ hB₁_minus_A₁, hB₂_minus_A₂ ] ;
288-
intro x hx; aesop;
289+
intro x hx; simp_all only [gt_iff_lt, Set.mem_diff, Set.mem_union, not_or, not_false_eq_true, and_true];
289290
refine' le_antisymm _ _;
290291
· apply_rules [ Jordan_inner_le_outer ];
291292
exact hE_bounded.union hF_bounded;
@@ -327,7 +328,8 @@ theorem JordanMeasurable.inter {d:ℕ} {E F : Set (EuclideanSpace' d)}
327328
have h_jordan_measurable : ∀ ε > 0, ∃ A B : Set (EuclideanSpace' d), ∃ hA : IsElementary A, ∃ hB : IsElementary B, A ⊆ E ∧ E ⊆ B ∧ (hB.sdiff hA).measure ≤ ε / 2 ∧ ∃ C D : Set (EuclideanSpace' d), ∃ hC : IsElementary C, ∃ hD : IsElementary D, C ⊆ F ∧ F ⊆ D ∧ (hD.sdiff hC).measure ≤ ε / 2 := by
328329
intro ε hε_pos
329330
obtain ⟨A, B, hA, hB, hA_sub, hB_sup, hA_B⟩ : ∃ A B : Set (EuclideanSpace' d), ∃ hA : IsElementary A, ∃ hB : IsElementary B, A ⊆ E ∧ E ⊆ B ∧ (hB.sdiff hA).measure ≤ ε / 2 := by
330-
have := JordanMeasurable.equiv (hE.1) |>.out 0 1; aesop;
331+
have := JordanMeasurable.equiv (hE.1) |>.out 0 1; simp_all only [gt_iff_lt, exists_and_left, implies_true,
332+
iff_true, div_pos_iff_of_pos_left, Nat.ofNat_pos];
331333
obtain ⟨C, D, hC, hD, hC_sub, hD_sup, hC_D⟩ : ∃ C D : Set (EuclideanSpace' d), ∃ hC : IsElementary C, ∃ hD : IsElementary D, C ⊆ F ∧ F ⊆ D ∧ (hD.sdiff hC).measure ≤ ε / 2 := by
332334
have := JordanMeasurable.equiv ( show Bornology.IsBounded F from hF.1 ) |>.out 0 1;
333335
exact this.mp hF ( ε / 2 ) ( half_pos hε_pos ) |> fun ⟨ C, D, hC, hD, hC_sub, hD_sup, hC_D ⟩ => ⟨ C, D, hC, hD, hC_sub, hD_sup, by linarith ⟩
@@ -367,7 +369,6 @@ theorem JordanMeasurable.inter {d:ℕ} {E F : Set (EuclideanSpace' d)}
367369
exact le_antisymm ( le_of_forall_pos_le_add fun ε hε => by linarith [ h_jordan_measurable ε hε ] ) ( sub_nonneg_of_le <| Jordan_inner_le_outer h_bound );
368370
exact ⟨ h_bound, by linarith ⟩
369371

370-
set_option maxHeartbeats 400000
371372
/-- Exercise 1.1.6 (i) (Boolean closure) -/
372373
theorem JordanMeasurable.sdiff {d:ℕ} {E F : Set (EuclideanSpace' d)}
373374
(hE: JordanMeasurable E) (hF: JordanMeasurable F) : JordanMeasurable (E \ F) := by
@@ -381,7 +382,10 @@ theorem JordanMeasurable.sdiff {d:ℕ} {E F : Set (EuclideanSpace' d)}
381382
exact this.mp hE ( ε / 2 ) ( half_pos hε_pos );
382383
have h_diff : ∀ ε > 0, ∃ C D : Set (EuclideanSpace' d), ∃ hC : IsElementary C, ∃ hD : IsElementary D, C ⊆ F ∧ F ⊆ D ∧ (hD.sdiff hC).measure ≤ ε / 2 := by
383384
have := JordanMeasurable.equiv hF.1;
384-
have := this.out 0 1; aesop;
385+
have := this.out 0 1;
386+
intro ε_1 a
387+
simp_all only [gt_iff_lt, exists_and_left, implies_true, exists_prop, List.tfae_cons_self, iff_true,
388+
div_pos_iff_of_pos_left, Nat.ofNat_pos];
385389
exact ⟨ A, B, hA, hB, hAB.1, hAB.2.1, hAB.2.2, h_diff ε hε_pos ⟩;
386390
intro ε hε
387391
obtain ⟨A, B, hA, hB, hA_sub_E, hE_sub_B, hB_diff_A, C, D, hC, hD, hC_sub_F, hF_sub_D, hD_diff_C⟩ := h_diff ε hε;
@@ -392,7 +396,7 @@ theorem JordanMeasurable.sdiff {d:ℕ} {E F : Set (EuclideanSpace' d)}
392396
· refine' le_trans ( IsElementary.measure_mono _ _ _ ) _;
393397
exact ( B \ A ) ∪ ( D \ C );
394398
exact IsElementary.union ( hB.sdiff hA ) ( hD.sdiff hC );
395-
· grind;
399+
· grind only [= Set.setOf_true, = Set.mem_union, = Set.subset_def, = Set.setOf_false, = Set.mem_diff];
396400
· exact le_trans ( IsElementary.measure_of_union _ _ ) ( by linarith );
397401
refine' le_antisymm _ _;
398402
· apply_rules [ Jordan_inner_le_outer ];
@@ -411,10 +415,11 @@ theorem JordanMeasurable.sdiff {d:ℕ} {E F : Set (EuclideanSpace' d)}
411415
have hB_le_inner : hB.measure ≤ hA.measure + (hB.sdiff hA).measure := by
412416
have hB_le_inner : hB.measure ≤ (hA.union (hB.sdiff hA)).measure := by
413417
apply_rules [ IsElementary.measure_mono ];
414-
exact fun x hx => by by_cases hx' : x ∈ A <;> aesop;
415-
exact hB_le_inner.trans ( by simpa using IsElementary.measure_of_disjUnion hA ( hB.sdiff hA ) ( Set.disjoint_left.mpr fun x hx₁ hx₂ => by aesop ) |> le_of_eq );
418+
exact fun x hx => by by_cases hx' : x ∈ A <;> simp_all only [gt_iff_lt, exists_and_left,
419+
Set.union_diff_self, Set.mem_union, or_true];
420+
exact hB_le_inner.trans ( by simpa using IsElementary.measure_of_disjUnion hA ( hB.sdiff hA ) ( Set.disjoint_left.mpr fun x hx₁ hx₂ => by simp_all only [gt_iff_lt,
421+
exists_and_left, Set.union_diff_self, Set.mem_diff, not_true_eq_false, and_false] ) |> le_of_eq );
416422
linarith
417-
set_option maxHeartbeats 200000
418423

419424
/-- Exercise 1.1.6 (i) (Boolean closure) -/
420425
theorem JordanMeasurable.symmDiff {d:ℕ} {E F : Set (EuclideanSpace' d)}
@@ -451,7 +456,8 @@ theorem Jordan_inner_add_le {d:ℕ} {E F: Set (EuclideanSpace' d)}
451456
have h_le : (hA.union hB).measure ≤ Jordan_inner_measure (E ∪ F) := by
452457
apply le_csSup; (
453458
obtain ⟨ C, hC ⟩ := IsElementary.contains_bounded ( hE.union hF );
454-
exact ⟨ _, by rintro x ⟨ A, hA, hAE, rfl ⟩ ; exact hA.measure_mono hC.1 ( hAE.trans hC.2 ) ⟩); use A ∪ B; aesop;
459+
exact ⟨ _, by rintro x ⟨ A, hA, hAE, rfl ⟩ ; exact hA.measure_mono hC.1 ( hAE.trans hC.2 ) ⟩); use A ∪ B; simp_all only [Set.union_subset_iff,
460+
and_self, exists_const];
455461
linarith [h_add, h_le];
456462
by_contra h_contra;
457463
-- By definition of supremum, for any $\epsilon > 0$, there exist $a \in S_E$ and $b \in S_F$ such that $a + b > \sup S_E + \sup S_F - \epsilon$.
@@ -500,25 +506,41 @@ theorem JordanMeasurable.mes_of_disjUnion {d:ℕ} {E F : Set (EuclideanSpace' d)
500506
exact Jordan_inner_add_le hE.1 hF.1 hEF;
501507
linarith [ hE.2, hF.2, Jordan_inner_le_outer hE.1, Jordan_inner_le_outer hF.1, Jordan_inner_le_outer ( hE.1.union hF.1 ) ]
502508
generalize_proofs at *;
503-
rw [ JordanMeasurable.eq_outer, JordanMeasurable.eq_outer, JordanMeasurable.eq_outer ] ; aesop
509+
rw [ JordanMeasurable.eq_outer, JordanMeasurable.eq_outer, JordanMeasurable.eq_outer ] ; simp_all only
510+
504511

505-
set_option maxHeartbeats 500000
506512
/-- Exercise 1.1.6 (iii) (finite additivity) -/
507513
lemma JordanMeasurable.measure_of_disjUnion' {d:ℕ} {S: Finset (Set (EuclideanSpace' d))}
508514
(hE: ∀ E ∈ S, JordanMeasurable E) (hdisj: S.toSet.PairwiseDisjoint id):
509515
(JordanMeasurable.union' hE).measure = ∑ E:S, (hE E.val E.property).measure := by
510516
induction' S using Finset.induction with E S hS ih;
511517
all_goals try { exact fun x y => Classical.propDecidable _ };
512-
· aesop;
513-
· simp_all +decide [ Finset.sum_insert, Set.PairwiseDisjoint ];
518+
· simp_all only [Finset.coe_empty, Set.pairwiseDisjoint_empty, Finset.notMem_empty, Set.iUnion_of_empty,
519+
Set.iUnion_empty, mes_of_empty, Finset.univ_eq_empty, Finset.coe_mem, Finset.sum_empty];
520+
· simp_all only [Set.PairwiseDisjoint, Finset.univ_eq_attach, Finset.mem_insert,
521+
Finset.coe_mem, or_true, Finset.coe_insert, Set.iUnion_iUnion_eq_or_left, Finset.attach_insert,
522+
Finset.mem_image, Finset.mem_attach, Subtype.mk.injEq, true_and, Subtype.exists, exists_prop,
523+
exists_eq_right, not_false_eq_true, Finset.sum_insert, Finset.coe_attach, Subtype.forall,
524+
implies_true, Set.injOn_of_eq_iff_eq, Finset.sum_image];
514525
convert JordanMeasurable.mes_of_disjUnion ( hE E ( Finset.mem_insert_self E S ) ) ( JordanMeasurable.union' fun x hx => hE x ( Finset.mem_insert_of_mem hx ) ) _ using 1;
515526
· congr! 1;
516527
· rw [ eq_comm ];
517528
convert JordanMeasurable.eq_outer ( hE E ( Finset.mem_insert_self E S ) ) using 1;
518-
· convert ih ( fun x hx => hE x ( Finset.mem_insert_of_mem hx ) ) ( fun x hx y hy hxy => hdisj ( by aesop ) ( by aesop ) hxy ) |> Eq.symm;
519-
· simp_all +decide [ Set.Pairwise, Finset.mem_insert ];
520-
exact fun x hx => hdisj.1 x hx ( by aesop )
521-
set_option maxHeartbeats 200000
529+
· convert ih ( fun x hx => hE x ( Finset.mem_insert_of_mem hx ) ) ( fun x hx y hy hxy => hdisj ( by simp_all only [Finset.mem_insert,
530+
forall_eq_or_imp, Finset.mem_coe, ne_eq, Set.mem_insert_iff, or_true] ) ( by simp_all only [Finset.mem_insert,
531+
forall_eq_or_imp, Finset.mem_coe, ne_eq, Set.mem_insert_iff, or_true] ) hxy ) |> Eq.symm;
532+
· simp_all only [Finset.mem_insert, forall_eq_or_imp, Set.Pairwise, Finset.mem_coe,
533+
ne_eq, Set.mem_insert_iff, not_true_eq_false, disjoint_self, id_eq, Set.bot_eq_empty,
534+
IsEmpty.forall_iff, true_and, Set.disjoint_iUnion_right, not_false_eq_true, implies_true,
535+
forall_const];
536+
exact fun x hx => hdisj.1 x hx ( by
537+
obtain ⟨left, right⟩ := hE
538+
obtain ⟨left_1, right_1⟩ := hdisj
539+
obtain ⟨left, right_2⟩ := left
540+
apply Aesop.BuiltinRules.not_intro
541+
intro a
542+
subst a
543+
simp_all only [not_true_eq_false] )
522544

523545
/-- Exercise 1.1.6 (iv) (monotonicity) -/
524546
theorem JordanMeasurable.mono {d:ℕ} {E F : Set (EuclideanSpace' d)}
@@ -541,13 +563,14 @@ theorem JordanMeasurable.mes_of_union {d:ℕ} {E F : Set (EuclideanSpace' d)}
541563
by_contra h_contra;
542564
-- Since $E$ and $F$ are not disjoint, we can find a smaller set $G$ such that $E \cup F = E \cup G$ and $G$ is disjoint from $E$.
543565
obtain ⟨G, hG⟩ : ∃ G : Set (EuclideanSpace' d), Disjoint E G ∧ E ∪ F = E ∪ G ∧ G ⊆ F := by
544-
exact ⟨ F \ E, disjoint_sdiff_self_right, by aesop, fun x hx => hx.1 ⟩;
566+
exact ⟨ F \ E, disjoint_sdiff_self_right, by simp_all only [not_le, Set.union_diff_self], fun x hx => hx.1 ⟩;
545567
have hG_measurable : JordanMeasurable G := by
546568
have hG_measurable : JordanMeasurable (F \ E) := by
547569
exact sdiff hF hE;
548570
convert hG_measurable using 1;
549571
ext x;
550-
exact ⟨ fun hx => ⟨ hG.2.2 hx, fun hx' => hG.1.le_bot ⟨ hx', hx ⟩ ⟩, fun hx => by rw [ Set.ext_iff ] at hG; specialize hG; have := hG.2.1 x; aesop ⟩;
572+
exact ⟨ fun hx => ⟨ hG.2.2 hx, fun hx' => hG.1.le_bot ⟨ hx', hx ⟩ ⟩, fun hx => by rw [ Set.ext_iff ] at hG; specialize hG; have := hG.2.1 x; simp_all only [not_le,
573+
Set.mem_diff, Set.mem_union, or_true, false_or, true_iff] ⟩;
551574
have hG_measure : (hE.union hG_measurable).measure = hE.measure + hG_measurable.measure := by
552575
convert JordanMeasurable.mes_of_disjUnion hE hG_measurable hG.1 using 1;
553576
have hG_measure_le : hG_measurable.measure ≤ hF.measure := by
@@ -561,9 +584,10 @@ lemma JordanMeasurable.measure_of_union' {d:ℕ} {S: Finset (Set (EuclideanSpace
561584
induction' S using Finset.induction_on with a S ha ih;
562585
rotate_right;
563586
exact Classical.typeDecidableEq (Set (EuclideanSpace' d));
564-
· aesop;
587+
· simp_all only [Finset.notMem_empty, Set.iUnion_of_empty, Set.iUnion_empty, mes_of_empty, Finset.univ_eq_empty,
588+
Finset.coe_mem, Finset.sum_empty, le_refl];
565589
· convert le_trans ( JordanMeasurable.mes_of_union ( hE a ( Finset.mem_insert_self a S ) ) ( JordanMeasurable.union' fun E hE' => hE E ( Finset.mem_insert_of_mem hE' ) ) ) ( add_le_add_left ( ih fun E hE' => hE E ( Finset.mem_insert_of_mem hE' ) ) _ ) using 1;
566-
· aesop;
590+
· simp_all only [Finset.univ_eq_attach, Finset.mem_insert, Finset.coe_mem, or_true, Set.iUnion_iUnion_eq_or_left];
567591
· simp +decide [ Finset.sum_insert, ha ]
568592

569593
open Pointwise
@@ -574,7 +598,8 @@ theorem JordanMeasurable.translate {d:ℕ} {E: Set (EuclideanSpace' d)}
574598
refine' ⟨ _, _ ⟩;
575599
· have := hE.1;
576600
rw [ isBounded_iff_forall_norm_le ] at *;
577-
exact ⟨ this.choose + ‖x‖, fun y hy => by rcases Set.mem_add.mp hy with ⟨ y', hy', z', hz', rfl ⟩ ; exact le_trans ( norm_add_le _ _ ) ( add_le_add ( this.choose_spec _ hy' ) ( by aesop ) ) ⟩;
601+
exact ⟨ this.choose + ‖x‖, fun y hy => by rcases Set.mem_add.mp hy with ⟨ y', hy', z', hz', rfl ⟩ ; exact le_trans ( norm_add_le _ _ ) ( add_le_add ( this.choose_spec _ hy' ) ( by simp_all only [Set.mem_singleton_iff,
602+
Set.add_singleton, Set.image_add_right, Set.mem_preimage, add_neg_cancel_right, le_refl] ) ) ⟩;
578603
· -- By definition of Jordan inner and outer measures, we have:
579604
have h_inner : Jordan_inner_measure (E + {x}) = Jordan_inner_measure E := by
580605
unfold Jordan_inner_measure;
@@ -583,7 +608,20 @@ theorem JordanMeasurable.translate {d:ℕ} {E: Set (EuclideanSpace' d)}
583608
· use A + { -x };
584609
refine' ⟨ _, _, _ ⟩;
585610
exact IsElementary.translate hA (-x);
586-
· intro y hy; obtain ⟨ a, ha, b, hb, rfl ⟩ := hy; aesop;
611+
intro y hy; obtain ⟨ a, ha, b, hb, rfl ⟩ := hy;
612+
subst h
613+
simp_all only [Set.add_singleton, Set.image_add_right, Set.mem_singleton_iff]
614+
subst hb
615+
obtain ⟨left, right⟩ := hE
616+
obtain ⟨w, h⟩ := hA
617+
subst h
618+
simp_all only [Set.iUnion_subset_iff, Set.mem_iUnion, exists_prop]
619+
obtain ⟨w_1, h⟩ := ha
620+
obtain ⟨left_1, right_1⟩ := h
621+
apply hA'
622+
on_goal 2 => { exact right_1
623+
}
624+
· simp_all only;
587625
· rw [ h, IsElementary.measure_of_translate ];
588626
· use A + {x};
589627
refine' ⟨ _, _, _ ⟩;
@@ -600,7 +638,8 @@ theorem JordanMeasurable.translate {d:ℕ} {E: Set (EuclideanSpace' d)}
600638
· exact Eq.symm (IsElementary.measure_of_translate hA x);
601639
· refine' ⟨ A + { -x }, _, _, _ ⟩;
602640
exact IsElementary.translate hA (-x);
603-
· intro y hy; specialize hA' ( Set.add_mem_add hy ( Set.mem_singleton x ) ) ; aesop;
641+
· intro y hy; specialize hA' ( Set.add_mem_add hy ( Set.mem_singleton x ) ) ; simp_all only [Set.add_singleton,
642+
Set.image_add_right, neg_neg, Set.mem_preimage];
604643
· exact Eq.symm (IsElementary.measure_of_translate hA (-x));
605644
exact h_inner.trans ( hE.2.trans h_outer.symm )
606645

0 commit comments

Comments
 (0)