import OAI.Computability.FourierCircuit.SymmetricLaplacian namespace OAI section namespace ExactFourier open scoped BigOperators variable {α : Type} [Fintype α] [DecidableEq α] noncomputable def diagonalBlocks {t : ℕ} (A : Fin t → Matrix α α ℂ) : Matrix (Fin t × α) (Fin t × α) ℂ := fun i j => if i.1=j.1 then A i.1 i.2 j.2 else 0 namespace MatrixPrice theorem diagonal_blocks (p : MatrixPrice) (t : ℕ) (A : Fin t → Matrix α α ℂ) (hA : ∀ i, IsUnit (A i)) : IsUnit (diagonalBlocks A) ∧ p.value (diagonalBlocks A)=∑ i, p.value (A i) := by have hu := (p.blocks_lower t (diagonalBlocks A) A hA (by intros; simp [diagonalBlocks]) (by intro i j a b hij; simp [diagonalBlocks,ne_of_lt hij])).1 refine ⟨hu,?_⟩ induction t with | zero => have he : diagonalBlocks A=1 := by ext i j; exact Fin.elim0 i.1 rw [he,p.one]; simp | succ t ih => have hD : IsUnit (diagonalBlocks (fun i : Fin t => A i.succ)) := (p.blocks_lower t _ _ (fun i => hA i.succ) (by intros; simp [diagonalBlocks]) (by intro i j a b hij; simp [diagonalBlocks,ne_of_lt hij])).1 have he : Matrix.reindex (timeSplit t α) (timeSplit t α) (diagonalBlocks A)= Matrix.fromBlocks (A 0) 0 0 (diagonalBlocks (fun i : Fin t => A i.succ)) := by ext i j rcases i with a|⟨i,a⟩ <;> rcases j with b|⟨j,b⟩ <;> simp [Matrix.reindex_apply,Matrix.submatrix_apply,timeSplit,diagonalBlocks, Ne.symm (Fin.succ_ne_zero _)] rw [← p.reindex (timeSplit t α) _ hu,he,p.directSum _ _ (hA 0) hD, ih _ (fun i => hA i.succ) hD,Fin.sum_univ_succ] end MatrixPrice end ExactFourier end section namespace ExactFourier.RootEvaluation open Polynomial open scoped BigOperators Kronecker noncomputable def fourier (t : ℕ) (ω : ℂ) : Matrix (Fin t) (Fin t) ℂ := fun i j => ω^(i.val*j.val) @[simp] theorem fourier_mulVec (t : ℕ) (ω : ℂ) (x : Fin t → ℂ) : (fourier t ω).mulVec x=RadixTwo.eval t ω x := rfl theorem fourier_unit (t : ℕ) (ht : 0 (a*ω^i.val)^j.val theorem matrix_eq (t : ℕ) (ω a : ℂ) : matrix t ω a=fourier t ω*Matrix.diagonal (fun j : Fin t => a^j.val) := by ext i j simp [matrix,fourier,Matrix.mul_diagonal,mul_pow,pow_mul,mul_comm] theorem matrix_unit (t : ℕ) (ht : 0 isUnit_iff_ne_zero.mpr (pow_ne_zero _ ha)))) theorem matrix_price (p : MatrixPrice) (j : ℕ) (ω a : ℂ) (hω : IsPrimitiveRoot ω (2^j)) (ha : a≠0) : p.value (matrix (2^j) ω a)≤(26/Real.log 2)*(2^j:ℝ)*Real.log (2*2^j) := by rw [matrix_eq,← one_mul (fourier (2^j) ω),p.monomial _ _ _ (fourier_unit _ (by positivity) ω hω) MonomialMatrix.one (MonomialMatrix.diagonal _ (fun i => pow_ne_zero _ ha))] exact fourier_price p j ω hω end ExactFourier.RootEvaluation end section namespace ExactFourier.RootEvaluation open Polynomial open scoped Kronecker BigOperators theorem coefficient_sum (t : ℕ) (ω a : ℂ) (f : Polynomial ℂ) (hf : f.natDegree rw [f.as_sum_range_C_mul_X_pow' hf] simp only [eval_finsetSum,eval_mul,eval_C,eval_pow,eval_X] rw [← Fin.sum_univ_eq_sum_range] apply Finset.sum_congr rfl intro j _ simp only [matrix,mul_comm] theorem eval_remainder (ℓ f : Polynomial ℂ) (s : ℂ) (hs : ℓ.eval s=0) : (f%ₘℓ).eval s=f.eval s := by rw [modByMonic_eq_sub_mul_div,eval_sub,eval_mul,hs,zero_mul,sub_zero] variable {α : Type} [Fintype α] [DecidableEq α] theorem intertwine (t : ℕ) (ht : 0 G.map (eval (a*ω^i.val)))* (matrix t ω a ⊗ₖ (1 : Matrix α α ℂ)) := by ext ⟨ai,aj⟩ ⟨bi,bj⟩ simp only [Matrix.mul_apply,Fintype.sum_prod_type,Matrix.kronecker_apply,Matrix.one_apply, diagonalBlocks,ite_mul,mul_ite,mul_one,mul_zero,zero_mul] simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] have hne : ℓ≠1 := by intro he have hh := congrArg Polynomial.natDegree he rw [hℓt] at hh simp only [natDegree_one] at hh omega have hd := natDegree_modByMonic_lt (G aj bj*X^bi.val) hℓ hne rw [hℓt] at hd simp only [Boundary.modulusMatrix,Finset.sum_ite_irrel,Finset.sum_const_zero, Finset.sum_ite_eq,Finset.sum_ite_eq',Finset.mem_univ,ite_true] rw [← coefficient_sum t ω a _ hd ai,eval_remainder _ _ _ (hs ai)] simp [eval_mul,eval_pow,eval_X,matrix,mul_comm] theorem root_modulus (t : ℕ) (ht : 0 G.map (eval (a*ω^i.val))) have hP : IsUnit P := TensorTools.unit_tensor _ _ (matrix_unit t ht ω a hω ha) isUnit_one obtain ⟨hDu,hDp⟩ := p.diagonal_blocks t _ hG change IsUnit D at hDu change p.value D=_ at hDp have he : P*W=D*P := intertwine t ht ω a ℓ hℓ hℓt (root_modulus t ht ω a hω) G have hW : IsUnit W := by have hh : IsUnit (P*W) := by rw [he]; exact hDu.mul hP have hd := (Matrix.isUnit_iff_isUnit_det _).mp hh rw [Matrix.det_mul] at hd exact (Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr (mul_ne_zero_iff.mp (isUnit_iff_ne_zero.mp hd)).2) refine ⟨hW,?_⟩ have hconj : P*W*P⁻¹=D := by rw [he,Matrix.mul_assoc,Matrix.mul_nonsing_inv _ ((Matrix.isUnit_iff_isUnit_det _).mp hP),mul_one] have hprice := p.le_conjugate P W hP hW rw [hconj,hDp] at hprice have hp : p.value P=(Fintype.card α:ℝ)*p.value (matrix t ω a) := by rw [p.tensor _ _ (matrix_unit t ht ω a hω ha) isUnit_one,p.one,mul_zero,add_zero] rw [hp] at hprice have hv := matrix_price p j ω a hω ha have hv' := mul_le_mul_of_nonneg_left hv (show (0:ℝ)≤Fintype.card α by positivity) change p.value W≤_ dsimp only [t] at hprice nlinarith only [hprice,hv'] end ExactFourier.RootEvaluation end section namespace ExactFourier.RootEvaluation theorem exists_dilation (t : ℕ) (ω : ℂ) (hω : ω≠0) (E : Finset ℂ) : ∃ a : ℂ, a≠0 ∧ ∀ i : Fin t, a*ω^i.val ∉ E := by classical let F : Finset ℂ := insert 0 (Finset.univ.biUnion (fun i : Fin t => E.image (fun s => s/ω^i.val))) obtain ⟨a,ha⟩ := F.exists_notMem refine ⟨a,?_,?_⟩ · intro he apply ha simp [F,he] · intro i hi apply ha apply Finset.mem_insert_of_mem apply Finset.mem_biUnion.mpr refine ⟨i,Finset.mem_univ _,Finset.mem_image.mpr ⟨a*ω^i.val,hi,?_⟩⟩ exact mul_div_cancel_right₀ _ (pow_ne_zero _ hω) end ExactFourier.RootEvaluation end section namespace ExactFourier open Filter Topology theorem exists_dyadic_between (b : ℕ) (hb : 0 f.coeff 0)=evalRingHom 0 := by funext f; exact coeff_zero_eq_eval_zero f have hGu0 : IsUnit (G.map (fun f => f.coeff 0)) := by rw [hcoeff,coe_evalRingHom]; exact hG0 obtain ⟨CB,hCB,hboundary⟩ := Boundary.exists_boundary_bound p G hGu0 let C : ℝ := CB+52/Real.log 2 have hC : 0≤C := by dsimp [C]; positivity apply fixed_price_of_dyadic_boundary (p.value (G.map (eval 0))) C0 (C*Fintype.card α) (by positivity) intro k j hk let t : ℕ := 2^j have ht : 0 (t:ℝ)*v*(p.value (G.map (eval 0))-C0)) hrel dsimp only [t] at hm ha push_cast at hm ha nlinarith only [hm,ha] end ExactFourier.MatrixPrice end end OAI