@[simp]theoremcubeDist_zero_iff (n : ℕ) (x y : Cube n) : cubeDist n x y = 0↔ x = y :=by
proof · 6
lines
induction n with
| zero => simp only [cubeDist]
| succ n ih =>
obtain ⟨b,x⟩ := x
obtain ⟨c,y⟩ := y
by_cases h : b = c <;> simp [cubeDist, h, ih, Prod.mk.injEq]
theoremcubeDist_triangle (n : ℕ) (x y z : Cube n) :
cubeDist n x z ≤ cubeDist n x y + cubeDist n y z :=by
proof · 8
lines
induction n with
| zero => simp [cubeDist]
| succ n ih =>
obtain ⟨b,x⟩ := x
obtain ⟨c,y⟩ := y
obtain ⟨d,z⟩ := z
have h := ih x y z
cases b <;> cases c <;> cases d <;> simp [cubeDist] <;> omega
theoremcubeCross_card_le {n : ℕ} (AB : Cube n →Prop) : cubeSize A≤ cubeSize B + cubeCross AB:=by
proof · 5
lines
classical
rw [cubeSize, cubeSize, cubeCross, ←Finset.sum_add_distrib]
apply Finset.sum_le_sum
intro x _
by_cases ha : A x <;> by_cases hb : B x <;> simp [ha, hb]
theoremcube_degree (n : ℕ) (x : Cube n) : (∑ y, if cubeDist n x y = 1then1else0) = n :=by
proof · 9
lines
classical
induction n with
| zero => simp [cubeDist]
| succ n ih =>
obtain ⟨b,x⟩ := x
cases b <;> simp only [Fintype.sum_prod_type, Fintype.sum_bool, cubeDist,
Bool.false_eq_true, Bool.true_eq_false, ↓reduceIte, zero_add, Nat.add_eq_left,
cubeDist_zero_iff, Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte, ih]
omega
theorembinEntropy_ge_two_mul {p : ℝ} (hp0 : 0≤ p) (hp2 : p ≤1/2) :
2 * p * Real.log 2≤Real.binEntropy p :=by
proof · 6
lines
havehc : ConcaveOnℝ (Set.Icc01) Real.binEntropy :=Real.strictConcave_binEntropy.concaveOn
have h := hc.2 (show (0 : ℝ) ∈Set.Icc01by norm_num)
(show (2 : ℝ)⁻¹∈Set.Icc01by norm_num)
(show0≤1 - 2*p by linarith) (show0≤2*p by positivity) (by ring)
simpa only [smul_eq_mul, Real.binEntropy_zero, Real.binEntropy_two_inv,
mul_zero, zero_add, show2*p*(2:ℝ)⁻¹ = p by ring] using h
theorementropy_merge {a b : ℝ} (ha : 0≤ a) (hb : 0≤ b) :
2 * min a b * Real.log 2≤ (a+b)*Real.log (a+b) - a*Real.log a - b*Real.log b :=by
proof · 7
lines
rcases le_total a b with hab | hba
· simpa [min_eq_left hab] using entropy_merge_of_le ha hab
· have h := entropy_merge_of_le hb hba
rw [min_eq_right hba]
convert h using1
rw [add_comm b a]
ring
theoremcubeBoundary_expand_bound {n : ℕ} (S : Cube n →Prop) :
cubeBoundary S + n * cubeSize S≤ n * cubeSize (cubeExpand S) :=by
proof · 32
lines
classical
have hdegree (y : Cube n) :
(∑ x, ifS x ∧¬S y ∧ cubeDist n x y = 1then1else0) ≤
n * (if¬S y ∧ (∃ x, S x ∧ cubeDist n x y = 1) then1else0) :=byby_cases hy : ¬S y ∧ (∃ x, S x ∧ cubeDist n x y = 1)
· rw [ite_eq_left hy, mul_one]
calc
_ ≤∑ x, if cubeDist n y x = 1then1else0:=by
apply Finset.sum_le_sum
intro x _
by_cases h : S x ∧¬S y ∧ cubeDist n x y = 1
· simp [h, cubeDist_symm n y x]
· simp [h]
_ = n := cube_degree n y
· simp only [hy, ↓reduceIte, mul_zero, Nat.le_zero]
apply Finset.sum_eq_zero
intro x _
havehnot : ¬(S x ∧¬S y ∧ cubeDist n x y = 1) :=by
rintro ⟨hs, hns, hd⟩
exact hy ⟨hns,x,hs,hd⟩
simp [hnot]
have hb :=Finset.sum_le_sum (s :=Finset.univ) (fun y _ => hdegree y)
rw [←Finset.mul_sum] at hb
haveheq : cubeSize (cubeExpand S) = cubeSize S +
∑ y, if¬S y ∧ (∃ x, S x ∧ cubeDist n x y = 1) then1else0:=by
rw [cubeSize, cubeSize, ←Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro y _
by_cases hs : S y <;> simp [cubeExpand, hs]
unfold cubeBoundary
rw [Finset.sum_comm, heq, Nat.mul_add]
omega
theoremcubeExpandIter_witness {n h : ℕ} {S : Cube n →Prop} {x : Cube n}
(hx : cubeExpandIter S h x) : ∃ y, S y ∧ cubeDist n y x ≤ h :=by
proof · 8
lines
induction h generalizing x with
| zero => exact ⟨x,hx,by simp⟩
| succ h ih =>
rcases hx with hx | ⟨z,hz,hzx⟩
· obtain ⟨y,hy,hyx⟩ := ih hx
exact ⟨y,hy,by omega⟩
· obtain ⟨y,hy,hyz⟩ := ih hz
exact ⟨y,hy,byhave ht := cubeDist_triangle n y z x; omega⟩
theoremcubeExpandIter_disjoint {n h : ℕ} {ST : Cube n →Prop}
(hsep : ∀ x, S x →∀ y, T y →2*h < cubeDist n x y) :
∀ x, ¬(cubeExpandIter S h x ∧ cubeExpandIter T h x) :=by
proof · 7
lines
rintro x ⟨hs,ht⟩
obtain ⟨y,hy,hyx⟩ := cubeExpandIter_witness hs
obtain ⟨z,hz,hzx⟩ := cubeExpandIter_witness ht
have h := hsep y hy z hz
have htri := cubeDist_triangle n y x z
rw [cubeDist_symm n x z] at htri
omega
theoremcubeSize_sum_le {n : ℕ} {ι : Type uIota} [Fintype ι] (S : ι →Cube n →Prop)
(hd : ∀ i j, i ≠ j →∀ x, ¬(S i x ∧S j x)) :
∑ i, cubeSize (S i) ≤2^n :=by
proof · 18
lines
classical
unfold cubeSize
rw [Finset.sum_comm]
calc
_ ≤∑_ : Cube n, 1:=by
apply Finset.sum_le_sum
intro x _
by_cases he : ∃ i, S i x
· obtain ⟨i,hi⟩ := he
rw [Finset.sum_eq_single i]
· simp [hi]
· intro j _ hji
havehnot : ¬S j x :=fun hj => hd j i hji x ⟨hj,hi⟩
simp [hnot]
· simp
· havehh : ∀ i, ¬S i x :=by simpa only [not_exists] using he
simp [hh]
_ = 2^n :=by simp [cube_card]
theoremcube_separated_bound {n h : ℕ} (hn : 0 < n) {ι : Type uIota} [Fintype ι]
(S : ι →Cube n →Prop) {a EA : ℝ} (ha : 0≤ a) (hE : 0 < E)
(hlogE : Real.log E≤ (n : ℝ) * Real.log 2 - a)
(hseed : ∀ i, A * cubeSize (S i) ≤E)
(hfactor : A≤ (1 + a / ((n : ℝ)*Real.log 2))^h)
(hsep : ∀ i j, i ≠ j →∀ x, S i x →∀ y, S j y →2*h < cubeDist n x y) :
A * (∑ i, (cubeSize (S i) : ℝ)) ≤ (2 : ℝ)^n :=by
proof · 12
lines
havehδ : 0≤ a / ((n : ℝ)*Real.log 2) :=by
apply div_nonneg ha
exact mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg (by norm_num))
have hlarge (i : ι) : A * cubeSize (S i) ≤ cubeSize (cubeExpandIter (S i) h) :=by
apply le_trans (le_min (hseed i) (mul_le_mul_of_nonneg_right hfactor (Nat.cast_nonneg _)))
exact cube_iter_growth (S i) hδ (funT ht => cube_growth hn T hE hlogE ht) h
rw [Finset.mul_sum]
apply (Finset.sum_le_sum (fun i _ => hlarge i)).trans
havehd : ∀ i j, i ≠ j →∀ x, ¬(cubeExpandIter (S i) h x ∧ cubeExpandIter (S j) h x) :=by
intro i j hij
exact cubeExpandIter_disjoint (hsep i j hij)
exact_mod_cast cubeSize_sum_le (fun i => cubeExpandIter (S i) h) hd