import Mathlib import OAI.Probability.CoordinateSweeps.Conditioning import OAI.Probability.CoordinateSweeps.SparseBound namespace OAI /-! Work on the genuinely missing main statements of the pinned manuscript. All definitions are finite and use the source's ordinary probability and trace normalizations. No result of the manuscript is assumed. -/ noncomputable section open scoped BigOperators Matrix.Norms.L2Operator ComplexOrder attribute [local instance] Classical.propDecidable namespace CoordinateSweeps.Grid /- Any cut retains exactly the ordered bit list; no coordinate permutation is introduced into the sweep law. -/ lemma exists_concat_of_length (G : Grid) (n m : ℕ) (hn : 0 < n) (hm : 0 < m) (hb : G.b=n+m) : ∃ A B : Grid, A.b=n ∧ B.b=m ∧ concat A B=G := by rcases G with ⟨b,hpos,bits⟩ dsimp only at hb subst b let A : Grid := ⟨n,hn,fun i => bits (Fin.castAdd m i)⟩ let B : Grid := ⟨m,hm,fun i => bits (Fin.natAdd n i)⟩ refine ⟨A,B,rfl,rfl,?_⟩ have he : Fin.addCases A.bits B.bits=bits := by funext i induction i using Fin.addCases with | left i => simp [A] | right i => simp [B] change Grid.mk (n+m) _ (Fin.addCases A.bits B.bits)=Grid.mk (n+m) _ bits rw [he] /- Cutting the coordinate list in half is balanced because every bit count is between r and 2r. This avoids choosing a cut by logarithmic rounding. -/ lemma exists_half_concat (G : Grid) (hb : 2 ≤ G.b) : ∃ A B : Grid, concat A B=G ∧ A.b nlinarith lemma balanced_sizes {A B : Grid} {r : ℕ} (hA : A.Allowed r) (hB : B.Allowed r) (hAB : A.b≤B.b) (hBA : B.b≤2*A.b) : ((concat A B).size : ℝ)^((1:ℝ)/5) ≤ A.size ∧ (A.size : ℝ) ≤ ((concat A B).size : ℝ)^((4:ℝ)/5) ∧ ((concat A B).size : ℝ)^((1:ℝ)/5) ≤ B.size ∧ (B.size : ℝ) ≤ ((concat A B).size : ℝ)^((4:ℝ)/5) := by have hh := balanced_logs hA hB hAB hBA have hs : (0:ℝ)<(concat A B).size := Nat.cast_pos.mpr (concat A B).size_pos have ha : (0:ℝ) linarith lemma hook_strengthening {L : ℝ} (hL : 0