Skip to content

Commit e17f7ae

Browse files
committed
finish after rebase
1 parent 11fad39 commit e17f7ae

3 files changed

Lines changed: 18 additions & 222 deletions

File tree

ArkLib/Data/CodingTheory/JohnsonBound.lean

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ lemma johnson_condition_weak_implies_strong {B : Finset (Fin n → F)} {v : Fin
7070
JohnsonConditionStrong (B ∩ ({ x | Δ₀(x, v) ≤ e } : Finset _)) v := by
7171
sorry
7272

73-
private lemma johnson_condition_strong_implies_n_pos {B : Finset (Fin n → F)} {v : Fin n → F}
7473
private lemma johnson_condition_strong_implies_n_pos
7574
(h_johnson : JohnsonConditionStrong B v)
7675
:
@@ -85,7 +84,6 @@ private lemma johnson_condition_strong_implies_2_le_F_card
8584
dsimp [JohnsonConditionStrong]
8685
rcases Fintype.card F with _ | _ | _ <;> aesop
8786

88-
private lemma johnson_condition_strong_implies_2_le_B_card {B : Finset (Fin n → F)} {v : Fin n → F}
8987
private lemma johnson_condition_strong_implies_2_le_B_card
9088
(h_johnson : JohnsonConditionStrong B v)
9189
:
@@ -113,31 +111,25 @@ lemma johnson_condition_strong_iff_johnson_denom_pos {B : Finset (Fin n → F)}
113111
/--
114112
Theorem 3.1.
115113
--/
116-
theorem johnson_bound [Field F] {B : Finset (Fin n → F)} {v : Fin n → F}
117-
lemma johnson_condition_strong_iff_johnson_denom_pos :
118-
JohnsonConditionStrong B v ↔ 0 < JohnsonDenominator B v := by
119-
simp [JohnsonDenominator, JohnsonConditionStrong]
120-
121-
theorem johnson_bound_OLD [Field F]
114+
theorem johnson_bound [Field F]
122115
(h_condition : JohnsonConditionStrong B v)
123116
:
124117
let d := d B
125118
let q : ℚ := Fintype.card F
126119
let frac := q / (q - 1)
127120
B.card ≤ (frac * d/n) / JohnsonDenominator B v
128121
:= by
129-
simp
130-
have h_condition' := h_condition
131-
rw [johnson_condition_strong_iff_johnson_denom_pos] at h_condition
132-
rw [Field.div_eq_mul_inv]
133-
apply le_of_mul_le_mul_right (a0 := h_condition)
134-
rw [mul_assoc, mul_comm ((_)⁻¹) _, Field.mul_inv_cancel _ (by linarith)]
135-
simp
122+
suffices B.card * JohnsonDenominator B v ≤
123+
Fintype.card F / (Fintype.card F - 1) * d B / n by
124+
rw [johnson_condition_strong_iff_johnson_denom_pos] at h_condition
125+
rw [←mul_le_mul_right h_condition]
126+
convert this using 1
127+
field_simp; rw [mul_div_mul_right]; linarith
136128
rw [johnson_denominator_def]
137129
exact JohnsonBound.johnson_bound_lemma
138-
(johnson_condition_strong_implies_n_pos h_condition')
139-
(johnson_condition_strong_implies_2_le_B_card h_condition')
140-
(johnson_condition_strong_implies_2_le_F_card h_condition')
130+
(johnson_condition_strong_implies_n_pos h_condition)
131+
(johnson_condition_strong_implies_2_le_B_card h_condition)
132+
(johnson_condition_strong_implies_2_le_F_card h_condition)
141133

142134
/--
143135
Alphabet-free Johnson bound from [codingtheory].
@@ -157,24 +149,5 @@ theorem johnson_bound_alphabet_free [Field F] [DecidableEq F]
157149
158150
(B ∩ ({ x | Δ₀(x, v) ≤ e } : Finset _)).card ≤ q * d * n := by
159151
sorry
160-
theorem johnson_bound [Field F]
161-
(h_condition : JohnsonConditionStrong B v)
162-
:
163-
let d := d B
164-
let q : ℚ := Fintype.card F
165-
let frac := q / (q - 1)
166-
B.card ≤ (frac * d/n) / JohnsonDenominator B v
167-
:= by
168-
suffices B.card * JohnsonDenominator B v ≤
169-
Fintype.card F / (Fintype.card F - 1) * d B / n by
170-
rw [johnson_condition_strong_iff_johnson_denom_pos] at h_condition
171-
rw [←mul_le_mul_right h_condition]
172-
convert this using 1
173-
field_simp; rw [mul_div_mul_right]; linarith
174-
rw [johnson_denominator_def]
175-
exact JohnsonBound.johnson_bound_lemma
176-
(johnson_condition_strong_implies_n_pos h_condition)
177-
(johnson_condition_strong_implies_2_le_B_card h_condition)
178-
(johnson_condition_strong_implies_2_le_F_card h_condition)
179152

180153
end JohnsonBound

ArkLib/Data/CodingTheory/JohnsonBound/Expectations.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ lemma lin_shift_d [Field F] [Fintype F]
5656
field_simp
5757
apply Finset.sum_bij (fun x _ => (x.1 - v, x.2 -v)) <;> try aesop
5858

59-
lemma e_ball_le_radius [Field F] {B : Finset (Fin n → F)} (v : Fin n → F) (r : ℚ)
59+
lemma e_ball_le_radius [Field F] [Fintype F] {B : Finset (Fin n → F)} (v : Fin n → F) (r : ℚ)
6060
:
6161
e (B ∩ ({ x | Δ₀(x, v) ≤ r} : Finset _)) v ≤ r := by
6262
sorry

ArkLib/Data/CodingTheory/JohnsonBound/Lemmas.lean

Lines changed: 7 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -48,175 +48,6 @@ private lemma sum_choose_K' [Zero F]
4848
:
4949
(Fintype.card (α := F) - 1) * choose_2 ((B.card - K B i 0) / (Fintype.card (α := F) - 1)) ≤
5050
∑ (α : F) with α ≠ 0, choose_2 (K B i α) := by
51-
52-
rw [←sum_K_eq_card (i := i)]
53-
simp
54-
have h_univ : Finset.univ = insert 0 ({x : F | x ≠ 0} : Finset F) := by
55-
ext x
56-
simp
57-
tauto
58-
rw [h_univ, Finset.sum_insert (by simp)]
59-
field_simp
60-
61-
have h : ((∑ x ∈ {x | ¬x = 0}, ↑(K B i x)) : ℚ) / (↑(Fintype.card F) - 1)
62-
= ∑ x ∈ {x : F | ¬x = 0}, ((1 : ℚ)/((Fintype.card F) - 1)) * ↑(K B i x) := by
63-
rw [Finset.sum_div]
64-
congr
65-
field_simp
66-
rw [h]
67-
let w : F → ℚ := fun _ => (1 : ℚ) / (↑(Fintype.card F) - 1)
68-
let p : F → ℚ := fun x => K B i x
69-
have h : ∑ x ∈ {x : F | ¬x = 0}, ((1 : ℚ)/((Fintype.card F) - 1)) * ↑(K B i x)
70-
= ∑ x ∈ {x : F | ¬x = 0}, w x • p x := by simp [w, p]
71-
rw [h]
72-
rw [mul_comm]
73-
apply le_trans
74-
rewrite [mul_le_mul_right (by field_simp; linarith)]
75-
apply ConvexOn.map_sum_le choose_2_convex (by {
76-
simp [w]
77-
intro i _
78-
linarith
79-
})
80-
(by {
81-
simp [w]
82-
have h : (Finset.univ (α := F)).card = Fintype.card F := by rfl
83-
conv =>
84-
congr
85-
congr
86-
rfl
87-
rw [←h, h_univ]
88-
rfl
89-
rfl
90-
simp
91-
rw [Field.mul_inv_cancel]
92-
simp
93-
rw [←ne_eq]
94-
rw [←Finset.nonempty_iff_ne_empty]
95-
simp [Finset.Nonempty]
96-
have h_two := (Finset.one_lt_card (s := Finset.univ (α := F))).1 (by omega)
97-
rcases h_two with ⟨a, ha, b, hb, hab⟩
98-
by_cases h_ne_a : a ≠ 0 <;> try tauto
99-
simp at h_ne_a
100-
rw [h_ne_a] at hab
101-
tauto
102-
})
103-
(by simp)
104-
rw [mul_comm]
105-
simp [w, p]
106-
rw [Finset.mul_sum]
107-
conv =>
108-
lhs
109-
congr
110-
rfl
111-
ext α
112-
rw [←mul_assoc]
113-
rw [Field.mul_inv_cancel _ (by {
114-
intro contr
115-
have contr : (↑(Fintype.card F) : ℚ) = 1 := by
116-
rw [←zero_add 1, ←contr]
117-
field_simp
118-
simp at contr
119-
omega
120-
})]
121-
rw [one_mul]
122-
rfl
123-
have h : ({x ∈ insert 0 ({x | ¬x = 0} : Finset F) | ¬x = 0} : Finset F)
124-
= ({ x : F | ¬ x = 0 } : Finset F) :=
125-
by
126-
ext x
127-
simp
128-
tauto
129-
rw [h]
130-
131-
private lemma sum_choose_K'' [Zero F]
132-
(h_card : 2 ≤ (Fintype.card F))
133-
:
134-
(Fintype.card (α := F) - 1) * choose_2 ((B.card - K B i 0) / (Fintype.card (α := F) - 1)) ≤
135-
∑ (α : F) with α ≠ 0, choose_2 (K B i α) := by
136-
rw [←sum_K_eq_card (i := i), Nat.cast_sum]
137-
set X₁ : ℚ := Fintype.card F - 1
138-
set X₂ := K B i
139-
suffices X₁ * choose_2 ((∑ x with x ≠ 0, ↑(X₂ x)) / X₁) ≤
140-
∑ α with α ≠ 0, choose_2 ↑(X₂ α) by
141-
convert this
142-
rw [Finset.sum_eq_sum_diff_singleton_add (i := 0) (by simp)]
143-
ring_nf; apply Finset.sum_congr (Finset.ext _) <;> simp
144-
145-
146-
147-
have h : ((∑ x ∈ {x : F | ¬x = 0}, ↑(K B i x)) : ℚ) / (↑(Fintype.card F) - 1)
148-
= ∑ x ∈ {x : F | ¬x = 0}, ((1 : ℚ)/((Fintype.card F) - 1)) * ↑(K B i x) := by
149-
rw [Finset.sum_div]
150-
congr
151-
field_simp
152-
rw [h]
153-
154-
let w : F → ℚ := fun _ => (1 : ℚ) / (↑(Fintype.card F) - 1)
155-
let p : F → ℚ := fun x => K B i x
156-
have h : ∑ x ∈ {x : F | ¬x = 0}, ((1 : ℚ)/((Fintype.card F) - 1)) * ↑(K B i x)
157-
= ∑ x ∈ {x : F | ¬x = 0}, w x • p x := by simp [w, p]
158-
rw [h]
159-
rw [mul_comm]
160-
apply le_trans
161-
rewrite [mul_le_mul_right (by field_simp; linarith)]
162-
apply ConvexOn.map_sum_le choose_2_convex (by {
163-
simp [w]
164-
intro i _
165-
linarith
166-
})
167-
(by {
168-
simp [w]
169-
have h : (Finset.univ (α := F)).card = Fintype.card F := by rfl
170-
conv =>
171-
congr
172-
congr
173-
rfl
174-
rw [←h, h_univ]
175-
rfl
176-
rfl
177-
simp
178-
rw [Field.mul_inv_cancel]
179-
simp
180-
rw [←ne_eq]
181-
rw [←Finset.nonempty_iff_ne_empty]
182-
simp [Finset.Nonempty]
183-
have h_two := (Finset.one_lt_card (s := Finset.univ (α := F))).1 (by omega)
184-
rcases h_two with ⟨a, ha, b, hb, hab⟩
185-
by_cases h_ne_a : a ≠ 0 <;> try tauto
186-
simp at h_ne_a
187-
rw [h_ne_a] at hab
188-
tauto
189-
})
190-
(by simp)
191-
rw [mul_comm]
192-
simp [w, p]
193-
rw [Finset.mul_sum]
194-
conv =>
195-
lhs
196-
congr
197-
rfl
198-
ext α
199-
rw [←mul_assoc]
200-
rw [Field.mul_inv_cancel _ (by {
201-
intro contr
202-
have contr : (↑(Fintype.card F) : ℚ) = 1 := by
203-
rw [←zero_add 1, ←contr]
204-
field_simp
205-
simp at contr
206-
omega
207-
})]
208-
rw [one_mul]
209-
rfl
210-
have h : ({x ∈ insert 0 ({x | ¬x = 0} : Finset F) | ¬x = 0} : Finset F)
211-
= ({ x : F | ¬ x = 0 } : Finset F) :=
212-
by
213-
ext x
214-
simp
215-
tauto
216-
rw [h]
217-
218-
private def sum_choose_K_i (B : Finset (Fin n → F)) (i : Fin n) : ℚ :=
219-
∑ (α : F), choose_2 (K B i α)
22051
rw [←sum_K_eq_card (i := i), Nat.cast_sum]
22152
set X₁ : ℚ := Fintype.card F - 1
22253
have X₁h : X₁ ≠ 0 := by simp [X₁, sub_eq_zero]; omega
@@ -237,14 +68,14 @@ private def sum_choose_K_i (B : Finset (Fin n → F)) (i : Fin n) : ℚ :=
23768
(by simp)
23869
· rw [mul_sum]; field_simp
23970

240-
private def sum_choose_K (B : Finset (Fin n → F)) (i : Fin n) : ℚ :=
241-
∑ (α : F), choose_2 (K B i α)
71+
private def sum_choose_K_i (B : Finset (Fin n → F)) (i : Fin n) : ℚ :=
72+
∑ (α : F), choose_2 (K B i α)
24273

24374
private lemma le_sum_choose_K [Zero F]
24475
(h_card : 2 ≤ (Fintype.card F)) :
24576
choose_2 (K B i 0) + (Fintype.card (α := F) - 1) *
246-
choose_2 ((B.card - K B i 0) / (Fintype.card (α := F) - 1)) ≤ sum_choose_K B i := by
247-
unfold sum_choose_K
77+
choose_2 ((B.card - K B i 0) / (Fintype.card (α := F) - 1)) ≤ sum_choose_K_i B i := by
78+
unfold sum_choose_K_i
24879
rw [show Finset.univ = {0} ∪ {x : F | x ≠ 0}.toFinset by ext; simp; tauto]
24980
simp [Finset.sum_union, sum_choose_K' h_card]
25081

@@ -342,7 +173,7 @@ private lemma le_sum_sum_choose_K [Zero F]
342173
:
343174
n * (choose_2 (k B) + (Fintype.card (α := F) - 1)
344175
* choose_2 ((B.card - k B) / ((Fintype.card (α := F) - 1))))
345-
≤ ∑ i, sum_choose_K B i := by
176+
≤ ∑ i, sum_choose_K_i B i := by
346177
rw [mul_add]
347178
transitivity
348179
apply add_le_add_right (k_choose_2 (n := n) (by omega) h_B)
@@ -451,12 +282,12 @@ private lemma d_eq_sum {B : Finset (Fin n → F)}
451282
private lemma sum_sum_K_i_eq_n_sub_d
452283
(h_B : 2 ≤ B.card)
453284
:
454-
∑ i, sum_choose_K B i = choose_2 B.card * (n - d B) := by
285+
∑ i, sum_choose_K_i B i = choose_2 B.card * (n - d B) := by
455286
rw [show
456287
choose_2 B.card * (n - d B) = choose_2 B.card * n - (2 * choose_2 B.card * d B) / 2 by ring
457288
]
458289
simp_rw [d_eq_sum h_B, sum_of_not_equals]
459-
field_simp [←Finset.mul_sum, sum_choose_K]
290+
field_simp [←Finset.mul_sum, sum_choose_K_i]
460291
ring
461292

462293
private lemma almost_johnson [Zero F]
@@ -594,14 +425,6 @@ protected lemma johnson_bound_lemma [Field F] {v : Fin n → F}
594425
((1 - ((Fintype.card F : ℚ) / (Fintype.card F - 1)) * (e B v / n)) ^ 2
595426
- (1 - ((Fintype.card F : ℚ) / (Fintype.card F - 1)) * (d B/n))) ≤
596427
((Fintype.card F : ℚ) / (Fintype.card F - 1)) * d B/n := by
597-
rw [lin_shift_e (B := B) (by omega)]
598-
rw [lin_shift_d h_B]
599-
rw [lin_shift_card (B := B) (v := v)]
600-
exact johnson_bound₀ h_n (by {
601-
rw [←lin_shift_card (B := B)]
602-
assumption
603-
})
604-
h_card
605428
rw [lin_shift_e (by omega), lin_shift_d h_B, lin_shift_card (v := v)]
606429
exact johnson_bound₀ h_n (lin_shift_card (B := B) ▸ h_B) h_card
607430

0 commit comments

Comments
 (0)