math / data /lean /OAI /LinearAlgebra /MatrixMultiplication /Polynomial /ComplexPolynomialKernelExecution.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7.15 kB
import OAI.LinearAlgebra.MatrixMultiplication.Polynomial.ComplexPolynomialControlledKernel
namespace OAI
/-! Polynomial tensor restrictions and exact coefficient extraction. -/
noncomputable section
namespace MatrixMultiplication.Foundation.PolynomialKernelExecution
open Tensor PolynomialLocalConstruction PolynomialControlledKernel
variable {X Y Z Prefix PX PY PZ AX AY AZ : Type*}
variable [Fintype AX] [Fintype AY] [Fintype AZ]
structure Execution (X Y Z Prefix PX PY PZ AX AY AZ : Type*)
[Fintype AX] [Fintype AY] [Fintype AZ] (support : X β†’ Y β†’ Z β†’ Prop) where
auxiliary : Tensor β„‚ AX AY AZ
rankBound : β„•
auxiliary_rank : RankAtMost auxiliary rankBound
order : β„•
leftDegree : β„•
middleDegree : β„•
rightDegree : β„•
leftMap : X β†’ (Prefix Γ— PX) β†’ AX β†’ Polynomial β„‚
middleMap : Y β†’ (Prefix Γ— PY) β†’ AY β†’ Polynomial β„‚
rightMap : Z β†’ (Prefix Γ— PZ) β†’ AZ β†’ Polynomial β„‚
left_degree : βˆ€ x output input, (leftMap x output input).degree ≀ leftDegree
middle_degree : βˆ€ y output input, (middleMap y output input).degree ≀ middleDegree
right_degree : βˆ€ z output input, (rightMap z output input).degree ≀ rightDegree
value : Tensor β„‚ (X Γ— (Prefix Γ— PX)) (Y Γ— (Prefix Γ— PY)) (Z Γ— (Prefix Γ— PZ))
vanishes : βˆ€ x y z, support x.1 y.1 z.1 β†’ βˆ€ j < order,
(kernel auxiliary leftMap middleMap rightMap x y z).coeff j = 0
leading : βˆ€ x y z, support x.1 y.1 z.1 β†’
(kernel auxiliary leftMap middleMap rightMap x y z).coeff order = value x y z
synchronized : βˆ€ x y z, support x.1 y.1 z.1 β†’ value x y z β‰  0 β†’
x.2.1 = y.2.1 ∧ x.2.1 = z.2.1
variable {support : X β†’ Y β†’ Z β†’ Prop}
variable (E : Execution X Y Z Prefix PX PY PZ AX AY AZ support)
variable {New NX NY NZ BX BY BZ : Type*}
variable [Fintype BX] [Fintype BY] [Fintype BZ]
structure Stage (New NX NY NZ BX BY BZ : Type*)
[Fintype BX] [Fintype BY] [Fintype BZ] where
auxiliary : Tensor β„‚ BX BY BZ
rankBound : β„•
auxiliary_rank : RankAtMost auxiliary rankBound
order : β„•
leftDegree : β„•
middleDegree : β„•
rightDegree : β„•
leftMap : Prefix β†’ X β†’ (New Γ— NX) β†’ BX β†’ Polynomial β„‚
middleMap : Prefix β†’ Y β†’ (New Γ— NY) β†’ BY β†’ Polynomial β„‚
rightMap : Prefix β†’ Z β†’ (New Γ— NZ) β†’ BZ β†’ Polynomial β„‚
left_degree : βˆ€ prior x output input, (leftMap prior x output input).degree ≀ leftDegree
middle_degree : βˆ€ prior y output input, (middleMap prior y output input).degree ≀ middleDegree
right_degree : βˆ€ prior z output input, (rightMap prior z output input).degree ≀ rightDegree
eligible : Prefix β†’ X β†’ Y β†’ Z β†’ Prop
previous_eligible : βˆ€ x y z, support x.1 y.1 z.1 β†’ E.value x y z β‰  0 β†’
eligible x.2.1 x.1 y.1 z.1
value : Prefix β†’ Tensor β„‚ (X Γ— (New Γ— NX)) (Y Γ— (New Γ— NY)) (Z Γ— (New Γ— NZ))
vanishes : βˆ€ prior x y z, eligible prior x.1 y.1 z.1 β†’ βˆ€ j < order,
(kernel auxiliary (leftMap prior) (middleMap prior) (rightMap prior) x y z).coeff j = 0
leading : βˆ€ prior x y z, eligible prior x.1 y.1 z.1 β†’
(kernel auxiliary (leftMap prior) (middleMap prior) (rightMap prior) x y z).coeff order =
value prior x y z
synchronized : βˆ€ prior x y z, eligible prior x.1 y.1 z.1 β†’ value prior x y z β‰  0 β†’
x.2.1 = y.2.1 ∧ x.2.1 = z.2.1
def pack {OldCoord NewCoord : Type*} :
((Prefix Γ— New) Γ— (OldCoord Γ— NewCoord)) β†’ Output Prefix New OldCoord NewCoord :=
fun output => ((output.1.1, output.2.1), (output.1.2, output.2.2))
namespace Execution
variable (S : Stage E New NX NY NZ BX BY BZ)
def step : Execution X Y Z (Prefix Γ— New) (PX Γ— NX) (PY Γ— NY) (PZ Γ— NZ)
(AX Γ— BX) (AY Γ— BY) (AZ Γ— BZ) support := by
have coefficients := controlledKernel_coefficients E.order S.order
E.auxiliary S.auxiliary E.leftMap E.middleMap E.rightMap
S.leftMap S.middleMap S.rightMap E.value S.value support S.eligible
E.vanishes E.leading
(fun x y z hs hn => ⟨(E.synchronized x y z hs hn).1,
(E.synchronized x y z hs hn).2, S.previous_eligible x y z hs hn⟩)
S.vanishes S.leading
refine {
auxiliary := Tensor.product E.auxiliary S.auxiliary
rankBound := E.rankBound * S.rankBound
auxiliary_rank := E.auxiliary_rank.product S.auxiliary_rank
order := E.order * (S.order + 1) + S.order
leftDegree := E.leftDegree * (S.order + 1) + S.leftDegree
middleDegree := E.middleDegree * (S.order + 1) + S.middleDegree
rightDegree := E.rightDegree * (S.order + 1) + S.rightDegree
leftMap := fun x output input =>
controlledMap S.order E.leftMap S.leftMap x (pack output) input
middleMap := fun y output input =>
controlledMap S.order E.middleMap S.middleMap y (pack output) input
rightMap := fun z output input =>
controlledMap S.order E.rightMap S.rightMap z (pack output) input
left_degree := fun x output input =>
controlledMap_degree S.order E.leftDegree S.leftDegree E.leftMap S.leftMap
E.left_degree S.left_degree x (pack output) input
middle_degree := fun y output input =>
controlledMap_degree S.order E.middleDegree S.middleDegree E.middleMap S.middleMap
E.middle_degree S.middle_degree y (pack output) input
right_degree := fun z output input =>
controlledMap_degree S.order E.rightDegree S.rightDegree E.rightMap S.rightMap
E.right_degree S.right_degree z (pack output) input
value := fun x y z => controlledLeading E.value S.value
(x.1, pack x.2) (y.1, pack y.2) (z.1, pack z.2)
vanishes := fun x y z hs j hj =>
coefficients.1 (x.1, pack x.2) (y.1, pack y.2) (z.1, pack z.2) hs j hj
leading := fun x y z hs =>
coefficients.2 (x.1, pack x.2) (y.1, pack y.2) (z.1, pack z.2) hs
synchronized := ?_
}
intro x y z hs hn
have hproduct :
E.value (x.1, (x.2.1.1, x.2.2.1)) (y.1, (y.2.1.1, y.2.2.1))
(z.1, (z.2.1.1, z.2.2.1)) *
S.value x.2.1.1 (x.1, (x.2.1.2, x.2.2.2))
(y.1, (y.2.1.2, y.2.2.2)) (z.1, (z.2.1.2, z.2.2.2)) β‰  0 := hn
have hp := (mul_ne_zero_iff.mp hproduct).1
have hs' := (mul_ne_zero_iff.mp hproduct).2
have hprior := E.synchronized _ _ _ hs hp
have heligible := S.previous_eligible _ _ _ hs hp
have hnew := S.synchronized _ _ _ _ heligible hs'
exact ⟨Prod.ext hprior.1 hnew.1, Prod.ext hprior.2 hnew.2⟩
@[simp] theorem step_rankBound : (step E S).rankBound = E.rankBound * S.rankBound := rfl
@[simp] theorem step_auxiliary :
(step E S).auxiliary = Tensor.product E.auxiliary S.auxiliary := rfl
@[simp] theorem step_order : (step E S).order = E.order * (S.order + 1) + S.order := rfl
@[simp] theorem step_value
(x : X Γ— ((Prefix Γ— New) Γ— (PX Γ— NX)))
(y : Y Γ— ((Prefix Γ— New) Γ— (PY Γ— NY)))
(z : Z Γ— ((Prefix Γ— New) Γ— (PZ Γ— NZ))) :
(step E S).value x y z =
E.value (x.1, (x.2.1.1, x.2.2.1)) (y.1, (y.2.1.1, y.2.2.1))
(z.1, (z.2.1.1, z.2.2.1)) *
S.value x.2.1.1 (x.1, (x.2.1.2, x.2.2.2))
(y.1, (y.2.1.2, y.2.2.2)) (z.1, (z.2.1.2, z.2.2.2)) := rfl
end Execution
end MatrixMultiplication.Foundation.PolynomialKernelExecution
end
end OAI