| 0, _, _, _, _ =>0
| d+1, ι, _, e, ω =>if d+1≤Hthen crowdedMass (Fintype.card ι) elselet σ := benesStepEquiv d ω
let x := e.trans (headTailEquiv d).toEmbedding
let c :=PairRouting.colors x σ.2.1let hc :=PairRouting.colors_compatible x σ.2.1
cutoffMass H d (PairRouting.childEmbedding x c hc false) σ.1.1 +
cutoffMass H d (PairRouting.childEmbedding x c hc true) σ.1.2
lemmapalindromeLowCost_eq (Hd : ℕ) (h : d ≤H) {ι : Type*} [Fintype ι]
(e : ι ↪ Card d) (ω : BenesCoins d) :
palindromeLowCost H d e ω = palindromeCost d e ω :=by
proof · 6
lines
classical
induction d generalizing ι with
| zero => rfl
| succ d ih =>
rw [palindromeLowCost,palindromeCost,ite_eq_left h]
congr 2 <;> exact ih (by omega) _ _
lemmapalindromeLowCost_le_cutoff (Hd : ℕ) {ι : Type*} [Fintype ι]
(e : ι ↪ Card d) (ω : BenesCoins d) :
palindromeLowCost H d e ω ≤H*cutoffMass H d e ω :=by
proof · 9
lines
classical
induction d generalizing ι with
| zero => simp [palindromeLowCost,cutoffMass]
| succ d ih =>by_cases h : d+1≤H
· rw [palindromeLowCost_eq H (d+1) h,cutoffMass,ite_eq_left h]
exact (palindromeCost_le_crowded (d+1) e ω).trans (Nat.mul_le_mul_right _ h)
· rw [palindromeLowCost,cutoffMass,ite_eq_right h,ite_eq_right h,zero_add,Nat.mul_add]
exact Nat.add_le_add (ih _ _) (ih _ _)
lemmamem_centralBlock (r H : ℕ) (b : Card r) (x : Card (H+r)) :
x ∈ centralBlock r H b ↔ (cardSplit r H x).1 = b :=by
proof · 9
lines
classical
constructor
· intro h
obtain ⟨z,_,rfl⟩ :=Finset.mem_image.mp h
simp only [Equiv.apply_symm_apply]
· intro h
apply Finset.mem_image.mpr
refine ⟨(cardSplit r H x).2,Finset.mem_univ _,?_⟩
rw [←h,Prod.mk.eta,Equiv.symm_apply_apply]
lemmacentralBlock_card (r H : ℕ) (b : Card r) : (centralBlock r H b).card = 2^H:=by
proof · 5
lines
classical
rw [centralBlock,Finset.card_image_of_injective]
· exact card_positions H
· intro x y h
exact congrArg Prod.snd ((cardSplit r H).symm.injective h)
lemmacentralBlock_disjoint (r H : ℕ) :
Pairwise (fun b b' =>Disjoint (centralBlock r H b) (centralBlock r H b')) :=by
proof · 6
lines
classical
intro b b' h
apply Finset.disjoint_left.mpr
intro x hx hy
exact h (((mem_centralBlock r H b x).mp hx).symm.trans
((mem_centralBlock r H b' x).mp hy))
lemmablock_inter_step (r H : ℕ) (b : Bool) (c : Card r) (A : Finset (Card (H+(r+1)))) :
centralBlock (r+1) H (Fin.cons b c) ∩A =
(centralBlock r H c ∩ childMarks A b).image (Fin.cons b) :=by
proof · 12
lines
classical
rw [centralBlock_step]
ext x
constructor
· intro hx
obtain ⟨hxB,hxA⟩ :=Finset.mem_inter.mp hx
obtain ⟨y,hy,rfl⟩ :=Finset.mem_image.mp hxB
exact Finset.mem_image.mpr ⟨y,Finset.mem_inter.mpr ⟨hy,(mem_childMarks A b y).mpr hxA⟩,rfl⟩
· intro hx
obtain ⟨y,hy,rfl⟩ :=Finset.mem_image.mp hx
exact Finset.mem_inter.mpr ⟨Finset.mem_image.mpr ⟨y,(Finset.mem_inter.mp hy).1,rfl⟩,
(mem_childMarks A b y).mp (Finset.mem_inter.mp hy).2⟩
lemmasparseMass_central_step (r H : ℕ) (A : Finset (Card (H+(r+1)))) :
sparseMass (centralBlock (r+1) H) A =
sparseMass (centralBlock r H) (childMarks Afalse) +
sparseMass (centralBlock r H) (childMarks Atrue) :=by
proof · 14
lines
classical
unfold sparseMass
rw [←Equiv.sum_comp (headTailEquiv r).symm,Fintype.sum_prod_type]
have ht (b : Bool) (c : Card r) : (headTailEquiv r).symm (b,c) = Fin.cons b c := rfl
simp only [Fintype.sum_bool,ht]
have hc (b : Bool) (c : Card r) :
(centralBlock (r+1) H (Fin.cons b c) ∩A).card =
(centralBlock r H c ∩ childMarks A b).card :=by
rw [block_inter_step]
apply Finset.card_image_of_injective
intro x y h
simpa only [Fin.tail_cons] using congrArg Fin.tail h
simp only [hc]
exact add_comm _ _
lemmainverseButterflyMarks_child (d : ℕ) {ι : Type*} [Fintype ι]
(e : ι ↪ Card (d+1))
(c : (SwitchIndex d →Bool) × (SwitchIndex d →Bool)) (ξ : Card d →Bool) (b : Bool) :
childMarks (inverseButterflyMarks (d+1) (Finset.univ.image e)
((coinStepEquiv d).symm (c,ξ))) b =
inverseButterflyMarks d
(Finset.univ.image (PairRouting.childEmbedding (e.trans (headTailEquiv d).toEmbedding)
(PairRouting.colors (e.trans (headTailEquiv d).toEmbedding) ξ)
(PairRouting.colors_compatible _ _) b)) (if b then c.2else c.1) :=by
proof · 30
lines
classical
let x := e.trans (headTailEquiv d).toEmbedding
let col :=PairRouting.colors x ξ
let child :=PairRouting.childEmbedding x col (PairRouting.colors_compatible x ξ) b
have hp (i : ι) : headTailEquiv d ((butterflyPerm (d+1)
(decodeButterfly (d+1) ((coinStepEquiv d).symm (c,ξ)))).symm (e i)) =
(col i,(butterflyPerm d (decodeButterfly d (if col i then c.2else c.1))).symm (x i).2) :=
inverseButterfly_coordinates_step d c ξ (e i)
ext y
simp only [mem_childMarks,inverseButterflyMarks,Finset.image_image,
Finset.mem_image,Finset.mem_univ,true_and,Function.comp_def]
constructor
· rintro ⟨i,hi⟩
have he := congrArg (headTailEquiv d) hi
rw [hp i] at he
change (col i,_) = (b,y) at he
have hb := congrArg Prod.fst he
have hy := congrArg Prod.snd he
dsimp only at hb hy
refine ⟨⟨i,hb⟩,?_⟩
change (butterflyPerm d (decodeButterfly d (if b then c.2else c.1))).symm (x i).2 = y
simpa only [hb] using hy
· rintro ⟨i,hi⟩
refine ⟨i.val,?_⟩
apply (headTailEquiv d).injective
rw [hp]
change (col i.val,_) = (b,y)
havehb : col i.val = b := i.property
rw [hb]
exact Prod.ext rfl hi
lemmacutoffMass_central (r H : ℕ) {ι : Type*} [Fintype ι]
(e : ι ↪ Card (H+r)) (ω : BenesCoins (H+r)) :
cutoffMass H (H+r) e ω =
sparseMass (centralBlock r H) (inverseButterflyMarks (H+r) (Finset.univ.image e) ω.2) :=by
proof · 24
lines
classical
induction r generalizing ι with
| zero =>
rw [sparseMass_central_zero,inverseButterflyMarks_card,
Finset.card_image_of_injective _ e.injective,Finset.card_univ]
cases Hwith
| zero =>havehcard : Fintype.card ι ≤1:=byhave hh :=Fintype.card_le_of_injective e e.injective
simpa only [Nat.add_zero,card_positions,pow_zero] using hh
simp [cutoffMass,crowdedMass,show¬2≤Fintype.card ι by omega]
| succ H=> simp only [cutoffMass,le_refl,ite_true]
| succ r ih =>
simp only [Nat.add_succ] at *
rw [cutoffMass,ite_eq_right (byomega : ¬H+r+1≤H)]
let σ := benesStepEquiv (H+r) ω
let x := e.trans (headTailEquiv (H+r)).toEmbedding
let col :=PairRouting.colors x σ.2.1let hc :=PairRouting.colors_compatible x σ.2.1
change cutoffMass H (H+r) (PairRouting.childEmbedding x col hc false) σ.1.1 +
cutoffMass H (H+r) (PairRouting.childEmbedding x col hc true) σ.1.2 = _
rw [ih,ih,sparseMass_central_step,benes_input_coordinates (H+r) ω]
rw [inverseButterflyMarks_child,inverseButterflyMarks_child]
rfl
(((Equiv.prodAssoc _ _ _).trans (Equiv.prodCongr (Equiv.refl B)
(Equiv.prodComm _ _))).trans (Equiv.prodCongr (Equiv.refl B) (cardSplit r s).symm)).trans post
lemmaparallel_exposed_perm (pre : α ≃ B×Card (s+r)) (post : B×Card (s+r) ≃ α)
(lo : B→Card r ×SwitchIndex s →Bool)
(hi : (B×Card s) ×SwitchIndex r →Bool) :
relabeledPerm pre post (parallelAssembled lo hi) =
relabeledPerm (parallelFreshPre pre lo) (parallelFreshPost post) hi :=by
proof · 8
lines
ext x
have h := butterfly_split r s (lo (pre x).1)
(fun j => hi (((pre x).1,j.1),j.2)) (pre x).2have hh := congrArg (fun y => post ((pre x).1,(cardSplit r s).symm y)) h
simpa only [relabeledPerm,parallelAssembled,parallelPerm,parallelFreshPre,parallelFreshPost,
Equiv.trans_apply,Equiv.prodCongr_apply,Equiv.prodCongrRight,Equiv.coe_fn_mk,
Equiv.refl_apply,Equiv.prodComm_apply,Prod.swap,Equiv.prodAssoc_apply,
Equiv.prodAssoc_symm_apply,Prod.map,Equiv.symm_apply_apply] using hh
lemmaorbitSet_conjugate (p g : Equiv.Perm α) (x : α) :
orbitSet (g*p*g⁻¹) (g x) = (orbitSet p x).image g :=by
proof · 10
lines
ext y
simp only [mem_orbitSet,Finset.mem_image]
rw [Equiv.Perm.sameCycle_conj]
change p.SameCycle (g.symm (g x)) (g.symm y) ↔∃ z, p.SameCycle x z ∧ g z = y
rw [Equiv.symm_apply_apply]
constructor
· intro h
exact ⟨g.symm y,h,g.apply_symm_apply y⟩
· rintro ⟨z,hz,rfl⟩
simpa only [Equiv.symm_apply_apply] using hz
lemmaselectedCycle_conjugate (p g : Equiv.Perm α) (S : Finset α) :
Fintype.card (RoutingNetwork.SelectedCycle (g*p*g⁻¹) (S.image g)) =
Fintype.card (RoutingNetwork.SelectedCycle p S) :=by
proof · 18
lines
apply Nat.le_antisymm
· have h :=Fintype.card_le_of_injective _
(conjugateCycle_injective (g*p*g⁻¹) g⁻¹ (S.image g))
havehp : g⁻¹*(g*p*g⁻¹)*g = p :=by group
rw [inv_inv,hp] at h
havehs : (S.image g).image g.symm = S:=by
ext x
simp only [Finset.mem_image]
constructor
· rintro ⟨y,⟨z,hz,rfl⟩,he⟩
havehz' : z = x :=by simpa only [Equiv.symm_apply_apply] using he
exact hz' ▸ hz
· intro hx
exact ⟨g x,⟨x,hx,rfl⟩,g.symm_apply_apply x⟩
change _ ≤Fintype.card (RoutingNetwork.SelectedCycle p ((S.image g).image g.symm)) at h
rw [hs] at h
exact h
· exact Fintype.card_le_of_injective _ (conjugateCycle_injective p g S)
lemmaalternatingCycles_le_projection {ι : Type*} [Fintype ι]
(e : ι ↪ Bool× α) (p : Bool→Equiv.Perm α) :
PairRouting.alternatingCycles e p ≤Fintype.card (RoutingNetwork.SelectedCycle (PairRouting.alternatingProjection p)
(boolFiber (PairRouting.labelSet e) false)) :=by
proof · 3
lines
have h :=CycleColoring.card_alternating_cycles_le (PairRouting.alternatingProjection p)
(boolFiber (PairRouting.labelSet e) false) (boolFiber (PairRouting.labelSet e) true)
simpa only [PairRouting.alternatingCycles,childJoin_boolFiber] using h
have h := card_childJoin (boolFiber (PairRouting.labelSet e) false)
(boolFiber (PairRouting.labelSet e) true)
rw [childJoin_boolFiber,PairRouting.card_labelSet] at h
omega
defhighStepEquiv (r s : ℕ) : (Card s ×SwitchIndex (r+1) →Bool) ≃
(((Card s ×SwitchIndex r →Bool) × (Card s ×SwitchIndex r →Bool)) ×
(Card s ×Card r →Bool)) where
body · 13
lines
toFun hi := ((fun j => hi (j.1,Sum.inr (false,j.2)),
fun j => hi (j.1,Sum.inr (true,j.2))),fun j => hi (j.1,Sum.inl j.2))
invFun c :=fun j =>match j.2with
| Sum.inl y => c.2 (j.1,y)
| Sum.inr (b,i) =>if b then c.1.2 (j.1,i) else c.1.1 (j.1,i)
left_inv hi :=by
funext j
rcases j with ⟨z,y|⟨b,i⟩⟩
· rfl
· cases b <;> rfl
right_inv c :=by
rcases c with ⟨⟨h₀,h₁⟩,η⟩
rfl
lemmaassembleBits_step (r s : ℕ) (lo : Card (r+1) ×SwitchIndex s →Bool)
(c : ((Card s ×SwitchIndex r →Bool) × (Card s ×SwitchIndex r →Bool)) ×
(Card s ×Card r →Bool)) :
assembleBits (r+1) s lo ((highStepEquiv r s).symm c) =
(coinStepEquiv (s+r)).symm
((assembleBits r s (fun j => lo (Fin.cons false j.1,j.2)) c.1.1,
assembleBits r s (fun j => lo (Fin.cons true j.1,j.2)) c.1.2),
fun y => c.2 ((cardSplit r s y).2,(cardSplit r s y).1)) :=by
proof · 4
lines
funext i
rcases i with y | ⟨b,i⟩
· rfl
· cases b <;> rfl
| 0, _, _, _, _ =>0
| d+1, _, _, e, ω =>let σ := benesStepEquiv d ω
let x := e.trans (headTailEquiv d).toEmbedding
let c :=PairRouting.colors x σ.2.1let hc :=PairRouting.colors_compatible x σ.2.1if t = d+1thenPairRouting.alternatingCycles (PairRouting.switchedEmbedding x σ.2.1)
(fun b => palindromePerm d (if b then σ.1.2else σ.1.1)) else
palindromeLevelCost t d (PairRouting.childEmbedding x c hc false) σ.1.1 +
palindromeLevelCost t d (PairRouting.childEmbedding x c hc true) σ.1.2
lemmapalindromeLevelCost_step (t d : ℕ) {ι : Type*} [Fintype ι]
(e : ι ↪ Card (d+1)) (XY : (SwitchIndex d →Bool) × (SwitchIndex d →Bool))
(ξ η : Card d →Bool) :
palindromeLevelCost t (d+1) e
((coinStepEquiv d).symm (Y,η),(coinStepEquiv d).symm (X,ξ)) =
let x := e.trans (headTailEquiv d).toEmbedding
proof · 8
lines
let c :=PairRouting.colors x ξ
let hc :=PairRouting.colors_compatible x ξ
if t = d+1thenPairRouting.alternatingCycles (PairRouting.switchedEmbedding x ξ)
(fun b => palindromePerm d (if b then (Y.2,X.2) else (Y.1,X.1))) else
palindromeLevelCost t d (PairRouting.childEmbedding x c hc false) (Y.1,X.1) +
palindromeLevelCost t d (PairRouting.childEmbedding x c hc true) (Y.2,X.2) :=by
rw [palindromeLevelCost]
rfl
lemmapalindromeLevelCost_gt (t d : ℕ) (h : d < t) {ι : Type*} [Fintype ι]
(e : ι ↪ Card d) (ω : BenesCoins d) : palindromeLevelCost t d e ω = 0:=by
proof · 5
lines
classical
induction d generalizing ι with
| zero => rfl
| succ d ih =>
rw [palindromeLevelCost,ite_eq_right (byomega : t ≠ d+1),ih (by omega),ih (by omega),Nat.zero_add]
theorempalindrome_level_partial_mgf (r s u : ℕ) (hu : u < r)
{ι : Type*} [Fintype ι] (e : ι ↪ Card (s+r)) (X : SwitchIndex (s+r) →Bool)
(lo : Card r ×SwitchIndex s →Bool) (J : ℕ) (hJ : 0 < J) (q : ℝ) (hq : 1≤ q) :
finiteMean (funhi : Card s ×SwitchIndex r →Bool=>
q^(palindromeLevelCost (s+u+1) (s+r) e (assembleBits r s lo hi,X))) ≤Real.exp (Fintype.card ι * cycleCoefficient u J q) :=by
proof · 69
lines
classical
induction r generalizing u ι with
| zero => omega
| succ r ih =>
simp only [Nat.add_succ] at *
let χ := coinStepEquiv (s+r) Xlet x := e.trans (headTailEquiv (s+r)).toEmbedding
let c :=PairRouting.colors x χ.2let hc :=PairRouting.colors_compatible x χ.2let e₀ :=PairRouting.childEmbedding x c hc falselet e₁ :=PairRouting.childEmbedding x c hc truelet e' :=PairRouting.switchedEmbedding x χ.2letlo₀ : Card r ×SwitchIndex s →Bool:=fun j => lo (Fin.cons false j.1,j.2)
letlo₁ : Card r ×SwitchIndex s →Bool:=fun j => lo (Fin.cons true j.1,j.2)
letY₀:=funhi : Card s ×SwitchIndex r →Bool=> assembleBits r s lo₀ hi
letY₁:=funhi : Card s ×SwitchIndex r →Bool=> assembleBits r s lo₁ hi
letN:=funhi : (Card s ×SwitchIndex r →Bool) × (Card s ×SwitchIndex r →Bool) =>PairRouting.alternatingCycles e' (fun b =>if b then palindromePerm (s+r) (Y₁ hi.2,χ.1.2)
else palindromePerm (s+r) (Y₀ hi.1,χ.1.1))
letL₀:=funhi : Card s ×SwitchIndex r →Bool=>
palindromeLevelCost (s+u+1) (s+r) e₀ (Y₀ hi,χ.1.1)
letL₁:=funhi : Card s ×SwitchIndex r →Bool=>
palindromeLevelCost (s+u+1) (s+r) e₁ (Y₁ hi,χ.1.2)
have hs (hi : (Card s ×SwitchIndex r →Bool) × (Card s ×SwitchIndex r →Bool))
(η : Card s ×Card r →Bool) :
palindromeLevelCost (s+u+1) (s+r+1) e
(assembleBits (r+1) s lo ((highStepEquiv r s).symm (hi,η)),X) =
if u = r thenN hi elseL₀ hi.1 + L₁ hi.2:=by
rw [assembleBits_step]
conv_lhs => rw [←(coinStepEquiv (s+r)).symm_apply_apply X]
rw [palindromeLevelCost_step]
simp only [Nat.add_right_cancel_iff,Nat.add_left_cancel_iff]
dsimp only [χ,x,c,hc,e₀,e₁,e',lo₀,lo₁,Y₀,Y₁,N,L₀,L₁]
congr 2
funext b
cases b <;> rfl
rw [finiteMean_equiv (highStepEquiv r s),finiteMean_prod]
simp_rw [hs,finiteMean_const]
by_cases hur : u = r
· subst u
simp only [ite_true]
rw [finiteMean_prod,finiteMean_comm]
calc
_ ≤ finiteMean (fun_hi : Card s ×SwitchIndex r →Bool=>Real.exp (Fintype.card ι * cycleCoefficient r J q)) :=by
apply finiteMean_mono
intro hi
have hn := node_partial_mgf r s e'
(butterflyPerm (s+r) (decodeButterfly (s+r) χ.1.1))
(butterflyPerm (s+r) (decodeButterfly (s+r) χ.1.2))
(butterflyPerm (s+r) (decodeButterfly (s+r) (Y₁ hi))) lo₀ J hJ q hq
exact hn
_ = _ := finiteMean_const _
· simp only [ite_eq_right hur,pow_add]
rw [finiteMean_prod_mul (fun hi => q ^ L₀ hi) (fun hi => q ^ L₁ hi)]
havehu' : u < r :=by omega
have h₀ := ih u hu' e₀ χ.1.1 lo₀
have h₁ := ih u hu' e₁ χ.1.2 lo₁
have hp := mul_le_mul h₀ h₁ (finiteMean_nonneg (fun _ => pow_nonneg (by linarith) _))
(Real.exp_nonneg _)
refine hp.trans_eq ?_
rw [←Real.exp_add]
congr 1have hcount :=PairRouting.color_card_add c
havehcount' : (Fintype.card {i : ι // c i = false} : ℝ) +
Fintype.card {i : ι // c i = true} = Fintype.card ι :=by exact_mod_cast hcount
change (Fintype.card {i : ι // c i = false} : ℝ) * cycleCoefficient u J q +
Fintype.card {i : ι // c i = true} * cycleCoefficient u J q = _
rw [←add_mul,hcount']
lemmalayerAdapted_sum {d s : ℕ} {ι : Type*} (A : Finset ι)
(f : ι → (SwitchIndex d →Bool) →ℕ)
(hf : ∀ i ∈A, LayerAdapted d s (f i)) :
LayerAdapted d s (funY=>∑ i ∈A, f i Y) :=by
proof · 2
lines
intro YY' h
exact Finset.sum_congr rfl (fun i hi => hf i hi YY' h)
lemmaassembleBits_agree (r s : ℕ) (lo : Card r ×SwitchIndex s →Bool)
(hi hi' : Card s ×SwitchIndex r →Bool) :
AgreeThrough (s+r) s (assembleBits r s lo hi) (assembleBits r s lo hi') :=by
proof · 9
lines
induction r with
| zero => intro i _; rfl
| succ r ih =>
intro i h
rcases i with y | ⟨b,i⟩
· have : s+r+1≤ s := h
omega
· exact ih (fun j => lo (Fin.cons b j.1,j.2))
(fun j => hi (j.1,Sum.inr (b,j.2))) (fun j => hi' (j.1,Sum.inr (b,j.2))) i h
lemmapalindromeLevelCost_adapted (t d : ℕ) {ι : Type*} [Fintype ι]
(e : ι ↪ Card d) (X : SwitchIndex d →Bool) :
LayerAdapted d (t-1) (funY=> palindromeLevelCost t d e (Y,X)) :=by
proof · 27
lines
classical
induction d generalizing ι with
| zero => intro YY' _; rfl
| succ d ih =>
intro YY' h
change palindromeLevelCost t (d+1) e (Y,X) = palindromeLevelCost t (d+1) e (Y',X)
conv_lhs => rw [←(coinStepEquiv d).symm_apply_apply Y,←(coinStepEquiv d).symm_apply_apply X]
conv_rhs => rw [←(coinStepEquiv d).symm_apply_apply Y',←(coinStepEquiv d).symm_apply_apply X]
rw [palindromeLevelCost_step,palindromeLevelCost_step]
by_cases ht : t = d+1
· subst t
rw [ite_eq_left rfl,ite_eq_left rfl]
havehe₀ : (coinStepEquiv d Y).1.1 = (coinStepEquiv d Y').1.1:=by
funext i
exact h (Sum.inr (false,i)) (by simpa only [switchHeight,Nat.add_sub_cancel] using switchHeight_le d i)
havehe₁ : (coinStepEquiv d Y).1.2 = (coinStepEquiv d Y').1.2:=by
funext i
exact h (Sum.inr (true,i)) (by simpa only [switchHeight,Nat.add_sub_cancel] using switchHeight_le d i)
rw [he₀,he₁]
· rw [ite_eq_right ht,ite_eq_right ht]
congr 1
· apply ih
intro i hi
exact h (Sum.inr (false,i)) hi
· apply ih
intro i hi
exact h (Sum.inr (true,i)) hi
lemmaadapted_mul_mean_le (r s : ℕ) (FG : (SwitchIndex (s+r) →Bool) →ℝ)
(hF : ∀Y, 0≤FY) (hA : LayerAdapted (s+r) s F) (B : ℝ)
(hG : ∀lo : Card r ×SwitchIndex s →Bool,
finiteMean (funhi : Card s ×SwitchIndex r →Bool=>G (assembleBits r s lo hi)) ≤B) :
finiteMean (funY=>FY*GY) ≤ finiteMean F * B:=by
proof · 12
lines
rw [finiteMean_split r s,finiteMean_split r s F,←finiteMean_mul_const]
apply finiteMean_mono
intro lo
letH : Card s ×SwitchIndex r →Bool:=fun _ =>falsehave hh (hi : Card s ×SwitchIndex r →Bool) :
F (assembleBits r s lo hi) = F (assembleBits r s lo H) :=
hA _ _ (assembleBits_agree r s lo hi H)
simp_rw [hh,finiteMean_const]
rw [show (fun hi =>F (assembleBits r s lo H) * G (assembleBits r s lo hi)) =
(fun hi =>G (assembleBits r s lo hi) * F (assembleBits r s lo H)) by
funext hi; exact mul_comm _ _,finiteMean_mul_const]
simpa only [mul_comm] using mul_le_mul_of_nonneg_left (hG lo) (hF _)
have h :=Nat.le_ceil (Real.exp ((l:ℝ)/32))
have he :=Real.exp_pos ((l:ℝ)/32)
have : (0:ℝ) < ⌈Real.exp ((l:ℝ)/32)⌉₊ := lt_of_lt_of_le he h
exact_mod_cast this
lemmapow_sum_le_mean_powers {ι : Type*} [Fintype ι] [Nonempty ι]
(z : ι →ℕ) (q : ℝ) (hq : 0 < q) :
q^(∑ i, z i) ≤ finiteMean (fun i => q^(Fintype.card ι*z i)) :=by
proof · 8
lines
havehn : (Fintype.card ι:ℝ) ≠0:=Nat.cast_ne_zero.mpr Fintype.card_ne_zero
havehm : finiteMean (fun i => (Fintype.card ι*z i:ℕ)*Real.log q) =
(∑ i, z i:ℕ)*Real.log q :=by
simp only [finiteMean,Nat.cast_mul,Nat.cast_sum,←Finset.mul_sum,←Finset.sum_mul]
field_simp
have he := exp_finiteMean_le (fun i => (Fintype.card ι*z i:ℕ)*Real.log q)
rw [hm,Real.exp_nat_mul,Real.exp_log hq] at he
simpa only [Real.exp_nat_mul,Real.exp_log hq] using he
lemmapalindromeSlabCost_adapted (l d : ℕ) {ι : Type*} [Fintype ι]
(e : ι ↪ Card d) (X : SwitchIndex d →Bool) :
LayerAdapted d (2*l) (funY=> palindromeSlabCost l d e (Y,X)) :=by
proof · 3
lines
apply layerAdapted_sum
intro i _
exact layerAdapted_mono (palindromeLevelCost_adapted (l+i.1+1) d e X) (by omega)
theorempalindrome_slab_partial_mgf (r s l : ℕ) (hl : 0 < l) (hs : 2*s ≤ l)
{ι : Type*} [Fintype ι] (e : ι ↪ Card (s+r)) (X : SwitchIndex (s+r) →Bool)
(lo : Card r ×SwitchIndex s →Bool) (q : ℝ) (hq : 1≤ q)
(hlog : Real.log q ≤1/250) :
finiteMean (funhi : Card s ×SwitchIndex r →Bool=>
q^(palindromeSlabCost l (s+r) e (assembleBits r s lo hi,X))) ≤Real.exp (Fintype.card ι * (68*Real.exp (-(l:ℝ)/64))) :=by
proof · 37
lines
classical
let : NeZero l := ⟨ne_of_gt hl⟩
havehqp : 0 < q := lt_of_lt_of_le (by norm_num) hq
calc
_ ≤ finiteMean (funhi : Card s ×SwitchIndex r →Bool=>
finiteMean (funi : Fin l => q^(l*palindromeLevelCost (l+i.1+1) (s+r) e
(assembleBits r s lo hi,X)))) :=by
apply finiteMean_mono
intro hi
simpa only [palindromeSlabCost,Fintype.card_fin] using
pow_sum_le_mean_powers (funi : Fin l => palindromeLevelCost (l+i.1+1) (s+r) e
(assembleBits r s lo hi,X)) q hqp
_ = finiteMean (funi : Fin l => finiteMean (funhi : Card s ×SwitchIndex r →Bool=>
q^(l*palindromeLevelCost (l+i.1+1) (s+r) e (assembleBits r s lo hi,X)))) := finiteMean_comm _
_ ≤ finiteMean (fun_i : Fin l =>Real.exp (Fintype.card ι * (68*Real.exp (-(l:ℝ)/64)))) :=by
apply finiteMean_mono
intro i
by_cases ht : l+i.1+1≤ s+r
· havehs' : s ≤ l+i.1:=by omega
havehe : l+i.1+1 = s+(l+i.1-s)+1:=by omega
havehu : l+i.1-s < r :=by omega
have hm := palindrome_level_partial_mgf r s (l+i.1-s) hu e X lo
⌈Real.exp ((l:ℝ)/32)⌉₊ (cycleCutoff_pos l) (q^l) (one_le_pow₀ hq)
have hc := cycleCoefficient_decay l (l+i.1-s) (by
rw [Nat.cast_sub hs',Nat.cast_add]
havehsr : (2:ℝ)*s ≤ l :=by exact_mod_cast hs
havehi : (0:ℝ) ≤ i.1:=Nat.cast_nonneg _
linarith) (q^l) (one_le_pow₀ hq) (by
rw [Real.log_pow]
nlinarith [mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg l)])
simp_rw [he,pow_mul]
exact hm.trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left hc (Nat.cast_nonneg _)))
· have hz := palindromeLevelCost_gt (l+i.1+1) (s+r) (by omega) e
simp only [hz,Nat.mul_zero,pow_zero,finiteMean_const]
exact Real.one_le_exp_iff.mpr (by positivity)
_ = _ := finiteMean_const _