Skip to content

Commit 8fa5a3a

Browse files
chore: tidy various files (#12121)
1 parent 38a7a53 commit 8fa5a3a

File tree

6 files changed

+101
-110
lines changed

6 files changed

+101
-110
lines changed

Mathlib/Algebra/Function/Indicator.lean

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,8 @@ theorem mulIndicator_preimage_of_not_mem (s : Set α) (f : α → M) {t : Set M}
322322
@[to_additive]
323323
theorem mem_range_mulIndicator {r : M} {s : Set α} {f : α → M} :
324324
r ∈ range (mulIndicator s f) ↔ r = 1 ∧ s ≠ univ ∨ r ∈ f '' s := by
325-
-- Porting note: This proof used to be:
326-
-- simp [mulIndicator, ite_eq_iff, exists_or, eq_univ_iff_forall, and_comm, or_comm,
327-
-- @eq_comm _ r 1]
328-
simp only [mem_range, mulIndicator, ne_eq, mem_image]
329-
rw [eq_univ_iff_forall, not_forall]
330-
refine ⟨?_, ?_⟩
331-
· rintro ⟨y, hy⟩
332-
split_ifs at hy with hys
333-
· tauto
334-
· left
335-
tauto
336-
· rintro (⟨hr, ⟨x, hx⟩⟩ | ⟨x, ⟨hx, hxs⟩⟩) <;> use x <;> split_ifs <;> tauto
325+
simp [mulIndicator, ite_eq_iff, exists_or, eq_univ_iff_forall, and_comm, or_comm,
326+
@eq_comm _ r 1]
337327
#align set.mem_range_mul_indicator Set.mem_range_mulIndicator
338328
#align set.mem_range_indicator Set.mem_range_indicator
339329

Mathlib/Data/Nat/ChineseRemainder.lean

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ lemma modEq_list_prod_iff {a b} {l : List ℕ} (co : l.Pairwise Coprime) :
3232
induction' l with m l ih
3333
· simp [modEq_one]
3434
· have : Coprime m l.prod := coprime_list_prod_right_iff.mpr (List.pairwise_cons.mp co).1
35-
simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)]
35+
simp only [List.prod_cons, ← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co),
36+
List.length_cons]
3637
constructor
3738
· rintro ⟨h0, hs⟩ i
3839
cases i using Fin.cases <;> simp [h0, hs]
@@ -42,8 +43,11 @@ lemma modEq_list_prod_iff' {a b} {s : ι → ℕ} {l : List ι} (co : l.Pairwise
4243
a ≡ b [MOD (l.map s).prod] ↔ ∀ i ∈ l, a ≡ b [MOD s i] := by
4344
induction' l with i l ih
4445
· simp [modEq_one]
45-
· have : Coprime (s i) (l.map s).prod := coprime_list_prod_right_iff.mpr
46-
(by simp; intro j hj; exact (List.pairwise_cons.mp co).1 j hj)
46+
· have : Coprime (s i) (l.map s).prod := by
47+
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
48+
forall_apply_eq_imp_iff₂]
49+
intro j hj
50+
exact (List.pairwise_cons.mp co).1 j hj
4751
simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)]
4852

4953
variable (a s : ι → ℕ)
@@ -54,38 +58,52 @@ def chineseRemainderOfList : (l : List ι) → l.Pairwise (Coprime on s) →
5458
{ k // ∀ i ∈ l, k ≡ a i [MOD s i] }
5559
| [], _ => ⟨0, by simp⟩
5660
| i :: l, co => by
57-
have : Coprime (s i) (l.map s).prod := coprime_list_prod_right_iff.mpr
58-
(by simp; intro j hj; exact (List.pairwise_cons.mp co).1 j hj)
61+
have : Coprime (s i) (l.map s).prod := by
62+
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
63+
forall_apply_eq_imp_iff₂]
64+
intro j hj
65+
exact (List.pairwise_cons.mp co).1 j hj
5966
have ih := chineseRemainderOfList l co.of_cons
6067
have k := chineseRemainder this (a i) ih
61-
exact ⟨k, by
62-
simp [k.prop.1]; intro j hj
63-
exact ((modEq_list_prod_iff' co.of_cons).mp k.prop.2 j hj).trans (ih.prop j hj)⟩
68+
use k
69+
simp only [List.mem_cons, forall_eq_or_imp, k.prop.1, true_and]
70+
intro j hj
71+
exact ((modEq_list_prod_iff' co.of_cons).mp k.prop.2 j hj).trans (ih.prop j hj)
6472

6573
@[simp] theorem chineseRemainderOfList_nil :
6674
(chineseRemainderOfList a s [] List.Pairwise.nil : ℕ) = 0 := rfl
6775

6876
theorem chineseRemainderOfList_lt_prod (l : List ι)
6977
(co : l.Pairwise (Coprime on s)) (hs : ∀ i ∈ l, s i ≠ 0) :
7078
chineseRemainderOfList a s l co < (l.map s).prod := by
71-
cases' l with i l <;> simp
72-
· simp [chineseRemainderOfList]
73-
have : Coprime (s i) (l.map s).prod := coprime_list_prod_right_iff.mpr
74-
(by simp; intro j hj; exact (List.pairwise_cons.mp co).1 j hj)
75-
exact chineseRemainder_lt_mul this (a i)
76-
(chineseRemainderOfList a s l co.of_cons)
77-
(hs i (by simp)) (by simp; intro j hj; exact hs j (by simp [hj]))
79+
cases l with
80+
| nil => simp
81+
| cons i l =>
82+
simp only [chineseRemainderOfList, List.map_cons, List.prod_cons]
83+
have : Coprime (s i) (l.map s).prod := by
84+
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
85+
forall_apply_eq_imp_iff₂]
86+
intro j hj
87+
exact (List.pairwise_cons.mp co).1 j hj
88+
refine chineseRemainder_lt_mul this (a i) (chineseRemainderOfList a s l co.of_cons)
89+
(hs i (List.mem_cons_self _ l)) ?_
90+
simp only [ne_eq, List.prod_eq_zero_iff, List.mem_map, not_exists, not_and]
91+
intro j hj
92+
exact hs j (List.mem_cons_of_mem _ hj)
7893

7994
theorem chineseRemainderOfList_modEq_unique (l : List ι)
8095
(co : l.Pairwise (Coprime on s)) {z} (hz : ∀ i ∈ l, z ≡ a i [MOD s i]) :
8196
z ≡ chineseRemainderOfList a s l co [MOD (l.map s).prod] := by
8297
induction' l with i l ih
8398
· simp [modEq_one]
84-
· simp [chineseRemainderOfList]
85-
have : Coprime (s i) (l.map s).prod := coprime_list_prod_right_iff.mpr
86-
(by simp; intro j hj; exact (List.pairwise_cons.mp co).1 j hj)
99+
· simp only [List.map_cons, List.prod_cons, chineseRemainderOfList]
100+
have : Coprime (s i) (l.map s).prod := by
101+
simp only [coprime_list_prod_right_iff, List.mem_map, forall_exists_index, and_imp,
102+
forall_apply_eq_imp_iff₂]
103+
intro j hj
104+
exact (List.pairwise_cons.mp co).1 j hj
87105
exact chineseRemainder_modEq_unique this
88-
(hz i (by simp)) (ih co.of_cons (fun j hj => hz j (by simp [hj])))
106+
(hz i (List.mem_cons_self _ _)) (ih co.of_cons (fun j hj => hz j (List.mem_cons_of_mem _ hj)))
89107

90108
theorem chineseRemainderOfList_perm {l l' : List ι} (hl : l.Perm l')
91109
(hs : ∀ i ∈ l, s i ≠ 0) (co : l.Pairwise (Coprime on s)) :
@@ -137,8 +155,8 @@ theorem chineseRemainderOfMultiset_lt_prod {m : Multiset ι}
137155
`a i` mod `s i` for all `i ∈ t`. -/
138156
def chineseRemainderOfFinset (t : Finset ι)
139157
(hs : ∀ i ∈ t, s i ≠ 0) (pp : Set.Pairwise t (Coprime on s)) :
140-
{ k // ∀ i ∈ t, k ≡ a i [MOD s i] } :=
141-
by simpa using chineseRemainderOfMultiset a s t.nodup (by simpa using hs) (by simpa using pp)
158+
{ k // ∀ i ∈ t, k ≡ a i [MOD s i] } := by
159+
simpa using chineseRemainderOfMultiset a s t.nodup (by simpa using hs) (by simpa using pp)
142160

143161
theorem chineseRemainderOfFinset_lt_prod {t : Finset ι}
144162
(hs : ∀ i ∈ t, s i ≠ 0) (pp : Set.Pairwise t (Coprime on s)) :

0 commit comments

Comments
 (0)