lemmamarked_nonnegative {α : Type*} {w v : α→ℝ}
(hw : ∀ a,0≤ w a) (hv : ∀ a,0≤ v a) {n : ℕ} (p : Pad α n) : 0≤ marked w v p :=by
proof · 7
lines
induction n with
| zero => exact le_refl _
| succ n ih =>
rcases p with ⟨a,p⟩
apply add_nonneg
· exact mul_nonneg (by cases a <;> simp_all) (weight_nonnegative hw p)
· exact mul_nonneg (by cases a <;> simp_all) (ih p)
lemmaweight_le_marked_encode {α : Type*} {w v : α→ℝ}
(hw : ∀ a,0≤ w a) (hv : ∀ a,0≤ v a) (n : ℕ) (as : List α)
(hl : as.length≤ n) (hb : ∃ a∈as,w a≤ v a) :
weight w (encode n as)≤ marked w v (encode n as) :=by
proof · 18
lines
induction n generalizing as with
| zero =>havehe : as=[]:=List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero hl)
subst as
simp at hb
| succ n ih =>
cases as with
| nil => simp at hb
| cons a as =>
obtain ⟨b,hb,hbv⟩:=hb
rcases List.mem_cons.mp hb with hba|hb
· subst b
change w a*weight w (encode n as)≤ v a*weight w (encode n as)+w a*marked w v (encode n as)
exact (mul_le_mul_of_nonneg_right hbv (weight_nonnegative hw _)).trans
(le_add_of_nonneg_right (mul_nonneg (hw a) (marked_nonnegative hw hv _)))
· change w a*weight w (encode n as)≤ v a*weight w (encode n as)+w a*marked w v (encode n as)
exact (mul_le_mul_of_nonneg_left (ih as (Nat.le_of_succ_le_succ hl) ⟨b,hb,hbv⟩) (hw a)).trans
(le_add_of_nonneg_left (mul_nonneg (hv a) (weight_nonnegative hw _)))
lemmasum_marked {α : Type*} [Fintype α] (w v : α→ℝ) (n : ℕ) :
(∑p : Pad α n,marked w v p)=markTotal (1+∑ a,w a) (∑ a,v a) n :=by
proof · 8
lines
induction n with
| zero => change (∑_ : PUnit,(0:ℝ))=0; simp
| succ n ih =>
change (∑p : Option α ×Pad α n,(p.1.elim 0 v*weight w p.2+p.1.elim 1 w*marked w v p.2))=_
rw [Fintype.sum_prod_type]
simp only [Finset.sum_add_distrib,←Finset.mul_sum]
rw [sum_weight,ih,←Finset.sum_mul,←Finset.sum_mul,Fintype.sum_option,Fintype.sum_option]
simp only [Option.elim_none,Option.elim_some,zero_add,markTotal]
lemmafinite_marked_system_bound {α : Type*} [Fintype α] (w v : α→ℝ)
(hw : ∀ a,0≤ w a) (hv : ∀ a,0≤ v a) (S : Finset (List α)) (n : ℕ)
(hlen : ∀ as∈S,as.length≤ n) (hbad : ∀ as∈S,∃ a∈as,w a≤ v a) :
(∑ as∈S,(as.map w).prod)≤ markTotal (1+∑ a,w a) (∑ a,v a) n :=by
proof · 18
lines
classical
calc
_ ≤∑ as∈S,marked w v (encode n as) :=by
apply Finset.sum_le_sum
intro as ha
rw [←weight_encode w n as (hlen as ha)]
exact weight_le_marked_encode hw hv n as (hlen as ha) (hbad as ha)
_ = ∑ p∈S.image (encode n),marked w v p :=by
symm
apply Finset.sum_image
intro as has bs hbs he
have hh:=congrArg decode he
simpa only [decode_encode n as (hlen as has),decode_encode n bs (hlen bs hbs)] using hh
_ ≤∑p : Pad α n,marked w v p :=by
apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _)
intro p hp hn
exact marked_nonnegative hw hv p
_ = _ := sum_marked w v n
induction n with
| zero => exact tendsto_const_nhds
| succ n ih =>
simpa only [markTotal,zero_mul,mul_zero,add_zero] using (hV.mul (hU.pow n)).add (hU.mul ih)
induction n with
| zero => exact le_refl _
| succ n ih =>
exact add_le_add (mul_le_mul hV (pow_le_pow_left₀ hnU hU n) (pow_nonneg hnU _) (hnV.trans hV))
(mul_le_mul hU ih (markTotal_nonnegative hnU hnV n) (hnU.trans hU))
lemmaprescribed_eq_allGrid (WH : ℕ) (west east : ColumnH) (south north : ColumnW) :
prescribedPartition WH west east south north=allGridPartition WH west east south north :=by
proof · 16
lines
classical
rw [prescribedPartition_eq_grid_sum]
unfold allGridPartition
trans ∑σ : GridWireWH→Fin3,ifHasWestNorth west north σ then
(if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i)
then (network WH).physical σ else0) else0
· convert (sum_subtype_indicator (HasWestNorth west north) (fun σ=>if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i)
then (network WH).physical σ else0)).symm using1
congr 1
ext x
simp
apply Finset.sum_congr rfl
intro σ hσ
simp only [HasWestNorth,ite_and]
split_ifs <;> simp_all
lemmaallGrid_transpose (WH : ℕ) (west east : ColumnH) (south north : ColumnW) :
allGridPartition WH west east south north=allGridPartition HW south north west east :=by
lemmaprescribed_transpose (WH : ℕ) (west east : ColumnH) (south north : ColumnW) :
prescribedPartition WH west east south north=prescribedPartition HW south north west east :=by
lemmaprescribed_hard_transfer (WH : ℕ) (south north : ColumnW) :
prescribedPartition WH (fun _=>1) (fun _=>1) south north=(rowTransfer W^H) south north :=by
proof · 2
lines
rw [prescribed_transpose,prescribedPartition_eq_transfer]
simp only [rowTransfer,List.ofFn_const,List.prod_replicate]
lemmashapeTensor_PT (q : Shape) (w n s e : Fin3) :
shapeTensor q w n s e=shapeTensor (transposeShape q) s e w n :=by
proof · 10
lines
cases q
all_goals simp only [shapeTensor,transposeShape]
case empty => rw [vacant_symm w s,vacant_symm n e]
case westSouth => rw [occupied_symm w s,vacant_symm n e]
case northEast => rw [vacant_symm w s,occupied_symm n e]
case both => rw [occupied_symm w s,occupied_symm n e]
case westNorth => ring
case southEast => ring
case westEast => rw [occupied_symm w e]; ring
case northSouth => rw [occupied_symm n s]; ring
lemmachosen_eq_allGrid {WH : ℕ} (cfg : CellWH→Shape) (west east : ColumnH) (south north : ColumnW) :
chosenPartition cfg west east south north=allChosenGrid cfg west east south north :=by
proof · 16
lines
classical
rw [chosenPartition_eq_grid_sum]
unfold allChosenGrid
trans ∑σ : GridWireWH→Fin3,ifHasWestNorth west north σ then
(if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i)
then (network WH).orientation cfg σ else0) else0
· convert (sum_subtype_indicator (HasWestNorth west north) (fun σ=>if (∀ j,σ (.inl (Fin.last W,j))=east j) ∧ (∀ i,σ (.inr (i,0))=south i)
then (network WH).orientation cfg σ else0)).symm using1
congr 1
ext x
simp
apply Finset.sum_congr rfl
intro σ hσ
simp only [HasWestNorth,ite_and]
split_ifs <;> simp_all
lemmachosen_transpose {WH : ℕ} (cfg : CellWH→Shape) (west east : ColumnH) (south north : ColumnW) :
chosenPartition cfg west east south north=
chosenPartition (transposeConfiguration cfg) south north west east :=by
lemmaweighted_chosen_transpose {WH : ℕ} (cfg : CellWH→Shape)
(west east : ColumnH) (south north : ColumnW) :
(kappa:ℂ)^(∑ t,(cfg t).visits)*chosenPartition cfg west east south north=
(kappa:ℂ)^(∑ t,(transposeConfiguration cfg t).visits)*
chosenPartition (transposeConfiguration cfg) south north west east :=by