@@ -32,7 +32,8 @@ lemma modEq_list_prod_iff {a b} {l : List ℕ} (co : l.Pairwise Coprime) :
32
32
induction' l with m l ih
33
33
· simp [modEq_one]
34
34
· 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]
36
37
constructor
37
38
· rintro ⟨h0, hs⟩ i
38
39
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
42
43
a ≡ b [MOD (l.map s).prod] ↔ ∀ i ∈ l, a ≡ b [MOD s i] := by
43
44
induction' l with i l ih
44
45
· 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
47
51
simp [← modEq_and_modEq_iff_modEq_mul this, ih (List.Pairwise.of_cons co)]
48
52
49
53
variable (a s : ι → ℕ)
@@ -54,38 +58,52 @@ def chineseRemainderOfList : (l : List ι) → l.Pairwise (Coprime on s) →
54
58
{ k // ∀ i ∈ l, k ≡ a i [MOD s i] }
55
59
| [], _ => ⟨0 , by simp⟩
56
60
| 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
59
66
have ih := chineseRemainderOfList l co.of_cons
60
67
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)
64
72
65
73
@[simp] theorem chineseRemainderOfList_nil :
66
74
(chineseRemainderOfList a s [] List.Pairwise.nil : ℕ) = 0 := rfl
67
75
68
76
theorem chineseRemainderOfList_lt_prod (l : List ι)
69
77
(co : l.Pairwise (Coprime on s)) (hs : ∀ i ∈ l, s i ≠ 0 ) :
70
78
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)
78
93
79
94
theorem chineseRemainderOfList_modEq_unique (l : List ι)
80
95
(co : l.Pairwise (Coprime on s)) {z} (hz : ∀ i ∈ l, z ≡ a i [MOD s i]) :
81
96
z ≡ chineseRemainderOfList a s l co [MOD (l.map s).prod] := by
82
97
induction' l with i l ih
83
98
· 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
87
105
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 )))
89
107
90
108
theorem chineseRemainderOfList_perm {l l' : List ι} (hl : l.Perm l')
91
109
(hs : ∀ i ∈ l, s i ≠ 0 ) (co : l.Pairwise (Coprime on s)) :
@@ -137,8 +155,8 @@ theorem chineseRemainderOfMultiset_lt_prod {m : Multiset ι}
137
155
`a i` mod `s i` for all `i ∈ t`. -/
138
156
def chineseRemainderOfFinset (t : Finset ι)
139
157
(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)
142
160
143
161
theorem chineseRemainderOfFinset_lt_prod {t : Finset ι}
144
162
(hs : ∀ i ∈ t, s i ≠ 0 ) (pp : Set.Pairwise t (Coprime on s)) :
0 commit comments