@@ -7,6 +7,7 @@ Some big operators for lists and finite sets.
7
7
-/
8
8
import data.list.basic data.list.perm data.finset
9
9
algebra.group algebra.ordered_group algebra.group_power
10
+ tactic.squeeze
10
11
11
12
universes u v w
12
13
variables {α : Type u} {β : Type v} {γ : Type w}
@@ -15,7 +16,7 @@ theorem directed.finset_le {r : α → α → Prop} [is_trans α r]
15
16
{ι} (hι : nonempty ι) {f : ι → α} (D : directed r f) (s : finset ι) :
16
17
∃ z, ∀ i ∈ s, r (f i) (f z) :=
17
18
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⟩ := hι in ⟨z, λ _, false.elim⟩) $
19
20
λ i s ⟨j, H⟩, let ⟨k, h₁, h₂⟩ := D i j in
20
21
⟨k, λ a h, or.cases_on (multiset.mem_cons.1 h)
21
22
(λ h, h.symm ▸ h₁)
@@ -373,29 +374,28 @@ lemma prod_sum {δ : α → Type*} [∀a, decidable_eq (δ a)]
373
374
begin
374
375
induction s using finset.induction with a s ha ih,
375
376
{ rw [pi_empty, sum_singleton], refl },
376
- { have h₁ : ∀x ∈ t a, ∀y∈ t a, ∀h : x ≠ y,
377
+ { have h₁ : ∀x ∈ t a, ∀y ∈ t a, ∀h : x ≠ y,
377
378
image (pi.cons s a x) (pi s t) ∩ image (pi.cons s a y) (pi s t) = ∅,
378
379
{ assume x hx y hy h,
379
380
apply eq_empty_of_forall_not_mem,
380
381
simp only [mem_inter, mem_image],
381
382
rintro p₁ ⟨⟨p₂, hp, eq⟩, ⟨p₃, hp₃, rfl⟩⟩,
382
383
have : pi.cons s a x p₂ a (mem_insert_self _ _) = pi.cons s a y p₃ a (mem_insert_self _ _),
383
384
{ 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 },
385
387
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
388
390
assume p₁ h₁ p₂ h₂ eq, injective_pi_cons ha eq,
389
391
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 } }
399
399
end
400
400
401
401
end comm_semiring
@@ -404,13 +404,9 @@ section integral_domain /- add integral_semi_domain to support nat and ennreal -
404
404
variables [decidable_eq α] [integral_domain β]
405
405
406
406
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]
414
410
415
411
end integral_domain
416
412
@@ -436,9 +432,9 @@ calc s₁.sum f ≤ (s₂ \ s₁).sum f + s₁.sum f :
436
432
lemma sum_eq_zero_iff_of_nonneg : (∀x∈s, 0 ≤ f x) → (s.sum f = 0 ↔ ∀x∈s, f x = 0 ) :=
437
433
finset.induction_on s (λ _, ⟨λ _ _, false.elim, λ _, rfl⟩) $ λ a s ha ih H,
438
434
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 ]
442
438
443
439
lemma single_le_sum (hf : ∀x∈s, 0 ≤ f x) {a} (h : a ∈ s) : f a ≤ s.sum f :=
444
440
have (singleton a).sum f ≤ s.sum f,
0 commit comments