Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 3aeb64c

Browse files
committed
refactor(*): touching up proofs from 'faster' branch
1 parent f02a88b commit 3aeb64c

17 files changed

+374
-437
lines changed

algebra/big_operators.lean

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Some big operators for lists and finite sets.
77
-/
88
import data.list.basic data.list.perm data.finset
99
algebra.group algebra.ordered_group algebra.group_power
10+
tactic.squeeze
1011

1112
universes u v w
1213
variables {α : Type u} {β : Type v} {γ : Type w}
@@ -15,7 +16,7 @@ theorem directed.finset_le {r : α → α → Prop} [is_trans α r]
1516
{ι} (hι : nonempty ι) {f : ι → α} (D : directed r f) (s : finset ι) :
1617
∃ z, ∀ i ∈ s, r (f i) (f z) :=
1718
show ∃ z, ∀ i ∈ s.1, r (f i) (f z), from
18-
multiset.induction_on s.1 (match hι with ⟨z⟩ := ⟨z, λ _, false.elim⟩ end) $
19+
multiset.induction_on s.1 (let ⟨z⟩ := in ⟨z, λ _, false.elim⟩) $
1920
λ i s ⟨j, H⟩, let ⟨k, h₁, h₂⟩ := D i j in
2021
⟨k, λ a h, or.cases_on (multiset.mem_cons.1 h)
2122
(λ h, h.symm ▸ h₁)
@@ -373,29 +374,28 @@ lemma prod_sum {δ : α → Type*} [∀a, decidable_eq (δ a)]
373374
begin
374375
induction s using finset.induction with a s ha ih,
375376
{ rw [pi_empty, sum_singleton], refl },
376-
{ have h₁ : ∀x ∈ t a, ∀yt a, ∀h : x ≠ y,
377+
{ have h₁ : ∀x ∈ t a, ∀yt a, ∀h : x ≠ y,
377378
image (pi.cons s a x) (pi s t) ∩ image (pi.cons s a y) (pi s t) = ∅,
378379
{ assume x hx y hy h,
379380
apply eq_empty_of_forall_not_mem,
380381
simp only [mem_inter, mem_image],
381382
rintro p₁ ⟨⟨p₂, hp, eq⟩, ⟨p₃, hp₃, rfl⟩⟩,
382383
have : pi.cons s a x p₂ a (mem_insert_self _ _) = pi.cons s a y p₃ a (mem_insert_self _ _),
383384
{ rw [eq] },
384-
rw [pi.cons_same, pi.cons_same] at this, cc },
385+
rw [pi.cons_same, pi.cons_same] at this,
386+
exact h this },
385387
rw [prod_insert ha, pi_insert ha, ih, sum_mul, sum_bind h₁],
386-
refine sum_congr rfl (λ x hx, _),
387-
have h₂ : ∀p₁∈pi s t, ∀p₂∈pi s t, pi.cons s a x p₁ = pi.cons s a x p₂ → p₁ = p₂, from
388+
refine sum_congr rfl (λ b _, _),
389+
have h₂ : ∀p₁∈pi s t, ∀p₂∈pi s t, pi.cons s a b p₁ = pi.cons s a b p₂ → p₁ = p₂, from
388390
assume p₁ h₁ p₂ h₂ eq, injective_pi_cons ha eq,
389391
rw [sum_image h₂, mul_sum],
390-
refine sum_congr rfl (λ g hg, _),
391-
have h₃ : ∀ x ∈ attach s, ∀ y ∈ attach s, (⟨x.1, mem_insert_of_mem x.2⟩ : {x // x ∈ insert a s}) = ⟨y.1, mem_insert_of_mem y.2⟩ → x = y, from
392-
λ _ _ _ _, subtype.eq ∘ subtype.mk.inj,
393-
have h₄ : (⟨a, _⟩ : {x // x ∈ insert a s}) ∉ image (λ (x : {x // x ∈ s}), (⟨x.1, _⟩ : {x // x ∈ insert a s})) (attach s),
394-
{ simp only [mem_image], rintro ⟨⟨_, _⟩, _, rfl⟩, cc },
395-
rw [attach_insert, prod_insert h₄, prod_image h₃],
396-
simp only [pi.cons_same],
397-
refine congr_arg _ (prod_congr rfl (λ v hv, congr_arg _ _)),
398-
exact (pi.cons_ne (by rintro rfl; exact ha v.2)).symm }
392+
refine sum_congr rfl (λ g _, _),
393+
rw [attach_insert, prod_insert, prod_image],
394+
{ simp only [pi.cons_same],
395+
congr', ext ⟨v, hv⟩, congr',
396+
exact (pi.cons_ne (by rintro rfl; exact ha hv)).symm },
397+
{ exact λ _ _ _ _, subtype.eq ∘ subtype.mk.inj },
398+
{ simp only [mem_image], rintro ⟨⟨_, hm⟩, _, rfl⟩, exact ha hm } }
399399
end
400400

401401
end comm_semiring
@@ -404,13 +404,9 @@ section integral_domain /- add integral_semi_domain to support nat and ennreal -
404404
variables [decidable_eq α] [integral_domain β]
405405

406406
lemma prod_eq_zero_iff : s.prod f = 0 ↔ (∃a∈s, f a = 0) :=
407-
finset.induction_on s ⟨false.elim ∘ one_ne_zero, λ ⟨_, H, _⟩, H.elim⟩
408-
begin
409-
intros a s ha,
410-
rw [bex_def, bex_def, exists_mem_insert],
411-
intro ih,
412-
simp only [prod_insert ha, mul_eq_zero_iff_eq_zero_or_eq_zero, ih]
413-
end
407+
finset.induction_on s ⟨not.elim one_ne_zero, λ ⟨_, H, _⟩, H.elim⟩ $ λ a s ha ih,
408+
by rw [prod_insert ha, mul_eq_zero_iff_eq_zero_or_eq_zero,
409+
bex_def, exists_mem_insert, ih, ← bex_def]
414410

415411
end integral_domain
416412

@@ -436,9 +432,9 @@ calc s₁.sum f ≤ (s₂ \ s₁).sum f + s₁.sum f :
436432
lemma sum_eq_zero_iff_of_nonneg : (∀x∈s, 0 ≤ f x) → (s.sum f = 0 ↔ ∀x∈s, f x = 0) :=
437433
finset.induction_on s (λ _, ⟨λ _ _, false.elim, λ _, rfl⟩) $ λ a s ha ih H,
438434
have ∀ x ∈ s, 0 ≤ f x, from λ _, H _ ∘ mem_insert_of_mem,
439-
by rw [sum_insert ha, add_eq_zero_iff_eq_zero_and_eq_zero_of_nonneg_of_nonneg' (H _ $ mem_insert_self _ _) (zero_le_sum' this)];
440-
simp only [mem_insert]; rintro ⟨_, _⟩ x (rfl | h2); cases ih this; solve_by_elim,
441-
λ h1, (sum_congr rfl h1).trans sum_const_zero⟩
435+
by rw [sum_insert ha,
436+
add_eq_zero_iff' (H _ $ mem_insert_self _ _) (zero_le_sum' this),
437+
forall_mem_insert, ih this]
442438

443439
lemma single_le_sum (hf : ∀x∈s, 0 ≤ f x) {a} (h : a ∈ s) : f a ≤ s.sum f :=
444440
have (singleton a).sum f ≤ s.sum f,

algebra/euclidean_domain.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ theorem xgcd_aux_P (a b : α) {r r' : α} : ∀ {s t s' t'}, P a b (r, s, t) →
200200
P a b (r', s', t') → P a b (xgcd_aux r s t r' s' t') :=
201201
gcd.induction r r' (by intros; simpa only [xgcd_zero_left]) $ λ x y h IH s t s' t' p p', begin
202202
rw [xgcd_aux_rec h], refine IH _ p, unfold P at p p' ⊢,
203-
conv {to_lhs, rw mod_eq_sub_mul_div, congr, rw p', skip, congr, rw p },
204-
rw [add_mul, mul_sub, mul_sub, sub_add_eq_sub_sub, add_sub, sub_add_eq_add_sub],
205-
simp only [mul_assoc, mul_comm, mul_left_comm]
203+
rw [mul_sub, mul_sub, add_sub, sub_add_eq_add_sub, ← p', sub_sub,
204+
mul_comm _ s, ← mul_assoc, mul_comm _ t, ← mul_assoc, ← add_mul, ← p,
205+
mod_eq_sub_mul_div]
206206
end
207207

208208
theorem gcd_eq_gcd_ab (a b : α) : (gcd a b : α) = a * gcd_a a b + b * gcd_b a b :=

algebra/field.lean

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ variables [discrete_field α] {a b c : α}
155155

156156
attribute [simp] inv_zero div_zero
157157

158-
lemma inv_sub_inv_eq (ha : a ≠ 0) (hb : b ≠ 0) : a⁻¹ - b⁻¹ = (b - a) / (a * b) :=
159-
inv_sub_inv ha hb
160-
161158
lemma div_right_comm (a b c : α) : (a / b) / c = (a / c) / b :=
162159
if b0 : b = 0 then by simp only [b0, div_zero, zero_div] else
163160
if c0 : c = 0 then by simp only [c0, div_zero, zero_div] else

algebra/gcd_domain.lean

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ end gcd
189189

190190
section lcm
191191

192-
lemma lcm_dvd_iff (a b c : α) : lcm a b ∣ c ↔ a ∣ c ∧ b ∣ c :=
192+
lemma lcm_dvd_iff {a b c : α} : lcm a b ∣ c ↔ a ∣ c ∧ b ∣ c :=
193193
classical.by_cases
194194
(assume : a = 0 ∨ b = 0, by rcases this with rfl | rfl;
195195
simp only [iff_def, lcm_zero_left, lcm_zero_right, zero_dvd_iff, dvd_zero,
@@ -202,14 +202,12 @@ classical.by_cases
202202
← gcd_mul_left, dvd_gcd_iff, mul_comm c a, mul_dvd_mul_iff_left h1,
203203
mul_dvd_mul_iff_right h2, and_comm])
204204

205-
lemma dvd_lcm_left (a b : α) : a ∣ lcm a b :=
206-
((lcm_dvd_iff _ _ _).1 (dvd_refl _)).1
205+
lemma dvd_lcm_left (a b : α) : a ∣ lcm a b := (lcm_dvd_iff.1 (dvd_refl _)).1
207206

208-
lemma dvd_lcm_right (a b : α) : b ∣ lcm a b :=
209-
((lcm_dvd_iff _ _ _).1 (dvd_refl _)).2
207+
lemma dvd_lcm_right (a b : α) : b ∣ lcm a b := (lcm_dvd_iff.1 (dvd_refl _)).2
210208

211209
lemma lcm_dvd {a b c : α} (hab : a ∣ b) (hcb : c ∣ b) : lcm a c ∣ b :=
212-
(lcm_dvd_iff _ _ _).2 ⟨hab, hcb⟩
210+
lcm_dvd_iff.2 ⟨hab, hcb⟩
213211

214212
@[simp] theorem lcm_eq_zero_iff (a b : α) : lcm a b = 0 ↔ a = 0 ∨ b = 0 :=
215213
iff.intro

algebra/group_power.lean

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,11 @@ theorem is_semiring_hom.map_pow {β} [semiring α] [semiring β]
354354
by induction n with n ih; [exact is_semiring_hom.map_one f,
355355
rw [pow_succ, pow_succ, is_semiring_hom.map_mul f, ih]]
356356

357-
theorem neg_one_pow_eq_or {R} [ring R] (n : ℕ) : (-1 : R)^n = 1 ∨ (-1 : R)^n = -1 :=
358-
begin
359-
induction n with n ih, {left, refl},
360-
cases ih with h h,
361-
{ right, rw [pow_succ, h, mul_one] },
362-
{ left, rw [pow_succ, h, neg_one_mul, neg_neg] }
363-
end
357+
theorem neg_one_pow_eq_or {R} [ring R] : ∀ n : ℕ, (-1 : R)^n = 1 ∨ (-1 : R)^n = -1
358+
| 0 := or.inl rfl
359+
| (n+1) := (neg_one_pow_eq_or n).swap.imp
360+
(λ h, by rw [pow_succ, h, neg_one_mul, neg_neg])
361+
(λ h, by rw [pow_succ, h, mul_one])
364362

365363
theorem gsmul_eq_mul [ring α] (a : α) : ∀ n, n •ℤ a = n * a
366364
| (n : ℕ) := add_monoid.smul_eq_mul _ _
@@ -384,11 +382,10 @@ by rw [← nat.mod_add_div n 2, pow_add, pow_mul]; simp [pow_two]
384382

385383
theorem pow_ne_zero [domain α] {a : α} (n : ℕ) (h : a ≠ 0) : a ^ n ≠ 0 :=
386384
begin
387-
induction n with n ih, { exact one_ne_zero },
385+
induction n with n ih, {exact one_ne_zero},
388386
intro H,
389387
cases mul_eq_zero.1 H with h1 h1,
390-
{ exact h h1 },
391-
{ exact ih h1 }
388+
exacts [h h1, ih h1]
392389
end
393390

394391
@[simp] theorem one_div_pow [division_ring α] {a : α} (ha : a ≠ 0) (n : ℕ) : (1 / a) ^ n = 1 / a ^ n :=
@@ -499,6 +496,7 @@ lemma units_pow_eq_pow_mod_two (u : units ℤ) (n : ℕ) : u ^ n = u ^ (n % 2) :
499496
by conv {to_lhs, rw ← nat.mod_add_div n 2}; rw [pow_add, pow_mul, units_pow_two, one_pow, mul_one]
500497

501498
end int
499+
502500
@[simp] lemma neg_square {α} [ring α] (z : α) : (-z)^2 = z^2 :=
503501
by simp [pow, monoid.pow]
504502

algebra/ordered_group.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ add_lt_of_nonpos_of_lt' (le_of_lt ha) hbc
119119
lemma add_lt_of_lt_of_neg' (hbc : b < c) (ha : a < 0) : b + a < c :=
120120
add_lt_of_lt_of_nonpos' hbc (le_of_lt ha)
121121

122-
lemma add_eq_zero_iff_eq_zero_and_eq_zero_of_nonneg_of_nonneg'
123-
(ha : 0 ≤ a) (hb : 0 ≤ b) : a + b = 0 ↔ a = 0 ∧ b = 0 :=
122+
lemma add_eq_zero_iff' (ha : 0 ≤ a) (hb : 0 ≤ b) : a + b = 0 ↔ a = 0 ∧ b = 0 :=
124123
iff.intro
125124
(assume hab : a + b = 0,
126125
have a ≤ 0, from hab ▸ le_add_of_le_of_nonneg' (le_refl _) hb,
@@ -340,7 +339,7 @@ canonically_ordered_monoid.le_iff_exists_add a b
340339
@[simp] lemma zero_le (a : α) : 0 ≤ a := le_iff_exists_add.mpr ⟨a, by simp⟩
341340

342341
@[simp] lemma add_eq_zero_iff : a + b = 0 ↔ a = 0 ∧ b = 0 :=
343-
add_eq_zero_iff_eq_zero_and_eq_zero_of_nonneg_of_nonneg' (zero_le _) (zero_le _)
342+
add_eq_zero_iff' (zero_le _) (zero_le _)
344343

345344
@[simp] lemma le_zero_iff_eq : a ≤ 0 ↔ a = 0 :=
346345
iff.intro

analysis/topology/topological_space.lean

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,23 @@ rfl
5555

5656
variables [topological_space α]
5757

58-
lemma is_open_union (h₁ : is_open s₁) (h₂ : is_open s₂) : is_open (s₁ ∪ s₂) :=
59-
have (⋃₀ {s₁, s₂}) = (s₁ ∪ s₂), from (sUnion_insert _ _).trans $ by rw [sUnion_singleton, union_comm],
60-
this ▸ is_open_sUnion $ show ∀(t : set α), t ∈ ({s₁, s₂} : set (set α)) → is_open t,
61-
from by rintro t (rfl|⟨rfl|ht⟩); [exact h₂, exact h₁, cases ht]
62-
6358
lemma is_open_Union {f : ι → set α} (h : ∀i, is_open (f i)) : is_open (⋃i, f i) :=
64-
is_open_sUnion $ assume t ⟨i, (heq : t = f i)⟩, heq.symm ▸ h i
59+
is_open_sUnion $ by rintro _ ⟨i, rfl⟩; exact h i
6560

6661
lemma is_open_bUnion {s : set β} {f : β → set α} (h : ∀i∈s, is_open (f i)) :
6762
is_open (⋃i∈s, f i) :=
6863
is_open_Union $ assume i, is_open_Union $ assume hi, h i hi
6964

65+
lemma is_open_union (h₁ : is_open s₁) (h₂ : is_open s₂) : is_open (s₁ ∪ s₂) :=
66+
by rw union_eq_Union; exact is_open_Union (bool.forall_bool.2 ⟨h₂, h₁⟩)
67+
7068
@[simp] lemma is_open_empty : is_open (∅ : set α) :=
71-
have is_open (⋃₀ ∅ : set α), from is_open_sUnion (assume a, false.elim),
72-
by rwa sUnion_empty at this
69+
by rw ← sUnion_empty; exact is_open_sUnion (assume a, false.elim)
7370

7471
lemma is_open_sInter {s : set (set α)} (hs : finite s) : (∀t ∈ s, is_open t) → is_open (⋂₀ s) :=
75-
finite.induction_on hs (λ _, by rw sInter_empty; exact is_open_univ) $ λ a s has hs ih h, begin
76-
suffices : is_open (a ∩ ⋂₀ s), { rwa sInter_insert },
77-
exact is_open_inter (h _ $ mem_insert _ _) (ih $ assume t ht, h _ $ mem_insert_of_mem _ ht)
78-
end
72+
finite.induction_on hs (λ _, by rw sInter_empty; exact is_open_univ) $
73+
λ a s has hs ih h, by rw sInter_insert; exact
74+
is_open_inter (h _ $ mem_insert _ _) (ih $ λ t, h t ∘ mem_insert_of_mem _)
7975

8076
lemma is_open_bInter {s : set β} {f : β → set α} (hs : finite s) :
8177
(∀i∈s, is_open (f i)) → is_open (⋂i∈s, f i) :=
@@ -562,7 +558,7 @@ lemma compact_of_finite_subcover {s : set α}
562558
(h : ∀c, (∀t∈c, is_open t) → s ⊆ ⋃₀ c → ∃c'⊆c, finite c' ∧ s ⊆ ⋃₀ c') : compact s :=
563559
assume f hfn hfs, classical.by_contradiction $ assume : ¬ (∃x∈s, f ⊓ nhds x ≠ ⊥),
564560
have hf : ∀x∈s, nhds x ⊓ f = ⊥,
565-
by simpa only [not_exists, not_not, inf_comm] using this,
561+
by simpa only [not_exists, not_not, inf_comm],
566562
have ¬ ∃x∈s, ∀t∈f.sets, x ∈ closure t,
567563
from assume ⟨x, hxs, hx⟩,
568564
have ∅ ∈ (nhds x ⊓ f).sets, by rw [empty_in_sets_eq_bot, hf x hxs],
@@ -572,7 +568,7 @@ assume f hfn hfs, classical.by_contradiction $ assume : ¬ (∃x∈s, f ⊓ nhds
572568
have nhds x ⊓ principal t₂ = ⊥,
573569
by rwa [empty_in_sets_eq_bot] at this,
574570
by simp only [closure_eq_nhds] at hx; exact hx t₂ ht₂ this,
575-
have ∀x∈s, ∃t∈f.sets, x ∉ closure t, by simpa only [not_exists, not_forall] using this,
571+
have ∀x∈s, ∃t∈f.sets, x ∉ closure t, by simpa only [not_exists, not_forall],
576572
let c := (λt, - closure t) '' f.sets, ⟨c', hcc', hcf, hsc'⟩ := h c
577573
(assume t ⟨s, hs, h⟩, h ▸ is_closed_closure) (by simpa only [subset_def, sUnion_image, mem_Union]) in
578574
let ⟨b, hb⟩ := axiom_of_choice $
@@ -1022,8 +1018,7 @@ end
10221018

10231019
lemma quotient_dense_of_dense [setoid α] [topological_space α] {s : set α} (H : ∀ x, x ∈ closure s) :
10241020
closure (quotient.mk '' s) = univ :=
1025-
begin
1026-
refine eq_univ_of_forall (λ x, _),
1021+
eq_univ_of_forall $ λ x, begin
10271022
rw mem_closure_iff,
10281023
intros U U_op x_in_U,
10291024
let V := quotient.mk ⁻¹' U,
@@ -1032,7 +1027,7 @@ begin
10321027
have V_op : is_open V := U_op,
10331028
have : V ∩ s ≠ ∅ := mem_closure_iff.1 (H y) V V_op y_in_V,
10341029
rcases exists_mem_of_ne_empty this with ⟨w, w_in_V, w_in_range⟩,
1035-
exact ne_empty_of_mem ⟨by tauto, mem_image_of_mem quotient.mk w_in_range⟩
1030+
exact ne_empty_of_mem ⟨w_in_V, mem_image_of_mem quotient.mk w_in_range⟩
10361031
end
10371032

10381033
lemma generate_from_le {t : topological_space α} { g : set (set α) } (h : ∀s∈g, is_open s) :
@@ -1157,8 +1152,8 @@ begin
11571152
let ⟨u, hu₁, hu₂, hu₃⟩ := hb.1 _ hs₂ _ ht₂ _ this in
11581153
⟨u, ⟨hu₂, hu₁⟩, le_principal_iff.2 (subset.trans hu₃ (inter_subset_left _ _)),
11591154
le_principal_iff.2 (subset.trans hu₃ (inter_subset_right _ _))⟩ },
1160-
{ suffices : a ∈ (⋃₀ b), { rcases this with ⟨i, h1, h2⟩, exact ⟨i, h2, h1⟩ },
1161-
{ rw [hb.2.1], trivial } }
1155+
{ rcases eq_univ_iff_forall.1 hb.2.1 a with ⟨i, h1, h2⟩,
1156+
exact ⟨i, h2, h1⟩ }
11621157
end
11631158

11641159
lemma is_open_of_is_topological_basis {s : set α} {b : set (set α)}

0 commit comments

Comments
 (0)