cfahlgren1/math / lean /OAI /Combinatorics /HadwigerCounterexample /CrossPatternCorrelation.lean
cfahlgren1's picture
download
raw
6.93 kB
import OAI.Combinatorics.HadwigerCounterexample.BoundedQueryTemplates
namespace OAI
/-! # Cross Pattern Correlation -/
noncomputable section
namespace HadwigerCounterexample
open scoped BigOperators
open Matrix Module LinearMap Submodule Finset Function
variable {p : Shape} {n N : ℕ}
variable {I J K A B : Type} [Fintype I] [Fintype J] [Fintype K]
variable [DecidableEq I] [DecidableEq J] [DecidableEq K]
def layerPhase (M : Mat I J) (N : ℕ) :
PlusRack I N →ₗ[F] (PlusRack J N →ₗ[F] F) where
toFun X := mpair (X*M)
map_add' X Y := LinearMap.ext fun Z => by rw [Matrix.add_mul,mpair_add,LinearMap.add_apply]
map_smul' a X := LinearMap.ext fun Z => by rw [Matrix.smul_mul,mpair_smul,LinearMap.smul_apply]; rfl
omit [DecidableEq I] [DecidableEq J] in
theorem layer_form (M : Mat I J) (X : PlusRack I N) (Y : PlusRack J N) :
layerPhase M N X Y=mpair M (Xᵀ*Y) := by
change (X*M*Yᵀ).trace=(M*(Xᵀ*Y)ᵀ).trace
rw [Matrix.transpose_mul,Matrix.transpose_transpose,
← Matrix.mul_assoc M,Matrix.trace_mul_comm _ X,Matrix.mul_assoc]
omit [DecidableEq I] [DecidableEq J] in
theorem layer_rank (M : Mat I J) (N : ℕ) :
rk (layerPhase M N)=N*M.rank := by
classical
obtain ⟨A,B,hA,hB,hM⟩ := rank_product M
let t := M.rank
let P := layerPhase B N
let X := rmult (Fin N) A
have h1 : P ∘ₗ X=layerPhase M N := by
refine LinearMap.ext fun W => ?_
change mpair ((W*A)*B)=mpair (W*M)
rw [Matrix.mul_assoc,hM]
have hp : Injective P := by
rw [←LinearMap.ker_eq_bot]
refine le_bot_iff.mp (fun V hV => ?_)
change mpair (V*B)=0 at hV
have hg := mpair_nondeg _ hV
have hh : Injective Bᵀ.mulVec := transpose_surj_iff.mp (by rwa [transpose_transpose])
obtain ⟨D,hD⟩ := mat_left_inv hh
have hf : B*Dᵀ=1 := by
rw [←transpose_transpose B,← transpose_mul,hD,transpose_one]
have he : V=0 := calc
V = V*1 := (Matrix.mul_one _).symm
_ = _ := by rw [←hf,←Matrix.mul_assoc,hg,Matrix.zero_mul]
rw [he]; exact Submodule.zero_mem _
have hx : Surjective X := by
obtain ⟨D,hD⟩ := mat_left_inv hA
intro v
exact ⟨v*D,by change v*D*A=v; rw [Matrix.mul_assoc,hD,Matrix.mul_one]⟩
have hf : rk (P ∘ₗ X)=rk P := by
unfold rk; rw [LinearMap.range_comp,LinearMap.range_eq_top.mpr hx,Submodule.map_top]
rw [←h1,hf]
exact (rk_inj.mp hp).trans ((dim_mat _ _).trans (by simp))
def phasedBy (M : Mat I I) (x : Rack I N) : ℝ := wsign (layerPhase M N x.1 x.2)
def upliftR (f : J→I) (x : PlusRack J N) : PlusRack I N := x * (embedMat f)ᵀ
omit [DecidableEq J] [DecidableEq K] in
theorem shifted_sub (M : Mat I I) (f : J→I) (g : K→I) (x : PlusRack J N) (y : PlusRack K N) :
layerPhase M N (upliftR f x) (upliftR g y)=layerPhase (M.submatrix f g) N x y := by
rw [layer_form,layer_form]
let X := embedMat f
let Y := embedMat g
have he : (upliftR f x)ᵀ* upliftR g y=liftM X Y (xᵀ*y) := by
simp only [upliftR,transpose_mul,transpose_transpose,liftM_def,X,Y,Matrix.mul_assoc]
rw [he,mpair_liftM]
rw [show liftM Xᵀ Yᵀ M=M.submatrix f g from (by
unfold X Y; rw [liftM_def,transpose_transpose,embedMat_mul,mul_embedMat]; rfl)]
private theorem uniform_shift {A : Type} [AddGroup A] [Fintype A] (f : Wgt A) (x : A) :
avg unif f=avg unif (fun y => f (y+x)) := by
let e : A≃ A :=
{ toFun := (·+x)
invFun := (·-x)
left_inv a := add_sub_cancel_right ..
right_inv a := sub_add_cancel .. }
have h := avg_bij e unif f
rw [show (fun y => unif (e y))=unif from (by ext; simp [unif_apply])] at h
exact h.symm
def pairedShift {I J K : Type} [Fintype J] [Fintype K] [DecidableEq I] (f : J→I) (g : K→I)
(P : PlusRack J N) (Q : PlusRack K N) := (upliftR f P,upliftR g Q)
set_option maxHeartbeats 600000 in
theorem layerLeak (M : Mat I I) (f g r : Wgt (Rack I N)) (U : J→I) (V : K→I)
(hf : ∀ x, |f x|≤1) (hg : ∀ x,|g x|≤1)
(h1 : ∀ x y, f (x+(0,upliftR V y))=f x)
(h2 : ∀ x y,g (x+(upliftR U y,0))=g x)
(h3 : ∀ x y z,r (x+(upliftR U y,upliftR V z))=r x) :
|avg unif (fun x => phasedBy M x*f x*g x*r x)| ≤
bp (- (N:ℝ)*(M.submatrix U V).rank / 2) * avg unif (fun x => |r x|) := by
classical
let A x := phasedBy M x*f x*g x*r x
let D : Wgt (PlusRack J N × PlusRack K N) := pairW unif unif
have hD : IsLaw D := pairW_law unif_law unif_law
have he :
avg unif A=avg unif (fun x => avg D (fun q => A (x+pairedShift U V q.1 q.2))) := by
rw [avg_avg]; refine (hD.avg_const (avg unif A)).symm.trans
(avg_congr fun q _ => uniform_shift A _)
let E := bp (- (N:ℝ)*(M.submatrix U V).rank /2)
let c (x : Rack I N) := layerPhase M N x.1 x.2
have hQ (x) : |avg D (fun q => A (x+pairedShift U V q.1 q.2))|≤E*|r x| := by
let S (y : PlusRack J N) := f (x+(upliftR U y,0))*wsign (layerPhase M N (upliftR U y) x.2)
let T (y : PlusRack K N) := g (x+(0,upliftR V y))*wsign (layerPhase M N x.1 (upliftR V y))
let L (q : PlusRack J N × PlusRack K N) :=
S q.1*(T q.2*wsign (layerPhase (M.submatrix U V) N q.1 q.2))
have hx q : A (x+pairedShift U V q.1 q.2)=L q*(r x*wsign (c x)) := by
rcases q with ⟨y,z⟩
let Y := upliftR U y
let Z := upliftR V z
have hfg : f (x+(Y,Z))=f (x+(Y,0)) := by
rw [show x+(Y,Z)=x+(Y,0)+(0,Z) from by
rw [add_assoc]; apply congrArg
apply Prod.ext <;> simp,h1]
have hgg : g (x+(Y,Z))=g (x+(0,Z)) := by
rw [show x+(Y,Z)=x+(0,Z)+(Y,0) from by
rw [add_assoc]; apply congrArg
apply Prod.ext <;> simp,h2]
unfold A L phasedBy; dsimp only
change wsign (layerPhase M N (x.1+Y) (x.2+Z))*f (x+(Y,Z))*g (x+(Y,Z))*r (x+(Y,Z))=_
rw [hfg,hgg,h3]
unfold S T c
simp only [map_add,LinearMap.add_apply,wsign_add]
rw [show layerPhase M N Y Z=_ from shifted_sub M U V y z]
dsimp only [Y,Z]; ring
have hs x : |S x|≤ 1 := by simpa only [S,abs_mul,wsign_abs,mul_one] using hf _
have ht x : |T x|≤ 1 := by simpa only [T,abs_mul,wsign_abs,mul_one] using hg _
have hl : |avg D L|≤ E := by
unfold D L
rw [pairW_avg,avg_avg]
simp_rw [mul_left_comm (S _),avg_mul']
refine (walsh_bound _ S T hs ht).trans_eq ?_
unfold E; rw [layer_rank,Nat.cast_mul,neg_mul]
simp_rw [hx]
rw [avg_mul,abs_mul,abs_mul,wsign_abs,mul_one]
exact mul_le_mul_of_nonneg_right hl (abs_nonneg _)
change |avg unif A| ≤_
rw [he]
exact ((abs_avg_le unif_law.nz).trans (avg_mono unif_law.nz hQ)).trans_eq (avg_mul' ..)
omit [DecidableEq I] in
theorem layer_zero (x : Rack I N) : phasedBy 0 x=1 := by unfold phasedBy; simp [layerPhase,mpair]
omit [DecidableEq I] in
theorem layer_add (M T : Mat I I) (x : Rack I N) : phasedBy (M+T) x=phasedBy M x*phasedBy T x := by
unfold phasedBy
rw [layer_form,layer_form,layer_form,mpair_add,wsign_add]
end HadwigerCounterexample
end
end OAI

Xet Storage Details

Size:
6.93 kB
·
Xet hash:
d437495fd595b091071b24a06a9a405fbace2da73d70db57e046b5142a940a9a

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.