File size: 7,360 Bytes
fcab081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import OAI.Combinatorics.HadwigerCounterexample.SumRankBounds

namespace OAI

/-! # Channel Frame Laws -/

noncomputable section
namespace HadwigerCounterexample
open Matrix LinearMap Module Submodule Finset Function
open scoped BigOperators

variable {A B : Type} [Fintype A] [Fintype B]

theorem map_pair_law {C D : Type} [Fintype C] [Fintype D]
    (w : Wgt A) (v : Wgt B) (f : A→C) (g : B→D) :
    mapW (pairW w v) (Prod.map f g)=pairW (mapW w f) (mapW v g) := by
  funext x
  unfold mapW pairW
  simp only [Prod.ext_iff]
  exact pairW_pr w v (fun y => f y=x.1) (fun y => g y=x.2)

theorem mapW_nested {C : Type} (w : Wgt A) (f : A→B) (g : B→C) :
    mapW (mapW w f) g=mapW w (g ∘ f) :=
  funext fun _ => mapW_pr _ _ _

omit [Fintype B] in
theorem mapW_repeat {I : Type} [Fintype I] [DecidableEq I]
    (w : I→ Wgt A) (f : I→ A→B) :
    mapW (prodW w) (fun x i => f i (x i))=prodW (fun i => mapW (w i) (f i)) := by
  funext x
  unfold mapW
  simp_rw [funext_iff]
  exact prodW_pr _ (fun i y => f i y=x i)

omit [Fintype B] in
theorem mapW_pr_eq (e : A≃A) (f : A→B) (u : B≃B) (h : ∀ x,f (e x)=u (f x))
    (w : Wgt A) (hw : ∀ x, w (e x)=w x) (x : B) : mapW w f (u x)=mapW w f x := by
  have he := avg_bij e w (fun y => ind (f y=u x))
  simp_rw [hw,h,u.injective.eq_iff] at he
  exact he.symm

private theorem pmax_test {x : A} (p : A → Prop) {w : Wgt A} (hw : SubLaw w)
    (h : ∀ y, p y → w y=w x) {m : ℝ} (hm : 0 < m)
    (hp : m ≤ pr unif p) [Nonempty A] :
    w x ≤ m⁻¹ * unif x := by
  have hh : pr w p=w x*nbr p := by
    simp only [pr,avg,nbr,tot,Finset.mul_sum]
    refine Finset.sum_congr rfl fun i _ => ?_
    by_cases he : p i
    · rw [h i he]
    rw [ind_zero he,mul_zero,mul_zero]
  have h1 := (pr_le_tot (p:=p) hw.nz).trans hw.total
  rw [hh] at h1
  have hU : 0 < (Fintype.card A : ℝ) := by exact_mod_cast Fintype.card_pos
  rw [pr_unif (A:=A)] at hp
  have hi := (le_div_iff₀ hU).mp hp
  rw [unif_apply]
  field_simp
  nlinarith only [h1,hi,mul_le_mul_of_nonneg_left hi (hw.nz x)]

theorem gram_norm_quarter {I J L : Type} [Fintype I] [Fintype J] [Fintype L]
    [DecidableEq I] [DecidableEq J] [DecidableEq L] (G : Mat I J)
    (h : num I + num J-num L ≤ -1) :
    bp (-num I * num J)/4 ≤ pr unif (gramGood (U:=L) G) := by
  have hn := (gram_norm G (by linarith : num I+num J≤num L)).2
  rw [pair_unif]
  refine le_trans ?_ hn
  have he {x : ℝ} (hx : x ≤ -1) : (1/2 : ℝ)≤ 1-bp x := by
    have ht := bp_le hx
    rw [bp_neg,bp_one] at ht
    linarith only [ht]
  let d := bp (-num I*num J)
  change d/4 ≤ d* _ * _
  have hk : 0 < d := bp_pos _
  have h1 := he (x:= num I-num L) (by
    have hg : 0≤num J := Nat.cast_nonneg _
    linarith)
  calc d/4 = d*(1/2)*(1/2) := by ring
       _ ≤ _ := mul_le_mul (mul_le_mul_of_nonneg_left h1 hk.le) (he h) (by norm_num)
         (mul_nonneg hk.le (le_trans (by norm_num) h1))

variable {I J U : Type} [Fintype I] [Fintype J] [Fintype U]
variable [DecidableEq I] [DecidableEq J] [DecidableEq U]

theorem gramObsCap {C : Mat (I⊕J) (I⊕J) → Prop}
    (hc : ∃ x : Mat U (I⊕J) × _, FramesAt C x)
    (T : Mat (I⊕J) J) (ht : Function.Injective T.mulVec)
    (hN : 2*num J-num U≤ -1) :
    let w := unifOn (FramesAt C)
    ∀ x : Mat U J × Mat U J,
      mapW w (observe T T) x ≤ (4*bp (num J*num J))*pairW unif unif x := by
  classical
  let w := unifOn (FramesAt (U:=U) C)
  have hw := unifOn_law hc
  let f := observe T T (U:=U)
  let v := mapW w f
  have hv : IsLaw v := mapW_law hw f
  have hg :
      carried v (fun x : Mat U J × _ => Injective x.1.mulVec ∧ Injective x.2.mulVec) := by
    refine mapW_carried (unifOn_carried _) (fun x hx => ?_)
    exact ⟨inj_comp_mat _ _ hx.2.1 ht,inj_comp_mat _ _ hx.2.2 ht⟩
  dsimp only
  intro x
  rw [← pair_unif]
  by_cases h : v x≠0
  · let G := (x.1ᵀ*x.2 : Mat J J)
    have hx : gramGood G x := ⟨rfl,Classical.byContradiction fun he => h (hg x he)⟩
    let m := bp (-num J*num J)/4
    have he (y : Mat U J × Mat U J) (hy : gramGood G y) : v y=v x := by
      obtain ⟨L,hL⟩ := move_exists G x y hx hy
      let e := L.perm (I⊕J) (I⊕J)
      have hl (y) : f (e y)=(L.perm J J) (f y) :=
        Prod.ext (Matrix.mul_assoc ..) (Matrix.mul_assoc ..)
      have hp y : w (e y)=w y := by
        unfold w; rw [unifOn_val, unifOn_val]
        congr 2
        exact propext (L.invar C y).symm
      exact hL ▸ mapW_pr_eq e f (L.perm J J) hl w hp x
    have hi := pmax_test (gramGood (U:=U) G) hv.sub he (m:=m)
      (div_pos (bp_pos _) (by norm_num)) (gram_norm_quarter G (by linarith only [hN]))
    apply hi.trans
    unfold m; rw [neg_mul,bp_neg]; field_simp
    exact le_rfl
  · change v x ≤ _
    rw [not_ne_iff.mp h]
    exact mul_nonneg (mul_nonneg (by norm_num) (bp_pos _).le) (unif_subLaw.nz _)

variable {p : Shape} {n N : ℕ}
abbrev HMat (p : Shape) (N : ℕ) := Mat (Fin N) (Chan p)
abbrev HFrame (p : Shape) (N : ℕ) := HMat p N × HMat p N
abbrev HCube (p : Shape) (N : ℕ) := Comp p.g → HFrame p N

def hchan (p : Shape) {n N} (x : Oframe p n N) : HFrame p N :=
  (channel x.1,channel x.2)
def hcube (p : Shape) {n N} (x : Orient p n N) : HCube p N := fun z => hchan p (x z)
def lawH (p : Shape) (N : ℕ) : Wgt (HCube p N) :=
  prodW (fun (_ : Comp p.g) => pairW unif unif)

def intoChan (p : Shape) (n) : Mat (Full p n) (Chan p) := embedMat (.inr ·)

theorem intoChan_inj : Injective (intoChan p n).mulVec :=
  embedMat_inj Sum.inr_injective
theorem intoChan_val (p : Shape) {n N} (x : Mat (Fin N) (Full p n)) :
    x * intoChan p n=channel x := by rw [intoChan,mul_embedMat]; rfl
theorem hchan_val (p : Shape) {n N} :
    hchan p (n:=n) (N:=N) = observe (intoChan p n) (intoChan p n) := by
  funext x
  exact Prod.ext (intoChan_val ..).symm (intoChan_val ..).symm

def chanPrice (p : Shape) : ℝ :=
  (4*bp ((p.h:ℝ)*p.h))^(Fintype.card (Comp p.g))

theorem hchan_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1) :
    let w := unifOn (FramesAt (U:=Fin N) (gramCond m))
    ∀ x : HFrame p N,mapW w (hchan p) x≤(4*bp ((p.h:ℝ)*p.h))*pairW unif unif x := by
  classical
  have he : 2*num (Full p n)-num (Fin N)≤ -1 := by simpa [num] using hN
  have hh : ∃ x : Oframe p n N, FramesAt (gramCond m) x :=
    framesAt_exists (gramCond_exists m) (by linarith only [he])
  rw [hchan_val]
  have hr : num (Chan p) ≤ num (Full p n) := by
    have hf : Fintype.card (Row p n) + Fintype.card (Chan p)=Fintype.card (Full p n) :=
      (Fintype.card_sum ..).symm
    exact_mod_cast (show Fintype.card (Chan p)≤Fintype.card (Full p n) by omega)
  have hk := gramObsCap hh (intoChan p n) intoChan_inj (by linarith only [he,hr])
  rw [show num (Chan p)=(p.h:ℝ) from (by simp [num,Chan])] at hk
  exact hk

theorem hcube_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1)
    (x : HCube p N) : mapW (raw m N) (hcube p) x ≤ chanPrice p*lawH p N x := by
  let w := unifOn (FramesAt (U:=Fin N) (gramCond m))
  have hh i := hchan_cap m hN (x i)
  change mapW (prodW (fun (_ : Comp p.g) => w)) _ x ≤ _
  unfold hcube
  rw [mapW_repeat (w:=fun (_:Comp p.g) => w) (f:=fun i => hchan p (n:=n) (N:=N))]
  refine le_trans (Finset.prod_le_prod₀ ?_ fun i _ => hh i) ?_
  · intro i _
    exact pr_nonneg (unifOn_sub _).nz
  rw [Finset.prod_mul_distrib]
  simp [chanPrice,lawH,prodW]

end HadwigerCounterexample

end

end OAI