import OAI.Computability.FourierTransform.Asymptotics import OAI.Computability.FourierTransform.RegisterBounds namespace OAI /-! Exact uniform Fourier transforms and convolution. The construction formalizes the exact arithmetic algorithms of *An explicit power saving for the exact discrete Fourier transform* (OpenAI). The finite phase network originates in the complex construction of *Integer multiplication below n log n*. `transform_main` and `convolution_main` give fixed finite RAM programs, including preparation and index work, polynomial storage bounds, and a canonical root whose order is computed from the input length. Each includes the paper exponent, decimal power saving, and little-o bound. The `_order` variants also specify the root order. The implementation uses a smaller concrete tensor network (32 binary coordinates per factor, 4060 triples, and a `2^50` role envelope) with a stronger saving that implies the stated paper constants. The general rational-algebra extraction, symbolic certificate search, circuit printer, and bounded-printer uniformization from the synthesis appendix are outside this formalization. -/ namespace PowerSaving open RAM Bench Selection Filter Asymptotics Real noncomputable section namespace Skies lemma multiplier_range : 1 < paperMultiplier ∧ paperMultiplier < paperM := by norm_num [paperMultiplier,paperM,paperDelta,paperW] lemma theta_lt : theta < 1 := by have h := multiplier_range have hg : 0 by rw [speed,Real.rpow_one]; rfl rw [h] at H; exact H lemma speed_paper : speed theta =O[atTop] paperTime := by rw [isBigO_iff] refine ⟨1,?_⟩ filter_upwards [Ttop.eventually_ge_atTop 1,Qtop.eventually_ge_atTop 1] with n hn hh have he : 0 (lunch a b N n:ℝ)) =O[atTop] decimalTime := hd.isBigO exact ⟨hp.isBigO.trans speed_paper,ht,ht.trans_isLittleO decimal_little⟩ end Skies /-! Main results. Provide formula for the order besides the existential specification. -/ theorem transform_main_order : ∃ order solve W, DFTProgram order solve W ∧ TimeBounds W ∧ ∀ n, 0 ⟨le_rfl,by dsimp; omega⟩) a b,fun n hn => ⟨ho n hn,(ho n hn).symm ▸ (receipt_bound n hn).2⟩⟩ theorem convolution_main_order : ∃ order solve W, ConvProgram order solve W ∧ TimeBounds W ∧ ∀ n, 0 ⟨ho n hn,(ho n hn).symm ▸ (receipt_bound _ (stretch_pos hn)).2⟩⟩ theorem transform_main : DFTGoal := let ⟨o,s,W,h,g,_⟩ := transform_main_order ⟨o,s,W,h,g⟩ theorem convolution_main : ConvGoal := let ⟨o,s,W,h,g,_⟩ := convolution_main_order ⟨o,s,W,h,g⟩ lemma matrix_definition (n : ℕ) (x : Vec n) : dft n x = Matrix.mulVec (dftMatrix n) x := rfl end end PowerSaving end OAI