introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
1.75 kB
import Mathlib
namespace OAI
section
namespace ExactFourier
/-- One charged scalar gate, referencing only available values. -/
inductive Gate (w : β„•) where
| add (i j : Fin w)
| sub (i j : Fin w)
| scale (c : β„‚) (i : Fin w)
def Gate.eval {w : β„•} (v : Fin w β†’ β„‚) : Gate w β†’ β„‚
| .add i j => v i + v j
| .sub i j => v i - v j
| .scale c i => c * v i
/-- A topologically ordered scalar DAG; available values are never consumed. -/
inductive Program (n : β„•) : β„• β†’ Type where
| nil : Program n 0
| step {k : β„•} (p : Program n k) (g : Gate (n + 1 + k)) : Program n (k + 1)
def Program.eval {n : β„•} : {k : β„•} β†’ Program n k β†’ (Fin n β†’ β„‚) β†’
(Fin (n + 1 + k) β†’ β„‚)
| 0, .nil, x => Fin.snoc x 0
| _ + 1, .step p g, x =>
let v := p.eval x
Fin.snoc v (g.eval v)
/-- Outputs name available values, so permutations and arbitrary fanout are uncharged. -/
structure Circuit (n : β„•) where
size : β„•
program : Program n size
outputs : Fin n β†’ Fin (n + 1 + size)
def Circuit.eval {n : β„•} (C : Circuit n) (x : Fin n β†’ β„‚) : Fin n β†’ β„‚ :=
fun i => C.program.eval x (C.outputs i)
noncomputable def zeta (n : β„•) : β„‚ := Complex.exp (2 * Real.pi * Complex.I / (n : β„‚))
noncomputable def fourierMatrix (n : β„•) : Matrix (Fin n) (Fin n) β„‚ :=
fun j k => zeta n ^ (j.val * k.val)
def Circuit.Computes {n : β„•} (C : Circuit n) (A : Matrix (Fin n) (Fin n) β„‚) : Prop :=
βˆ€ x, C.eval x = A.mulVec x
def MainStatement : Prop :=
βˆ€ c : ℝ, 0 < c β†’ βˆ€ Nβ‚€ : β„•, 2 ≀ Nβ‚€ β†’ βˆƒ n : β„•, Nβ‚€ ≀ n ∧
βˆƒ C : Circuit n, C.Computes (fourierMatrix n) ∧
(C.size : ℝ) < c * (n : ℝ) * Real.logb 2 (n : ℝ)
end ExactFourier
end
end OAI