Sync from openai/math@faee2cf485a8 (part 9)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveProjectionBounds.lean +124 -124
- lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveRecordBounds.lean +102 -102
- lean/OAI/Combinatorics/HadwigerCounterexample/AdditionalProbeBounds.lean +171 -171
- lean/OAI/Combinatorics/HadwigerCounterexample/AffineFrames.lean +195 -195
- lean/OAI/Combinatorics/HadwigerCounterexample/AggregateCostBounds.lean +124 -124
- lean/OAI/Combinatorics/HadwigerCounterexample/AmbientBatchSlots.lean +211 -211
- lean/OAI/Combinatorics/HadwigerCounterexample/AnalyticParameters.lean +143 -143
- lean/OAI/Combinatorics/HadwigerCounterexample/AtomFlavors.lean +148 -148
- lean/OAI/Combinatorics/HadwigerCounterexample/AttackCutDecomposition.lean +277 -277
- lean/OAI/Combinatorics/HadwigerCounterexample/BaselineExtension.lean +124 -124
- lean/OAI/Combinatorics/HadwigerCounterexample/BaselineForms.lean +147 -147
- lean/OAI/Combinatorics/HadwigerCounterexample/BasisConditioning.lean +113 -113
- lean/OAI/Combinatorics/HadwigerCounterexample/BatchCharacters.lean +153 -153
- lean/OAI/Combinatorics/HadwigerCounterexample/BiasedRotationBounds.lean +142 -142
- lean/OAI/Combinatorics/HadwigerCounterexample/BilinearBlockCorrelation.lean +107 -107
- lean/OAI/Combinatorics/HadwigerCounterexample/BilinearCompression.lean +126 -126
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryEvaluationForms.lean +174 -174
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMatrices.lean +125 -125
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMixingBounds.lean +106 -106
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryPrescriptions.lean +265 -265
- lean/OAI/Combinatorics/HadwigerCounterexample/BinaryStatusComparison.lean +143 -143
- lean/OAI/Combinatorics/HadwigerCounterexample/BooleanLabels.lean +151 -151
- lean/OAI/Combinatorics/HadwigerCounterexample/BoundedQueryTemplates.lean +134 -134
- lean/OAI/Combinatorics/HadwigerCounterexample/CellPositivityScales.lean +177 -177
- lean/OAI/Combinatorics/HadwigerCounterexample/CellPruning.lean +128 -128
- lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFactorization.lean +144 -144
- lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFrameLaws.lean +186 -186
- lean/OAI/Combinatorics/HadwigerCounterexample/CollisionInequality.lean +204 -204
- lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitionRefinement.lean +79 -79
- lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitions.lean +119 -119
- lean/OAI/Combinatorics/HadwigerCounterexample/CommonPredictions.lean +112 -112
- lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleOptionRealization.lean +130 -130
- lean/OAI/Combinatorics/HadwigerCounterexample/CompatiblePairTests.lean +105 -105
- lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleTableEvents.lean +149 -149
- lean/OAI/Combinatorics/HadwigerCounterexample/ComponentIndices.lean +115 -115
- lean/OAI/Combinatorics/HadwigerCounterexample/ConcentrationScales.lean +169 -169
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalCellEntropy.lean +156 -156
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFlags.lean +107 -107
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFourCorners.lean +101 -101
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalLargeSetHits.lean +106 -106
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProductLaws.lean +125 -125
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProjection.lean +96 -96
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalSignaturePositivity.lean +110 -110
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedBatchLaws.lean +198 -198
- lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedCorrelations.lean +97 -97
- lean/OAI/Combinatorics/HadwigerCounterexample/ConstructionScales.lean +100 -100
- lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateBlocks.lean +147 -147
- lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateDuality.lean +87 -87
- lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateEmbeddings.lean +163 -163
- lean/OAI/Combinatorics/HadwigerCounterexample/CoverAlternatives.lean +86 -86
lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveProjectionBounds.lean
CHANGED
|
@@ -1,124 +1,124 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.KeyProjectionBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Adaptive Projection Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
variable {p:Shape} {n N K M r z s0:ℕ} {q:Format} {d e:Rates} {b:Bool}
|
| 14 |
-
|
| 15 |
-
private theorem avg_side_bounds {A : Type} [Fintype A] (w : Wgt A) (hw:IsLaw w)
|
| 16 |
-
(b:Bool) (f : Wgt A) (F:A×A→ℝ) (h:∀ i,F i≤f (onSide i b)) :
|
| 17 |
-
avg (pairW w w) F≤avg w f := by
|
| 18 |
-
apply (avg_mono (pairW_law hw hw).nz h).trans
|
| 19 |
-
cases b
|
| 20 |
-
· rw [pairW_avg]
|
| 21 |
-
simp [onSide,hw.avg_const]
|
| 22 |
-
rw [pairW_avg]; simp only [onSide,ite_true,hw.avg_const]; rfl
|
| 23 |
-
|
| 24 |
-
namespace Quill
|
| 25 |
-
variable (w:Quill p q d b)
|
| 26 |
-
(m:Mixer p n) (t:Tagging p (Messenger q)) (φ:Messenger q→F)
|
| 27 |
-
(u:LeafMixture p n N) (Y:Silhouette p N r)
|
| 28 |
-
|
| 29 |
-
set_option maxHeartbeats 1200000 in
|
| 30 |
-
theorem oneTrestle (omega_:Wgt u.T) (hv:IsLaw omega_) (s:u.T→ Charts p n d)
|
| 31 |
-
(μ:u.T→Wgt (UnitType p n N)) (hμ:∀ i,IsLaw (μ i))
|
| 32 |
-
(P : Keys (p:=p) t N→ Fin z) (F:u.T×u.T → UnitType p n N→Prop)
|
| 33 |
-
(hF : ∀ i o,F i o→PreparationParameters.frameSide p m o)
|
| 34 |
-
(hw:∀ i,IsLaw (w.policies t φ n i)) (hν:IsLaw (lawNu p N t φ))
|
| 35 |
-
(ε v A B:ℝ) (he:0≤ε)
|
| 36 |
-
(ha:∀ i:Fin z,
|
| 37 |
-
pr (mixW omega_ μ) (w.flunk t φ Y (fun x=>ind (P x=i)) m v ε) ≤ A)
|
| 38 |
-
(hh: pr (mixW omega_ μ) (fun x=>¬ w.matchesArea t φ Y x v)≤B) :
|
| 39 |
-
let L (i:u.T×u.T):=onSide i b
|
| 40 |
-
avg (pairW omega_ omega_) (fun i=>varOne (mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P)
|
| 41 |
-
(mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P)) ≤ z*(ε+2*(A+B)) := by
|
| 42 |
-
classical
|
| 43 |
-
intro L
|
| 44 |
-
let Q (i:u.T×u.T) (x:Fin z):=
|
| 45 |
-
|mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P x-
|
| 46 |
-
mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P x|
|
| 47 |
-
let V:= pairW omega_ omega_
|
| 48 |
-
have h (x : Fin z) :
|
| 49 |
-
avg V (fun i=>Q i x) ≤ ε+ 2*(A+B) := by
|
| 50 |
-
let H k:= P k=x
|
| 51 |
-
let R:= w.flunk t φ Y (fun i=>ind (H i)) m v ε
|
| 52 |
-
let Z (i:UnitType p n N):= ¬ w.matchesArea t φ Y i v
|
| 53 |
-
let S o:=R o∨ Z o
|
| 54 |
-
have heq (i): Q i x≤ ε+2*pr (μ (L i)) S := by
|
| 55 |
-
refine w.display_test t φ (μ (L i)) (F i) m (s (L i)) Y H (hμ _) hw hν S he
|
| 56 |
-
(fun y hy hz=> ?_)
|
| 57 |
-
by_cases hf :Z y
|
| 58 |
-
· exact Or.inr hf
|
| 59 |
-
exact Or.inl ⟨hF _ _ hy,not_not.mp hf,s (L i),hz⟩
|
| 60 |
-
let U:=mixW omega_ μ
|
| 61 |
-
have hu : IsLaw U:=mixW_law hv hμ
|
| 62 |
-
have hm (o) : avg omega_ (fun i=>pr (μ i) o)= pr U o := (mixW_avg ..).symm
|
| 63 |
-
apply (avg_side_bounds omega_ hv b (fun i=>ε+2*pr (μ i) S) _ heq).trans
|
| 64 |
-
rw [avg_add,avg_mul',hm,hv.avg_const]
|
| 65 |
-
exact add_le_add_right (mul_le_mul_of_nonneg_left ((pr_or_le hu.nz).trans
|
| 66 |
-
(add_le_add (ha _) hh)) (by norm_num)) _
|
| 67 |
-
change avg V (fun x=> ∑ i,Q x i) ≤ _
|
| 68 |
-
rw [avg_sum]; exact (Finset.sum_le_sum fun i _=> h i).trans_eq (by simp; ring)
|
| 69 |
-
end Quill
|
| 70 |
-
|
| 71 |
-
open Station PreparationParameters
|
| 72 |
-
namespace Station
|
| 73 |
-
variable {w:LeafMixture p n N} (t:Station p n N K w)
|
| 74 |
-
(x:Typus p q d e) (m:Mixer p n) (k: Fin (2^deckMax p K))
|
| 75 |
-
(μ:Wgt (UnitType p n N)) (Y:Silhouette p N r)
|
| 76 |
-
|
| 77 |
-
theorem gauzed_area (Y:Silhouette p N r) (w : Quill p q d b)
|
| 78 |
-
(t: Tagging p (Messenger q)) (u : Messenger q → F)
|
| 79 |
-
(h:w.moral t u) (δ:ℝ)
|
| 80 |
-
{K : ℕ} {m:Mixer p n} {ε v:ℝ} (he:ε≤v)
|
| 81 |
-
(o : UnitType p n N) (hc:gauze p ε δ Y m K o) :
|
| 82 |
-
w.matchesArea t u Y o v := by
|
| 83 |
-
intro i; have heq := w.allure_apt t u h i
|
| 84 |
-
exact ((hc _ (w.allure t u i)).1 heq).trans he
|
| 85 |
-
|
| 86 |
-
set_option maxHeartbeats 1200000 in
|
| 87 |
-
theorem projectSum (P : Keys (p:=p) x.t N→Fin z)
|
| 88 |
-
(h :apart w.T) (hm:IsLaw μ) (hw :∀ i∈w.T,0<partMass μ i) (hs : 0<w.amount μ)
|
| 89 |
-
(ha : ∀ i,IsLaw (x.qA.policies x.t x.z n i)) (hb:∀ i,IsLaw (x.qB.policies x.t x.z n i))
|
| 90 |
-
(hν : IsLaw (lawNu p N x.t x.z)) (ε v v' τ B δ : ℝ) (he:0≤ε)
|
| 91 |
-
(hf : x.permission)
|
| 92 |
-
(ht : τ ≤ v ∧ τ≤v')
|
| 93 |
-
(hh : pr (w.sap μ) (fun i=>¬gauze p τ δ Y m K i)≤B)
|
| 94 |
-
(hx : ∀ i:Fin z,pr (w.sap μ) (x.qA.flunk x.t x.z Y (fun y=>ind (P y=i)) m v ε)≤B)
|
| 95 |
-
(hy : ∀ i:Fin z,pr (w.sap μ) (x.qB.flunk x.t x.z Y (fun y=>ind (P y=i)) m v' ε)≤B) :
|
| 96 |
-
t.due x m μ k Y P≤2*(z*(ε+2*(B+B))) := by
|
| 97 |
-
classical
|
| 98 |
-
obtain ⟨hp,hq⟩:=rebuild hm.nz h hw hs
|
| 99 |
-
let A (i:w.T):=partW μ i.val
|
| 100 |
-
let u:=portionW μ w.T
|
| 101 |
-
have hQ : w.sap μ=mixW u A :=hq
|
| 102 |
-
let V:=pairW u u; have hA i:IsLaw (A i):=on_law hm.nz (hw i.val i.property)
|
| 103 |
-
have hL : avg V (fun i=> taxLeft t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := by
|
| 104 |
-
refine x.qA.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i d) A hA P
|
| 105 |
-
(fun i=> t.frontPage x m i.1 i.2 k) (fun i o h => h.2.2.1) ha hν ε v B B he
|
| 106 |
-
(fun i=>by rw [←hQ]; exact hx i) ?_
|
| 107 |
-
rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hh
|
| 108 |
-
exact fun i hi h=> hi (gauzed_area _ _ _ _ hf.2.1 δ ht.1 i h)
|
| 109 |
-
have hR : avg V (fun i=> taxRight t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := by
|
| 110 |
-
refine x.qB.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i e) A hA P
|
| 111 |
-
(fun i=> t.backPage x m i.1 i.2 k) (fun i o h => h.2.2.1) hb hν ε v' B B he
|
| 112 |
-
(fun i=>by rw [←hQ]; exact hy i) ?_
|
| 113 |
-
rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hh
|
| 114 |
-
exact fun i hi h=>hi (gauzed_area _ _ _ _ hf.2.2.1 δ ht.2 i h)
|
| 115 |
-
unfold due; rw [avg_add,two_mul]
|
| 116 |
-
exact add_le_add hL hR
|
| 117 |
-
|
| 118 |
-
end Station
|
| 119 |
-
end StatusAnalysis
|
| 120 |
-
end HadwigerCounterexample
|
| 121 |
-
|
| 122 |
-
end
|
| 123 |
-
|
| 124 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.KeyProjectionBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Adaptive Projection Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
variable {p:Shape} {n N K M r z s0:ℕ} {q:Format} {d e:Rates} {b:Bool}
|
| 14 |
+
|
| 15 |
+
private theorem avg_side_bounds {A : Type} [Fintype A] (w : Wgt A) (hw:IsLaw w)
|
| 16 |
+
(b:Bool) (f : Wgt A) (F:A×A→ℝ) (h:∀ i,F i≤f (onSide i b)) :
|
| 17 |
+
avg (pairW w w) F≤avg w f := by
|
| 18 |
+
apply (avg_mono (pairW_law hw hw).nz h).trans
|
| 19 |
+
cases b
|
| 20 |
+
· rw [pairW_avg]
|
| 21 |
+
simp [onSide,hw.avg_const]
|
| 22 |
+
rw [pairW_avg]; simp only [onSide,ite_true,hw.avg_const]; rfl
|
| 23 |
+
|
| 24 |
+
namespace Quill
|
| 25 |
+
variable (w:Quill p q d b)
|
| 26 |
+
(m:Mixer p n) (t:Tagging p (Messenger q)) (φ:Messenger q→F)
|
| 27 |
+
(u:LeafMixture p n N) (Y:Silhouette p N r)
|
| 28 |
+
|
| 29 |
+
set_option maxHeartbeats 1200000 in
|
| 30 |
+
theorem oneTrestle (omega_:Wgt u.T) (hv:IsLaw omega_) (s:u.T→ Charts p n d)
|
| 31 |
+
(μ:u.T→Wgt (UnitType p n N)) (hμ:∀ i,IsLaw (μ i))
|
| 32 |
+
(P : Keys (p:=p) t N→ Fin z) (F:u.T×u.T → UnitType p n N→Prop)
|
| 33 |
+
(hF : ∀ i o,F i o→PreparationParameters.frameSide p m o)
|
| 34 |
+
(hw:∀ i,IsLaw (w.policies t φ n i)) (hν:IsLaw (lawNu p N t φ))
|
| 35 |
+
(ε v A B:ℝ) (he:0≤ε)
|
| 36 |
+
(ha:∀ i:Fin z,
|
| 37 |
+
pr (mixW omega_ μ) (w.flunk t φ Y (fun x=>ind (P x=i)) m v ε) ≤ A)
|
| 38 |
+
(hh: pr (mixW omega_ μ) (fun x=>¬ w.matchesArea t φ Y x v)≤B) :
|
| 39 |
+
let L (i:u.T×u.T):=onSide i b
|
| 40 |
+
avg (pairW omega_ omega_) (fun i=>varOne (mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P)
|
| 41 |
+
(mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P)) ≤ z*(ε+2*(A+B)) := by
|
| 42 |
+
classical
|
| 43 |
+
intro L
|
| 44 |
+
let Q (i:u.T×u.T) (x:Fin z):=
|
| 45 |
+
|mapW (w.displayMass t φ (μ (L i)) (F i) m (s (L i)) Y) P x-
|
| 46 |
+
mapW (w.sales t φ (μ (L i)) (F i) m (s (L i))) P x|
|
| 47 |
+
let V:= pairW omega_ omega_
|
| 48 |
+
have h (x : Fin z) :
|
| 49 |
+
avg V (fun i=>Q i x) ≤ ε+ 2*(A+B) := by
|
| 50 |
+
let H k:= P k=x
|
| 51 |
+
let R:= w.flunk t φ Y (fun i=>ind (H i)) m v ε
|
| 52 |
+
let Z (i:UnitType p n N):= ¬ w.matchesArea t φ Y i v
|
| 53 |
+
let S o:=R o∨ Z o
|
| 54 |
+
have heq (i): Q i x≤ ε+2*pr (μ (L i)) S := by
|
| 55 |
+
refine w.display_test t φ (μ (L i)) (F i) m (s (L i)) Y H (hμ _) hw hν S he
|
| 56 |
+
(fun y hy hz=> ?_)
|
| 57 |
+
by_cases hf :Z y
|
| 58 |
+
· exact Or.inr hf
|
| 59 |
+
exact Or.inl ⟨hF _ _ hy,not_not.mp hf,s (L i),hz⟩
|
| 60 |
+
let U:=mixW omega_ μ
|
| 61 |
+
have hu : IsLaw U:=mixW_law hv hμ
|
| 62 |
+
have hm (o) : avg omega_ (fun i=>pr (μ i) o)= pr U o := (mixW_avg ..).symm
|
| 63 |
+
apply (avg_side_bounds omega_ hv b (fun i=>ε+2*pr (μ i) S) _ heq).trans
|
| 64 |
+
rw [avg_add,avg_mul',hm,hv.avg_const]
|
| 65 |
+
exact add_le_add_right (mul_le_mul_of_nonneg_left ((pr_or_le hu.nz).trans
|
| 66 |
+
(add_le_add (ha _) hh)) (by norm_num)) _
|
| 67 |
+
change avg V (fun x=> ∑ i,Q x i) ≤ _
|
| 68 |
+
rw [avg_sum]; exact (Finset.sum_le_sum fun i _=> h i).trans_eq (by simp; ring)
|
| 69 |
+
end Quill
|
| 70 |
+
|
| 71 |
+
open Station PreparationParameters
|
| 72 |
+
namespace Station
|
| 73 |
+
variable {w:LeafMixture p n N} (t:Station p n N K w)
|
| 74 |
+
(x:Typus p q d e) (m:Mixer p n) (k: Fin (2^deckMax p K))
|
| 75 |
+
(μ:Wgt (UnitType p n N)) (Y:Silhouette p N r)
|
| 76 |
+
|
| 77 |
+
theorem gauzed_area (Y:Silhouette p N r) (w : Quill p q d b)
|
| 78 |
+
(t: Tagging p (Messenger q)) (u : Messenger q → F)
|
| 79 |
+
(h:w.moral t u) (δ:ℝ)
|
| 80 |
+
{K : ℕ} {m:Mixer p n} {ε v:ℝ} (he:ε≤v)
|
| 81 |
+
(o : UnitType p n N) (hc:gauze p ε δ Y m K o) :
|
| 82 |
+
w.matchesArea t u Y o v := by
|
| 83 |
+
intro i; have heq := w.allure_apt t u h i
|
| 84 |
+
exact ((hc _ (w.allure t u i)).1 heq).trans he
|
| 85 |
+
|
| 86 |
+
set_option maxHeartbeats 1200000 in
|
| 87 |
+
theorem projectSum (P : Keys (p:=p) x.t N→Fin z)
|
| 88 |
+
(h :apart w.T) (hm:IsLaw μ) (hw :∀ i∈w.T,0<partMass μ i) (hs : 0<w.amount μ)
|
| 89 |
+
(ha : ∀ i,IsLaw (x.qA.policies x.t x.z n i)) (hb:∀ i,IsLaw (x.qB.policies x.t x.z n i))
|
| 90 |
+
(hν : IsLaw (lawNu p N x.t x.z)) (ε v v' τ B δ : ℝ) (he:0≤ε)
|
| 91 |
+
(hf : x.permission)
|
| 92 |
+
(ht : τ ≤ v ∧ τ≤v')
|
| 93 |
+
(hh : pr (w.sap μ) (fun i=>¬gauze p τ δ Y m K i)≤B)
|
| 94 |
+
(hx : ∀ i:Fin z,pr (w.sap μ) (x.qA.flunk x.t x.z Y (fun y=>ind (P y=i)) m v ε)≤B)
|
| 95 |
+
(hy : ∀ i:Fin z,pr (w.sap μ) (x.qB.flunk x.t x.z Y (fun y=>ind (P y=i)) m v' ε)≤B) :
|
| 96 |
+
t.due x m μ k Y P≤2*(z*(ε+2*(B+B))) := by
|
| 97 |
+
classical
|
| 98 |
+
obtain ⟨hp,hq⟩:=rebuild hm.nz h hw hs
|
| 99 |
+
let A (i:w.T):=partW μ i.val
|
| 100 |
+
let u:=portionW μ w.T
|
| 101 |
+
have hQ : w.sap μ=mixW u A :=hq
|
| 102 |
+
let V:=pairW u u; have hA i:IsLaw (A i):=on_law hm.nz (hw i.val i.property)
|
| 103 |
+
have hL : avg V (fun i=> taxLeft t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := by
|
| 104 |
+
refine x.qA.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i d) A hA P
|
| 105 |
+
(fun i=> t.frontPage x m i.1 i.2 k) (fun i o h => h.2.2.1) ha hν ε v B B he
|
| 106 |
+
(fun i=>by rw [←hQ]; exact hx i) ?_
|
| 107 |
+
rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hh
|
| 108 |
+
exact fun i hi h=> hi (gauzed_area _ _ _ _ hf.2.1 δ ht.1 i h)
|
| 109 |
+
have hR : avg V (fun i=> taxRight t x m μ k Y P i.1 i.2) ≤ z*(ε+2*(B+B)) := by
|
| 110 |
+
refine x.qB.oneTrestle m x.t x.z w Y u hp (fun i=>t.cAxes i e) A hA P
|
| 111 |
+
(fun i=> t.backPage x m i.1 i.2 k) (fun i o h => h.2.2.1) hb hν ε v' B B he
|
| 112 |
+
(fun i=>by rw [←hQ]; exact hy i) ?_
|
| 113 |
+
rw [←hQ]; apply (pr_mono (LeafMixture.sapLaw hs hm).nz ?_).trans hh
|
| 114 |
+
exact fun i hi h=>hi (gauzed_area _ _ _ _ hf.2.2.1 δ ht.2 i h)
|
| 115 |
+
unfold due; rw [avg_add,two_mul]
|
| 116 |
+
exact add_le_add hL hR
|
| 117 |
+
|
| 118 |
+
end Station
|
| 119 |
+
end StatusAnalysis
|
| 120 |
+
end HadwigerCounterexample
|
| 121 |
+
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AdaptiveRecordBounds.lean
CHANGED
|
@@ -1,102 +1,102 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.IndependentTestWitnesses
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Adaptive Record Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Module Submodule Function Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N r : ℕ} {T : Cov p N}
|
| 12 |
-
|
| 13 |
-
def quest (p : Shape) (r k n N : ℕ) (H ε : ℝ) :=
|
| 14 |
-
∀ x : ℕ,x≤2*r →
|
| 15 |
-
bp ((x:ℝ)*N)*bp (0.51*k*N)*(H*heatRate p n N ε x k)≤bp (-0.2*N)
|
| 16 |
-
|
| 17 |
-
namespace Bazaar
|
| 18 |
-
variable (s : Bazaar p n r T)
|
| 19 |
-
|
| 20 |
-
set_option maxHeartbeats 800000 in
|
| 21 |
-
private theorem probe_event {w : Wgt (UnitType p n N)} {Δ}
|
| 22 |
-
(hw : IsLaw w) (h : s.opened Δ w)
|
| 23 |
-
(S : Party) (j : Bool) (hi : S j=1) {k : ℕ}
|
| 24 |
-
{q : Place p→ℕ} (R : DTuple (p:=p) q N) (F : Catalog p T r q)
|
| 25 |
-
(hq : ctot p q=k) (hr : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))
|
| 26 |
-
(m : Mixer p n) {ε H : ℝ} (he₀ : initCap p N m ε) (hH : 0≤H) (hZ : quest p r k n N H ε)
|
| 27 |
-
(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)
|
| 28 |
-
(hT : num (Atlas p r T) ≤ bp (0.002*N)) :
|
| 29 |
-
pr w (fun x => s.atList S j R F x ∧ glimpse p x j R) ≤ bp (-0.1*N) := by
|
| 30 |
-
classical
|
| 31 |
-
let P (M : Atlas p r T) (z : Batch M N) (v : DTuple (p:=p) q N) :=
|
| 32 |
-
fun x => basisFrom p (x : UnitType p n N) j z ∧ glimpse p x j R ∧ thermal p x S R=v
|
| 33 |
-
let L (M : Atlas p r T) (x) := standard M ∧ ∃ z,∃ v∈ F M z,P M z v x
|
| 34 |
-
have he x : w x≠0 → s.atList S j R F x ∧ glimpse p x j R →
|
| 35 |
-
∃ M,L M x := by
|
| 36 |
-
rintro hx ⟨hx',hy⟩
|
| 37 |
-
exact ⟨s.ix x,(h x hx).1,s.bag (s.ix x) j x, thermal p x S R,hx',
|
| 38 |
-
((h x hx).2 j).1,hy,rfl⟩
|
| 39 |
-
have ht (M : Atlas p r T) : pr w (L M) ≤ bp (-0.2*N) := by
|
| 40 |
-
by_cases hu : standard M
|
| 41 |
-
· let x := cells M
|
| 42 |
-
have hb (z : Batch M N) :
|
| 43 |
-
pr w (fun y => ∃ v∈F M z,P M z v y) ≤ bp (0.51*k*N)*(H*heatRate p n N ε x k) := by
|
| 44 |
-
have ha v : pr w (P M z v) ≤ H*heatRate p n N ε x k := by
|
| 45 |
-
rw [← hq]; exact (pr_cap hg _).trans
|
| 46 |
-
(mul_le_mul_of_nonneg_left (heat_rate _ S hi R v z m he₀) hH)
|
| 47 |
-
refine (pr_union_le hw.nz (F M z) (P M z)).trans ((Finset.sum_le_sum fun v _ => ha v).trans ?_)
|
| 48 |
-
rw [Finset.sum_const,nsmul_eq_mul]
|
| 49 |
-
apply mul_le_mul_of_nonneg_right (hr M z)
|
| 50 |
-
unfold heatRate
|
| 51 |
-
exact mul_nonneg hH (mul_nonneg (bp_pos _).le (bp_pos _).le)
|
| 52 |
-
simp only [L,hu,true_and]
|
| 53 |
-
refine (pr_exists_le hw.nz (fun z y => ∃ v∈F M z,P M z v y)).trans
|
| 54 |
-
((Finset.sum_le_sum (fun z _ => hb z)).trans ?_)
|
| 55 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_space]
|
| 56 |
-
rw [show dim (Batch M N)=x*N from tuple_dim.trans (Nat.mul_comm ..),
|
| 57 |
-
Nat.cast_mul, ← mul_assoc]
|
| 58 |
-
exact hZ x hu.2.1
|
| 59 |
-
simp only [L,hu,false_and,pr_false]
|
| 60 |
-
exact (bp_pos _).le
|
| 61 |
-
refine ((pr_on_mono hw.nz he).trans (pr_exists_le hw.nz L)).trans
|
| 62 |
-
((Finset.sum_le_sum fun i _ => ht i).trans ?_)
|
| 63 |
-
rw [Finset.sum_const,nsmul_eq_mul]
|
| 64 |
-
apply (mul_le_mul_of_nonneg_right hT (bp_pos _).le).trans
|
| 65 |
-
rw [←bp_add]
|
| 66 |
-
apply bp_le; linarith [(Nat.cast_nonneg N : 0≤(N:ℝ))]
|
| 67 |
-
|
| 68 |
-
set_option maxHeartbeats 600000 in
|
| 69 |
-
theorem frequent_sparse {w : Wgt (UnitType p n N)} {Δ}
|
| 70 |
-
(hw : IsLaw w) (h : s.opened Δ w)
|
| 71 |
-
(S : Party) (j : Bool) (hi : S j=1)
|
| 72 |
-
(k d : ℕ) (hh : k ≤ d) (l : ℝ) (hl : 0< l)
|
| 73 |
-
(hC : ∀ C : Cov p N,cdim p C≤d → pr w (fun x => offsetCov (s.ix x) ≤ C) ≤ l)
|
| 74 |
-
(hb : ∀ A M Z,(↑(s.bids w S j A M Z).card:ℝ) ≤ bp (0.51*N))
|
| 75 |
-
(m : Mixer p n) {ε H L : ℝ} (hN : 2*num (Full p n)-N≤ -1)
|
| 76 |
-
(he : initCap p N m ε)
|
| 77 |
-
(hH : 0≤H) (hZ : quest p r k n N H ε)
|
| 78 |
-
(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)
|
| 79 |
-
(hL : 0 ≤ L) (hv : bySide p w m L)
|
| 80 |
-
(hT : num (Atlas p r T) ≤ bp (0.002*N))
|
| 81 |
-
(hk : glimpsesBill p k L+bp (-0.1*N)<l^(k+1)) :
|
| 82 |
-
pr (pairW w w) (fun x => s.frequent w S j (s.ix x.1) (s.ix x.2) x.2) ≤5*l := by
|
| 83 |
-
classical
|
| 84 |
-
by_contra! hr
|
| 85 |
-
obtain ⟨q,R,F,hq,hR,hF,hx⟩ := s.shooting hw S j k d hh l hl hr.le hC hb
|
| 86 |
-
have hp := s.probe_event hw h S j hi R F hq hF m he hH hZ hg hT
|
| 87 |
-
have hq' z : q z≤ k := hq ▸ Finset.single_le_sum (fun i _ => Nat.zero_le (q i))
|
| 88 |
-
(Finset.mem_univ z)
|
| 89 |
-
have hu := glimpse_failure m hL hv hw.sub j hN R k hR hq'
|
| 90 |
-
let T := fun (x : UnitType p n N) => glimpse p x j R
|
| 91 |
-
let V := s.atList S j R F
|
| 92 |
-
have hh' x : V x → ¬T x ∨ (V x ∧ T x) := fun h => by by_cases ht:T x <;> simp [ht,h]
|
| 93 |
-
exact not_lt_of_ge
|
| 94 |
-
(hx.trans ((pr_mono hw.nz hh').trans ((pr_or_le hw.nz).trans (add_le_add hu hp)))) hk
|
| 95 |
-
|
| 96 |
-
end Bazaar
|
| 97 |
-
|
| 98 |
-
end HadwigerCounterexample
|
| 99 |
-
|
| 100 |
-
end
|
| 101 |
-
|
| 102 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.IndependentTestWitnesses
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Adaptive Record Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Module Submodule Function Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N r : ℕ} {T : Cov p N}
|
| 12 |
+
|
| 13 |
+
def quest (p : Shape) (r k n N : ℕ) (H ε : ℝ) :=
|
| 14 |
+
∀ x : ℕ,x≤2*r →
|
| 15 |
+
bp ((x:ℝ)*N)*bp (0.51*k*N)*(H*heatRate p n N ε x k)≤bp (-0.2*N)
|
| 16 |
+
|
| 17 |
+
namespace Bazaar
|
| 18 |
+
variable (s : Bazaar p n r T)
|
| 19 |
+
|
| 20 |
+
set_option maxHeartbeats 800000 in
|
| 21 |
+
private theorem probe_event {w : Wgt (UnitType p n N)} {Δ}
|
| 22 |
+
(hw : IsLaw w) (h : s.opened Δ w)
|
| 23 |
+
(S : Party) (j : Bool) (hi : S j=1) {k : ℕ}
|
| 24 |
+
{q : Place p→ℕ} (R : DTuple (p:=p) q N) (F : Catalog p T r q)
|
| 25 |
+
(hq : ctot p q=k) (hr : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))
|
| 26 |
+
(m : Mixer p n) {ε H : ℝ} (he₀ : initCap p N m ε) (hH : 0≤H) (hZ : quest p r k n N H ε)
|
| 27 |
+
(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)
|
| 28 |
+
(hT : num (Atlas p r T) ≤ bp (0.002*N)) :
|
| 29 |
+
pr w (fun x => s.atList S j R F x ∧ glimpse p x j R) ≤ bp (-0.1*N) := by
|
| 30 |
+
classical
|
| 31 |
+
let P (M : Atlas p r T) (z : Batch M N) (v : DTuple (p:=p) q N) :=
|
| 32 |
+
fun x => basisFrom p (x : UnitType p n N) j z ∧ glimpse p x j R ∧ thermal p x S R=v
|
| 33 |
+
let L (M : Atlas p r T) (x) := standard M ∧ ∃ z,∃ v∈ F M z,P M z v x
|
| 34 |
+
have he x : w x≠0 → s.atList S j R F x ∧ glimpse p x j R →
|
| 35 |
+
∃ M,L M x := by
|
| 36 |
+
rintro hx ⟨hx',hy⟩
|
| 37 |
+
exact ⟨s.ix x,(h x hx).1,s.bag (s.ix x) j x, thermal p x S R,hx',
|
| 38 |
+
((h x hx).2 j).1,hy,rfl⟩
|
| 39 |
+
have ht (M : Atlas p r T) : pr w (L M) ≤ bp (-0.2*N) := by
|
| 40 |
+
by_cases hu : standard M
|
| 41 |
+
· let x := cells M
|
| 42 |
+
have hb (z : Batch M N) :
|
| 43 |
+
pr w (fun y => ∃ v∈F M z,P M z v y) ≤ bp (0.51*k*N)*(H*heatRate p n N ε x k) := by
|
| 44 |
+
have ha v : pr w (P M z v) ≤ H*heatRate p n N ε x k := by
|
| 45 |
+
rw [← hq]; exact (pr_cap hg _).trans
|
| 46 |
+
(mul_le_mul_of_nonneg_left (heat_rate _ S hi R v z m he₀) hH)
|
| 47 |
+
refine (pr_union_le hw.nz (F M z) (P M z)).trans ((Finset.sum_le_sum fun v _ => ha v).trans ?_)
|
| 48 |
+
rw [Finset.sum_const,nsmul_eq_mul]
|
| 49 |
+
apply mul_le_mul_of_nonneg_right (hr M z)
|
| 50 |
+
unfold heatRate
|
| 51 |
+
exact mul_nonneg hH (mul_nonneg (bp_pos _).le (bp_pos _).le)
|
| 52 |
+
simp only [L,hu,true_and]
|
| 53 |
+
refine (pr_exists_le hw.nz (fun z y => ∃ v∈F M z,P M z v y)).trans
|
| 54 |
+
((Finset.sum_le_sum (fun z _ => hb z)).trans ?_)
|
| 55 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_space]
|
| 56 |
+
rw [show dim (Batch M N)=x*N from tuple_dim.trans (Nat.mul_comm ..),
|
| 57 |
+
Nat.cast_mul, ← mul_assoc]
|
| 58 |
+
exact hZ x hu.2.1
|
| 59 |
+
simp only [L,hu,false_and,pr_false]
|
| 60 |
+
exact (bp_pos _).le
|
| 61 |
+
refine ((pr_on_mono hw.nz he).trans (pr_exists_le hw.nz L)).trans
|
| 62 |
+
((Finset.sum_le_sum fun i _ => ht i).trans ?_)
|
| 63 |
+
rw [Finset.sum_const,nsmul_eq_mul]
|
| 64 |
+
apply (mul_le_mul_of_nonneg_right hT (bp_pos _).le).trans
|
| 65 |
+
rw [←bp_add]
|
| 66 |
+
apply bp_le; linarith [(Nat.cast_nonneg N : 0≤(N:ℝ))]
|
| 67 |
+
|
| 68 |
+
set_option maxHeartbeats 600000 in
|
| 69 |
+
theorem frequent_sparse {w : Wgt (UnitType p n N)} {Δ}
|
| 70 |
+
(hw : IsLaw w) (h : s.opened Δ w)
|
| 71 |
+
(S : Party) (j : Bool) (hi : S j=1)
|
| 72 |
+
(k d : ℕ) (hh : k ≤ d) (l : ℝ) (hl : 0< l)
|
| 73 |
+
(hC : ∀ C : Cov p N,cdim p C≤d → pr w (fun x => offsetCov (s.ix x) ≤ C) ≤ l)
|
| 74 |
+
(hb : ∀ A M Z,(↑(s.bids w S j A M Z).card:ℝ) ≤ bp (0.51*N))
|
| 75 |
+
(m : Mixer p n) {ε H L : ℝ} (hN : 2*num (Full p n)-N≤ -1)
|
| 76 |
+
(he : initCap p N m ε)
|
| 77 |
+
(hH : 0≤H) (hZ : quest p r k n N H ε)
|
| 78 |
+
(hg : ∀ x,w x≤H*pairW (raw m N) (raw m N) x)
|
| 79 |
+
(hL : 0 ≤ L) (hv : bySide p w m L)
|
| 80 |
+
(hT : num (Atlas p r T) ≤ bp (0.002*N))
|
| 81 |
+
(hk : glimpsesBill p k L+bp (-0.1*N)<l^(k+1)) :
|
| 82 |
+
pr (pairW w w) (fun x => s.frequent w S j (s.ix x.1) (s.ix x.2) x.2) ≤5*l := by
|
| 83 |
+
classical
|
| 84 |
+
by_contra! hr
|
| 85 |
+
obtain ⟨q,R,F,hq,hR,hF,hx⟩ := s.shooting hw S j k d hh l hl hr.le hC hb
|
| 86 |
+
have hp := s.probe_event hw h S j hi R F hq hF m he hH hZ hg hT
|
| 87 |
+
have hq' z : q z≤ k := hq ▸ Finset.single_le_sum (fun i _ => Nat.zero_le (q i))
|
| 88 |
+
(Finset.mem_univ z)
|
| 89 |
+
have hu := glimpse_failure m hL hv hw.sub j hN R k hR hq'
|
| 90 |
+
let T := fun (x : UnitType p n N) => glimpse p x j R
|
| 91 |
+
let V := s.atList S j R F
|
| 92 |
+
have hh' x : V x → ¬T x ∨ (V x ∧ T x) := fun h => by by_cases ht:T x <;> simp [ht,h]
|
| 93 |
+
exact not_lt_of_ge
|
| 94 |
+
(hx.trans ((pr_mono hw.nz hh').trans ((pr_or_le hw.nz).trans (add_le_add hu hp)))) hk
|
| 95 |
+
|
| 96 |
+
end Bazaar
|
| 97 |
+
|
| 98 |
+
end HadwigerCounterexample
|
| 99 |
+
|
| 100 |
+
end
|
| 101 |
+
|
| 102 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AdditionalProbeBounds.lean
CHANGED
|
@@ -1,171 +1,171 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.SingletonPhaseTests
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Additional Probe Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module Submodule Function Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J K : Type} [Fintype I] [Fintype J] [Fintype K]
|
| 12 |
-
|
| 13 |
-
private def moreMatrix {r : ℕ} (A : Mat I (Fin r)) (v : Vec I) : Mat I (Fin (r+1)) :=
|
| 14 |
-
Matrix.of (fun i => Fin.cons (v i) (A i))
|
| 15 |
-
|
| 16 |
-
omit [Fintype I] in
|
| 17 |
-
private theorem moreMatrix_act {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)
|
| 18 |
-
(x : Vec (Fin (r+1))) :
|
| 19 |
-
moreMatrix A v *ᵥ x=x 0 • v + A *ᵥ (fun i => x i.succ) := by
|
| 20 |
-
funext i; simp only [Matrix.mulVec,dotProduct,moreMatrix,Matrix.of_apply,
|
| 21 |
-
Fin.sum_univ_succ,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Fin.cons_zero,Fin.cons_succ]
|
| 22 |
-
congr 1; exact mul_comm _ _
|
| 23 |
-
|
| 24 |
-
omit [Fintype I] in
|
| 25 |
-
private theorem moreMatrix_inj {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)
|
| 26 |
-
(ha : Injective A.mulVec) (h : v∉colSp A) :
|
| 27 |
-
Injective (moreMatrix A v).mulVec := by
|
| 28 |
-
rw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]
|
| 29 |
-
intro x hx
|
| 30 |
-
rw [moreMatrix_act] at hx
|
| 31 |
-
let b (i : Fin r) := x i.succ
|
| 32 |
-
rcases bit_cases (x 0) with he|he
|
| 33 |
-
· have hh : b=0 := by
|
| 34 |
-
apply ha
|
| 35 |
-
rw [he,zero_smul,zero_add] at hx
|
| 36 |
-
exact hx.trans (Matrix.mulVec_zero _).symm
|
| 37 |
-
funext i
|
| 38 |
-
refine Fin.cases he (fun k => ?_) i
|
| 39 |
-
exact congr_fun hh k
|
| 40 |
-
· rw [he,one_smul] at hx
|
| 41 |
-
have heq : v=A *ᵥ b := add_right_cancel (hx.trans (char_two _).symm)
|
| 42 |
-
exact (h ⟨b,heq.symm⟩).elim
|
| 43 |
-
|
| 44 |
-
omit [Fintype J] in
|
| 45 |
-
private theorem moreMatrix_mul {r} (B : Mat J I) (A : Mat I (Fin r)) (v) :
|
| 46 |
-
B*moreMatrix A v=moreMatrix (B*A) (B *ᵥ v) := by
|
| 47 |
-
ext i j
|
| 48 |
-
refine Fin.cases ?_ (fun j => ?_) j
|
| 49 |
-
· rfl
|
| 50 |
-
simp only [moreMatrix,Matrix.mul_apply,Matrix.of_apply,Fin.cons_succ]
|
| 51 |
-
|
| 52 |
-
variable {p : Shape} {n N r : ℕ} {T : Cov p N}
|
| 53 |
-
variable {q : Place p → ℕ}
|
| 54 |
-
|
| 55 |
-
private def growFmt (q : Place p→ℕ) (z : Place p) := fun i =>
|
| 56 |
-
q i+(if i=z then 1 else 0)
|
| 57 |
-
|
| 58 |
-
private theorem grow_sum (q : Place p→ℕ) (z : Place p) :
|
| 59 |
-
ctot p (growFmt (p:=p) q z)=ctot p q+1 := by simp [growFmt,ctot,Finset.sum_add_distrib]
|
| 60 |
-
|
| 61 |
-
private def growing (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N)) :
|
| 62 |
-
DTuple (p:=p) (growFmt (p:=p) q z) N := fun i => by
|
| 63 |
-
change Mat (Fin N) (Fin (q i+ if i=z then 1 else 0))
|
| 64 |
-
by_cases h : i=z
|
| 65 |
-
· rw [ite_eq_left h]; exact moreMatrix (A i) v
|
| 66 |
-
rw [ite_eq_right h]; exact A i
|
| 67 |
-
|
| 68 |
-
private theorem castMat_inj {r n m : ℕ} (e : r=n)
|
| 69 |
-
(A : Mat (Fin m) (Fin r)) (h : Injective A.mulVec) :
|
| 70 |
-
Injective (cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A).mulVec := by
|
| 71 |
-
subst n
|
| 72 |
-
exact h
|
| 73 |
-
private theorem castMat_prod {r n m : ℕ} (e : r=n)
|
| 74 |
-
(A : Mat (Fin m) (Fin r)) (B : Mat (Fin m) (Fin m)) :
|
| 75 |
-
B*(cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A) =
|
| 76 |
-
cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) (B*A) := by
|
| 77 |
-
subst n; rfl
|
| 78 |
-
|
| 79 |
-
private theorem growth_inj (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))
|
| 80 |
-
(hv : v∉colSp (A z)) (h : ∀ i, Injective (A i).mulVec) :
|
| 81 |
-
∀ i,Injective (growing A z v i).mulVec := by
|
| 82 |
-
intro i
|
| 83 |
-
by_cases he : i=z
|
| 84 |
-
· subst i
|
| 85 |
-
simp [growing,growFmt]
|
| 86 |
-
apply castMat_inj _ (moreMatrix (A z) v) (moreMatrix_inj (A z) v (h z) hv)
|
| 87 |
-
simp
|
| 88 |
-
simp [growing,growFmt,he]
|
| 89 |
-
apply castMat_inj _ (A i) (h i)
|
| 90 |
-
simp [he]
|
| 91 |
-
|
| 92 |
-
private theorem growth_value (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))
|
| 93 |
-
(x : UnitType p n N) (S : Party) :
|
| 94 |
-
thermal p x S (growing A z v)=growing (thermal p x S A) z (heat p x S z *ᵥ v) := by
|
| 95 |
-
funext i
|
| 96 |
-
by_cases he : i=z
|
| 97 |
-
· subst i
|
| 98 |
-
simp [thermal,growing,growFmt]
|
| 99 |
-
rw [←moreMatrix_mul]
|
| 100 |
-
apply castMat_prod
|
| 101 |
-
simp
|
| 102 |
-
simp [thermal,growing,growFmt,he]
|
| 103 |
-
apply castMat_prod
|
| 104 |
-
simp [he]
|
| 105 |
-
|
| 106 |
-
theorem column_observe (A : DTuple (p:=p) q N) (z : Place p) (j : Fin (q z))
|
| 107 |
-
(x : UnitType p n N) (S : Party) :
|
| 108 |
-
heat p x S z *ᵥ (A z).col j=(thermal p x S A z).col j := rfl
|
| 109 |
-
|
| 110 |
-
namespace Bazaar
|
| 111 |
-
variable (s : Bazaar p n r T)
|
| 112 |
-
|
| 113 |
-
abbrev Catalog (p : Shape) {N} (T : Cov p N) (r : ℕ) (q : Place p→ℕ) :=
|
| 114 |
-
(M : Atlas p r T) → Batch M N → Finset (DTuple (p:=p) q N)
|
| 115 |
-
|
| 116 |
-
def atList (s : Bazaar p n r T) (S : Party) (j : Bool)
|
| 117 |
-
(A : DTuple (p:=p) q N) (F : Catalog p T r q) (x : UnitType p n N) :=
|
| 118 |
-
let M := s.ix x
|
| 119 |
-
thermal p x S A∈ F M (s.bag M j x)
|
| 120 |
-
|
| 121 |
-
def probed (p : Shape) {N} {q : Place p→ℕ} (A : DTuple (p:=p) q N) : Cov p N :=
|
| 122 |
-
fun z => colSp (A z)
|
| 123 |
-
|
| 124 |
-
theorem extend_probe (w : Wgt (UnitType p n N)) (S : Party) (j : Bool) {k : ℕ}
|
| 125 |
-
(A : DTuple (p:=p) q N) (hq : ctot p q=k)
|
| 126 |
-
(h : ∀ i, Injective (A i).mulVec)
|
| 127 |
-
(F : Catalog p T r q) (hF : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))
|
| 128 |
-
(G : Atlas p r T) (hg : ¬ offsetCov G ≤ probed p A)
|
| 129 |
-
(hb : ∀ M Z,(↑(s.bids w S j G M Z).card:ℝ) ≤ bp (0.51*N)) :
|
| 130 |
-
∃ (q : Place p→ℕ) (A' : DTuple (p:=p) q N)
|
| 131 |
-
(F' : Catalog p T r q), ctot p q=k+1 ∧
|
| 132 |
-
(∀ i, Injective (A' i).mulVec) ∧
|
| 133 |
-
(∀ M Z,(↑(F' M Z).card:ℝ) ≤ bp (0.51*(k+1)*N)) ∧
|
| 134 |
-
∀ x,s.atList S j A F x → s.frequent w S j G (s.ix x) x →
|
| 135 |
-
s.atList S j A' F' x := by
|
| 136 |
-
classical
|
| 137 |
-
obtain ⟨z,i,hg⟩ :
|
| 138 |
-
∃ (z : Place p) (i : Fin (breadth G z)),(src G z).col i∉colSp (A z) := by
|
| 139 |
-
by_contra! hh
|
| 140 |
-
apply hg
|
| 141 |
-
intro z
|
| 142 |
-
change colSp (src G z) ≤ _
|
| 143 |
-
rw [colSp,range_mulVecLin]
|
| 144 |
-
exact Submodule.span_le.mpr (Set.range_subset_iff.mpr (hh z))
|
| 145 |
-
let q' := growFmt (p:=p) q z
|
| 146 |
-
let v := (src G z).col i
|
| 147 |
-
let f (M Z) : Finset (DTuple (p:=p) q' N) :=
|
| 148 |
-
((F M Z) ×ˢ (s.bids w S j G M Z)).image
|
| 149 |
-
(fun a => growing a.1 z ((a.2 z).col i))
|
| 150 |
-
refine ⟨q',growing A z v, f,(grow_sum q z).trans (by rw [hq]),
|
| 151 |
-
growth_inj A z v hg h,fun M Z => ?_,fun x hx hi => ?_⟩
|
| 152 |
-
· have he := bp_pos (0.51*(k:ℝ)*N)
|
| 153 |
-
have h1 :
|
| 154 |
-
(↑(f M Z).card:ℝ) ≤ (↑(F M Z).card:ℝ)*(↑(s.bids w S j G M Z).card:ℝ) := by
|
| 155 |
-
exact_mod_cast (show (f M Z).card ≤ _*_ from
|
| 156 |
-
Finset.card_image_le.trans_eq (Finset.card_product ..))
|
| 157 |
-
apply (h1.trans (mul_le_mul (hF M Z) (hb M Z) (Nat.cast_nonneg _) he.le)).trans_eq
|
| 158 |
-
rw [←bp_add]; congr 1; ring
|
| 159 |
-
· rw [atList,growth_value]
|
| 160 |
-
|
| 161 |
-
refine Finset.mem_image.mpr ⟨(thermal p x S A,thermal p x S (src G)),?_,?_⟩
|
| 162 |
-
· exact Finset.mem_product.mpr ⟨hx,(s.bids_mem ..).mp hi⟩
|
| 163 |
-
· change growing _ _ _ = _
|
| 164 |
-
rw [show heat p x S z *ᵥ v=_ from column_observe (src G) z i x S]
|
| 165 |
-
|
| 166 |
-
end Bazaar
|
| 167 |
-
end HadwigerCounterexample
|
| 168 |
-
|
| 169 |
-
end
|
| 170 |
-
|
| 171 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.SingletonPhaseTests
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Additional Probe Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module Submodule Function Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J K : Type} [Fintype I] [Fintype J] [Fintype K]
|
| 12 |
+
|
| 13 |
+
private def moreMatrix {r : ℕ} (A : Mat I (Fin r)) (v : Vec I) : Mat I (Fin (r+1)) :=
|
| 14 |
+
Matrix.of (fun i => Fin.cons (v i) (A i))
|
| 15 |
+
|
| 16 |
+
omit [Fintype I] in
|
| 17 |
+
private theorem moreMatrix_act {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)
|
| 18 |
+
(x : Vec (Fin (r+1))) :
|
| 19 |
+
moreMatrix A v *ᵥ x=x 0 • v + A *ᵥ (fun i => x i.succ) := by
|
| 20 |
+
funext i; simp only [Matrix.mulVec,dotProduct,moreMatrix,Matrix.of_apply,
|
| 21 |
+
Fin.sum_univ_succ,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Fin.cons_zero,Fin.cons_succ]
|
| 22 |
+
congr 1; exact mul_comm _ _
|
| 23 |
+
|
| 24 |
+
omit [Fintype I] in
|
| 25 |
+
private theorem moreMatrix_inj {r : ℕ} (A : Mat I (Fin r)) (v : Vec I)
|
| 26 |
+
(ha : Injective A.mulVec) (h : v∉colSp A) :
|
| 27 |
+
Injective (moreMatrix A v).mulVec := by
|
| 28 |
+
rw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]
|
| 29 |
+
intro x hx
|
| 30 |
+
rw [moreMatrix_act] at hx
|
| 31 |
+
let b (i : Fin r) := x i.succ
|
| 32 |
+
rcases bit_cases (x 0) with he|he
|
| 33 |
+
· have hh : b=0 := by
|
| 34 |
+
apply ha
|
| 35 |
+
rw [he,zero_smul,zero_add] at hx
|
| 36 |
+
exact hx.trans (Matrix.mulVec_zero _).symm
|
| 37 |
+
funext i
|
| 38 |
+
refine Fin.cases he (fun k => ?_) i
|
| 39 |
+
exact congr_fun hh k
|
| 40 |
+
· rw [he,one_smul] at hx
|
| 41 |
+
have heq : v=A *ᵥ b := add_right_cancel (hx.trans (char_two _).symm)
|
| 42 |
+
exact (h ⟨b,heq.symm⟩).elim
|
| 43 |
+
|
| 44 |
+
omit [Fintype J] in
|
| 45 |
+
private theorem moreMatrix_mul {r} (B : Mat J I) (A : Mat I (Fin r)) (v) :
|
| 46 |
+
B*moreMatrix A v=moreMatrix (B*A) (B *ᵥ v) := by
|
| 47 |
+
ext i j
|
| 48 |
+
refine Fin.cases ?_ (fun j => ?_) j
|
| 49 |
+
· rfl
|
| 50 |
+
simp only [moreMatrix,Matrix.mul_apply,Matrix.of_apply,Fin.cons_succ]
|
| 51 |
+
|
| 52 |
+
variable {p : Shape} {n N r : ℕ} {T : Cov p N}
|
| 53 |
+
variable {q : Place p → ℕ}
|
| 54 |
+
|
| 55 |
+
private def growFmt (q : Place p→ℕ) (z : Place p) := fun i =>
|
| 56 |
+
q i+(if i=z then 1 else 0)
|
| 57 |
+
|
| 58 |
+
private theorem grow_sum (q : Place p→ℕ) (z : Place p) :
|
| 59 |
+
ctot p (growFmt (p:=p) q z)=ctot p q+1 := by simp [growFmt,ctot,Finset.sum_add_distrib]
|
| 60 |
+
|
| 61 |
+
private def growing (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N)) :
|
| 62 |
+
DTuple (p:=p) (growFmt (p:=p) q z) N := fun i => by
|
| 63 |
+
change Mat (Fin N) (Fin (q i+ if i=z then 1 else 0))
|
| 64 |
+
by_cases h : i=z
|
| 65 |
+
· rw [ite_eq_left h]; exact moreMatrix (A i) v
|
| 66 |
+
rw [ite_eq_right h]; exact A i
|
| 67 |
+
|
| 68 |
+
private theorem castMat_inj {r n m : ℕ} (e : r=n)
|
| 69 |
+
(A : Mat (Fin m) (Fin r)) (h : Injective A.mulVec) :
|
| 70 |
+
Injective (cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A).mulVec := by
|
| 71 |
+
subst n
|
| 72 |
+
exact h
|
| 73 |
+
private theorem castMat_prod {r n m : ℕ} (e : r=n)
|
| 74 |
+
(A : Mat (Fin m) (Fin r)) (B : Mat (Fin m) (Fin m)) :
|
| 75 |
+
B*(cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) A) =
|
| 76 |
+
cast (show Mat (Fin m) (Fin r)=Mat (Fin m) (Fin n) from congrArg (fun t => Mat (Fin m) (Fin t)) e) (B*A) := by
|
| 77 |
+
subst n; rfl
|
| 78 |
+
|
| 79 |
+
private theorem growth_inj (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))
|
| 80 |
+
(hv : v∉colSp (A z)) (h : ∀ i, Injective (A i).mulVec) :
|
| 81 |
+
∀ i,Injective (growing A z v i).mulVec := by
|
| 82 |
+
intro i
|
| 83 |
+
by_cases he : i=z
|
| 84 |
+
· subst i
|
| 85 |
+
simp [growing,growFmt]
|
| 86 |
+
apply castMat_inj _ (moreMatrix (A z) v) (moreMatrix_inj (A z) v (h z) hv)
|
| 87 |
+
simp
|
| 88 |
+
simp [growing,growFmt,he]
|
| 89 |
+
apply castMat_inj _ (A i) (h i)
|
| 90 |
+
simp [he]
|
| 91 |
+
|
| 92 |
+
private theorem growth_value (A : DTuple (p:=p) q N) (z : Place p) (v : Vec (Fin N))
|
| 93 |
+
(x : UnitType p n N) (S : Party) :
|
| 94 |
+
thermal p x S (growing A z v)=growing (thermal p x S A) z (heat p x S z *ᵥ v) := by
|
| 95 |
+
funext i
|
| 96 |
+
by_cases he : i=z
|
| 97 |
+
· subst i
|
| 98 |
+
simp [thermal,growing,growFmt]
|
| 99 |
+
rw [←moreMatrix_mul]
|
| 100 |
+
apply castMat_prod
|
| 101 |
+
simp
|
| 102 |
+
simp [thermal,growing,growFmt,he]
|
| 103 |
+
apply castMat_prod
|
| 104 |
+
simp [he]
|
| 105 |
+
|
| 106 |
+
theorem column_observe (A : DTuple (p:=p) q N) (z : Place p) (j : Fin (q z))
|
| 107 |
+
(x : UnitType p n N) (S : Party) :
|
| 108 |
+
heat p x S z *ᵥ (A z).col j=(thermal p x S A z).col j := rfl
|
| 109 |
+
|
| 110 |
+
namespace Bazaar
|
| 111 |
+
variable (s : Bazaar p n r T)
|
| 112 |
+
|
| 113 |
+
abbrev Catalog (p : Shape) {N} (T : Cov p N) (r : ℕ) (q : Place p→ℕ) :=
|
| 114 |
+
(M : Atlas p r T) → Batch M N → Finset (DTuple (p:=p) q N)
|
| 115 |
+
|
| 116 |
+
def atList (s : Bazaar p n r T) (S : Party) (j : Bool)
|
| 117 |
+
(A : DTuple (p:=p) q N) (F : Catalog p T r q) (x : UnitType p n N) :=
|
| 118 |
+
let M := s.ix x
|
| 119 |
+
thermal p x S A∈ F M (s.bag M j x)
|
| 120 |
+
|
| 121 |
+
def probed (p : Shape) {N} {q : Place p→ℕ} (A : DTuple (p:=p) q N) : Cov p N :=
|
| 122 |
+
fun z => colSp (A z)
|
| 123 |
+
|
| 124 |
+
theorem extend_probe (w : Wgt (UnitType p n N)) (S : Party) (j : Bool) {k : ℕ}
|
| 125 |
+
(A : DTuple (p:=p) q N) (hq : ctot p q=k)
|
| 126 |
+
(h : ∀ i, Injective (A i).mulVec)
|
| 127 |
+
(F : Catalog p T r q) (hF : ∀ M Z,(↑(F M Z).card:ℝ) ≤ bp (0.51*k*N))
|
| 128 |
+
(G : Atlas p r T) (hg : ¬ offsetCov G ≤ probed p A)
|
| 129 |
+
(hb : ∀ M Z,(↑(s.bids w S j G M Z).card:ℝ) ≤ bp (0.51*N)) :
|
| 130 |
+
∃ (q : Place p→ℕ) (A' : DTuple (p:=p) q N)
|
| 131 |
+
(F' : Catalog p T r q), ctot p q=k+1 ∧
|
| 132 |
+
(∀ i, Injective (A' i).mulVec) ∧
|
| 133 |
+
(∀ M Z,(↑(F' M Z).card:ℝ) ≤ bp (0.51*(k+1)*N)) ∧
|
| 134 |
+
∀ x,s.atList S j A F x → s.frequent w S j G (s.ix x) x →
|
| 135 |
+
s.atList S j A' F' x := by
|
| 136 |
+
classical
|
| 137 |
+
obtain ⟨z,i,hg⟩ :
|
| 138 |
+
∃ (z : Place p) (i : Fin (breadth G z)),(src G z).col i∉colSp (A z) := by
|
| 139 |
+
by_contra! hh
|
| 140 |
+
apply hg
|
| 141 |
+
intro z
|
| 142 |
+
change colSp (src G z) ≤ _
|
| 143 |
+
rw [colSp,range_mulVecLin]
|
| 144 |
+
exact Submodule.span_le.mpr (Set.range_subset_iff.mpr (hh z))
|
| 145 |
+
let q' := growFmt (p:=p) q z
|
| 146 |
+
let v := (src G z).col i
|
| 147 |
+
let f (M Z) : Finset (DTuple (p:=p) q' N) :=
|
| 148 |
+
((F M Z) ×ˢ (s.bids w S j G M Z)).image
|
| 149 |
+
(fun a => growing a.1 z ((a.2 z).col i))
|
| 150 |
+
refine ⟨q',growing A z v, f,(grow_sum q z).trans (by rw [hq]),
|
| 151 |
+
growth_inj A z v hg h,fun M Z => ?_,fun x hx hi => ?_⟩
|
| 152 |
+
· have he := bp_pos (0.51*(k:ℝ)*N)
|
| 153 |
+
have h1 :
|
| 154 |
+
(↑(f M Z).card:ℝ) ≤ (↑(F M Z).card:ℝ)*(↑(s.bids w S j G M Z).card:ℝ) := by
|
| 155 |
+
exact_mod_cast (show (f M Z).card ≤ _*_ from
|
| 156 |
+
Finset.card_image_le.trans_eq (Finset.card_product ..))
|
| 157 |
+
apply (h1.trans (mul_le_mul (hF M Z) (hb M Z) (Nat.cast_nonneg _) he.le)).trans_eq
|
| 158 |
+
rw [←bp_add]; congr 1; ring
|
| 159 |
+
· rw [atList,growth_value]
|
| 160 |
+
|
| 161 |
+
refine Finset.mem_image.mpr ⟨(thermal p x S A,thermal p x S (src G)),?_,?_⟩
|
| 162 |
+
· exact Finset.mem_product.mpr ⟨hx,(s.bids_mem ..).mp hi⟩
|
| 163 |
+
· change growing _ _ _ = _
|
| 164 |
+
rw [show heat p x S z *ᵥ v=_ from column_observe (src G) z i x S]
|
| 165 |
+
|
| 166 |
+
end Bazaar
|
| 167 |
+
end HadwigerCounterexample
|
| 168 |
+
|
| 169 |
+
end
|
| 170 |
+
|
| 171 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AffineFrames.lean
CHANGED
|
@@ -1,195 +1,195 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.QuadraticTesters
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.SampledGraphs
|
| 3 |
-
import Mathlib.Data.Matrix.ColumnRowPartitioned
|
| 4 |
-
|
| 5 |
-
namespace OAI
|
| 6 |
-
|
| 7 |
-
/-! # Affine Frames -/
|
| 8 |
-
|
| 9 |
-
noncomputable section
|
| 10 |
-
namespace HadwigerCounterexample
|
| 11 |
-
|
| 12 |
-
open Matrix
|
| 13 |
-
open scoped BigOperators
|
| 14 |
-
|
| 15 |
-
structure Mixer (p : Shape) (n : ℕ) where
|
| 16 |
-
mixL : Fin p.J → Comp p.g → Comp p.g → Moment p n
|
| 17 |
-
mixR : Fin p.J → Comp p.g → Comp p.g → Moment p n
|
| 18 |
-
mixM : Fin p.b → Mat (Fin n) (Fin n)
|
| 19 |
-
|
| 20 |
-
abbrev Pdual (p : Shape) (n : ℕ) := Profile p n →ₗ[F] F
|
| 21 |
-
|
| 22 |
-
def linTensor {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F) : V →ₗ[F] V →ₗ[F] F :=
|
| 23 |
-
a.smulRight b
|
| 24 |
-
|
| 25 |
-
theorem linTensor_val {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F)
|
| 26 |
-
(x y : V) : linTensor a b x y = a x * b y := rfl
|
| 27 |
-
|
| 28 |
-
variable {p : Shape} {n N : ℕ}
|
| 29 |
-
|
| 30 |
-
def T0 (p : Shape) (n : ℕ) : Profile p n →ₗ[F] Pdual p n :=
|
| 31 |
-
linTensor (role p n) (role p n) +
|
| 32 |
-
∑ i : Tag p.g, (linTensor (roleT p n i) (sharedT p n i) +
|
| 33 |
-
linTensor (sharedT p n i) (roleT p n i))
|
| 34 |
-
|
| 35 |
-
theorem T0_val (x y : Profile p n) : T0 p n x y =
|
| 36 |
-
role p n x * role p n y +
|
| 37 |
-
∑ i : Tag p.g, (roleT p n i x * sharedT p n i y + sharedT p n i x * roleT p n i y) := by
|
| 38 |
-
simp only [T0,LinearMap.add_apply,LinearMap.sum_apply,linTensor_val]
|
| 39 |
-
|
| 40 |
-
def B1 (m : Mixer p n) : Profile p n →ₗ[F] Pdual p n where
|
| 41 |
-
toFun x := {
|
| 42 |
-
toFun := fun y => ∑ j, ∑ e, ∑ f,
|
| 43 |
-
mpair (x e) (liftM (m.mixL j e f) (m.mixR j e f) (y f))
|
| 44 |
-
map_add' y z := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]
|
| 45 |
-
map_smul' b y := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,smul_eq_mul,
|
| 46 |
-
Finset.mul_sum] }
|
| 47 |
-
map_add' x y := LinearMap.ext fun z => by
|
| 48 |
-
simp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.add_apply,
|
| 49 |
-
Pi.add_apply,mpair_add, Finset.sum_add_distrib]
|
| 50 |
-
map_smul' b x := LinearMap.ext fun z => by
|
| 51 |
-
simp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.smul_apply,RingHom.id_apply,
|
| 52 |
-
Pi.smul_apply,mpair_smul,smul_eq_mul, Finset.mul_sum]
|
| 53 |
-
|
| 54 |
-
def Tmix (m : Mixer p n) := B1 m + LinearMap.flip (B1 m)
|
| 55 |
-
def Tsym (m : Mixer p n) := T0 p n + Tmix m
|
| 56 |
-
|
| 57 |
-
theorem Tsym_val (m : Mixer p n) (x y : Profile p n) :
|
| 58 |
-
Tsym m x y = T0 p n x y + (B1 m x y + B1 m y x) := by
|
| 59 |
-
change (T0 p n + (B1 m + _)) x y = _
|
| 60 |
-
simp
|
| 61 |
-
|
| 62 |
-
theorem T_swap (m : Mixer p n) (x y : Profile p n) : Tsym m x y = Tsym m y x := by
|
| 63 |
-
simp only [Tsym_val,T0_val]
|
| 64 |
-
refine congrArg₂ (· + ·) (congrArg₂ (· + ·) (mul_comm _ _)
|
| 65 |
-
(Finset.sum_congr rfl fun i _ => ?_)) (add_comm _ _)
|
| 66 |
-
rw [mul_comm (roleT p n i x),mul_comm (sharedT p n i x),add_comm]
|
| 67 |
-
|
| 68 |
-
theorem T_diag (m : Mixer p n) (x : Profile p n) : Tsym m x x = role p n x := by
|
| 69 |
-
have h (a b : F) : a*b+b*a=0 := by rw [mul_comm b a,char_two]
|
| 70 |
-
simp only [Tsym_val,T0_val,char_two,h,Finset.sum_const_zero,add_zero,bit_sq]
|
| 71 |
-
|
| 72 |
-
def grad (m : Mixer p n) (x : Profile p n) := role p n + Tsym m x
|
| 73 |
-
theorem grad_val (m : Mixer p n) (x y : Profile p n) :
|
| 74 |
-
grad m x y = role p n y + Tsym m x y := rfl
|
| 75 |
-
|
| 76 |
-
abbrev Full (p : Shape) (n : ℕ) := Row p n ⊕ Fin p.h
|
| 77 |
-
abbrev RawFrame (I J : Type) := Mat J I × Mat J I
|
| 78 |
-
abbrev Oframe (p : Shape) (n N : ℕ) := RawFrame (Full p n) (Fin N)
|
| 79 |
-
abbrev Orient (p : Shape) (n N : ℕ) := Comp p.g → Oframe p n N
|
| 80 |
-
|
| 81 |
-
def primary {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E I := M.submatrix id Sum.inl
|
| 82 |
-
def channel {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E J := M.submatrix id Sum.inr
|
| 83 |
-
|
| 84 |
-
theorem fromCols_frame {I J E : Type} (M : Mat E (I ⊕ J)) :
|
| 85 |
-
fromCols (primary M) (channel M) = M := by ext i j; rcases j with i|j <;> rfl
|
| 86 |
-
|
| 87 |
-
theorem primary_inj {I J E : Type} [Fintype I] [Fintype J]
|
| 88 |
-
{M : Mat E (I ⊕ J)} (h : Function.Injective M.mulVec) :
|
| 89 |
-
Function.Injective (primary M).mulVec := by
|
| 90 |
-
intro a b hab
|
| 91 |
-
let v (x : Vec I) := Sum.elim x (fun _ : J => (0:F))
|
| 92 |
-
have he (x : Vec I) : M *ᵥ v x = primary M *ᵥ x := by
|
| 93 |
-
conv_lhs => rw [← fromCols_frame M]
|
| 94 |
-
unfold v; rw [fromCols_mulVec_sumElim]
|
| 95 |
-
change _ + (channel M *ᵥ 0) = _
|
| 96 |
-
rw [Matrix.mulVec_zero,add_zero]
|
| 97 |
-
have hh : v a = v b := h (by rw [he,he]; exact hab)
|
| 98 |
-
exact funext fun i => congr_fun hh (.inl i)
|
| 99 |
-
|
| 100 |
-
def valid (M : Moment p n) (o : Oframe p n N) : Prop :=
|
| 101 |
-
Function.Injective o.1.mulVec ∧ Function.Injective o.2.mulVec ∧
|
| 102 |
-
(primary o.1)ᵀ * primary o.2 = M ∧ (channel o.1)ᵀ * primary o.2 = 0 ∧
|
| 103 |
-
(primary o.1)ᵀ * channel o.2 = 0
|
| 104 |
-
|
| 105 |
-
def frameLaw (m : Mixer p n) (o : Orient p n N) :=
|
| 106 |
-
∀ e, valid (selfM p n m.mixM) (o e)
|
| 107 |
-
|
| 108 |
-
abbrev Ambient (p : Shape) (N : ℕ) := Comp p.g → Mat (Fin N) (Fin N)
|
| 109 |
-
|
| 110 |
-
def Uembed (o : Orient p n N) : Profile p n →ₗ[F] Ambient p N where
|
| 111 |
-
toFun x e := liftM (primary (o e).1) (primary (o e).2) (x e)
|
| 112 |
-
map_add' x y := by funext e; simp only [Pi.add_apply,map_add]
|
| 113 |
-
map_smul' a x := by funext e; simp only [Pi.smul_apply,map_smul,RingHom.id_apply]
|
| 114 |
-
|
| 115 |
-
def ufun (o : Orient p n N) : Ambient p N →ₗ[F] F where
|
| 116 |
-
toFun x := ∑ e, mpair (channel (o e).2 * (channel (o e).1)ᵀ) (x e)
|
| 117 |
-
map_add' x y := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]
|
| 118 |
-
map_smul' a x := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,
|
| 119 |
-
smul_eq_mul,Finset.mul_sum]
|
| 120 |
-
|
| 121 |
-
theorem Uembed_inj {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) :
|
| 122 |
-
Function.Injective (Uembed o) := by
|
| 123 |
-
intro x y e
|
| 124 |
-
exact funext fun i =>
|
| 125 |
-
liftM_inj (primary_inj (h i).1) (primary_inj (h i).2.1) (congr_fun e i)
|
| 126 |
-
|
| 127 |
-
theorem ufun_self {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) (x : Profile p n) :
|
| 128 |
-
ufun o (Uembed o x) = 0 := by
|
| 129 |
-
simp only [ufun,Uembed,LinearMap.coe_mk,AddHom.coe_mk]
|
| 130 |
-
refine Finset.sum_eq_zero fun i _ => ?_
|
| 131 |
-
rw [mpair_liftM,liftM_def,← Matrix.mul_assoc,(h i).2.2.2.2,Matrix.zero_mul,
|
| 132 |
-
Matrix.zero_mul,mpair_comm,map_zero]
|
| 133 |
-
|
| 134 |
-
/-- Witnesses v,w are in the cut-profile space. The gradients agree over that
|
| 135 |
-
*whole* space. -/
|
| 136 |
-
def hole (m : Mixer p n) (x y : Orient p n N) :=
|
| 137 |
-
frameLaw m x ∧ frameLaw m y ∧ ∃ v w : Profile p n,
|
| 138 |
-
v ∈ Xspace p n ∧ w ∈ Xspace p n ∧
|
| 139 |
-
Uembed x v = Uembed y w ∧
|
| 140 |
-
(∀ i ∈ Xspace p n, ufun y (Uembed x i) = grad m v i) ∧
|
| 141 |
-
(∀ i ∈ Xspace p n, ufun x (Uembed y i) = grad m w i) ∧
|
| 142 |
-
role p n v + role p n w = 1
|
| 143 |
-
|
| 144 |
-
theorem hole_sym {m : Mixer p n} {x y : Orient p n N} (h : hole m x y) : hole m y x := by
|
| 145 |
-
obtain ⟨hx,hy,v,w,hv,hw,e,h,g,p⟩ := h
|
| 146 |
-
exact ⟨hy,hx,w,v,hw,hv,e.symm,g,h,(add_comm _ _).trans p⟩
|
| 147 |
-
|
| 148 |
-
theorem not_hole_self (m : Mixer p n) (x : Orient p n N) : ¬hole m x x := by
|
| 149 |
-
rintro ⟨hx,_,v,w,_,_,e,_,_,hp⟩
|
| 150 |
-
rw [Uembed_inj hx e,char_two] at hp
|
| 151 |
-
exact zero_ne_one hp
|
| 152 |
-
|
| 153 |
-
theorem hole_triangle {m : Mixer p n} {x y z : Orient p n N}
|
| 154 |
-
(h1 : hole m x y) (h2 : hole m y z) : ¬ hole m x z := by
|
| 155 |
-
intro h3
|
| 156 |
-
obtain ⟨_,_,a,b,ha,hb,hab,u1,u2,p1⟩ := h1
|
| 157 |
-
obtain ⟨_,_,c,d,hc,hd,hcd,u3,u4,p2⟩ := h2
|
| 158 |
-
obtain ⟨_,_,e,f,he,hf,hef,u5,u6,p3⟩ := h3
|
| 159 |
-
have hx : grad m b c = grad m f d := by rw [←u2 _ hc, ←u6 _ hd,hcd]
|
| 160 |
-
have hy : grad m a e = grad m d f := by rw [←u1 _ he, ←u4 _ hf,hef]
|
| 161 |
-
have hz : grad m e a = grad m c b := by rw [←u5 _ ha, ←u3 _ hb,hab]
|
| 162 |
-
simp only [grad_val] at hx hy hz
|
| 163 |
-
let A := role p n
|
| 164 |
-
have hw (x y : F) (h : x=y) : x+y=0 := by rw [h,char_two]
|
| 165 |
-
have hp : (A a+A b)+(A c+A d)+(A e+A f)=0 := by
|
| 166 |
-
let H := Tsym m
|
| 167 |
-
change A _ + H _ _ = A _ + H _ _ at hx hy hz
|
| 168 |
-
calc (A a+A b)+(A c+A d)+(A e+A f)
|
| 169 |
-
_ = ((A c+H b c)+(A d+H f d)) +
|
| 170 |
-
((A e+H a e)+(A f+H d f)) +
|
| 171 |
-
((A a+H e a)+(A b+H c b)) := by
|
| 172 |
-
have h (x y) : H x y+H y x=0 := hw _ _ (T_swap m _ _)
|
| 173 |
-
symm
|
| 174 |
-
calc ((A c+H b c)+(A d+H f d)) +
|
| 175 |
-
((A e+H a e)+(A f+H d f)) +
|
| 176 |
-
((A a+H e a)+(A b+H c b))
|
| 177 |
-
_ = ((A a+A b)+(A c+A d)+(A e+A f)) + (H b c+H c b) +
|
| 178 |
-
(H f d+H d f)+(H a e+H e a) := by ac_rfl
|
| 179 |
-
_ = _ := by simp only [h,add_zero]
|
| 180 |
-
_ = 0 := by rw [hw _ _ hx, hw _ _ hy, hw _ _ hz]; simp
|
| 181 |
-
unfold A at hp
|
| 182 |
-
rw [p1,p2,p3,char_two,zero_add] at hp
|
| 183 |
-
exact one_ne_zero hp
|
| 184 |
-
|
| 185 |
-
def rawHoles (m : Mixer p n) : Holes (Orient p n N) where
|
| 186 |
-
rel := hole m
|
| 187 |
-
sym := hole_sym
|
| 188 |
-
irr := not_hole_self m
|
| 189 |
-
ntri := hole_triangle
|
| 190 |
-
|
| 191 |
-
end HadwigerCounterexample
|
| 192 |
-
|
| 193 |
-
end
|
| 194 |
-
|
| 195 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.QuadraticTesters
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.SampledGraphs
|
| 3 |
+
import Mathlib.Data.Matrix.ColumnRowPartitioned
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! # Affine Frames -/
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace HadwigerCounterexample
|
| 11 |
+
|
| 12 |
+
open Matrix
|
| 13 |
+
open scoped BigOperators
|
| 14 |
+
|
| 15 |
+
structure Mixer (p : Shape) (n : ℕ) where
|
| 16 |
+
mixL : Fin p.J → Comp p.g → Comp p.g → Moment p n
|
| 17 |
+
mixR : Fin p.J → Comp p.g → Comp p.g → Moment p n
|
| 18 |
+
mixM : Fin p.b → Mat (Fin n) (Fin n)
|
| 19 |
+
|
| 20 |
+
abbrev Pdual (p : Shape) (n : ℕ) := Profile p n →ₗ[F] F
|
| 21 |
+
|
| 22 |
+
def linTensor {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F) : V →ₗ[F] V →ₗ[F] F :=
|
| 23 |
+
a.smulRight b
|
| 24 |
+
|
| 25 |
+
theorem linTensor_val {V : Type} [AddCommGroup V] [Module F V] (a b : V →ₗ[F] F)
|
| 26 |
+
(x y : V) : linTensor a b x y = a x * b y := rfl
|
| 27 |
+
|
| 28 |
+
variable {p : Shape} {n N : ℕ}
|
| 29 |
+
|
| 30 |
+
def T0 (p : Shape) (n : ℕ) : Profile p n →ₗ[F] Pdual p n :=
|
| 31 |
+
linTensor (role p n) (role p n) +
|
| 32 |
+
∑ i : Tag p.g, (linTensor (roleT p n i) (sharedT p n i) +
|
| 33 |
+
linTensor (sharedT p n i) (roleT p n i))
|
| 34 |
+
|
| 35 |
+
theorem T0_val (x y : Profile p n) : T0 p n x y =
|
| 36 |
+
role p n x * role p n y +
|
| 37 |
+
∑ i : Tag p.g, (roleT p n i x * sharedT p n i y + sharedT p n i x * roleT p n i y) := by
|
| 38 |
+
simp only [T0,LinearMap.add_apply,LinearMap.sum_apply,linTensor_val]
|
| 39 |
+
|
| 40 |
+
def B1 (m : Mixer p n) : Profile p n →ₗ[F] Pdual p n where
|
| 41 |
+
toFun x := {
|
| 42 |
+
toFun := fun y => ∑ j, ∑ e, ∑ f,
|
| 43 |
+
mpair (x e) (liftM (m.mixL j e f) (m.mixR j e f) (y f))
|
| 44 |
+
map_add' y z := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]
|
| 45 |
+
map_smul' b y := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,smul_eq_mul,
|
| 46 |
+
Finset.mul_sum] }
|
| 47 |
+
map_add' x y := LinearMap.ext fun z => by
|
| 48 |
+
simp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.add_apply,
|
| 49 |
+
Pi.add_apply,mpair_add, Finset.sum_add_distrib]
|
| 50 |
+
map_smul' b x := LinearMap.ext fun z => by
|
| 51 |
+
simp only [LinearMap.coe_mk,AddHom.coe_mk,LinearMap.smul_apply,RingHom.id_apply,
|
| 52 |
+
Pi.smul_apply,mpair_smul,smul_eq_mul, Finset.mul_sum]
|
| 53 |
+
|
| 54 |
+
def Tmix (m : Mixer p n) := B1 m + LinearMap.flip (B1 m)
|
| 55 |
+
def Tsym (m : Mixer p n) := T0 p n + Tmix m
|
| 56 |
+
|
| 57 |
+
theorem Tsym_val (m : Mixer p n) (x y : Profile p n) :
|
| 58 |
+
Tsym m x y = T0 p n x y + (B1 m x y + B1 m y x) := by
|
| 59 |
+
change (T0 p n + (B1 m + _)) x y = _
|
| 60 |
+
simp
|
| 61 |
+
|
| 62 |
+
theorem T_swap (m : Mixer p n) (x y : Profile p n) : Tsym m x y = Tsym m y x := by
|
| 63 |
+
simp only [Tsym_val,T0_val]
|
| 64 |
+
refine congrArg₂ (· + ·) (congrArg₂ (· + ·) (mul_comm _ _)
|
| 65 |
+
(Finset.sum_congr rfl fun i _ => ?_)) (add_comm _ _)
|
| 66 |
+
rw [mul_comm (roleT p n i x),mul_comm (sharedT p n i x),add_comm]
|
| 67 |
+
|
| 68 |
+
theorem T_diag (m : Mixer p n) (x : Profile p n) : Tsym m x x = role p n x := by
|
| 69 |
+
have h (a b : F) : a*b+b*a=0 := by rw [mul_comm b a,char_two]
|
| 70 |
+
simp only [Tsym_val,T0_val,char_two,h,Finset.sum_const_zero,add_zero,bit_sq]
|
| 71 |
+
|
| 72 |
+
def grad (m : Mixer p n) (x : Profile p n) := role p n + Tsym m x
|
| 73 |
+
theorem grad_val (m : Mixer p n) (x y : Profile p n) :
|
| 74 |
+
grad m x y = role p n y + Tsym m x y := rfl
|
| 75 |
+
|
| 76 |
+
abbrev Full (p : Shape) (n : ℕ) := Row p n ⊕ Fin p.h
|
| 77 |
+
abbrev RawFrame (I J : Type) := Mat J I × Mat J I
|
| 78 |
+
abbrev Oframe (p : Shape) (n N : ℕ) := RawFrame (Full p n) (Fin N)
|
| 79 |
+
abbrev Orient (p : Shape) (n N : ℕ) := Comp p.g → Oframe p n N
|
| 80 |
+
|
| 81 |
+
def primary {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E I := M.submatrix id Sum.inl
|
| 82 |
+
def channel {I J E : Type} (M : Mat E (I ⊕ J)) : Mat E J := M.submatrix id Sum.inr
|
| 83 |
+
|
| 84 |
+
theorem fromCols_frame {I J E : Type} (M : Mat E (I ⊕ J)) :
|
| 85 |
+
fromCols (primary M) (channel M) = M := by ext i j; rcases j with i|j <;> rfl
|
| 86 |
+
|
| 87 |
+
theorem primary_inj {I J E : Type} [Fintype I] [Fintype J]
|
| 88 |
+
{M : Mat E (I ⊕ J)} (h : Function.Injective M.mulVec) :
|
| 89 |
+
Function.Injective (primary M).mulVec := by
|
| 90 |
+
intro a b hab
|
| 91 |
+
let v (x : Vec I) := Sum.elim x (fun _ : J => (0:F))
|
| 92 |
+
have he (x : Vec I) : M *ᵥ v x = primary M *ᵥ x := by
|
| 93 |
+
conv_lhs => rw [← fromCols_frame M]
|
| 94 |
+
unfold v; rw [fromCols_mulVec_sumElim]
|
| 95 |
+
change _ + (channel M *ᵥ 0) = _
|
| 96 |
+
rw [Matrix.mulVec_zero,add_zero]
|
| 97 |
+
have hh : v a = v b := h (by rw [he,he]; exact hab)
|
| 98 |
+
exact funext fun i => congr_fun hh (.inl i)
|
| 99 |
+
|
| 100 |
+
def valid (M : Moment p n) (o : Oframe p n N) : Prop :=
|
| 101 |
+
Function.Injective o.1.mulVec ∧ Function.Injective o.2.mulVec ∧
|
| 102 |
+
(primary o.1)ᵀ * primary o.2 = M ∧ (channel o.1)ᵀ * primary o.2 = 0 ∧
|
| 103 |
+
(primary o.1)ᵀ * channel o.2 = 0
|
| 104 |
+
|
| 105 |
+
def frameLaw (m : Mixer p n) (o : Orient p n N) :=
|
| 106 |
+
∀ e, valid (selfM p n m.mixM) (o e)
|
| 107 |
+
|
| 108 |
+
abbrev Ambient (p : Shape) (N : ℕ) := Comp p.g → Mat (Fin N) (Fin N)
|
| 109 |
+
|
| 110 |
+
def Uembed (o : Orient p n N) : Profile p n →ₗ[F] Ambient p N where
|
| 111 |
+
toFun x e := liftM (primary (o e).1) (primary (o e).2) (x e)
|
| 112 |
+
map_add' x y := by funext e; simp only [Pi.add_apply,map_add]
|
| 113 |
+
map_smul' a x := by funext e; simp only [Pi.smul_apply,map_smul,RingHom.id_apply]
|
| 114 |
+
|
| 115 |
+
def ufun (o : Orient p n N) : Ambient p N →ₗ[F] F where
|
| 116 |
+
toFun x := ∑ e, mpair (channel (o e).2 * (channel (o e).1)ᵀ) (x e)
|
| 117 |
+
map_add' x y := by simp only [Pi.add_apply,map_add, Finset.sum_add_distrib]
|
| 118 |
+
map_smul' a x := by simp only [Pi.smul_apply,map_smul,RingHom.id_apply,
|
| 119 |
+
smul_eq_mul,Finset.mul_sum]
|
| 120 |
+
|
| 121 |
+
theorem Uembed_inj {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) :
|
| 122 |
+
Function.Injective (Uembed o) := by
|
| 123 |
+
intro x y e
|
| 124 |
+
exact funext fun i =>
|
| 125 |
+
liftM_inj (primary_inj (h i).1) (primary_inj (h i).2.1) (congr_fun e i)
|
| 126 |
+
|
| 127 |
+
theorem ufun_self {m : Mixer p n} {o : Orient p n N} (h : frameLaw m o) (x : Profile p n) :
|
| 128 |
+
ufun o (Uembed o x) = 0 := by
|
| 129 |
+
simp only [ufun,Uembed,LinearMap.coe_mk,AddHom.coe_mk]
|
| 130 |
+
refine Finset.sum_eq_zero fun i _ => ?_
|
| 131 |
+
rw [mpair_liftM,liftM_def,← Matrix.mul_assoc,(h i).2.2.2.2,Matrix.zero_mul,
|
| 132 |
+
Matrix.zero_mul,mpair_comm,map_zero]
|
| 133 |
+
|
| 134 |
+
/-- Witnesses v,w are in the cut-profile space. The gradients agree over that
|
| 135 |
+
*whole* space. -/
|
| 136 |
+
def hole (m : Mixer p n) (x y : Orient p n N) :=
|
| 137 |
+
frameLaw m x ∧ frameLaw m y ∧ ∃ v w : Profile p n,
|
| 138 |
+
v ∈ Xspace p n ∧ w ∈ Xspace p n ∧
|
| 139 |
+
Uembed x v = Uembed y w ∧
|
| 140 |
+
(∀ i ∈ Xspace p n, ufun y (Uembed x i) = grad m v i) ∧
|
| 141 |
+
(∀ i ∈ Xspace p n, ufun x (Uembed y i) = grad m w i) ∧
|
| 142 |
+
role p n v + role p n w = 1
|
| 143 |
+
|
| 144 |
+
theorem hole_sym {m : Mixer p n} {x y : Orient p n N} (h : hole m x y) : hole m y x := by
|
| 145 |
+
obtain ⟨hx,hy,v,w,hv,hw,e,h,g,p⟩ := h
|
| 146 |
+
exact ⟨hy,hx,w,v,hw,hv,e.symm,g,h,(add_comm _ _).trans p⟩
|
| 147 |
+
|
| 148 |
+
theorem not_hole_self (m : Mixer p n) (x : Orient p n N) : ¬hole m x x := by
|
| 149 |
+
rintro ⟨hx,_,v,w,_,_,e,_,_,hp⟩
|
| 150 |
+
rw [Uembed_inj hx e,char_two] at hp
|
| 151 |
+
exact zero_ne_one hp
|
| 152 |
+
|
| 153 |
+
theorem hole_triangle {m : Mixer p n} {x y z : Orient p n N}
|
| 154 |
+
(h1 : hole m x y) (h2 : hole m y z) : ¬ hole m x z := by
|
| 155 |
+
intro h3
|
| 156 |
+
obtain ⟨_,_,a,b,ha,hb,hab,u1,u2,p1⟩ := h1
|
| 157 |
+
obtain ⟨_,_,c,d,hc,hd,hcd,u3,u4,p2⟩ := h2
|
| 158 |
+
obtain ⟨_,_,e,f,he,hf,hef,u5,u6,p3⟩ := h3
|
| 159 |
+
have hx : grad m b c = grad m f d := by rw [←u2 _ hc, ←u6 _ hd,hcd]
|
| 160 |
+
have hy : grad m a e = grad m d f := by rw [←u1 _ he, ←u4 _ hf,hef]
|
| 161 |
+
have hz : grad m e a = grad m c b := by rw [←u5 _ ha, ←u3 _ hb,hab]
|
| 162 |
+
simp only [grad_val] at hx hy hz
|
| 163 |
+
let A := role p n
|
| 164 |
+
have hw (x y : F) (h : x=y) : x+y=0 := by rw [h,char_two]
|
| 165 |
+
have hp : (A a+A b)+(A c+A d)+(A e+A f)=0 := by
|
| 166 |
+
let H := Tsym m
|
| 167 |
+
change A _ + H _ _ = A _ + H _ _ at hx hy hz
|
| 168 |
+
calc (A a+A b)+(A c+A d)+(A e+A f)
|
| 169 |
+
_ = ((A c+H b c)+(A d+H f d)) +
|
| 170 |
+
((A e+H a e)+(A f+H d f)) +
|
| 171 |
+
((A a+H e a)+(A b+H c b)) := by
|
| 172 |
+
have h (x y) : H x y+H y x=0 := hw _ _ (T_swap m _ _)
|
| 173 |
+
symm
|
| 174 |
+
calc ((A c+H b c)+(A d+H f d)) +
|
| 175 |
+
((A e+H a e)+(A f+H d f)) +
|
| 176 |
+
((A a+H e a)+(A b+H c b))
|
| 177 |
+
_ = ((A a+A b)+(A c+A d)+(A e+A f)) + (H b c+H c b) +
|
| 178 |
+
(H f d+H d f)+(H a e+H e a) := by ac_rfl
|
| 179 |
+
_ = _ := by simp only [h,add_zero]
|
| 180 |
+
_ = 0 := by rw [hw _ _ hx, hw _ _ hy, hw _ _ hz]; simp
|
| 181 |
+
unfold A at hp
|
| 182 |
+
rw [p1,p2,p3,char_two,zero_add] at hp
|
| 183 |
+
exact one_ne_zero hp
|
| 184 |
+
|
| 185 |
+
def rawHoles (m : Mixer p n) : Holes (Orient p n N) where
|
| 186 |
+
rel := hole m
|
| 187 |
+
sym := hole_sym
|
| 188 |
+
irr := not_hole_self m
|
| 189 |
+
ntri := hole_triangle
|
| 190 |
+
|
| 191 |
+
end HadwigerCounterexample
|
| 192 |
+
|
| 193 |
+
end
|
| 194 |
+
|
| 195 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AggregateCostBounds.lean
CHANGED
|
@@ -1,124 +1,124 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PositiveTestMass
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Aggregate Cost Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Filter Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
variable {p:Shape} {n N r M s0 K:ℕ}
|
| 13 |
-
namespace StatusAnalysis
|
| 14 |
-
open PreparationParameters Station DualAnalysis
|
| 15 |
-
|
| 16 |
-
theorem couplings {I A : Type} [Fintype I] [Fintype A] (p:Wgt I)(f:I→ Wgt A)
|
| 17 |
-
(F:(I×A)×(I×A)→ℝ):
|
| 18 |
-
avg (pairW (semi p f) (semi p f)) F=
|
| 19 |
-
avg (pairW p p) (fun i=>avg (pairW (f i.1) (f i.2)) (fun a=>F ((i.1,a.1),(i.2,a.2)))) := by
|
| 20 |
-
rw [pairW_avg,pairW_avg]
|
| 21 |
-
simp_rw [semi_avg,pairW_avg]
|
| 22 |
-
refine avg_congr (fun i _=>?_); exact avg_avg ..
|
| 23 |
-
|
| 24 |
-
theorem ship_cost (w:LeafMixture p n N)(U:Wgt (UnitType p n N))(m:Mixer p n)
|
| 25 |
-
(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r) :
|
| 26 |
-
avg (cirque w U) (fun x=>v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2))
|
| 27 |
-
= v.stratum i.2.2 m U i.2.1 Y := couplings (portionW U w.T) (fun i=>partW U i.val) _
|
| 28 |
-
|
| 29 |
-
theorem ship_pos (w:LeafMixture p n N) (m:Mixer p n)
|
| 30 |
-
(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r)
|
| 31 |
-
(h:i.2.2.permission)(hp:1≤p.r)(hn:2*p.r≤n)
|
| 32 |
-
(x:ViewPair p n N w):
|
| 33 |
-
0≤ v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2) := by
|
| 34 |
-
classical
|
| 35 |
-
let a:=i.2.2
|
| 36 |
-
have hA j:= Appearance.witLaw (a.qA.allure_apt a.t a.z h.2.1 j) hp hn
|
| 37 |
-
have hB j:= Appearance.witLaw (a.qB.allure_apt a.t a.z h.2.2.1 j) hp hn
|
| 38 |
-
let s:= v.cAxes x.1.1 (toRates i.1.2.1)
|
| 39 |
-
let t:= v.cAxes x.2.1 (toRates i.1.2.2)
|
| 40 |
-
have hc (j) : 0≤ a.chimera x.1.2 x.2.2 s t m Y j := avg_nonneg (unifOn_sub _).nz
|
| 41 |
-
(fun k=> mul_nonneg (a.qA.seraphFloor a.t a.z x.1.2 m s Y j (hA j) k).1
|
| 42 |
-
(a.qB.seraphFloor a.t a.z x.2.2 m t Y j (hB j) k).1)
|
| 43 |
-
have hM : 0≤a.momus:= mul_nonneg (kappa_pos _).le (kappa_pos _).le
|
| 44 |
-
exact mul_nonneg (ind_nonneg _) (mul_nonneg hM (Finset.prod_nonneg fun i _=>hc i))
|
| 45 |
-
|
| 46 |
-
theorem prognosis (w:LeafMixture p n N) (U: Wgt (UnitType p n N)) (m:Mixer p n)
|
| 47 |
-
(b:PreparationParameters) (v:Station p n N b.pins w) (Y:Silhouette p N r)
|
| 48 |
-
{ε a : ℝ} (he:0 ≤ ε)(ha:0<a) (hp:1≤p.r)(hn:2*p.r≤n)
|
| 49 |
-
(hs:Lead U w m b)
|
| 50 |
-
(h:∀ i:Scrip p b.pins,i.2.2.permission→v.stratum i.2.2 m U i.2.1 Y ≤ ε):
|
| 51 |
-
pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a)≤ num (Scrip p b.pins)*(ε/a) := by
|
| 52 |
-
classical
|
| 53 |
-
let J:= Scrip p b.pins; let I:=ViewPair p n N w; let V:=cirque w U
|
| 54 |
-
let Q (i:J)(x:I):= v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2)
|
| 55 |
-
have ht:= (troupe_bill hs).1; have hv:IsLaw V:=pairW_law ht ht
|
| 56 |
-
let P (i:J)(x:I):= i.2.2.permission∧ a ≤ Q i x
|
| 57 |
-
have hF (i:J): pr V (P i)≤ ε/a := by
|
| 58 |
-
by_cases ht:i.2.2.permission
|
| 59 |
-
· simp only [P,ht,true_and]
|
| 60 |
-
refine (le_div_iff₀ ha).mpr ?_
|
| 61 |
-
rw [mul_comm]
|
| 62 |
-
exact ((le_avg_markov hv.nz (ship_pos w m v i Y ht hp hn) a).trans_eq (ship_cost ..)).trans
|
| 63 |
-
(h i ht)
|
| 64 |
-
rw [show P i=(fun _=>False) from funext fun a=>eq_false fun hh=>ht hh.1,pr_false]; exact div_nonneg he ha.le
|
| 65 |
-
change pr V (fun x=>∃ i,P i x)≤ _
|
| 66 |
-
exact ((pr_exists_le hv.nz P).trans (Finset.sum_le_sum fun i _=> hF i)).trans_eq (by simp [J,num])
|
| 67 |
-
|
| 68 |
-
structure Beams (b:PreparationParameters) (m:Mixer p n) (Y:Silhouette p N r)
|
| 69 |
-
(w:LeafMixture p n N)(U:Wgt (UnitType p n N)) (v:Station p n N b.pins w)
|
| 70 |
-
(a ε δ τ :ℝ):Prop where
|
| 71 |
-
soft : origami p r (wisp p Y) δ
|
| 72 |
-
rare : pr (w.sap U) (fun i=>¬gauze p δ δ Y m b.pins i) ≤ τ
|
| 73 |
-
zone : pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a) ≤ τ
|
| 74 |
-
haze : 0<δ∧ δ≤ ε
|
| 75 |
-
|
| 76 |
-
variable {l:Filter ℕ} {m:cycleM p} {U:tale p M} {w:rhythms p M} {b:PreparationParameters}
|
| 77 |
-
set_option maxHeartbeats 1400000 in
|
| 78 |
-
theorem lightmap (v:Stations p M b.pins w) (h:veil p M b s0 l m w U)
|
| 79 |
-
(a ε τ:ℝ) (ha:0<a)(he:0<ε)(hτ:0<τ)
|
| 80 |
-
(k:ℕ)(Y:∀ n,Silhouette p (M*n) k):
|
| 81 |
-
∃ (r:ℕ) (δ:ℝ), ∀ᶠ n in l,
|
| 82 |
-
∃ X:Silhouette p (M*n) r,refines X (Y n)∧
|
| 83 |
-
Beams b (m n) X (w n) (U n) (v n) a ε δ τ := by
|
| 84 |
-
classical
|
| 85 |
-
let L:= num (Scrip p b.pins); have hL:0≤L:=Nat.cast_nonneg _
|
| 86 |
-
let η := a*τ/(L+1)
|
| 87 |
-
have hη:0<η:=by unfold η; positivity
|
| 88 |
-
let u:= min τ (min ε (1/4))
|
| 89 |
-
have hu :0<u:=lt_min hτ (lt_min he (by norm_num))
|
| 90 |
-
obtain ⟨r,δ,hd,hV,hT⟩:= lateSilk v h η u hη hu k
|
| 91 |
-
refine ⟨r,δ,?_⟩; have he:= h.easel.enter.first
|
| 92 |
-
filter_upwards [h.upright,hT,h.moment,h.durableS.shape,h.durableS.mass.positive,
|
| 93 |
-
(trend_sizes l h.timeL he.hM).2.eventually (eventually_ge_atTop (2*num (Toast p)+1))]
|
| 94 |
-
with n hn ht hp hC hP hN
|
| 95 |
-
obtain ⟨X,hX,hW,hY⟩:=ht (Y n)
|
| 96 |
-
let N:=M*n
|
| 97 |
-
refine ⟨X,hX, ?_,hW.trans (min_le_left ..),?_, hd,?_⟩
|
| 98 |
-
· have h0 i j:IsLaw (wisp p X i j):=
|
| 99 |
-
mapW_law (omegaLaw p i j (show 2*num (Toast p)-(N:ℝ)≤-1 by
|
| 100 |
-
change _≤(N:ℝ) at hN
|
| 101 |
-
linarith only [hN])) _
|
| 102 |
-
refine ⟨h0,fun i j=>?_⟩
|
| 103 |
-
let ν:=wisp p X i j
|
| 104 |
-
have hs : pr ν (fun i=>¬δ≤ν i) = 1-pr ν (fun i=>δ≤ν i) :=by rw [pr_not,(show tot ν=1
|
| 105 |
-
from (h0 i j).total)]
|
| 106 |
-
have hi:u≤1/4:=le_trans (min_le_right ..) (min_le_right ..)
|
| 107 |
-
simp_rw [not_le] at hs
|
| 108 |
-
have hf:= haze_small ν δ hd.le
|
| 109 |
-
linarith only [hf,hs,hV,hi,hd]
|
| 110 |
-
· apply (prognosis (w n) (U n) (m n) b (v n) X hη.le ha he.hR hn.age
|
| 111 |
-
⟨hC.1,hP,hp.1.law,hC.2⟩ hY).trans
|
| 112 |
-
change L*(η/a)≤τ
|
| 113 |
-
have h : η/a= τ/(L+1) := by unfold η; field_simp
|
| 114 |
-
rw [h,mul_div_assoc',div_le_iff₀ (by linarith)]
|
| 115 |
-
linarith only [hτ]
|
| 116 |
-
have hi:u≤ε:=le_trans (min_le_right ..) (min_le_left ..)
|
| 117 |
-
nlinarith only [hi,hV,hd,Nat.cast_nonneg (α:=ℝ) r]
|
| 118 |
-
|
| 119 |
-
end StatusAnalysis
|
| 120 |
-
end HadwigerCounterexample
|
| 121 |
-
|
| 122 |
-
end
|
| 123 |
-
|
| 124 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PositiveTestMass
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Aggregate Cost Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Filter Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
variable {p:Shape} {n N r M s0 K:ℕ}
|
| 13 |
+
namespace StatusAnalysis
|
| 14 |
+
open PreparationParameters Station DualAnalysis
|
| 15 |
+
|
| 16 |
+
theorem couplings {I A : Type} [Fintype I] [Fintype A] (p:Wgt I)(f:I→ Wgt A)
|
| 17 |
+
(F:(I×A)×(I×A)→ℝ):
|
| 18 |
+
avg (pairW (semi p f) (semi p f)) F=
|
| 19 |
+
avg (pairW p p) (fun i=>avg (pairW (f i.1) (f i.2)) (fun a=>F ((i.1,a.1),(i.2,a.2)))) := by
|
| 20 |
+
rw [pairW_avg,pairW_avg]
|
| 21 |
+
simp_rw [semi_avg,pairW_avg]
|
| 22 |
+
refine avg_congr (fun i _=>?_); exact avg_avg ..
|
| 23 |
+
|
| 24 |
+
theorem ship_cost (w:LeafMixture p n N)(U:Wgt (UnitType p n N))(m:Mixer p n)
|
| 25 |
+
(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r) :
|
| 26 |
+
avg (cirque w U) (fun x=>v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2))
|
| 27 |
+
= v.stratum i.2.2 m U i.2.1 Y := couplings (portionW U w.T) (fun i=>partW U i.val) _
|
| 28 |
+
|
| 29 |
+
theorem ship_pos (w:LeafMixture p n N) (m:Mixer p n)
|
| 30 |
+
(v:Station p n N K w) (i:Scrip p K) (Y:Silhouette p N r)
|
| 31 |
+
(h:i.2.2.permission)(hp:1≤p.r)(hn:2*p.r≤n)
|
| 32 |
+
(x:ViewPair p n N w):
|
| 33 |
+
0≤ v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2) := by
|
| 34 |
+
classical
|
| 35 |
+
let a:=i.2.2
|
| 36 |
+
have hA j:= Appearance.witLaw (a.qA.allure_apt a.t a.z h.2.1 j) hp hn
|
| 37 |
+
have hB j:= Appearance.witLaw (a.qB.allure_apt a.t a.z h.2.2.1 j) hp hn
|
| 38 |
+
let s:= v.cAxes x.1.1 (toRates i.1.2.1)
|
| 39 |
+
let t:= v.cAxes x.2.1 (toRates i.1.2.2)
|
| 40 |
+
have hc (j) : 0≤ a.chimera x.1.2 x.2.2 s t m Y j := avg_nonneg (unifOn_sub _).nz
|
| 41 |
+
(fun k=> mul_nonneg (a.qA.seraphFloor a.t a.z x.1.2 m s Y j (hA j) k).1
|
| 42 |
+
(a.qB.seraphFloor a.t a.z x.2.2 m t Y j (hB j) k).1)
|
| 43 |
+
have hM : 0≤a.momus:= mul_nonneg (kappa_pos _).le (kappa_pos _).le
|
| 44 |
+
exact mul_nonneg (ind_nonneg _) (mul_nonneg hM (Finset.prod_nonneg fun i _=>hc i))
|
| 45 |
+
|
| 46 |
+
theorem prognosis (w:LeafMixture p n N) (U: Wgt (UnitType p n N)) (m:Mixer p n)
|
| 47 |
+
(b:PreparationParameters) (v:Station p n N b.pins w) (Y:Silhouette p N r)
|
| 48 |
+
{ε a : ℝ} (he:0 ≤ ε)(ha:0<a) (hp:1≤p.r)(hn:2*p.r≤n)
|
| 49 |
+
(hs:Lead U w m b)
|
| 50 |
+
(h:∀ i:Scrip p b.pins,i.2.2.permission→v.stratum i.2.2 m U i.2.1 Y ≤ ε):
|
| 51 |
+
pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a)≤ num (Scrip p b.pins)*(ε/a) := by
|
| 52 |
+
classical
|
| 53 |
+
let J:= Scrip p b.pins; let I:=ViewPair p n N w; let V:=cirque w U
|
| 54 |
+
let Q (i:J)(x:I):= v.twilight i.2.2 m i.2.1 Y x.1.1 x.2.1 (x.1.2,x.2.2)
|
| 55 |
+
have ht:= (troupe_bill hs).1; have hv:IsLaw V:=pairW_law ht ht
|
| 56 |
+
let P (i:J)(x:I):= i.2.2.permission∧ a ≤ Q i x
|
| 57 |
+
have hF (i:J): pr V (P i)≤ ε/a := by
|
| 58 |
+
by_cases ht:i.2.2.permission
|
| 59 |
+
· simp only [P,ht,true_and]
|
| 60 |
+
refine (le_div_iff₀ ha).mpr ?_
|
| 61 |
+
rw [mul_comm]
|
| 62 |
+
exact ((le_avg_markov hv.nz (ship_pos w m v i Y ht hp hn) a).trans_eq (ship_cost ..)).trans
|
| 63 |
+
(h i ht)
|
| 64 |
+
rw [show P i=(fun _=>False) from funext fun a=>eq_false fun hh=>ht hh.1,pr_false]; exact div_nonneg he ha.le
|
| 65 |
+
change pr V (fun x=>∃ i,P i x)≤ _
|
| 66 |
+
exact ((pr_exists_le hv.nz P).trans (Finset.sum_le_sum fun i _=> hF i)).trans_eq (by simp [J,num])
|
| 67 |
+
|
| 68 |
+
structure Beams (b:PreparationParameters) (m:Mixer p n) (Y:Silhouette p N r)
|
| 69 |
+
(w:LeafMixture p n N)(U:Wgt (UnitType p n N)) (v:Station p n N b.pins w)
|
| 70 |
+
(a ε δ τ :ℝ):Prop where
|
| 71 |
+
soft : origami p r (wisp p Y) δ
|
| 72 |
+
rare : pr (w.sap U) (fun i=>¬gauze p δ δ Y m b.pins i) ≤ τ
|
| 73 |
+
zone : pr (cirque w U) (fun x=> eligiblePair v m x.1 x.2 Y a) ≤ τ
|
| 74 |
+
haze : 0<δ∧ δ≤ ε
|
| 75 |
+
|
| 76 |
+
variable {l:Filter ℕ} {m:cycleM p} {U:tale p M} {w:rhythms p M} {b:PreparationParameters}
|
| 77 |
+
set_option maxHeartbeats 1400000 in
|
| 78 |
+
theorem lightmap (v:Stations p M b.pins w) (h:veil p M b s0 l m w U)
|
| 79 |
+
(a ε τ:ℝ) (ha:0<a)(he:0<ε)(hτ:0<τ)
|
| 80 |
+
(k:ℕ)(Y:∀ n,Silhouette p (M*n) k):
|
| 81 |
+
∃ (r:ℕ) (δ:ℝ), ∀ᶠ n in l,
|
| 82 |
+
∃ X:Silhouette p (M*n) r,refines X (Y n)∧
|
| 83 |
+
Beams b (m n) X (w n) (U n) (v n) a ε δ τ := by
|
| 84 |
+
classical
|
| 85 |
+
let L:= num (Scrip p b.pins); have hL:0≤L:=Nat.cast_nonneg _
|
| 86 |
+
let η := a*τ/(L+1)
|
| 87 |
+
have hη:0<η:=by unfold η; positivity
|
| 88 |
+
let u:= min τ (min ε (1/4))
|
| 89 |
+
have hu :0<u:=lt_min hτ (lt_min he (by norm_num))
|
| 90 |
+
obtain ⟨r,δ,hd,hV,hT⟩:= lateSilk v h η u hη hu k
|
| 91 |
+
refine ⟨r,δ,?_⟩; have he:= h.easel.enter.first
|
| 92 |
+
filter_upwards [h.upright,hT,h.moment,h.durableS.shape,h.durableS.mass.positive,
|
| 93 |
+
(trend_sizes l h.timeL he.hM).2.eventually (eventually_ge_atTop (2*num (Toast p)+1))]
|
| 94 |
+
with n hn ht hp hC hP hN
|
| 95 |
+
obtain ⟨X,hX,hW,hY⟩:=ht (Y n)
|
| 96 |
+
let N:=M*n
|
| 97 |
+
refine ⟨X,hX, ?_,hW.trans (min_le_left ..),?_, hd,?_⟩
|
| 98 |
+
· have h0 i j:IsLaw (wisp p X i j):=
|
| 99 |
+
mapW_law (omegaLaw p i j (show 2*num (Toast p)-(N:ℝ)≤-1 by
|
| 100 |
+
change _≤(N:ℝ) at hN
|
| 101 |
+
linarith only [hN])) _
|
| 102 |
+
refine ⟨h0,fun i j=>?_⟩
|
| 103 |
+
let ν:=wisp p X i j
|
| 104 |
+
have hs : pr ν (fun i=>¬δ≤ν i) = 1-pr ν (fun i=>δ≤ν i) :=by rw [pr_not,(show tot ν=1
|
| 105 |
+
from (h0 i j).total)]
|
| 106 |
+
have hi:u≤1/4:=le_trans (min_le_right ..) (min_le_right ..)
|
| 107 |
+
simp_rw [not_le] at hs
|
| 108 |
+
have hf:= haze_small ν δ hd.le
|
| 109 |
+
linarith only [hf,hs,hV,hi,hd]
|
| 110 |
+
· apply (prognosis (w n) (U n) (m n) b (v n) X hη.le ha he.hR hn.age
|
| 111 |
+
⟨hC.1,hP,hp.1.law,hC.2⟩ hY).trans
|
| 112 |
+
change L*(η/a)≤τ
|
| 113 |
+
have h : η/a= τ/(L+1) := by unfold η; field_simp
|
| 114 |
+
rw [h,mul_div_assoc',div_le_iff₀ (by linarith)]
|
| 115 |
+
linarith only [hτ]
|
| 116 |
+
have hi:u≤ε:=le_trans (min_le_right ..) (min_le_left ..)
|
| 117 |
+
nlinarith only [hi,hV,hd,Nat.cast_nonneg (α:=ℝ) r]
|
| 118 |
+
|
| 119 |
+
end StatusAnalysis
|
| 120 |
+
end HadwigerCounterexample
|
| 121 |
+
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AmbientBatchSlots.lean
CHANGED
|
@@ -1,211 +1,211 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.TesterSummaryMass
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.ChannelFrameLaws
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Ambient Batch Slots -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix Module LinearMap Finset Function
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {I J G A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]
|
| 13 |
-
variable {p : Shape} {n N : ℕ}
|
| 14 |
-
|
| 15 |
-
omit [Fintype B] in
|
| 16 |
-
theorem mapW_equiv_val (e : A≃B) (w : Wgt A) (y : B) :
|
| 17 |
-
mapW w e y=w (e.symm y) := by
|
| 18 |
-
classical
|
| 19 |
-
have h : (fun x => e x=y)=(fun x => x=e.symm y) := by
|
| 20 |
-
funext x; apply propext
|
| 21 |
-
exact ⟨fun h => by rw [← h,Equiv.symm_apply_apply],fun h => by rw [h,Equiv.apply_symm_apply]⟩
|
| 22 |
-
unfold mapW; rw [h]; simp
|
| 23 |
-
|
| 24 |
-
theorem unif_equiv (e : A≃B) : mapW unif e = unif := by
|
| 25 |
-
funext x; rw [mapW_equiv_val, unif_apply, unif_apply, Fintype.card_congr e]
|
| 26 |
-
|
| 27 |
-
theorem on_equiv (e : A≃B) (p : B→Prop) :
|
| 28 |
-
mapW (unifOn (fun x => p (e x))) e = unifOn p := by
|
| 29 |
-
classical
|
| 30 |
-
have h : nbr (fun x => p (e x))=nbr p := Equiv.sum_comp e (fun y => ind (p y))
|
| 31 |
-
funext x
|
| 32 |
-
rw [mapW_equiv_val,unifOn_val,unifOn_val]; simp only [Equiv.apply_symm_apply,h]
|
| 33 |
-
|
| 34 |
-
abbrev PlusRack (I : Type) (N : ℕ) := Mat (Fin N) I
|
| 35 |
-
abbrev Rack (I : Type) (N : ℕ) := PlusRack I N × PlusRack I N
|
| 36 |
-
def sectionR {I J : Type} (f : J→I) (x : Rack I N) : Rack J N :=
|
| 37 |
-
((x.1).submatrix _root_.id f, (x.2).submatrix _root_.id f)
|
| 38 |
-
abbrev Route (I G : Type) := I → G
|
| 39 |
-
abbrev Port {I G : Type} (f : Route I G) (g : G) := {i:I//f i=g}
|
| 40 |
-
abbrev Network {I G : Type} (f : Route I G) (N : ℕ) := ∀ i,Rack (Port f i) N
|
| 41 |
-
|
| 42 |
-
variable [Fintype G]
|
| 43 |
-
variable [DecidableEq I] [DecidableEq J] [DecidableEq G]
|
| 44 |
-
variable {f : Route I G}
|
| 45 |
-
|
| 46 |
-
def rackEquiv (f : Route I G) (N : ℕ) : Rack I N ≃ Network f N where
|
| 47 |
-
toFun x i := sectionR Subtype.val x
|
| 48 |
-
invFun x := (Matrix.of (fun j i => (x (f i)).1 j ⟨i,rfl⟩),
|
| 49 |
-
Matrix.of (fun j i => (x (f i)).2 j ⟨i,rfl⟩))
|
| 50 |
-
left_inv x := by apply Prod.ext <;> rfl
|
| 51 |
-
right_inv x := by
|
| 52 |
-
funext i; apply Prod.ext <;>
|
| 53 |
-
· ext j ⟨y,rfl⟩; rfl
|
| 54 |
-
|
| 55 |
-
abbrev GeoM (f : Route I G) := ∀ i,Mat (Port f i) (Port f i)
|
| 56 |
-
|
| 57 |
-
def gramPart {N} (A : GeoM f) (x : Rack I N) :=
|
| 58 |
-
∀ i,let P:=rackEquiv f N x i;
|
| 59 |
-
P.1ᵀ*P.2=A i
|
| 60 |
-
def injPart (f : Route I G) {N} (x : Rack I N) :=
|
| 61 |
-
∀ i,let P:=rackEquiv f N x i;
|
| 62 |
-
Injective P.1.mulVec ∧ Injective P.2.mulVec
|
| 63 |
-
|
| 64 |
-
def bothPart {N} (A : GeoM f) (x : Rack I N) := ∀ i, gramGood (A i) (rackEquiv f N x i)
|
| 65 |
-
|
| 66 |
-
def scoreR {I : Type} (x : Rack I N) (i j : I) : F := (x.1ᵀ*x.2) i j
|
| 67 |
-
|
| 68 |
-
omit [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] in
|
| 69 |
-
theorem part_scores (x : Rack I N) (A : GeoM f) :
|
| 70 |
-
gramPart A x↔ ∀ i, ∀ a b : Port f i,scoreR x a.val b.val=A i a b := by
|
| 71 |
-
constructor
|
| 72 |
-
· intro h i a b; exact congr_fun (congr_fun (h i) a) b
|
| 73 |
-
intro h i; exact Matrix.ext (fun a b => h i a b)
|
| 74 |
-
|
| 75 |
-
omit [Fintype G] [DecidableEq I] in
|
| 76 |
-
theorem both_test (A : GeoM f) (x : Rack I N) :
|
| 77 |
-
bothPart A x↔ gramPart A x ∧injPart f x := by simp [gramPart,injPart,bothPart,gramGood,forall_and]
|
| 78 |
-
|
| 79 |
-
private theorem pi_unif {I : Type} [Fintype I] [DecidableEq I]
|
| 80 |
-
{A : I→Type} [∀ i,Fintype (A i)] :
|
| 81 |
-
unif (α:=(∀ i,A i)) = prodW (fun i => unif (α:=A i)) := by
|
| 82 |
-
classical
|
| 83 |
-
funext x
|
| 84 |
-
simp [unif_apply,prodW,Fintype.card_pi]
|
| 85 |
-
|
| 86 |
-
private theorem pi_unifOn {I : Type} [Fintype I] [DecidableEq I]
|
| 87 |
-
{A : I→Type} [∀ i,Fintype (A i)] (p : ∀ i,A i→Prop) :
|
| 88 |
-
unifOn (fun x => ∀ i,p i (x i)) = prodW (fun i => unifOn (p i)) := by
|
| 89 |
-
classical
|
| 90 |
-
funext x
|
| 91 |
-
rw [unifOn_val]
|
| 92 |
-
have he : nbr (fun x : (∀ i, A i) => ∀ i,p i (x i)) = ∏ i,nbr (p i) := by
|
| 93 |
-
unfold nbr; simp_rw [ind_all]
|
| 94 |
-
exact prodW_tot (fun (i : I) (x : A i) => ind (p i x))
|
| 95 |
-
simp only [prodW,he,unifOn_val,ind_all,Finset.prod_div_distrib]
|
| 96 |
-
|
| 97 |
-
def rackStation (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (bothPart A)
|
| 98 |
-
def rackWave (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (gramPart A)
|
| 99 |
-
|
| 100 |
-
theorem station_split (A : GeoM f) (N : ℕ) :
|
| 101 |
-
mapW (rackStation A N) (rackEquiv f N)=
|
| 102 |
-
prodW (fun i => unifOn (gramGood (A i))) := by
|
| 103 |
-
classical
|
| 104 |
-
unfold rackStation bothPart
|
| 105 |
-
rw [show mapW _ _= _ from on_equiv (rackEquiv f N)
|
| 106 |
-
(fun x => ∀ i,gramGood (A i) (x i))]
|
| 107 |
-
exact pi_unifOn _
|
| 108 |
-
|
| 109 |
-
def netSize (f : Route I G) := ∑ i : G,num (Port f i)*num (Port f i)
|
| 110 |
-
def netFact (f : Route I G) :=
|
| 111 |
-
(4:ℝ)^(Fintype.card G)*bp (netSize f)
|
| 112 |
-
|
| 113 |
-
omit [DecidableEq I] in
|
| 114 |
-
theorem netFact_pos : 0<netFact f := mul_pos (pow_pos (by norm_num) _) (bp_pos _)
|
| 115 |
-
|
| 116 |
-
theorem net_norm (A : GeoM f) (N : ℕ)
|
| 117 |
-
(h : ∀ i,2*num (Port f i)-N≤ -1) :
|
| 118 |
-
(netFact f)⁻¹ ≤ pr unif (bothPart (N:=N) A) ∧
|
| 119 |
-
pr unif (bothPart (N:=N) A) ≤ bp (-netSize f) := by
|
| 120 |
-
classical
|
| 121 |
-
let p := fun i => gramGood (U:=Fin N) (A i)
|
| 122 |
-
have hnum (t : ℕ) : num (Fin t)=(t:ℝ) := by simp [num]
|
| 123 |
-
have ht i : num (Port f i) + num (Port f i)-num (Fin N)≤ -1 := by rw [←two_mul,hnum]; exact h _
|
| 124 |
-
have he : pr unif (bothPart (N:=N) A) = ∏ i,pr unif (p i) := by
|
| 125 |
-
unfold bothPart
|
| 126 |
-
rw [←mapW_pr unif (rackEquiv f N) (fun x => ∀ i,p i (x i)), unif_equiv]
|
| 127 |
-
conv_lhs => rw [pi_unif]
|
| 128 |
-
exact prodW_pr ..
|
| 129 |
-
rw [he]; constructor
|
| 130 |
-
· let h' (i : G) := bp (-(num (Port f i))*num (Port f i))/4
|
| 131 |
-
have hh i : h' i ≤ pr unif (p i) := gram_norm_quarter _ (ht _)
|
| 132 |
-
refine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => div_nonneg (bp_pos _).le
|
| 133 |
-
(by norm_num)) fun i _ => hh i)
|
| 134 |
-
unfold netFact
|
| 135 |
-
rw [_root_.mul_inv_rev,Finset.prod_div_distrib,←bp_sum,netSize,Finset.prod_const,
|
| 136 |
-
← bp_neg, ← Finset.sum_neg_distrib]
|
| 137 |
-
simp_rw [neg_mul, Finset.card_univ,div_eq_mul_inv]
|
| 138 |
-
exact le_rfl
|
| 139 |
-
· have h i :=
|
| 140 |
-
(gram_norm (U:=Fin N) (A i) (show _≤ _ by linarith only [ht i])).1
|
| 141 |
-
unfold netSize
|
| 142 |
-
rw [← Finset.sum_neg_distrib, bp_sum]
|
| 143 |
-
apply Finset.prod_le_prod₀ (fun i _ => pr_nonneg unif_law.nz)
|
| 144 |
-
intro i _
|
| 145 |
-
rw [pair_unif,←neg_mul]
|
| 146 |
-
exact h i
|
| 147 |
-
|
| 148 |
-
theorem wave_norm (A : GeoM f) (N : ℕ)
|
| 149 |
-
(h : ∀ i,2*num (Port f i)-N≤ -1) :
|
| 150 |
-
(netFact f)⁻¹ ≤ pr unif (gramPart (N:=N) A) :=
|
| 151 |
-
((net_norm A N h).1).trans
|
| 152 |
-
(pr_mono unif_law.nz (fun _ hx => ((both_test ..).mp hx).1))
|
| 153 |
-
|
| 154 |
-
theorem injPart_failure (f : Route I G) (N : ℕ) (k : ℝ) (h : ∀ i,num (Port f i)≤k) :
|
| 155 |
-
pr unif (fun x : Rack I N => ¬injPart f x)≤num G*(2*bp (k-N)) := by
|
| 156 |
-
classical
|
| 157 |
-
let Q := fun x : Network f N =>
|
| 158 |
-
∀ i, Injective (x i).1.mulVec ∧ Injective (x i).2.mulVec
|
| 159 |
-
have he :
|
| 160 |
-
pr unif (fun x : Rack I N => ¬injPart f x)=
|
| 161 |
-
pr (prodW (fun i : G => unif (α:=Rack (Port f i) N))) (fun x => ¬Q x) := by
|
| 162 |
-
rw [←pi_unif,← unif_equiv (rackEquiv f N),mapW_pr]
|
| 163 |
-
rfl
|
| 164 |
-
rw [he]
|
| 165 |
-
let P i := fun x : Rack (Port f i) N => ¬ (Injective x.1.mulVec∧Injective x.2.mulVec)
|
| 166 |
-
let w : Wgt (Network f N) := prodW (fun i => unif)
|
| 167 |
-
have hw : IsLaw w := prodW_law (fun _ => unif_law)
|
| 168 |
-
have ht i : pr unif (P i) ≤ 2*bp (k-N) := by
|
| 169 |
-
let g := fun x : PlusRack (Port f i) N => ¬Injective x.mulVec
|
| 170 |
-
have hi : pr unif g≤ bp (k-N) := by
|
| 171 |
-
refine unif_fail.trans (bp_le ?_)
|
| 172 |
-
have he := h i
|
| 173 |
-
simp only [num,Fintype.card_fin] at *
|
| 174 |
-
linarith only [he]
|
| 175 |
-
have hQ (x : Rack (Port f i) N) :
|
| 176 |
-
P i x→ (True∧g x.2)∨(g x.1∧True) := by unfold P g; tauto
|
| 177 |
-
rw [pair_unif,two_mul]
|
| 178 |
-
let nz := (pairW_law (α:=PlusRack (Port f i) N) unif_law (β:=PlusRack (Port f i) N) unif_law).nz
|
| 179 |
-
calc pr _ _
|
| 180 |
-
_ ≤ _ := pr_mono nz hQ
|
| 181 |
-
_ ≤ _ := pr_or_le nz
|
| 182 |
-
_ ≤ _ := by rw [pairW_pr unif unif (fun _ : PlusRack (Port f i) N => True) g,pairW_pr unif unif g (fun _ : PlusRack (Port f i) N => True),pr_true,unif_law.total,one_mul,mul_one]
|
| 183 |
-
exact add_le_add hi hi
|
| 184 |
-
have hP x (h : ¬Q x) : ∃ i,P i (x i) := Classical.byContradiction (fun g =>
|
| 185 |
-
h (fun i => Classical.byContradiction (fun he => g ⟨i,he⟩)))
|
| 186 |
-
have hc i :
|
| 187 |
-
pr w (fun x => P i (x i))=pr unif (P i) := by
|
| 188 |
-
let g (j : G) (x : Rack (Port f j) N) :=
|
| 189 |
-
if h:j=i then by subst i; exact P j x else True
|
| 190 |
-
have he (x : Network f N) :
|
| 191 |
-
P i (x i) ↔ ∀ j,g j (x j) := by
|
| 192 |
-
constructor
|
| 193 |
-
· intro h j
|
| 194 |
-
by_cases he : j=i
|
| 195 |
-
· subst j; exact (by simpa [g])
|
| 196 |
-
simp [g,he]
|
| 197 |
-
· intro h; simpa [g] using h i
|
| 198 |
-
simp_rw [he]; unfold w; rw [prodW_pr _ g,Finset.prod_eq_single i]
|
| 199 |
-
· simp [g]
|
| 200 |
-
· intro j _ hj; simp [g,hj,unif_law.total]
|
| 201 |
-
simp
|
| 202 |
-
refine le_trans (pr_mono hw.nz hP) ((pr_exists_le hw.nz (fun i x => P i (x i))).trans ?_)
|
| 203 |
-
simp_rw [hc]
|
| 204 |
-
refine (Finset.sum_le_sum fun i _ => ht i).trans_eq ?_
|
| 205 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,num]
|
| 206 |
-
|
| 207 |
-
end HadwigerCounterexample
|
| 208 |
-
|
| 209 |
-
end
|
| 210 |
-
|
| 211 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.TesterSummaryMass
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.ChannelFrameLaws
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Ambient Batch Slots -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix Module LinearMap Finset Function
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {I J G A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]
|
| 13 |
+
variable {p : Shape} {n N : ℕ}
|
| 14 |
+
|
| 15 |
+
omit [Fintype B] in
|
| 16 |
+
theorem mapW_equiv_val (e : A≃B) (w : Wgt A) (y : B) :
|
| 17 |
+
mapW w e y=w (e.symm y) := by
|
| 18 |
+
classical
|
| 19 |
+
have h : (fun x => e x=y)=(fun x => x=e.symm y) := by
|
| 20 |
+
funext x; apply propext
|
| 21 |
+
exact ⟨fun h => by rw [← h,Equiv.symm_apply_apply],fun h => by rw [h,Equiv.apply_symm_apply]⟩
|
| 22 |
+
unfold mapW; rw [h]; simp
|
| 23 |
+
|
| 24 |
+
theorem unif_equiv (e : A≃B) : mapW unif e = unif := by
|
| 25 |
+
funext x; rw [mapW_equiv_val, unif_apply, unif_apply, Fintype.card_congr e]
|
| 26 |
+
|
| 27 |
+
theorem on_equiv (e : A≃B) (p : B→Prop) :
|
| 28 |
+
mapW (unifOn (fun x => p (e x))) e = unifOn p := by
|
| 29 |
+
classical
|
| 30 |
+
have h : nbr (fun x => p (e x))=nbr p := Equiv.sum_comp e (fun y => ind (p y))
|
| 31 |
+
funext x
|
| 32 |
+
rw [mapW_equiv_val,unifOn_val,unifOn_val]; simp only [Equiv.apply_symm_apply,h]
|
| 33 |
+
|
| 34 |
+
abbrev PlusRack (I : Type) (N : ℕ) := Mat (Fin N) I
|
| 35 |
+
abbrev Rack (I : Type) (N : ℕ) := PlusRack I N × PlusRack I N
|
| 36 |
+
def sectionR {I J : Type} (f : J→I) (x : Rack I N) : Rack J N :=
|
| 37 |
+
((x.1).submatrix _root_.id f, (x.2).submatrix _root_.id f)
|
| 38 |
+
abbrev Route (I G : Type) := I → G
|
| 39 |
+
abbrev Port {I G : Type} (f : Route I G) (g : G) := {i:I//f i=g}
|
| 40 |
+
abbrev Network {I G : Type} (f : Route I G) (N : ℕ) := ∀ i,Rack (Port f i) N
|
| 41 |
+
|
| 42 |
+
variable [Fintype G]
|
| 43 |
+
variable [DecidableEq I] [DecidableEq J] [DecidableEq G]
|
| 44 |
+
variable {f : Route I G}
|
| 45 |
+
|
| 46 |
+
def rackEquiv (f : Route I G) (N : ℕ) : Rack I N ≃ Network f N where
|
| 47 |
+
toFun x i := sectionR Subtype.val x
|
| 48 |
+
invFun x := (Matrix.of (fun j i => (x (f i)).1 j ⟨i,rfl⟩),
|
| 49 |
+
Matrix.of (fun j i => (x (f i)).2 j ⟨i,rfl⟩))
|
| 50 |
+
left_inv x := by apply Prod.ext <;> rfl
|
| 51 |
+
right_inv x := by
|
| 52 |
+
funext i; apply Prod.ext <;>
|
| 53 |
+
· ext j ⟨y,rfl⟩; rfl
|
| 54 |
+
|
| 55 |
+
abbrev GeoM (f : Route I G) := ∀ i,Mat (Port f i) (Port f i)
|
| 56 |
+
|
| 57 |
+
def gramPart {N} (A : GeoM f) (x : Rack I N) :=
|
| 58 |
+
∀ i,let P:=rackEquiv f N x i;
|
| 59 |
+
P.1ᵀ*P.2=A i
|
| 60 |
+
def injPart (f : Route I G) {N} (x : Rack I N) :=
|
| 61 |
+
∀ i,let P:=rackEquiv f N x i;
|
| 62 |
+
Injective P.1.mulVec ∧ Injective P.2.mulVec
|
| 63 |
+
|
| 64 |
+
def bothPart {N} (A : GeoM f) (x : Rack I N) := ∀ i, gramGood (A i) (rackEquiv f N x i)
|
| 65 |
+
|
| 66 |
+
def scoreR {I : Type} (x : Rack I N) (i j : I) : F := (x.1ᵀ*x.2) i j
|
| 67 |
+
|
| 68 |
+
omit [Fintype I] [Fintype G] [DecidableEq I] [DecidableEq G] in
|
| 69 |
+
theorem part_scores (x : Rack I N) (A : GeoM f) :
|
| 70 |
+
gramPart A x↔ ∀ i, ∀ a b : Port f i,scoreR x a.val b.val=A i a b := by
|
| 71 |
+
constructor
|
| 72 |
+
· intro h i a b; exact congr_fun (congr_fun (h i) a) b
|
| 73 |
+
intro h i; exact Matrix.ext (fun a b => h i a b)
|
| 74 |
+
|
| 75 |
+
omit [Fintype G] [DecidableEq I] in
|
| 76 |
+
theorem both_test (A : GeoM f) (x : Rack I N) :
|
| 77 |
+
bothPart A x↔ gramPart A x ∧injPart f x := by simp [gramPart,injPart,bothPart,gramGood,forall_and]
|
| 78 |
+
|
| 79 |
+
private theorem pi_unif {I : Type} [Fintype I] [DecidableEq I]
|
| 80 |
+
{A : I→Type} [∀ i,Fintype (A i)] :
|
| 81 |
+
unif (α:=(∀ i,A i)) = prodW (fun i => unif (α:=A i)) := by
|
| 82 |
+
classical
|
| 83 |
+
funext x
|
| 84 |
+
simp [unif_apply,prodW,Fintype.card_pi]
|
| 85 |
+
|
| 86 |
+
private theorem pi_unifOn {I : Type} [Fintype I] [DecidableEq I]
|
| 87 |
+
{A : I→Type} [∀ i,Fintype (A i)] (p : ∀ i,A i→Prop) :
|
| 88 |
+
unifOn (fun x => ∀ i,p i (x i)) = prodW (fun i => unifOn (p i)) := by
|
| 89 |
+
classical
|
| 90 |
+
funext x
|
| 91 |
+
rw [unifOn_val]
|
| 92 |
+
have he : nbr (fun x : (∀ i, A i) => ∀ i,p i (x i)) = ∏ i,nbr (p i) := by
|
| 93 |
+
unfold nbr; simp_rw [ind_all]
|
| 94 |
+
exact prodW_tot (fun (i : I) (x : A i) => ind (p i x))
|
| 95 |
+
simp only [prodW,he,unifOn_val,ind_all,Finset.prod_div_distrib]
|
| 96 |
+
|
| 97 |
+
def rackStation (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (bothPart A)
|
| 98 |
+
def rackWave (A : GeoM f) (N : ℕ) : Wgt (Rack I N) := unifOn (gramPart A)
|
| 99 |
+
|
| 100 |
+
theorem station_split (A : GeoM f) (N : ℕ) :
|
| 101 |
+
mapW (rackStation A N) (rackEquiv f N)=
|
| 102 |
+
prodW (fun i => unifOn (gramGood (A i))) := by
|
| 103 |
+
classical
|
| 104 |
+
unfold rackStation bothPart
|
| 105 |
+
rw [show mapW _ _= _ from on_equiv (rackEquiv f N)
|
| 106 |
+
(fun x => ∀ i,gramGood (A i) (x i))]
|
| 107 |
+
exact pi_unifOn _
|
| 108 |
+
|
| 109 |
+
def netSize (f : Route I G) := ∑ i : G,num (Port f i)*num (Port f i)
|
| 110 |
+
def netFact (f : Route I G) :=
|
| 111 |
+
(4:ℝ)^(Fintype.card G)*bp (netSize f)
|
| 112 |
+
|
| 113 |
+
omit [DecidableEq I] in
|
| 114 |
+
theorem netFact_pos : 0<netFact f := mul_pos (pow_pos (by norm_num) _) (bp_pos _)
|
| 115 |
+
|
| 116 |
+
theorem net_norm (A : GeoM f) (N : ℕ)
|
| 117 |
+
(h : ∀ i,2*num (Port f i)-N≤ -1) :
|
| 118 |
+
(netFact f)⁻¹ ≤ pr unif (bothPart (N:=N) A) ∧
|
| 119 |
+
pr unif (bothPart (N:=N) A) ≤ bp (-netSize f) := by
|
| 120 |
+
classical
|
| 121 |
+
let p := fun i => gramGood (U:=Fin N) (A i)
|
| 122 |
+
have hnum (t : ℕ) : num (Fin t)=(t:ℝ) := by simp [num]
|
| 123 |
+
have ht i : num (Port f i) + num (Port f i)-num (Fin N)≤ -1 := by rw [←two_mul,hnum]; exact h _
|
| 124 |
+
have he : pr unif (bothPart (N:=N) A) = ∏ i,pr unif (p i) := by
|
| 125 |
+
unfold bothPart
|
| 126 |
+
rw [←mapW_pr unif (rackEquiv f N) (fun x => ∀ i,p i (x i)), unif_equiv]
|
| 127 |
+
conv_lhs => rw [pi_unif]
|
| 128 |
+
exact prodW_pr ..
|
| 129 |
+
rw [he]; constructor
|
| 130 |
+
· let h' (i : G) := bp (-(num (Port f i))*num (Port f i))/4
|
| 131 |
+
have hh i : h' i ≤ pr unif (p i) := gram_norm_quarter _ (ht _)
|
| 132 |
+
refine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => div_nonneg (bp_pos _).le
|
| 133 |
+
(by norm_num)) fun i _ => hh i)
|
| 134 |
+
unfold netFact
|
| 135 |
+
rw [_root_.mul_inv_rev,Finset.prod_div_distrib,←bp_sum,netSize,Finset.prod_const,
|
| 136 |
+
← bp_neg, ← Finset.sum_neg_distrib]
|
| 137 |
+
simp_rw [neg_mul, Finset.card_univ,div_eq_mul_inv]
|
| 138 |
+
exact le_rfl
|
| 139 |
+
· have h i :=
|
| 140 |
+
(gram_norm (U:=Fin N) (A i) (show _≤ _ by linarith only [ht i])).1
|
| 141 |
+
unfold netSize
|
| 142 |
+
rw [← Finset.sum_neg_distrib, bp_sum]
|
| 143 |
+
apply Finset.prod_le_prod₀ (fun i _ => pr_nonneg unif_law.nz)
|
| 144 |
+
intro i _
|
| 145 |
+
rw [pair_unif,←neg_mul]
|
| 146 |
+
exact h i
|
| 147 |
+
|
| 148 |
+
theorem wave_norm (A : GeoM f) (N : ℕ)
|
| 149 |
+
(h : ∀ i,2*num (Port f i)-N≤ -1) :
|
| 150 |
+
(netFact f)⁻¹ ≤ pr unif (gramPart (N:=N) A) :=
|
| 151 |
+
((net_norm A N h).1).trans
|
| 152 |
+
(pr_mono unif_law.nz (fun _ hx => ((both_test ..).mp hx).1))
|
| 153 |
+
|
| 154 |
+
theorem injPart_failure (f : Route I G) (N : ℕ) (k : ℝ) (h : ∀ i,num (Port f i)≤k) :
|
| 155 |
+
pr unif (fun x : Rack I N => ¬injPart f x)≤num G*(2*bp (k-N)) := by
|
| 156 |
+
classical
|
| 157 |
+
let Q := fun x : Network f N =>
|
| 158 |
+
∀ i, Injective (x i).1.mulVec ∧ Injective (x i).2.mulVec
|
| 159 |
+
have he :
|
| 160 |
+
pr unif (fun x : Rack I N => ¬injPart f x)=
|
| 161 |
+
pr (prodW (fun i : G => unif (α:=Rack (Port f i) N))) (fun x => ¬Q x) := by
|
| 162 |
+
rw [←pi_unif,← unif_equiv (rackEquiv f N),mapW_pr]
|
| 163 |
+
rfl
|
| 164 |
+
rw [he]
|
| 165 |
+
let P i := fun x : Rack (Port f i) N => ¬ (Injective x.1.mulVec∧Injective x.2.mulVec)
|
| 166 |
+
let w : Wgt (Network f N) := prodW (fun i => unif)
|
| 167 |
+
have hw : IsLaw w := prodW_law (fun _ => unif_law)
|
| 168 |
+
have ht i : pr unif (P i) ≤ 2*bp (k-N) := by
|
| 169 |
+
let g := fun x : PlusRack (Port f i) N => ¬Injective x.mulVec
|
| 170 |
+
have hi : pr unif g≤ bp (k-N) := by
|
| 171 |
+
refine unif_fail.trans (bp_le ?_)
|
| 172 |
+
have he := h i
|
| 173 |
+
simp only [num,Fintype.card_fin] at *
|
| 174 |
+
linarith only [he]
|
| 175 |
+
have hQ (x : Rack (Port f i) N) :
|
| 176 |
+
P i x→ (True∧g x.2)∨(g x.1∧True) := by unfold P g; tauto
|
| 177 |
+
rw [pair_unif,two_mul]
|
| 178 |
+
let nz := (pairW_law (α:=PlusRack (Port f i) N) unif_law (β:=PlusRack (Port f i) N) unif_law).nz
|
| 179 |
+
calc pr _ _
|
| 180 |
+
_ ≤ _ := pr_mono nz hQ
|
| 181 |
+
_ ≤ _ := pr_or_le nz
|
| 182 |
+
_ ≤ _ := by rw [pairW_pr unif unif (fun _ : PlusRack (Port f i) N => True) g,pairW_pr unif unif g (fun _ : PlusRack (Port f i) N => True),pr_true,unif_law.total,one_mul,mul_one]
|
| 183 |
+
exact add_le_add hi hi
|
| 184 |
+
have hP x (h : ¬Q x) : ∃ i,P i (x i) := Classical.byContradiction (fun g =>
|
| 185 |
+
h (fun i => Classical.byContradiction (fun he => g ⟨i,he⟩)))
|
| 186 |
+
have hc i :
|
| 187 |
+
pr w (fun x => P i (x i))=pr unif (P i) := by
|
| 188 |
+
let g (j : G) (x : Rack (Port f j) N) :=
|
| 189 |
+
if h:j=i then by subst i; exact P j x else True
|
| 190 |
+
have he (x : Network f N) :
|
| 191 |
+
P i (x i) ↔ ∀ j,g j (x j) := by
|
| 192 |
+
constructor
|
| 193 |
+
· intro h j
|
| 194 |
+
by_cases he : j=i
|
| 195 |
+
· subst j; exact (by simpa [g])
|
| 196 |
+
simp [g,he]
|
| 197 |
+
· intro h; simpa [g] using h i
|
| 198 |
+
simp_rw [he]; unfold w; rw [prodW_pr _ g,Finset.prod_eq_single i]
|
| 199 |
+
· simp [g]
|
| 200 |
+
· intro j _ hj; simp [g,hj,unif_law.total]
|
| 201 |
+
simp
|
| 202 |
+
refine le_trans (pr_mono hw.nz hP) ((pr_exists_le hw.nz (fun i x => P i (x i))).trans ?_)
|
| 203 |
+
simp_rw [hc]
|
| 204 |
+
refine (Finset.sum_le_sum fun i _ => ht i).trans_eq ?_
|
| 205 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,num]
|
| 206 |
+
|
| 207 |
+
end HadwigerCounterexample
|
| 208 |
+
|
| 209 |
+
end
|
| 210 |
+
|
| 211 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AnalyticParameters.lean
CHANGED
|
@@ -1,143 +1,143 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PairedMassIdentities
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBounds
|
| 3 |
-
import OAI.Combinatorics.HadwigerCounterexample.RecursiveComparisonErrors
|
| 4 |
-
import OAI.Combinatorics.HadwigerCounterexample.MixerExistence
|
| 5 |
-
|
| 6 |
-
namespace OAI
|
| 7 |
-
|
| 8 |
-
/-! # Analytic Parameters -/
|
| 9 |
-
|
| 10 |
-
noncomputable section
|
| 11 |
-
namespace HadwigerCounterexample
|
| 12 |
-
open Filter Finset Matrix
|
| 13 |
-
open scoped BigOperators Topology
|
| 14 |
-
open StatusAnalysis StatusAnalysis.Station
|
| 15 |
-
|
| 16 |
-
def frameBills (g K : ℕ) :=
|
| 17 |
-
2*Fintype.card (Comp g)*K*qorth K
|
| 18 |
-
|
| 19 |
-
structure AnalyticParameters (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ) : Prop where
|
| 20 |
-
enter : b.entry p M
|
| 21 |
-
thickness : 4≤ M
|
| 22 |
-
profiles : 2*profileA p b.pins < r
|
| 23 |
-
jump : 1≤p.J
|
| 24 |
-
bigJ : r≤p.J
|
| 25 |
-
gleaming : bp (-((p.J-r:ℕ):ℝ))*bp r < glintRate b.pins
|
| 26 |
-
penRoom : (b.pins+1)*qorth b.pins≤p.j+1
|
| 27 |
-
forbid : frameBills p.g b.pins+1000 ≤ b.B
|
| 28 |
-
spare : 3*b.B < Fintype.card (Label p.b)
|
| 29 |
-
secure : ∀ᶠ n : ℕ in atTop, Station.earnsScore p n (M*n) b.pins (2*b.ζ)
|
| 30 |
-
|
| 31 |
-
namespace PreparationParameters
|
| 32 |
-
variable {b : PreparationParameters} {p : Shape} {N M r : ℕ} {l : Filter ℕ} {m : cycleM p}
|
| 33 |
-
{s : rhythms p M} {w : tale p M}
|
| 34 |
-
|
| 35 |
-
def conflicted {n : ℕ} (p : Shape) (m : Mixer p n) (N : ℕ) (w : Wgt (UnitType p n N)) :=
|
| 36 |
-
pr (pairW w w) (clash p m N)<bp (-100*p.g*(N:ℝ))
|
| 37 |
-
|
| 38 |
-
structure veil (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ)
|
| 39 |
-
(l : Filter ℕ) (m : cycleM p) (s : rhythms p M) (w : tale p M) : Prop where
|
| 40 |
-
easel : AnalyticParameters p M b r
|
| 41 |
-
timeL : l≤atTop
|
| 42 |
-
durableS : b.durable l p M m w s
|
| 43 |
-
moment : ∀ᶠ n in l,b.nascent p (M*n) (w n) (m n) ∧ unaryGood (m n) b.pins r ∧
|
| 44 |
-
binaryGood (m n) ∧ conflicted p (m n) (M*n) (w n)
|
| 45 |
-
|
| 46 |
-
abbrev Stations (p : Shape) (M K : ℕ) (s : rhythms p M) :=
|
| 47 |
-
∀ n : ℕ, Station p n (M*n) K (s n)
|
| 48 |
-
|
| 49 |
-
theorem beam_cost (p : Shape) (N : ℕ) (h : 3≤p.g) :
|
| 50 |
-
beamPrice p N * bp (-100*p.g*(N:ℝ)) ≤ bp (-(N:ℝ)) := by
|
| 51 |
-
unfold beamPrice; rw [←bp_add]; refine bp_le ?_
|
| 52 |
-
have hh : kmax p ≤56*p.g := by unfold kmax; omega
|
| 53 |
-
have ht : (kmax p:ℝ)≤56*p.g := by exact_mod_cast hh
|
| 54 |
-
have hg : 3 ≤ (p.g:ℝ) := by exact_mod_cast h
|
| 55 |
-
apply le_trans ?_ (le_of_eq (neg_one_mul _))
|
| 56 |
-
rw [← add_mul]
|
| 57 |
-
exact mul_le_mul_of_nonneg_right (by linarith only [ht,hg]) (by positivity)
|
| 58 |
-
|
| 59 |
-
set_option maxHeartbeats 1200000 in
|
| 60 |
-
theorem veil.score_cost (h : veil p M b r l m s w)
|
| 61 |
-
(v : Stations p M b.pins s) :
|
| 62 |
-
∃ δ : ℕ → ℝ,ExpSmall l (fun n=> ((M*n:ℕ):ℝ)) δ ∧
|
| 63 |
-
∀ᶠ n in l, ∀ (q : Format) (d e : Rates) (x : Typus p q d e) (k : Fin (2^deckMax p b.pins)),
|
| 64 |
-
|arena (v n) x (m n) (w n) k|≤δ n := by
|
| 65 |
-
let N:=fun n : ℕ=> M*n; let z:=fun n=>((N n):ℝ)
|
| 66 |
-
have hq := h.easel
|
| 67 |
-
have ht := hq.enter.first
|
| 68 |
-
have hz : Tendsto z l atTop := (trend_sizes l h.timeL ht.hM).2
|
| 69 |
-
let C n:= ((s n).amount (w n))⁻¹
|
| 70 |
-
have hc := h.durableS.mass.inv_cap
|
| 71 |
-
let δ n := bp (-1*z n)*C n*C n + bp (-0.005*z n)*2
|
| 72 |
-
have hd : ExpSmall l z δ :=
|
| 73 |
-
(((ExpSmall.bp_n zero_lt_one).mul hc).mul hc).add hz
|
| 74 |
-
((ExpSmall.bp_n (by norm_num)).mul (expO_const hz _))
|
| 75 |
-
refine ⟨δ,hd,?_⟩
|
| 76 |
-
filter_upwards [h.moment,h.durableS.mass.positive,h.durableS.shape,hq.secure.filter_mono h.timeL]
|
| 77 |
-
with n hn hN hA hB q d e x k
|
| 78 |
-
have hm := hn.1.law
|
| 79 |
-
rw [abs_of_nonneg (arena_pos _ _ _ _ _ hN hm)]
|
| 80 |
-
let u:=(s n).sap (w n)
|
| 81 |
-
refine (arena_bound (v n) x _ _ k hA.1 hm hN hB).trans ?_
|
| 82 |
-
have hμ i : 0≤u i := (LeafMixture.sapLaw hN hm).nz _
|
| 83 |
-
have hk i : u i ≤ C n*w n i := LeafMixture.upper_sap hm hN i
|
| 84 |
-
have hv (x:UnitType p n (N n) × UnitType p n (N n)) :
|
| 85 |
-
pairW u u x ≤ (C n*C n)*pairW (w n) (w n) x :=
|
| 86 |
-
(mul_le_mul (hk _) (hk _) (hμ _) ((hμ _).trans (hk _))).trans_eq (by unfold pairW; ring)
|
| 87 |
-
have hf : pr (pairW u u) (clash p (m n) (N n)) ≤
|
| 88 |
-
(C n*C n)*bp (-100*p.g * (z n)) := (pr_cap hv _).trans
|
| 89 |
-
(mul_le_mul_of_nonneg_left hn.2.2.2.le (mul_self_nonneg _))
|
| 90 |
-
unfold δ
|
| 91 |
-
rw [mul_comm _ 2]
|
| 92 |
-
refine add_le_add_left ((mul_le_mul_of_nonneg_left hf (bp_pos _).le).trans ?_) _
|
| 93 |
-
calc _ = (beamPrice p (N n) * bp (-100 * p.g * z n))*(C n*C n) := by unfold beamPrice N; ring
|
| 94 |
-
_ ≤ _ := (mul_le_mul_of_nonneg_right (beam_cost p (N n) ht.hG) (mul_self_nonneg _)).trans_eq
|
| 95 |
-
(by unfold z; rw [neg_one_mul,mul_assoc])
|
| 96 |
-
|
| 97 |
-
structure Align (b : PreparationParameters) (r : ℕ) (p : Shape) (M n : ℕ) (m : Mixer p n)
|
| 98 |
-
(u : Wgt (UnitType p n (M*n))) : Prop where
|
| 99 |
-
rum : binaryGood m
|
| 100 |
-
hymn : unaryGood m b.pins r
|
| 101 |
-
age : 2*p.r ≤ n
|
| 102 |
-
cols : 2*num (Full p n)<(M*n:ℕ)
|
| 103 |
-
drain : Template.drained m b.spJoint u
|
| 104 |
-
|
| 105 |
-
set_option maxHeartbeats 1200000 in
|
| 106 |
-
theorem veil.upright (h : veil p M b r l m s w) :
|
| 107 |
-
∀ᶠ n in l,Align b r p M n (m n) ((s n).sap (w n)) := by
|
| 108 |
-
let z n:= ((M*n:ℕ):ℝ)
|
| 109 |
-
have ht := h.easel.enter.first
|
| 110 |
-
have hM : 1 ≤ (M:ℝ) := by exact_mod_cast ht.hM
|
| 111 |
-
let e :
|
| 112 |
-
have he : 0< e:=by unfold e; positivity
|
| 113 |
-
have hz := (trend_sizes l h.timeL ht.hM).2
|
| 114 |
-
let D n:=((s n).amount (w n))⁻¹
|
| 115 |
-
filter_upwards [h.moment,h.durableS.mass.inv_cap e he,
|
| 116 |
-
h.durableS.mass.positive,expO_const hz b.L e he, ht.wrap.filter_mono h.timeL,
|
| 117 |
-
(eventually_ge_atTop (2*p.r)).filter_mono h.timeL] with n hn he' ht' hL hG hH
|
| 118 |
-
have hw := hn.1.law
|
| 119 |
-
have h1 (i) := LeafMixture.upper_sap hw ht' i
|
| 120 |
-
have h2 : 0≤D n := (inv_pos_of_pos ht').le
|
| 121 |
-
have hB : D n * b.L ≤ bp (1/32*(n:ℝ)) := by
|
| 122 |
-
have hi : e*z n=(1/128)*(n:ℝ) := by unfold e z; push_cast; field_simp
|
| 123 |
-
calc _ ≤ bp (e*z n)*bp (e*z n) :=
|
| 124 |
-
mul_le_mul ((le_abs_self _).trans he') ((le_abs_self _).trans hL) ht.early.hL
|
| 125 |
-
(bp_pos _).le
|
| 126 |
-
_ ≤ _ := by rw [←bp_add,hi]; apply bp_le; linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]
|
| 127 |
-
have hv := LeafMixture.upperSide hn.1.border h1 h2 hB
|
| 128 |
-
refine ⟨hn.2.2.1,hn.2.1,hH,hG.1, LeafMixture.sapLaw ht' hw, hv true,hv false,fun i=>?_⟩
|
| 129 |
-
have hh := hn.1.total i
|
| 130 |
-
apply ((h1 i).trans (mul_le_mul_of_nonneg_left hh h2)).trans
|
| 131 |
-
rw [←mul_assoc]
|
| 132 |
-
refine mul_le_mul_of_nonneg_right ?_ (mul_nonneg (raw_nonneg ..) (raw_nonneg ..))
|
| 133 |
-
have hx : e ≤1 := by unfold e; exact (div_le_iff₀ (by positivity)).mpr (by linarith)
|
| 134 |
-
refine (mul_le_mul_of_nonneg_right ((le_abs_self _).trans he') (bp_pos _).le).trans ?_
|
| 135 |
-
rw [←bp_add]
|
| 136 |
-
unfold spJoint; refine bp_le ?_; rw [←add_mul]
|
| 137 |
-
exact mul_le_mul_of_nonneg_right (by linarith only [hx]) (by positivity)
|
| 138 |
-
end PreparationParameters
|
| 139 |
-
end HadwigerCounterexample
|
| 140 |
-
|
| 141 |
-
end
|
| 142 |
-
|
| 143 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PairedMassIdentities
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBounds
|
| 3 |
+
import OAI.Combinatorics.HadwigerCounterexample.RecursiveComparisonErrors
|
| 4 |
+
import OAI.Combinatorics.HadwigerCounterexample.MixerExistence
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
/-! # Analytic Parameters -/
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
namespace HadwigerCounterexample
|
| 12 |
+
open Filter Finset Matrix
|
| 13 |
+
open scoped BigOperators Topology
|
| 14 |
+
open StatusAnalysis StatusAnalysis.Station
|
| 15 |
+
|
| 16 |
+
def frameBills (g K : ℕ) :=
|
| 17 |
+
2*Fintype.card (Comp g)*K*qorth K
|
| 18 |
+
|
| 19 |
+
structure AnalyticParameters (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ) : Prop where
|
| 20 |
+
enter : b.entry p M
|
| 21 |
+
thickness : 4≤ M
|
| 22 |
+
profiles : 2*profileA p b.pins < r
|
| 23 |
+
jump : 1≤p.J
|
| 24 |
+
bigJ : r≤p.J
|
| 25 |
+
gleaming : bp (-((p.J-r:ℕ):ℝ))*bp r < glintRate b.pins
|
| 26 |
+
penRoom : (b.pins+1)*qorth b.pins≤p.j+1
|
| 27 |
+
forbid : frameBills p.g b.pins+1000 ≤ b.B
|
| 28 |
+
spare : 3*b.B < Fintype.card (Label p.b)
|
| 29 |
+
secure : ∀ᶠ n : ℕ in atTop, Station.earnsScore p n (M*n) b.pins (2*b.ζ)
|
| 30 |
+
|
| 31 |
+
namespace PreparationParameters
|
| 32 |
+
variable {b : PreparationParameters} {p : Shape} {N M r : ℕ} {l : Filter ℕ} {m : cycleM p}
|
| 33 |
+
{s : rhythms p M} {w : tale p M}
|
| 34 |
+
|
| 35 |
+
def conflicted {n : ℕ} (p : Shape) (m : Mixer p n) (N : ℕ) (w : Wgt (UnitType p n N)) :=
|
| 36 |
+
pr (pairW w w) (clash p m N)<bp (-100*p.g*(N:ℝ))
|
| 37 |
+
|
| 38 |
+
structure veil (p : Shape) (M : ℕ) (b : PreparationParameters) (r : ℕ)
|
| 39 |
+
(l : Filter ℕ) (m : cycleM p) (s : rhythms p M) (w : tale p M) : Prop where
|
| 40 |
+
easel : AnalyticParameters p M b r
|
| 41 |
+
timeL : l≤atTop
|
| 42 |
+
durableS : b.durable l p M m w s
|
| 43 |
+
moment : ∀ᶠ n in l,b.nascent p (M*n) (w n) (m n) ∧ unaryGood (m n) b.pins r ∧
|
| 44 |
+
binaryGood (m n) ∧ conflicted p (m n) (M*n) (w n)
|
| 45 |
+
|
| 46 |
+
abbrev Stations (p : Shape) (M K : ℕ) (s : rhythms p M) :=
|
| 47 |
+
∀ n : ℕ, Station p n (M*n) K (s n)
|
| 48 |
+
|
| 49 |
+
theorem beam_cost (p : Shape) (N : ℕ) (h : 3≤p.g) :
|
| 50 |
+
beamPrice p N * bp (-100*p.g*(N:ℝ)) ≤ bp (-(N:ℝ)) := by
|
| 51 |
+
unfold beamPrice; rw [←bp_add]; refine bp_le ?_
|
| 52 |
+
have hh : kmax p ≤56*p.g := by unfold kmax; omega
|
| 53 |
+
have ht : (kmax p:ℝ)≤56*p.g := by exact_mod_cast hh
|
| 54 |
+
have hg : 3 ≤ (p.g:ℝ) := by exact_mod_cast h
|
| 55 |
+
apply le_trans ?_ (le_of_eq (neg_one_mul _))
|
| 56 |
+
rw [← add_mul]
|
| 57 |
+
exact mul_le_mul_of_nonneg_right (by linarith only [ht,hg]) (by positivity)
|
| 58 |
+
|
| 59 |
+
set_option maxHeartbeats 1200000 in
|
| 60 |
+
theorem veil.score_cost (h : veil p M b r l m s w)
|
| 61 |
+
(v : Stations p M b.pins s) :
|
| 62 |
+
∃ δ : ℕ → ℝ,ExpSmall l (fun n=> ((M*n:ℕ):ℝ)) δ ∧
|
| 63 |
+
∀ᶠ n in l, ∀ (q : Format) (d e : Rates) (x : Typus p q d e) (k : Fin (2^deckMax p b.pins)),
|
| 64 |
+
|arena (v n) x (m n) (w n) k|≤δ n := by
|
| 65 |
+
let N:=fun n : ℕ=> M*n; let z:=fun n=>((N n):ℝ)
|
| 66 |
+
have hq := h.easel
|
| 67 |
+
have ht := hq.enter.first
|
| 68 |
+
have hz : Tendsto z l atTop := (trend_sizes l h.timeL ht.hM).2
|
| 69 |
+
let C n:= ((s n).amount (w n))⁻¹
|
| 70 |
+
have hc := h.durableS.mass.inv_cap
|
| 71 |
+
let δ n := bp (-1*z n)*C n*C n + bp (-0.005*z n)*2
|
| 72 |
+
have hd : ExpSmall l z δ :=
|
| 73 |
+
(((ExpSmall.bp_n zero_lt_one).mul hc).mul hc).add hz
|
| 74 |
+
((ExpSmall.bp_n (by norm_num)).mul (expO_const hz _))
|
| 75 |
+
refine ⟨δ,hd,?_⟩
|
| 76 |
+
filter_upwards [h.moment,h.durableS.mass.positive,h.durableS.shape,hq.secure.filter_mono h.timeL]
|
| 77 |
+
with n hn hN hA hB q d e x k
|
| 78 |
+
have hm := hn.1.law
|
| 79 |
+
rw [abs_of_nonneg (arena_pos _ _ _ _ _ hN hm)]
|
| 80 |
+
let u:=(s n).sap (w n)
|
| 81 |
+
refine (arena_bound (v n) x _ _ k hA.1 hm hN hB).trans ?_
|
| 82 |
+
have hμ i : 0≤u i := (LeafMixture.sapLaw hN hm).nz _
|
| 83 |
+
have hk i : u i ≤ C n*w n i := LeafMixture.upper_sap hm hN i
|
| 84 |
+
have hv (x:UnitType p n (N n) × UnitType p n (N n)) :
|
| 85 |
+
pairW u u x ≤ (C n*C n)*pairW (w n) (w n) x :=
|
| 86 |
+
(mul_le_mul (hk _) (hk _) (hμ _) ((hμ _).trans (hk _))).trans_eq (by unfold pairW; ring)
|
| 87 |
+
have hf : pr (pairW u u) (clash p (m n) (N n)) ≤
|
| 88 |
+
(C n*C n)*bp (-100*p.g * (z n)) := (pr_cap hv _).trans
|
| 89 |
+
(mul_le_mul_of_nonneg_left hn.2.2.2.le (mul_self_nonneg _))
|
| 90 |
+
unfold δ
|
| 91 |
+
rw [mul_comm _ 2]
|
| 92 |
+
refine add_le_add_left ((mul_le_mul_of_nonneg_left hf (bp_pos _).le).trans ?_) _
|
| 93 |
+
calc _ = (beamPrice p (N n) * bp (-100 * p.g * z n))*(C n*C n) := by unfold beamPrice N; ring
|
| 94 |
+
_ ≤ _ := (mul_le_mul_of_nonneg_right (beam_cost p (N n) ht.hG) (mul_self_nonneg _)).trans_eq
|
| 95 |
+
(by unfold z; rw [neg_one_mul,mul_assoc])
|
| 96 |
+
|
| 97 |
+
structure Align (b : PreparationParameters) (r : ℕ) (p : Shape) (M n : ℕ) (m : Mixer p n)
|
| 98 |
+
(u : Wgt (UnitType p n (M*n))) : Prop where
|
| 99 |
+
rum : binaryGood m
|
| 100 |
+
hymn : unaryGood m b.pins r
|
| 101 |
+
age : 2*p.r ≤ n
|
| 102 |
+
cols : 2*num (Full p n)<(M*n:ℕ)
|
| 103 |
+
drain : Template.drained m b.spJoint u
|
| 104 |
+
|
| 105 |
+
set_option maxHeartbeats 1200000 in
|
| 106 |
+
theorem veil.upright (h : veil p M b r l m s w) :
|
| 107 |
+
∀ᶠ n in l,Align b r p M n (m n) ((s n).sap (w n)) := by
|
| 108 |
+
let z n:= ((M*n:ℕ):ℝ)
|
| 109 |
+
have ht := h.easel.enter.first
|
| 110 |
+
have hM : 1 ≤ (M:ℝ) := by exact_mod_cast ht.hM
|
| 111 |
+
let e : ℝ := 1/(128*M)
|
| 112 |
+
have he : 0< e:=by unfold e; positivity
|
| 113 |
+
have hz := (trend_sizes l h.timeL ht.hM).2
|
| 114 |
+
let D n:=((s n).amount (w n))⁻¹
|
| 115 |
+
filter_upwards [h.moment,h.durableS.mass.inv_cap e he,
|
| 116 |
+
h.durableS.mass.positive,expO_const hz b.L e he, ht.wrap.filter_mono h.timeL,
|
| 117 |
+
(eventually_ge_atTop (2*p.r)).filter_mono h.timeL] with n hn he' ht' hL hG hH
|
| 118 |
+
have hw := hn.1.law
|
| 119 |
+
have h1 (i) := LeafMixture.upper_sap hw ht' i
|
| 120 |
+
have h2 : 0≤D n := (inv_pos_of_pos ht').le
|
| 121 |
+
have hB : D n * b.L ≤ bp (1/32*(n:ℝ)) := by
|
| 122 |
+
have hi : e*z n=(1/128)*(n:ℝ) := by unfold e z; push_cast; field_simp
|
| 123 |
+
calc _ ≤ bp (e*z n)*bp (e*z n) :=
|
| 124 |
+
mul_le_mul ((le_abs_self _).trans he') ((le_abs_self _).trans hL) ht.early.hL
|
| 125 |
+
(bp_pos _).le
|
| 126 |
+
_ ≤ _ := by rw [←bp_add,hi]; apply bp_le; linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]
|
| 127 |
+
have hv := LeafMixture.upperSide hn.1.border h1 h2 hB
|
| 128 |
+
refine ⟨hn.2.2.1,hn.2.1,hH,hG.1, LeafMixture.sapLaw ht' hw, hv true,hv false,fun i=>?_⟩
|
| 129 |
+
have hh := hn.1.total i
|
| 130 |
+
apply ((h1 i).trans (mul_le_mul_of_nonneg_left hh h2)).trans
|
| 131 |
+
rw [←mul_assoc]
|
| 132 |
+
refine mul_le_mul_of_nonneg_right ?_ (mul_nonneg (raw_nonneg ..) (raw_nonneg ..))
|
| 133 |
+
have hx : e ≤1 := by unfold e; exact (div_le_iff₀ (by positivity)).mpr (by linarith)
|
| 134 |
+
refine (mul_le_mul_of_nonneg_right ((le_abs_self _).trans he') (bp_pos _).le).trans ?_
|
| 135 |
+
rw [←bp_add]
|
| 136 |
+
unfold spJoint; refine bp_le ?_; rw [←add_mul]
|
| 137 |
+
exact mul_le_mul_of_nonneg_right (by linarith only [hx]) (by positivity)
|
| 138 |
+
end PreparationParameters
|
| 139 |
+
end HadwigerCounterexample
|
| 140 |
+
|
| 141 |
+
end
|
| 142 |
+
|
| 143 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AtomFlavors.lean
CHANGED
|
@@ -1,148 +1,148 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.QuadraticTesters
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.KeyDirections
|
| 3 |
-
import OAI.Combinatorics.HadwigerCounterexample.SumRankBounds
|
| 4 |
-
|
| 5 |
-
namespace OAI
|
| 6 |
-
|
| 7 |
-
/-! # Atom Flavors -/
|
| 8 |
-
|
| 9 |
-
noncomputable section
|
| 10 |
-
namespace HadwigerCounterexample
|
| 11 |
-
open Matrix LinearMap Finset Function
|
| 12 |
-
open scoped BigOperators
|
| 13 |
-
variable {g r n b : ℕ} {p : Shape}
|
| 14 |
-
|
| 15 |
-
abbrev Flavor (g : ℕ) := Option (Option (Finset (Tag g × Tag g)))
|
| 16 |
-
namespace Flavor
|
| 17 |
-
abbrev full {g : ℕ} : Flavor g := none
|
| 18 |
-
abbrev sharedOnly {g : ℕ} : Flavor g := some none
|
| 19 |
-
abbrev pure {g : ℕ} (s : Finset (Tag g × Tag g)) : Flavor g := some (some s)
|
| 20 |
-
|
| 21 |
-
def keeps (f : Flavor g) (x : Tag g) (y : Block g) : Prop :=
|
| 22 |
-
match f,y with
|
| 23 |
-
| none, .inl (i,_) => allowed i x
|
| 24 |
-
| some none,.inl _ => False
|
| 25 |
-
| some (some s),.inl (i,j) => allowed i x ∧ (i,j) ∈ s
|
| 26 |
-
| some (some _), .inr v => v≠0
|
| 27 |
-
| _, .inr _ => True
|
| 28 |
-
instance (f : Flavor g) (x : Tag g) (y : Block g) : Decidable (keeps f x y) :=
|
| 29 |
-
Classical.propDecidable _
|
| 30 |
-
|
| 31 |
-
theorem keep_o {f : Flavor g} {x : Tag g} {i j}
|
| 32 |
-
(h : keeps f x (Block.O i j)) : allowed i x := by
|
| 33 |
-
rcases f with (_|_|_) <;> simp [keeps] at h
|
| 34 |
-
· exact h
|
| 35 |
-
exact h.1
|
| 36 |
-
|
| 37 |
-
theorem keepZ (f : Flavor g) (x : Tag g) : keeps f x Block.Z := by
|
| 38 |
-
rcases f with (_|_|_) <;> simp [keeps]
|
| 39 |
-
theorem keepSharp (f : Flavor g) (x : Tag g) : keeps f x Block.sharp := by
|
| 40 |
-
rcases f with (_|_|_) <;> simp [keeps]
|
| 41 |
-
|
| 42 |
-
end Flavor
|
| 43 |
-
|
| 44 |
-
abbrev Knobs (g n : ℕ) := Block g → Vec (Fin n)
|
| 45 |
-
|
| 46 |
-
def lit (f : Flavor g) (x : Tag g) (y : Knobs g n) : Base g n :=
|
| 47 |
-
fun i => if f.keeps x i.1 then y i.1 i.2 else 0
|
| 48 |
-
|
| 49 |
-
theorem lit_allows (f : Flavor g) (x : Tag g) (y : Knobs g n) :
|
| 50 |
-
allows x (lit f x y) :=
|
| 51 |
-
fun _ _ h _ => ite_eq_right (fun g => h (Flavor.keep_o g))
|
| 52 |
-
|
| 53 |
-
def useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b) (f : Flavor p.g)
|
| 54 |
-
(y : Knobs p.g n) := atom p x s (lit f x y)
|
| 55 |
-
theorem mem_useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b)
|
| 56 |
-
(f : Flavor p.g) (y : Knobs p.g n) : useAtom p x s f y∈Xspace p n :=
|
| 57 |
-
atom_mem s (lit_allows f x y)
|
| 58 |
-
|
| 59 |
-
abbrev ProbeIdx (g : ℕ) := (Tag g × Tag g)⊕Unit
|
| 60 |
-
abbrev Digest (g : ℕ) := Vec (ProbeIdx g)
|
| 61 |
-
|
| 62 |
-
def asBlock (i : ProbeIdx g) : Block g := i.elim (fun q => Block.O q.1 q.2) (fun _ => Block.S)
|
| 63 |
-
theorem asBlock_inj {g : ℕ} : Injective (@asBlock g) := by
|
| 64 |
-
rintro (⟨i,j⟩|⟨⟩) (⟨k,l⟩|⟨⟩) e <;> simp_all [asBlock,Block.O,Block.S]
|
| 65 |
-
|
| 66 |
-
def zget (y : Vec (Fin n)) (i : ℕ) := if h:i<n then y ⟨i,h⟩ else 0
|
| 67 |
-
def tested (r : ℕ) (y : Vec (Fin n)) :=
|
| 68 |
-
∑ i : Fin r,zget y (2*i.val)*zget y (2*i.val+1)
|
| 69 |
-
|
| 70 |
-
def scan (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :
|
| 71 |
-
Digest p.g :=
|
| 72 |
-
fun i => if Flavor.keeps f l (asBlock i) then tested p.r (x (asBlock i)) else 0
|
| 73 |
-
|
| 74 |
-
namespace Digest
|
| 75 |
-
variable (q : Digest g)
|
| 76 |
-
|
| 77 |
-
def feasible (l : Tag g) (f : Flavor g) := ∀ i,¬ Flavor.keeps f l (asBlock i) → q i=0
|
| 78 |
-
|
| 79 |
-
def diagO := ∑ d : Tag g, ∑ t,q (.inl (d,t))
|
| 80 |
-
def sumBit := q.diagO+q (.inr ())
|
| 81 |
-
|
| 82 |
-
end Digest
|
| 83 |
-
|
| 84 |
-
theorem scan_feasible (p : Shape) {n} (l) (f : Flavor p.g) (x : Knobs p.g n) :
|
| 85 |
-
(scan p l f x).feasible l f := fun _ h => ite_eq_right h
|
| 86 |
-
|
| 87 |
-
theorem scan_is (p : Shape) {n} (l) (s : Label p.b) (f : Flavor p.g) (x : Knobs p.g n)
|
| 88 |
-
(i : ProbeIdx p.g) :
|
| 89 |
-
scan p l f x i=etab p n (asBlock i) (mom p s (lit f l x)) := by
|
| 90 |
-
classical
|
| 91 |
-
rw [mom,etab_point]
|
| 92 |
-
let d := asBlock i
|
| 93 |
-
unfold scan
|
| 94 |
-
split
|
| 95 |
-
· rename_i he
|
| 96 |
-
have hg j : readBit (lit f l x) d j=zget (x d) j := by
|
| 97 |
-
by_cases h : j<n <;> simp [readBit,zget,h,lit,d,he]
|
| 98 |
-
unfold tested test
|
| 99 |
-
simp_rw [show ∀ j, readBit (lit f l x) (asBlock i) j=zget (x (asBlock i)) j from hg]
|
| 100 |
-
rename_i he
|
| 101 |
-
unfold test
|
| 102 |
-
have hZ j :
|
| 103 |
-
readBit (lit f l x) (asBlock i) j=0 := by
|
| 104 |
-
by_cases h : j<n <;> simp [readBit,lit,h,he]
|
| 105 |
-
simp_rw [hZ,zero_mul,Finset.sum_const_zero]
|
| 106 |
-
|
| 107 |
-
theorem etaScan (p : Shape) {n} (l s f) (x : Knobs p.g n) :
|
| 108 |
-
(scan p l f x).sumBit=eta p n (mom p s (lit f l x)) := by
|
| 109 |
-
simp only [Digest.sumBit,Digest.diagO,eta,etaO,LinearMap.add_apply,LinearMap.sum_apply]
|
| 110 |
-
simp_rw [scan_is p l s]
|
| 111 |
-
rfl
|
| 112 |
-
|
| 113 |
-
theorem role_scan (p : Shape) {n} (l s f) (x : Knobs p.g n) :
|
| 114 |
-
role p n (useAtom p l s f x)=(scan p l f x).diagO := by
|
| 115 |
-
unfold Digest.diagO useAtom atom
|
| 116 |
-
let M := mom p s (lit f l x)
|
| 117 |
-
have h (i : Tag p.g) :
|
| 118 |
-
(Pi.single l M : Tag p.g → Moment p n) i∈Wtag p n i := by
|
| 119 |
-
by_cases h : i=l
|
| 120 |
-
· subst i; rw [Pi.single_eq_same]
|
| 121 |
-
exact Submodule.subset_span ⟨_,_,lit_allows f l x,rfl⟩
|
| 122 |
-
simp [h]
|
| 123 |
-
rw [role_cut _ _ h,Finset.sum_eq_single l]
|
| 124 |
-
· rw [Pi.single_eq_same,etaO,LinearMap.sum_apply]
|
| 125 |
-
simp_rw [LinearMap.sum_apply,scan_is p l s]
|
| 126 |
-
rfl
|
| 127 |
-
· intro i _ hi; simp [hi]
|
| 128 |
-
simp
|
| 129 |
-
|
| 130 |
-
def dialed (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :=
|
| 131 |
-
(scan p l f x).sumBit
|
| 132 |
-
|
| 133 |
-
def spins (p : Shape) (n : ℕ) : Wgt (Knobs p.g n) := draws (Block p.g) unif
|
| 134 |
-
|
| 135 |
-
theorem spins_law (p : Shape) (n : ℕ) : IsLaw (spins p n) := draws_law unif_law
|
| 136 |
-
|
| 137 |
-
/-- Projection notation for conditioning on a specified (possible)
|
| 138 |
-
diagnostic or diagonal only. -/
|
| 139 |
-
def scopedBit (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (q : F) :
|
| 140 |
-
Wgt (Knobs p.g n) := onW (spins p n) (fun x => dialed p l f x=q)
|
| 141 |
-
def scopedScan (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (z : Digest p.g) :
|
| 142 |
-
Wgt (Knobs p.g n) := onW (spins p n) (fun x => scan p l f x=z)
|
| 143 |
-
|
| 144 |
-
end HadwigerCounterexample
|
| 145 |
-
|
| 146 |
-
end
|
| 147 |
-
|
| 148 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.QuadraticTesters
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.KeyDirections
|
| 3 |
+
import OAI.Combinatorics.HadwigerCounterexample.SumRankBounds
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! # Atom Flavors -/
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace HadwigerCounterexample
|
| 11 |
+
open Matrix LinearMap Finset Function
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
variable {g r n b : ℕ} {p : Shape}
|
| 14 |
+
|
| 15 |
+
abbrev Flavor (g : ℕ) := Option (Option (Finset (Tag g × Tag g)))
|
| 16 |
+
namespace Flavor
|
| 17 |
+
abbrev full {g : ℕ} : Flavor g := none
|
| 18 |
+
abbrev sharedOnly {g : ℕ} : Flavor g := some none
|
| 19 |
+
abbrev pure {g : ℕ} (s : Finset (Tag g × Tag g)) : Flavor g := some (some s)
|
| 20 |
+
|
| 21 |
+
def keeps (f : Flavor g) (x : Tag g) (y : Block g) : Prop :=
|
| 22 |
+
match f,y with
|
| 23 |
+
| none, .inl (i,_) => allowed i x
|
| 24 |
+
| some none,.inl _ => False
|
| 25 |
+
| some (some s),.inl (i,j) => allowed i x ∧ (i,j) ∈ s
|
| 26 |
+
| some (some _), .inr v => v≠0
|
| 27 |
+
| _, .inr _ => True
|
| 28 |
+
instance (f : Flavor g) (x : Tag g) (y : Block g) : Decidable (keeps f x y) :=
|
| 29 |
+
Classical.propDecidable _
|
| 30 |
+
|
| 31 |
+
theorem keep_o {f : Flavor g} {x : Tag g} {i j}
|
| 32 |
+
(h : keeps f x (Block.O i j)) : allowed i x := by
|
| 33 |
+
rcases f with (_|_|_) <;> simp [keeps] at h
|
| 34 |
+
· exact h
|
| 35 |
+
exact h.1
|
| 36 |
+
|
| 37 |
+
theorem keepZ (f : Flavor g) (x : Tag g) : keeps f x Block.Z := by
|
| 38 |
+
rcases f with (_|_|_) <;> simp [keeps]
|
| 39 |
+
theorem keepSharp (f : Flavor g) (x : Tag g) : keeps f x Block.sharp := by
|
| 40 |
+
rcases f with (_|_|_) <;> simp [keeps]
|
| 41 |
+
|
| 42 |
+
end Flavor
|
| 43 |
+
|
| 44 |
+
abbrev Knobs (g n : ℕ) := Block g → Vec (Fin n)
|
| 45 |
+
|
| 46 |
+
def lit (f : Flavor g) (x : Tag g) (y : Knobs g n) : Base g n :=
|
| 47 |
+
fun i => if f.keeps x i.1 then y i.1 i.2 else 0
|
| 48 |
+
|
| 49 |
+
theorem lit_allows (f : Flavor g) (x : Tag g) (y : Knobs g n) :
|
| 50 |
+
allows x (lit f x y) :=
|
| 51 |
+
fun _ _ h _ => ite_eq_right (fun g => h (Flavor.keep_o g))
|
| 52 |
+
|
| 53 |
+
def useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b) (f : Flavor p.g)
|
| 54 |
+
(y : Knobs p.g n) := atom p x s (lit f x y)
|
| 55 |
+
theorem mem_useAtom (p : Shape) {n : ℕ} (x : Tag p.g) (s : Label p.b)
|
| 56 |
+
(f : Flavor p.g) (y : Knobs p.g n) : useAtom p x s f y∈Xspace p n :=
|
| 57 |
+
atom_mem s (lit_allows f x y)
|
| 58 |
+
|
| 59 |
+
abbrev ProbeIdx (g : ℕ) := (Tag g × Tag g)⊕Unit
|
| 60 |
+
abbrev Digest (g : ℕ) := Vec (ProbeIdx g)
|
| 61 |
+
|
| 62 |
+
def asBlock (i : ProbeIdx g) : Block g := i.elim (fun q => Block.O q.1 q.2) (fun _ => Block.S)
|
| 63 |
+
theorem asBlock_inj {g : ℕ} : Injective (@asBlock g) := by
|
| 64 |
+
rintro (⟨i,j⟩|⟨⟩) (⟨k,l⟩|⟨⟩) e <;> simp_all [asBlock,Block.O,Block.S]
|
| 65 |
+
|
| 66 |
+
def zget (y : Vec (Fin n)) (i : ℕ) := if h:i<n then y ⟨i,h⟩ else 0
|
| 67 |
+
def tested (r : ℕ) (y : Vec (Fin n)) :=
|
| 68 |
+
∑ i : Fin r,zget y (2*i.val)*zget y (2*i.val+1)
|
| 69 |
+
|
| 70 |
+
def scan (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :
|
| 71 |
+
Digest p.g :=
|
| 72 |
+
fun i => if Flavor.keeps f l (asBlock i) then tested p.r (x (asBlock i)) else 0
|
| 73 |
+
|
| 74 |
+
namespace Digest
|
| 75 |
+
variable (q : Digest g)
|
| 76 |
+
|
| 77 |
+
def feasible (l : Tag g) (f : Flavor g) := ∀ i,¬ Flavor.keeps f l (asBlock i) → q i=0
|
| 78 |
+
|
| 79 |
+
def diagO := ∑ d : Tag g, ∑ t,q (.inl (d,t))
|
| 80 |
+
def sumBit := q.diagO+q (.inr ())
|
| 81 |
+
|
| 82 |
+
end Digest
|
| 83 |
+
|
| 84 |
+
theorem scan_feasible (p : Shape) {n} (l) (f : Flavor p.g) (x : Knobs p.g n) :
|
| 85 |
+
(scan p l f x).feasible l f := fun _ h => ite_eq_right h
|
| 86 |
+
|
| 87 |
+
theorem scan_is (p : Shape) {n} (l) (s : Label p.b) (f : Flavor p.g) (x : Knobs p.g n)
|
| 88 |
+
(i : ProbeIdx p.g) :
|
| 89 |
+
scan p l f x i=etab p n (asBlock i) (mom p s (lit f l x)) := by
|
| 90 |
+
classical
|
| 91 |
+
rw [mom,etab_point]
|
| 92 |
+
let d := asBlock i
|
| 93 |
+
unfold scan
|
| 94 |
+
split
|
| 95 |
+
· rename_i he
|
| 96 |
+
have hg j : readBit (lit f l x) d j=zget (x d) j := by
|
| 97 |
+
by_cases h : j<n <;> simp [readBit,zget,h,lit,d,he]
|
| 98 |
+
unfold tested test
|
| 99 |
+
simp_rw [show ∀ j, readBit (lit f l x) (asBlock i) j=zget (x (asBlock i)) j from hg]
|
| 100 |
+
rename_i he
|
| 101 |
+
unfold test
|
| 102 |
+
have hZ j :
|
| 103 |
+
readBit (lit f l x) (asBlock i) j=0 := by
|
| 104 |
+
by_cases h : j<n <;> simp [readBit,lit,h,he]
|
| 105 |
+
simp_rw [hZ,zero_mul,Finset.sum_const_zero]
|
| 106 |
+
|
| 107 |
+
theorem etaScan (p : Shape) {n} (l s f) (x : Knobs p.g n) :
|
| 108 |
+
(scan p l f x).sumBit=eta p n (mom p s (lit f l x)) := by
|
| 109 |
+
simp only [Digest.sumBit,Digest.diagO,eta,etaO,LinearMap.add_apply,LinearMap.sum_apply]
|
| 110 |
+
simp_rw [scan_is p l s]
|
| 111 |
+
rfl
|
| 112 |
+
|
| 113 |
+
theorem role_scan (p : Shape) {n} (l s f) (x : Knobs p.g n) :
|
| 114 |
+
role p n (useAtom p l s f x)=(scan p l f x).diagO := by
|
| 115 |
+
unfold Digest.diagO useAtom atom
|
| 116 |
+
let M := mom p s (lit f l x)
|
| 117 |
+
have h (i : Tag p.g) :
|
| 118 |
+
(Pi.single l M : Tag p.g → Moment p n) i∈Wtag p n i := by
|
| 119 |
+
by_cases h : i=l
|
| 120 |
+
· subst i; rw [Pi.single_eq_same]
|
| 121 |
+
exact Submodule.subset_span ⟨_,_,lit_allows f l x,rfl⟩
|
| 122 |
+
simp [h]
|
| 123 |
+
rw [role_cut _ _ h,Finset.sum_eq_single l]
|
| 124 |
+
· rw [Pi.single_eq_same,etaO,LinearMap.sum_apply]
|
| 125 |
+
simp_rw [LinearMap.sum_apply,scan_is p l s]
|
| 126 |
+
rfl
|
| 127 |
+
· intro i _ hi; simp [hi]
|
| 128 |
+
simp
|
| 129 |
+
|
| 130 |
+
def dialed (p : Shape) {n} (l : Tag p.g) (f : Flavor p.g) (x : Knobs p.g n) :=
|
| 131 |
+
(scan p l f x).sumBit
|
| 132 |
+
|
| 133 |
+
def spins (p : Shape) (n : ℕ) : Wgt (Knobs p.g n) := draws (Block p.g) unif
|
| 134 |
+
|
| 135 |
+
theorem spins_law (p : Shape) (n : ℕ) : IsLaw (spins p n) := draws_law unif_law
|
| 136 |
+
|
| 137 |
+
/-- Projection notation for conditioning on a specified (possible)
|
| 138 |
+
diagnostic or diagonal only. -/
|
| 139 |
+
def scopedBit (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (q : F) :
|
| 140 |
+
Wgt (Knobs p.g n) := onW (spins p n) (fun x => dialed p l f x=q)
|
| 141 |
+
def scopedScan (p : Shape) (n : ℕ) (l : Tag p.g) (f : Flavor p.g) (z : Digest p.g) :
|
| 142 |
+
Wgt (Knobs p.g n) := onW (spins p n) (fun x => scan p l f x=z)
|
| 143 |
+
|
| 144 |
+
end HadwigerCounterexample
|
| 145 |
+
|
| 146 |
+
end
|
| 147 |
+
|
| 148 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/AttackCutDecomposition.lean
CHANGED
|
@@ -1,277 +1,277 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ResponseAnnihilators
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Attack Cut Decomposition -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Submodule LinearMap Module Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ}
|
| 12 |
-
variable {I J : Type} [Fintype I] [Fintype J]
|
| 13 |
-
|
| 14 |
-
theorem colSp_kill (S : Space (Vec I)) (M : Mat I J) :
|
| 15 |
-
colSp M ≤ annih S ↔ ∀ x∈S,Mᵀ *ᵥ x=0 := by
|
| 16 |
-
constructor
|
| 17 |
-
· intro h x hx
|
| 18 |
-
refine dot_ext_zero fun y => ?_
|
| 19 |
-
rw [dotProduct_transpose_mulVec,dotProduct_comm]
|
| 20 |
-
exact (annih_mem ..).mp (h ⟨y,rfl⟩) x hx
|
| 21 |
-
rintro h z ⟨y,rfl⟩
|
| 22 |
-
rw [annih_mem]; intro x hx
|
| 23 |
-
rw [dotProduct_comm,mulVecLin_apply,←dotProduct_transpose_mulVec,h x hx,dotProduct_zero]
|
| 24 |
-
|
| 25 |
-
theorem box_kill {S : Space (Vec I)} {T : Space (Vec J)} {M : Mat I J} :
|
| 26 |
-
M∈box (annih S) (annih T) ↔ (∀ x∈S,Mᵀ *ᵥ x=0) ∧ (∀ y ∈ T,M *ᵥ y=0) := by
|
| 27 |
-
rw [box_mem,colSp_kill,colSp_kill,transpose_transpose]
|
| 28 |
-
|
| 29 |
-
theorem orth_sub {f b : Plan p n} {x y : Xpair p n} {C : ChanOut p n} {j}
|
| 30 |
-
(hx : orth p C f b j x) (hy : orth p C f b j y) : orth p C f b j (x-y) := by
|
| 31 |
-
intro D hd A ha; rw [map_sub,hx _ hd _ ha,hy _ hd _ ha,sub_self]
|
| 32 |
-
|
| 33 |
-
theorem orth_sum {f b : Plan p n} (x : I→Xpair p n) (c : I→F) {C : ChanOut p n} {j}
|
| 34 |
-
(hx : ∀ i,orth p C f b j (x i)) : orth p C f b j (∑ i,c i • x i) := by
|
| 35 |
-
intro D hd A ha
|
| 36 |
-
rw [map_sum]
|
| 37 |
-
refine Finset.sum_eq_zero fun i _ => ?_
|
| 38 |
-
rw [map_smul,hx i _ hd _ ha,smul_zero]
|
| 39 |
-
|
| 40 |
-
namespace Volley
|
| 41 |
-
variable (v : Volley p n I)
|
| 42 |
-
|
| 43 |
-
def strike (t : Tagging p I) (ht : v.legal t) (j : I) : Xpair p n :=
|
| 44 |
-
Pi.single (v.obj j) (⟨v.atomAt t j,atom_mem _ (ht j)⟩ : Xspace p n)
|
| 45 |
-
|
| 46 |
-
theorem strike_here (t : Tagging p I) (ht : v.legal t)
|
| 47 |
-
(c : I → F) (i : Bool) :
|
| 48 |
-
((∑ j : I, c j • v.strike t ht j) i).val=∑ j∈v.here i,c j • v.atomAt t j := by
|
| 49 |
-
classical
|
| 50 |
-
rw [Finset.sum_apply]
|
| 51 |
-
simp only [Submodule.coe_sum, Pi.smul_apply,Submodule.coe_smul,here,Finset.sum_filter]
|
| 52 |
-
refine Finset.sum_congr rfl fun j _ => ?_
|
| 53 |
-
by_cases h : v.obj j=i
|
| 54 |
-
· simp only [ite_eq_left h]
|
| 55 |
-
unfold strike
|
| 56 |
-
rw [h,Pi.single_eq_same]
|
| 57 |
-
simp [strike,h]
|
| 58 |
-
|
| 59 |
-
omit [Fintype I] in
|
| 60 |
-
theorem strike_pair (t : Tagging p I) (ht : v.legal t) (j : I) (e : Comp p.g) :
|
| 61 |
-
purePair p n (v.strike t ht j) e=
|
| 62 |
-
if inc e (t j) then vecMulVec (v.rayLoc j) (v.rayLoc j) else 0 := by
|
| 63 |
-
classical
|
| 64 |
-
simp only [purePair, Finset.sum_apply]
|
| 65 |
-
rw [Finset.sum_eq_single (v.obj j)]
|
| 66 |
-
· rw [strike,Pi.single_eq_same]
|
| 67 |
-
change liftM _ _ (atom p _ _ _ e)=_
|
| 68 |
-
rw [atom_def]; split
|
| 69 |
-
· exact liftM_outer _ _ _ _
|
| 70 |
-
rw [map_zero]
|
| 71 |
-
· intro i _ hi; rw [strike,Pi.single_eq_of_ne hi]; exact map_zero _
|
| 72 |
-
simp
|
| 73 |
-
|
| 74 |
-
theorem strike_orth {a b : Plan p n} {C : ChanOut p n} {i : Bool}
|
| 75 |
-
(t : Tagging p I) (ht : v.legal t) (j : I) :
|
| 76 |
-
orth p C (v.frozen a t) b i (v.strike t ht j) := by
|
| 77 |
-
intro D hd A ha
|
| 78 |
-
change ∑ e, _ = _
|
| 79 |
-
refine Finset.sum_eq_zero fun e _ => ?_
|
| 80 |
-
rw [v.strike_pair]
|
| 81 |
-
by_cases h : inc e (t j)
|
| 82 |
-
· have hy (z) : v.rayLoc j ∈ (v.frozen a t (e,z)) :=
|
| 83 |
-
Submodule.mem_sup_right (colSp_mem (P:=v.keyM t e) (⟨j,h⟩ : visits p t e))
|
| 84 |
-
let V := v.rayLoc j
|
| 85 |
-
have h1 : A e *ᵥ V=0 := (box_kill.mp ((pureSpace_mem _).mp ha e)).2 V (hy false)
|
| 86 |
-
have h2 (z) : D (e,z) *ᵥ V=0 :=
|
| 87 |
-
(box_kill.mp ((deltaSpace_mem _).mp hd _)).2 V (hy z)
|
| 88 |
-
rw [ite_eq_left h,mpair_outer,evmat]
|
| 89 |
-
change dotProduct V (((C (e,true))ᵀ * D (e,false)+
|
| 90 |
-
(D (e,true))ᵀ * C (e,false)+A e) *ᵥ V)=_
|
| 91 |
-
simp only [Matrix.add_mulVec, ← Matrix.mulVec_mulVec,h1,h2,mulVec_zero,
|
| 92 |
-
dotProduct_zero,zero_add,add_zero,dotProduct_transpose_mulVec]
|
| 93 |
-
rw [ite_eq_right h,map_zero]
|
| 94 |
-
end Volley
|
| 95 |
-
|
| 96 |
-
def labStruct (p : Shape) (n : ℕ) (M : Moment p n) (R : ℕ)
|
| 97 |
-
(L : Finset (Label p.b)) (Z : Label p.b→BaseMat p n) :=
|
| 98 |
-
M=labelSum p L Z ∧ L.card ≤ R ∧ (∀ s,s∉L → Z s=0) ∧
|
| 99 |
-
∀ s∈L,(Z s)ᵀ=Z s ∧ ∀ i,Z s i i=Z s none i
|
| 100 |
-
|
| 101 |
-
private theorem struct_tri {M1 M2 M3 : Moment p n} {R : ℕ}
|
| 102 |
-
{L1 L2 L3 : Finset (Label p.b)} {Z1 Z2 Z3 : Label p.b→BaseMat p n}
|
| 103 |
-
(h1 : labStruct p n M1 R L1 Z1)
|
| 104 |
-
(h2 : labStruct p n M2 R L2 Z2)
|
| 105 |
-
(h3 : labStruct p n M3 R L3 Z3)
|
| 106 |
-
(hr : 3*R≤p.j) (hm : M1+M2+M3=0) (s : Label p.b) :
|
| 107 |
-
Z1 s+Z2 s+Z3 s=0 := by
|
| 108 |
-
classical
|
| 109 |
-
let W := L1∪L2∪L3
|
| 110 |
-
have hs1 : L1⊆W := subset_trans subset_union_left subset_union_left
|
| 111 |
-
have hs2 : L2⊆W := subset_trans subset_union_right subset_union_left
|
| 112 |
-
have hs3 : L3⊆W := subset_union_right
|
| 113 |
-
have hh : W.card ≤ p.j+1 :=
|
| 114 |
-
(Finset.card_union_le (L1∪L2) L3).trans ((add_le_add
|
| 115 |
-
((Finset.card_union_le L1 L2).trans (add_le_add h1.2.1 h2.2.1)) h3.2.1).trans (by omega))
|
| 116 |
-
by_cases hs : s∈W
|
| 117 |
-
· have hv {M : Moment p n} {L Z} (h : labStruct p n M R L Z) (hL : L ⊆ W)
|
| 118 |
-
(i j : AIdx p.g n) (r : SelIdx p.b p.j) :
|
| 119 |
-
(∑ s∈W,Z s i j*monoBit s r.val) = M (r,i) (emptySel,j) := by
|
| 120 |
-
rw [h.1,labelSum, Matrix.sum_apply,←Finset.sum_subset hL]
|
| 121 |
-
· simp only [mput_apply,emptySel,monoBit,Finset.prod_empty,mul_one,mul_comm]
|
| 122 |
-
intro y _ hy
|
| 123 |
-
simp [h.2.2.1 y hy]
|
| 124 |
-
ext i j
|
| 125 |
-
refine selector_indep W (fun s => (Z1 s i j+Z2 s i j+Z3 s i j)) p.j hh ?_ s hs
|
| 126 |
-
intro T hT
|
| 127 |
-
let r : SelIdx p.b p.j := ⟨T,hT⟩
|
| 128 |
-
simp only [add_mul,Finset.sum_add_distrib]
|
| 129 |
-
rw [hv h1 hs1 i j r,hv h2 hs2 i j r,hv h3 hs3 i j r]
|
| 130 |
-
exact congr_fun (congr_fun hm (r,i)) (emptySel,j)
|
| 131 |
-
rw [h1.2.2.1 s (fun h => hs (hs1 h)), h2.2.2.1 s (fun h => hs (hs2 h)),
|
| 132 |
-
h3.2.2.1 s (fun h => hs (hs3 h)), zero_add,zero_add]
|
| 133 |
-
|
| 134 |
-
namespace Volley
|
| 135 |
-
variable {v : Volley p n I}
|
| 136 |
-
|
| 137 |
-
private theorem orth_structure {x : Xpair p n} {a b : Plan p n}
|
| 138 |
-
{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}
|
| 139 |
-
(hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x)
|
| 140 |
-
(R : ℕ) (hr : 2*planRank a+28≤R) (hj : 6*R+4 ≤ p.j)
|
| 141 |
-
(i : Bool) (e : Comp p.g) :
|
| 142 |
-
∃ L Z,labStruct p n ((x i).val e) R L Z := by
|
| 143 |
-
classical
|
| 144 |
-
have h (z) := v.frozen_here_dim hb a t i z
|
| 145 |
-
have he : ((x i).val e).rank ≤ R :=
|
| 146 |
-
(rank_vanish (vanish_one ho i e)).trans
|
| 147 |
-
((Nat.add_le_add (h (e,true)) (h (e,false))).trans (by omega))
|
| 148 |
-
have hf : ((x i).val e)∈ Wspace p n := by
|
| 149 |
-
obtain ⟨w,h,hx⟩ := mem_X.mp (x i).property
|
| 150 |
-
rw [← hx]
|
| 151 |
-
exact ((Wspace p n).add_mem ((Wtag_le _) (h e.val.1)) ((Wtag_le _) (h e.val.2)))
|
| 152 |
-
obtain ⟨L,Z,hL,_,hZ,hA⟩ := label_support hf R hj he
|
| 153 |
-
let g (s : Label p.b) := if s∈L then Z s else 0
|
| 154 |
-
refine ⟨L,g,?_,hL,(fun s hs => ite_eq_right hs), fun s hs => ?_⟩
|
| 155 |
-
· rw [hZ]
|
| 156 |
-
exact Finset.sum_congr rfl fun s hs => by simp [g,hs]
|
| 157 |
-
simp only [g,ite_eq_left hs]
|
| 158 |
-
exact hA _ hs
|
| 159 |
-
|
| 160 |
-
private theorem edge_at (l : Tag p.g) (e : Comp p.g) (h : inc e l) :
|
| 161 |
-
∃ (k : Tag p.g) (h : l≠k),e = edge l k h := by
|
| 162 |
-
rcases e with ⟨⟨i,j⟩,hj⟩
|
| 163 |
-
change i=l∨j=l at h
|
| 164 |
-
rcases h with rfl|rfl
|
| 165 |
-
· exact ⟨j,hj.ne,(edge_eq hj).symm⟩
|
| 166 |
-
exact ⟨i,hj.ne.symm, by rw [edge_symm,edge_eq hj]⟩
|
| 167 |
-
|
| 168 |
-
private theorem cut_tri {x : Profile p n} (hx : x∈Xspace p n)
|
| 169 |
-
(l k j : Tag p.g) (h : l≠k) (h' : l ≠ j) (h'' : k≠j) :
|
| 170 |
-
x (edge l k h)+x (edge l j h')+x (edge k j h'')=0 := by
|
| 171 |
-
obtain ⟨w,hv,rfl⟩ := mem_X.mp hx
|
| 172 |
-
rw [← getPair_edge l k h (cut p n w), ←getPair_edge l j h' (cut p n w), ←getPair_edge k j h'' (cut p n w),
|
| 173 |
-
getPair_cut,getPair_cut,getPair_cut]
|
| 174 |
-
have he (x y z : Moment p n) : x+y+(x+z)+(y+z)=0 := calc
|
| 175 |
-
_ = (x+x)+(y+y)+(z+z) := by ac_rfl
|
| 176 |
-
_ = _ := by simp only [char_two]
|
| 177 |
-
exact he _ _ _
|
| 178 |
-
|
| 179 |
-
private theorem structure_mark {x : Xpair p n} {a b : Plan p n}
|
| 180 |
-
{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}
|
| 181 |
-
{q R : ℕ} (hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)
|
| 182 |
-
(hr : 6*R+4≤p.j) (hq : R+14≤q)
|
| 183 |
-
(l : I)
|
| 184 |
-
{L : Comp p.g → Finset (Label p.b)} {Z : Comp p.g → Label p.b → BaseMat p n}
|
| 185 |
-
(he : ∀ e,labStruct p n ((x (v.obj l)).val e) R (L e) (Z e)) :
|
| 186 |
-
∃ c : F, ∀ e,mput p (v.sel l) (Z e (v.sel l))=c • v.atomAt t l e := by
|
| 187 |
-
classical
|
| 188 |
-
let s := v.sel l
|
| 189 |
-
let u := t l
|
| 190 |
-
let M := vecMulVec (baseV (v.par l)) (baseV (v.par l))
|
| 191 |
-
let coeff := fun e : Comp p.g => Z e s none none
|
| 192 |
-
have h1 (e : Comp p.g) : Z e s= if inc e u then coeff e • M else 0 := by
|
| 193 |
-
have ⟨hE,hL,hT,hH⟩ := he e
|
| 194 |
-
exact mark_atom hb t hv l e _ (le_trans (Nat.add_le_add_right hL 14) hq)
|
| 195 |
-
_ hT hH (hE ▸ vanish_one ho (v.obj l) e)
|
| 196 |
-
have h2 (e f : Comp p.g) (h : inc e u) (h' : inc f u) :
|
| 197 |
-
coeff e=coeff f := by
|
| 198 |
-
by_cases hi : e=f
|
| 199 |
-
· rw [hi]
|
| 200 |
-
obtain ⟨k,hk,rfl⟩ := edge_at u e h
|
| 201 |
-
obtain ⟨u2,hl,rfl⟩ := edge_at u f h'
|
| 202 |
-
have hj : k ≠ u2 := by rintro rfl; exact hi rfl
|
| 203 |
-
have hh := cut_tri (x (v.obj l)).property u k u2 hk hl hj
|
| 204 |
-
have heq := struct_tri (he (edge u k hk)) (he (edge u u2 hl)) (he (edge k u2 hj))
|
| 205 |
-
(by omega) hh s
|
| 206 |
-
have hn : ¬ inc (edge k u2 hj) u := fun he => by
|
| 207 |
-
rcases (inc_edge_iff _).mp he with h|h; exact hk h.symm; exact hl h.symm
|
| 208 |
-
rw [h1 (edge k u2 hj), ite_eq_right hn,add_zero] at heq
|
| 209 |
-
have h0 := congr_fun (congr_fun heq none) none
|
| 210 |
-
change coeff _ + coeff _ = 0 at h0
|
| 211 |
-
exact add_right_cancel (h0.trans (char_two _).symm)
|
| 212 |
-
have h3 (e) : mput p s (Z e s)= coeff e • v.atomAt t l e := by
|
| 213 |
-
rw [h1,atomAt,atom_def]
|
| 214 |
-
by_cases hf : inc e u
|
| 215 |
-
· rw [ite_eq_left hf,ite_eq_left hf,map_smul]
|
| 216 |
-
change coeff e • liftM (labMat p n s) (labMat p n s) M=_
|
| 217 |
-
unfold M
|
| 218 |
-
rw [liftM_outer,labMat_act]; rfl
|
| 219 |
-
rw [ite_eq_right hf,ite_eq_right hf,map_zero,smul_zero]
|
| 220 |
-
by_cases hh : ∃ e,inc e u
|
| 221 |
-
· obtain ⟨f,hf⟩ := hh
|
| 222 |
-
refine ⟨coeff f,fun e => ?_⟩
|
| 223 |
-
by_cases h : inc e u
|
| 224 |
-
· exact (h3 e).trans (by rw [h2 e f h hf])
|
| 225 |
-
refine (h3 e).trans ?_
|
| 226 |
-
rw [atomAt,atom_def,ite_eq_right h,smul_zero,smul_zero]
|
| 227 |
-
refine ⟨0,fun e => ?_
|
| 228 |
-
refine (h3 e).trans ?_
|
| 229 |
-
rw [atomAt,atom_def,ite_eq_right (show ¬inc e u from fun he => hh ⟨e,he⟩),
|
| 230 |
-
smul_zero,zero_smul]
|
| 231 |
-
|
| 232 |
-
/-- a component uses at most R nonattack labels. -/
|
| 233 |
-
def clean (v : Volley p n I) (i : Bool) (R : ℕ) (M : Moment p n) :=
|
| 234 |
-
∃ (L : Finset (Label p.b)) (Z : Label p.b → BaseMat p n),
|
| 235 |
-
M=labelSum p L Z ∧ L.card≤R ∧ Disjoint L (v.marked i)
|
| 236 |
-
|
| 237 |
-
theorem split_orth {x : Xpair p n} {a b : Plan p n}
|
| 238 |
-
{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}
|
| 239 |
-
{q R : ℕ} (hb : v.bounded w) (ht : v.legal t)
|
| 240 |
-
(ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)
|
| 241 |
-
(hr : 6*R+4≤p.j) (hr' : 2*planRank a+28≤R) (hq : R+14≤q) :
|
| 242 |
-
∃ (c : I → F) (y : Xpair p n), x=y+∑ i,c i • v.strike t ht i ∧
|
| 243 |
-
orth p C (v.frozen a t) b j y ∧ ∀ i e,v.clean i R ((y i).val e) := by
|
| 244 |
-
classical
|
| 245 |
-
choose L Z hZ using orth_structure hb ho R hr' hr
|
| 246 |
-
choose c hc using fun l => structure_mark hb ho hv hr hq l (hZ (v.obj l))
|
| 247 |
-
let A := ∑ i,c i • v.strike t ht i
|
| 248 |
-
refine ⟨c,x-A,(sub_add_cancel x A).symm,orth_sub ho (orth_sum _ _ (v.strike_orth t ht)),
|
| 249 |
-
fun i e => ?_⟩
|
| 250 |
-
obtain ⟨B,h1,hA,hv',h3⟩ := hv i
|
| 251 |
-
let T := v.marked i
|
| 252 |
-
have he : (A i).val e=labelSum p T (Z i e) := by
|
| 253 |
-
rw [show (A i).val=_ from v.strike_here t ht c i, Finset.sum_apply]
|
| 254 |
-
dsimp only [labelSum,T,marked]
|
| 255 |
-
rw [Finset.sum_image h3]
|
| 256 |
-
refine Finset.sum_congr rfl fun l hl => ?_
|
| 257 |
-
have he : v.obj l=i := (mem_filter.mp hl).2
|
| 258 |
-
exact (he ▸ hc l e).symm
|
| 259 |
-
let W := L i e
|
| 260 |
-
refine ⟨W \ T,Z i e,?_,(Finset.card_le_card sdiff_subset).trans (hZ i e).2.1, ?_⟩
|
| 261 |
-
· change (x i).val e-(A i).val e=_
|
| 262 |
-
rw [(hZ i e).1,he]
|
| 263 |
-
have hz : labelSum p W (Z i e)=labelSum p (W∪T) (Z i e) := by
|
| 264 |
-
refine Finset.sum_subset subset_union_left fun s _ hs => ?_
|
| 265 |
-
rw [(hZ i e).2.2.1 s hs,map_zero]
|
| 266 |
-
rw [hz]
|
| 267 |
-
have hS : (W∪T)=(W \ T) ∪ T := by ext i; simp
|
| 268 |
-
rw [hS,labelSum,Finset.sum_union (show Disjoint (W \ T) T from Disjoint.symm disjoint_sdiff)]
|
| 269 |
-
exact add_sub_cancel_right _ _
|
| 270 |
-
exact Disjoint.symm disjoint_sdiff
|
| 271 |
-
|
| 272 |
-
end Volley
|
| 273 |
-
end HadwigerCounterexample
|
| 274 |
-
|
| 275 |
-
end
|
| 276 |
-
|
| 277 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ResponseAnnihilators
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Attack Cut Decomposition -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Submodule LinearMap Module Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ}
|
| 12 |
+
variable {I J : Type} [Fintype I] [Fintype J]
|
| 13 |
+
|
| 14 |
+
theorem colSp_kill (S : Space (Vec I)) (M : Mat I J) :
|
| 15 |
+
colSp M ≤ annih S ↔ ∀ x∈S,Mᵀ *ᵥ x=0 := by
|
| 16 |
+
constructor
|
| 17 |
+
· intro h x hx
|
| 18 |
+
refine dot_ext_zero fun y => ?_
|
| 19 |
+
rw [dotProduct_transpose_mulVec,dotProduct_comm]
|
| 20 |
+
exact (annih_mem ..).mp (h ⟨y,rfl⟩) x hx
|
| 21 |
+
rintro h z ⟨y,rfl⟩
|
| 22 |
+
rw [annih_mem]; intro x hx
|
| 23 |
+
rw [dotProduct_comm,mulVecLin_apply,←dotProduct_transpose_mulVec,h x hx,dotProduct_zero]
|
| 24 |
+
|
| 25 |
+
theorem box_kill {S : Space (Vec I)} {T : Space (Vec J)} {M : Mat I J} :
|
| 26 |
+
M∈box (annih S) (annih T) ↔ (∀ x∈S,Mᵀ *ᵥ x=0) ∧ (∀ y ∈ T,M *ᵥ y=0) := by
|
| 27 |
+
rw [box_mem,colSp_kill,colSp_kill,transpose_transpose]
|
| 28 |
+
|
| 29 |
+
theorem orth_sub {f b : Plan p n} {x y : Xpair p n} {C : ChanOut p n} {j}
|
| 30 |
+
(hx : orth p C f b j x) (hy : orth p C f b j y) : orth p C f b j (x-y) := by
|
| 31 |
+
intro D hd A ha; rw [map_sub,hx _ hd _ ha,hy _ hd _ ha,sub_self]
|
| 32 |
+
|
| 33 |
+
theorem orth_sum {f b : Plan p n} (x : I→Xpair p n) (c : I→F) {C : ChanOut p n} {j}
|
| 34 |
+
(hx : ∀ i,orth p C f b j (x i)) : orth p C f b j (∑ i,c i • x i) := by
|
| 35 |
+
intro D hd A ha
|
| 36 |
+
rw [map_sum]
|
| 37 |
+
refine Finset.sum_eq_zero fun i _ => ?_
|
| 38 |
+
rw [map_smul,hx i _ hd _ ha,smul_zero]
|
| 39 |
+
|
| 40 |
+
namespace Volley
|
| 41 |
+
variable (v : Volley p n I)
|
| 42 |
+
|
| 43 |
+
def strike (t : Tagging p I) (ht : v.legal t) (j : I) : Xpair p n :=
|
| 44 |
+
Pi.single (v.obj j) (⟨v.atomAt t j,atom_mem _ (ht j)⟩ : Xspace p n)
|
| 45 |
+
|
| 46 |
+
theorem strike_here (t : Tagging p I) (ht : v.legal t)
|
| 47 |
+
(c : I → F) (i : Bool) :
|
| 48 |
+
((∑ j : I, c j • v.strike t ht j) i).val=∑ j∈v.here i,c j • v.atomAt t j := by
|
| 49 |
+
classical
|
| 50 |
+
rw [Finset.sum_apply]
|
| 51 |
+
simp only [Submodule.coe_sum, Pi.smul_apply,Submodule.coe_smul,here,Finset.sum_filter]
|
| 52 |
+
refine Finset.sum_congr rfl fun j _ => ?_
|
| 53 |
+
by_cases h : v.obj j=i
|
| 54 |
+
· simp only [ite_eq_left h]
|
| 55 |
+
unfold strike
|
| 56 |
+
rw [h,Pi.single_eq_same]
|
| 57 |
+
simp [strike,h]
|
| 58 |
+
|
| 59 |
+
omit [Fintype I] in
|
| 60 |
+
theorem strike_pair (t : Tagging p I) (ht : v.legal t) (j : I) (e : Comp p.g) :
|
| 61 |
+
purePair p n (v.strike t ht j) e=
|
| 62 |
+
if inc e (t j) then vecMulVec (v.rayLoc j) (v.rayLoc j) else 0 := by
|
| 63 |
+
classical
|
| 64 |
+
simp only [purePair, Finset.sum_apply]
|
| 65 |
+
rw [Finset.sum_eq_single (v.obj j)]
|
| 66 |
+
· rw [strike,Pi.single_eq_same]
|
| 67 |
+
change liftM _ _ (atom p _ _ _ e)=_
|
| 68 |
+
rw [atom_def]; split
|
| 69 |
+
· exact liftM_outer _ _ _ _
|
| 70 |
+
rw [map_zero]
|
| 71 |
+
· intro i _ hi; rw [strike,Pi.single_eq_of_ne hi]; exact map_zero _
|
| 72 |
+
simp
|
| 73 |
+
|
| 74 |
+
theorem strike_orth {a b : Plan p n} {C : ChanOut p n} {i : Bool}
|
| 75 |
+
(t : Tagging p I) (ht : v.legal t) (j : I) :
|
| 76 |
+
orth p C (v.frozen a t) b i (v.strike t ht j) := by
|
| 77 |
+
intro D hd A ha
|
| 78 |
+
change ∑ e, _ = _
|
| 79 |
+
refine Finset.sum_eq_zero fun e _ => ?_
|
| 80 |
+
rw [v.strike_pair]
|
| 81 |
+
by_cases h : inc e (t j)
|
| 82 |
+
· have hy (z) : v.rayLoc j ∈ (v.frozen a t (e,z)) :=
|
| 83 |
+
Submodule.mem_sup_right (colSp_mem (P:=v.keyM t e) (⟨j,h⟩ : visits p t e))
|
| 84 |
+
let V := v.rayLoc j
|
| 85 |
+
have h1 : A e *ᵥ V=0 := (box_kill.mp ((pureSpace_mem _).mp ha e)).2 V (hy false)
|
| 86 |
+
have h2 (z) : D (e,z) *ᵥ V=0 :=
|
| 87 |
+
(box_kill.mp ((deltaSpace_mem _).mp hd _)).2 V (hy z)
|
| 88 |
+
rw [ite_eq_left h,mpair_outer,evmat]
|
| 89 |
+
change dotProduct V (((C (e,true))ᵀ * D (e,false)+
|
| 90 |
+
(D (e,true))ᵀ * C (e,false)+A e) *ᵥ V)=_
|
| 91 |
+
simp only [Matrix.add_mulVec, ← Matrix.mulVec_mulVec,h1,h2,mulVec_zero,
|
| 92 |
+
dotProduct_zero,zero_add,add_zero,dotProduct_transpose_mulVec]
|
| 93 |
+
rw [ite_eq_right h,map_zero]
|
| 94 |
+
end Volley
|
| 95 |
+
|
| 96 |
+
def labStruct (p : Shape) (n : ℕ) (M : Moment p n) (R : ℕ)
|
| 97 |
+
(L : Finset (Label p.b)) (Z : Label p.b→BaseMat p n) :=
|
| 98 |
+
M=labelSum p L Z ∧ L.card ≤ R ∧ (∀ s,s∉L → Z s=0) ∧
|
| 99 |
+
∀ s∈L,(Z s)ᵀ=Z s ∧ ∀ i,Z s i i=Z s none i
|
| 100 |
+
|
| 101 |
+
private theorem struct_tri {M1 M2 M3 : Moment p n} {R : ℕ}
|
| 102 |
+
{L1 L2 L3 : Finset (Label p.b)} {Z1 Z2 Z3 : Label p.b→BaseMat p n}
|
| 103 |
+
(h1 : labStruct p n M1 R L1 Z1)
|
| 104 |
+
(h2 : labStruct p n M2 R L2 Z2)
|
| 105 |
+
(h3 : labStruct p n M3 R L3 Z3)
|
| 106 |
+
(hr : 3*R≤p.j) (hm : M1+M2+M3=0) (s : Label p.b) :
|
| 107 |
+
Z1 s+Z2 s+Z3 s=0 := by
|
| 108 |
+
classical
|
| 109 |
+
let W := L1∪L2∪L3
|
| 110 |
+
have hs1 : L1⊆W := subset_trans subset_union_left subset_union_left
|
| 111 |
+
have hs2 : L2⊆W := subset_trans subset_union_right subset_union_left
|
| 112 |
+
have hs3 : L3⊆W := subset_union_right
|
| 113 |
+
have hh : W.card ≤ p.j+1 :=
|
| 114 |
+
(Finset.card_union_le (L1∪L2) L3).trans ((add_le_add
|
| 115 |
+
((Finset.card_union_le L1 L2).trans (add_le_add h1.2.1 h2.2.1)) h3.2.1).trans (by omega))
|
| 116 |
+
by_cases hs : s∈W
|
| 117 |
+
· have hv {M : Moment p n} {L Z} (h : labStruct p n M R L Z) (hL : L ⊆ W)
|
| 118 |
+
(i j : AIdx p.g n) (r : SelIdx p.b p.j) :
|
| 119 |
+
(∑ s∈W,Z s i j*monoBit s r.val) = M (r,i) (emptySel,j) := by
|
| 120 |
+
rw [h.1,labelSum, Matrix.sum_apply,←Finset.sum_subset hL]
|
| 121 |
+
· simp only [mput_apply,emptySel,monoBit,Finset.prod_empty,mul_one,mul_comm]
|
| 122 |
+
intro y _ hy
|
| 123 |
+
simp [h.2.2.1 y hy]
|
| 124 |
+
ext i j
|
| 125 |
+
refine selector_indep W (fun s => (Z1 s i j+Z2 s i j+Z3 s i j)) p.j hh ?_ s hs
|
| 126 |
+
intro T hT
|
| 127 |
+
let r : SelIdx p.b p.j := ⟨T,hT⟩
|
| 128 |
+
simp only [add_mul,Finset.sum_add_distrib]
|
| 129 |
+
rw [hv h1 hs1 i j r,hv h2 hs2 i j r,hv h3 hs3 i j r]
|
| 130 |
+
exact congr_fun (congr_fun hm (r,i)) (emptySel,j)
|
| 131 |
+
rw [h1.2.2.1 s (fun h => hs (hs1 h)), h2.2.2.1 s (fun h => hs (hs2 h)),
|
| 132 |
+
h3.2.2.1 s (fun h => hs (hs3 h)), zero_add,zero_add]
|
| 133 |
+
|
| 134 |
+
namespace Volley
|
| 135 |
+
variable {v : Volley p n I}
|
| 136 |
+
|
| 137 |
+
private theorem orth_structure {x : Xpair p n} {a b : Plan p n}
|
| 138 |
+
{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}
|
| 139 |
+
(hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x)
|
| 140 |
+
(R : ℕ) (hr : 2*planRank a+28≤R) (hj : 6*R+4 ≤ p.j)
|
| 141 |
+
(i : Bool) (e : Comp p.g) :
|
| 142 |
+
∃ L Z,labStruct p n ((x i).val e) R L Z := by
|
| 143 |
+
classical
|
| 144 |
+
have h (z) := v.frozen_here_dim hb a t i z
|
| 145 |
+
have he : ((x i).val e).rank ≤ R :=
|
| 146 |
+
(rank_vanish (vanish_one ho i e)).trans
|
| 147 |
+
((Nat.add_le_add (h (e,true)) (h (e,false))).trans (by omega))
|
| 148 |
+
have hf : ((x i).val e)∈ Wspace p n := by
|
| 149 |
+
obtain ⟨w,h,hx⟩ := mem_X.mp (x i).property
|
| 150 |
+
rw [← hx]
|
| 151 |
+
exact ((Wspace p n).add_mem ((Wtag_le _) (h e.val.1)) ((Wtag_le _) (h e.val.2)))
|
| 152 |
+
obtain ⟨L,Z,hL,_,hZ,hA⟩ := label_support hf R hj he
|
| 153 |
+
let g (s : Label p.b) := if s∈L then Z s else 0
|
| 154 |
+
refine ⟨L,g,?_,hL,(fun s hs => ite_eq_right hs), fun s hs => ?_⟩
|
| 155 |
+
· rw [hZ]
|
| 156 |
+
exact Finset.sum_congr rfl fun s hs => by simp [g,hs]
|
| 157 |
+
simp only [g,ite_eq_left hs]
|
| 158 |
+
exact hA _ hs
|
| 159 |
+
|
| 160 |
+
private theorem edge_at (l : Tag p.g) (e : Comp p.g) (h : inc e l) :
|
| 161 |
+
∃ (k : Tag p.g) (h : l≠k),e = edge l k h := by
|
| 162 |
+
rcases e with ⟨⟨i,j⟩,hj⟩
|
| 163 |
+
change i=l∨j=l at h
|
| 164 |
+
rcases h with rfl|rfl
|
| 165 |
+
· exact ⟨j,hj.ne,(edge_eq hj).symm⟩
|
| 166 |
+
exact ⟨i,hj.ne.symm, by rw [edge_symm,edge_eq hj]⟩
|
| 167 |
+
|
| 168 |
+
private theorem cut_tri {x : Profile p n} (hx : x∈Xspace p n)
|
| 169 |
+
(l k j : Tag p.g) (h : l≠k) (h' : l ≠ j) (h'' : k≠j) :
|
| 170 |
+
x (edge l k h)+x (edge l j h')+x (edge k j h'')=0 := by
|
| 171 |
+
obtain ⟨w,hv,rfl⟩ := mem_X.mp hx
|
| 172 |
+
rw [← getPair_edge l k h (cut p n w), ←getPair_edge l j h' (cut p n w), ←getPair_edge k j h'' (cut p n w),
|
| 173 |
+
getPair_cut,getPair_cut,getPair_cut]
|
| 174 |
+
have he (x y z : Moment p n) : x+y+(x+z)+(y+z)=0 := calc
|
| 175 |
+
_ = (x+x)+(y+y)+(z+z) := by ac_rfl
|
| 176 |
+
_ = _ := by simp only [char_two]
|
| 177 |
+
exact he _ _ _
|
| 178 |
+
|
| 179 |
+
private theorem structure_mark {x : Xpair p n} {a b : Plan p n}
|
| 180 |
+
{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}
|
| 181 |
+
{q R : ℕ} (hb : v.bounded w) (ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)
|
| 182 |
+
(hr : 6*R+4≤p.j) (hq : R+14≤q)
|
| 183 |
+
(l : I)
|
| 184 |
+
{L : Comp p.g → Finset (Label p.b)} {Z : Comp p.g → Label p.b → BaseMat p n}
|
| 185 |
+
(he : ∀ e,labStruct p n ((x (v.obj l)).val e) R (L e) (Z e)) :
|
| 186 |
+
∃ c : F, ∀ e,mput p (v.sel l) (Z e (v.sel l))=c • v.atomAt t l e := by
|
| 187 |
+
classical
|
| 188 |
+
let s := v.sel l
|
| 189 |
+
let u := t l
|
| 190 |
+
let M := vecMulVec (baseV (v.par l)) (baseV (v.par l))
|
| 191 |
+
let coeff := fun e : Comp p.g => Z e s none none
|
| 192 |
+
have h1 (e : Comp p.g) : Z e s= if inc e u then coeff e • M else 0 := by
|
| 193 |
+
have ⟨hE,hL,hT,hH⟩ := he e
|
| 194 |
+
exact mark_atom hb t hv l e _ (le_trans (Nat.add_le_add_right hL 14) hq)
|
| 195 |
+
_ hT hH (hE ▸ vanish_one ho (v.obj l) e)
|
| 196 |
+
have h2 (e f : Comp p.g) (h : inc e u) (h' : inc f u) :
|
| 197 |
+
coeff e=coeff f := by
|
| 198 |
+
by_cases hi : e=f
|
| 199 |
+
· rw [hi]
|
| 200 |
+
obtain ⟨k,hk,rfl⟩ := edge_at u e h
|
| 201 |
+
obtain ⟨u2,hl,rfl⟩ := edge_at u f h'
|
| 202 |
+
have hj : k ≠ u2 := by rintro rfl; exact hi rfl
|
| 203 |
+
have hh := cut_tri (x (v.obj l)).property u k u2 hk hl hj
|
| 204 |
+
have heq := struct_tri (he (edge u k hk)) (he (edge u u2 hl)) (he (edge k u2 hj))
|
| 205 |
+
(by omega) hh s
|
| 206 |
+
have hn : ¬ inc (edge k u2 hj) u := fun he => by
|
| 207 |
+
rcases (inc_edge_iff _).mp he with h|h; exact hk h.symm; exact hl h.symm
|
| 208 |
+
rw [h1 (edge k u2 hj), ite_eq_right hn,add_zero] at heq
|
| 209 |
+
have h0 := congr_fun (congr_fun heq none) none
|
| 210 |
+
change coeff _ + coeff _ = 0 at h0
|
| 211 |
+
exact add_right_cancel (h0.trans (char_two _).symm)
|
| 212 |
+
have h3 (e) : mput p s (Z e s)= coeff e • v.atomAt t l e := by
|
| 213 |
+
rw [h1,atomAt,atom_def]
|
| 214 |
+
by_cases hf : inc e u
|
| 215 |
+
· rw [ite_eq_left hf,ite_eq_left hf,map_smul]
|
| 216 |
+
change coeff e • liftM (labMat p n s) (labMat p n s) M=_
|
| 217 |
+
unfold M
|
| 218 |
+
rw [liftM_outer,labMat_act]; rfl
|
| 219 |
+
rw [ite_eq_right hf,ite_eq_right hf,map_zero,smul_zero]
|
| 220 |
+
by_cases hh : ∃ e,inc e u
|
| 221 |
+
· obtain ⟨f,hf⟩ := hh
|
| 222 |
+
refine ⟨coeff f,fun e => ?_⟩
|
| 223 |
+
by_cases h : inc e u
|
| 224 |
+
· exact (h3 e).trans (by rw [h2 e f h hf])
|
| 225 |
+
refine (h3 e).trans ?_
|
| 226 |
+
rw [atomAt,atom_def,ite_eq_right h,smul_zero,smul_zero]
|
| 227 |
+
refine ⟨0,fun e => ?_⟩
|
| 228 |
+
refine (h3 e).trans ?_
|
| 229 |
+
rw [atomAt,atom_def,ite_eq_right (show ¬inc e u from fun he => hh ⟨e,he⟩),
|
| 230 |
+
smul_zero,zero_smul]
|
| 231 |
+
|
| 232 |
+
/-- a component uses at most R nonattack labels. -/
|
| 233 |
+
def clean (v : Volley p n I) (i : Bool) (R : ℕ) (M : Moment p n) :=
|
| 234 |
+
∃ (L : Finset (Label p.b)) (Z : Label p.b → BaseMat p n),
|
| 235 |
+
M=labelSum p L Z ∧ L.card≤R ∧ Disjoint L (v.marked i)
|
| 236 |
+
|
| 237 |
+
theorem split_orth {x : Xpair p n} {a b : Plan p n}
|
| 238 |
+
{C : ChanOut p n} {t : Tagging p I} {w : I→Bool} {j : Bool}
|
| 239 |
+
{q R : ℕ} (hb : v.bounded w) (ht : v.legal t)
|
| 240 |
+
(ho : orth p C (v.frozen a t) b j x) (hv : v.avoids a q)
|
| 241 |
+
(hr : 6*R+4≤p.j) (hr' : 2*planRank a+28≤R) (hq : R+14≤q) :
|
| 242 |
+
∃ (c : I → F) (y : Xpair p n), x=y+∑ i,c i • v.strike t ht i ∧
|
| 243 |
+
orth p C (v.frozen a t) b j y ∧ ∀ i e,v.clean i R ((y i).val e) := by
|
| 244 |
+
classical
|
| 245 |
+
choose L Z hZ using orth_structure hb ho R hr' hr
|
| 246 |
+
choose c hc using fun l => structure_mark hb ho hv hr hq l (hZ (v.obj l))
|
| 247 |
+
let A := ∑ i,c i • v.strike t ht i
|
| 248 |
+
refine ⟨c,x-A,(sub_add_cancel x A).symm,orth_sub ho (orth_sum _ _ (v.strike_orth t ht)),
|
| 249 |
+
fun i e => ?_⟩
|
| 250 |
+
obtain ⟨B,h1,hA,hv',h3⟩ := hv i
|
| 251 |
+
let T := v.marked i
|
| 252 |
+
have he : (A i).val e=labelSum p T (Z i e) := by
|
| 253 |
+
rw [show (A i).val=_ from v.strike_here t ht c i, Finset.sum_apply]
|
| 254 |
+
dsimp only [labelSum,T,marked]
|
| 255 |
+
rw [Finset.sum_image h3]
|
| 256 |
+
refine Finset.sum_congr rfl fun l hl => ?_
|
| 257 |
+
have he : v.obj l=i := (mem_filter.mp hl).2
|
| 258 |
+
exact (he ▸ hc l e).symm
|
| 259 |
+
let W := L i e
|
| 260 |
+
refine ⟨W \ T,Z i e,?_,(Finset.card_le_card sdiff_subset).trans (hZ i e).2.1, ?_⟩
|
| 261 |
+
· change (x i).val e-(A i).val e=_
|
| 262 |
+
rw [(hZ i e).1,he]
|
| 263 |
+
have hz : labelSum p W (Z i e)=labelSum p (W∪T) (Z i e) := by
|
| 264 |
+
refine Finset.sum_subset subset_union_left fun s _ hs => ?_
|
| 265 |
+
rw [(hZ i e).2.2.1 s hs,map_zero]
|
| 266 |
+
rw [hz]
|
| 267 |
+
have hS : (W∪T)=(W \ T) ∪ T := by ext i; simp
|
| 268 |
+
rw [hS,labelSum,Finset.sum_union (show Disjoint (W \ T) T from Disjoint.symm disjoint_sdiff)]
|
| 269 |
+
exact add_sub_cancel_right _ _
|
| 270 |
+
exact Disjoint.symm disjoint_sdiff
|
| 271 |
+
|
| 272 |
+
end Volley
|
| 273 |
+
end HadwigerCounterexample
|
| 274 |
+
|
| 275 |
+
end
|
| 276 |
+
|
| 277 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BaselineExtension.lean
CHANGED
|
@@ -1,124 +1,124 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PrimalChannelDecomposition
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Baseline Extension -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Submodule
|
| 10 |
-
|
| 11 |
-
variable {p : Shape} {n : ℕ}
|
| 12 |
-
|
| 13 |
-
theorem project_table (a : Plan p n) (z : Place p) (Q : Space (Dir p n))
|
| 14 |
-
(hq : Q ≤ primal p n) (hd : Disjoint (tabSpace a z) Q) :
|
| 15 |
-
∃ B, ProjData (tabSpace a z) Q B ∧ ∀ x∈ primal p n, B*ᵥx∈prSmall a z := by
|
| 16 |
-
classical
|
| 17 |
-
let H := channels p n
|
| 18 |
-
let A := primal p n
|
| 19 |
-
let P := prSmall a z
|
| 20 |
-
have hp : P≤ A := prSmall_le _ _
|
| 21 |
-
have he : tabSpace a z=P ⊔ H := prSmall_table a z
|
| 22 |
-
obtain ⟨X,hX⟩ := proj_exists H A channels_disjoint.symm
|
| 23 |
-
have hj : Disjoint P (Q⊔H) := by
|
| 24 |
-
rw [disjoint_iff_inf_le]
|
| 25 |
-
rintro v ⟨hv,hv'⟩
|
| 26 |
-
obtain ⟨y,hy,w,hw,g⟩ := Submodule.mem_sup.mp hv'
|
| 27 |
-
have h := (show w=v-y by rw [←g]; abel) ▸
|
| 28 |
-
A.sub_mem (hp hv) (hq hy)
|
| 29 |
-
have hz : w∈ A ⊓ H := ⟨h,hw⟩
|
| 30 |
-
rw [channels_disjoint.eq_bot] at hz
|
| 31 |
-
have hi : w=0 := by simpa using hz
|
| 32 |
-
rw [hi,add_zero] at g
|
| 33 |
-
have ht : v∈tabSpace a z ⊓ Q :=
|
| 34 |
-
⟨he.symm ▸ Submodule.mem_sup_left hv,g ▸ hy⟩
|
| 35 |
-
rwa [hd.eq_bot] at ht
|
| 36 |
-
obtain ⟨Y,hY⟩ := proj_exists P (Q⊔H) hj
|
| 37 |
-
refine ⟨X+Y,⟨fun x => ?_,fun x hx => ?_,fun x hx => ?_⟩, fun x hx => ?_⟩
|
| 38 |
-
· rw [add_mulVec,he,add_comm]; exact add_mem_sup (hY.onto _) (hX.onto _)
|
| 39 |
-
· rw [he] at hx
|
| 40 |
-
obtain ⟨v,hv,w,hw,rfl⟩ := Submodule.mem_sup.mp hx
|
| 41 |
-
rw [add_mulVec,mulVec_add,mulVec_add,hX.kills v (hp hv),hX.fixes _ hw,hY.fixes _ hv,
|
| 42 |
-
hY.kills _ (Submodule.mem_sup_right hw),add_zero,zero_add,add_comm]
|
| 43 |
-
· rw [add_mulVec,hX.kills x (hq hx),hY.kills x (Submodule.mem_sup_left hx),zero_add]
|
| 44 |
-
· rw [add_mulVec,hX.kills x hx,zero_add]; exact hY.onto _
|
| 45 |
-
|
| 46 |
-
abbrev CrossM (p : Shape) (n : ℕ) := Mat (JointIdx p n) (JointIdx p n)
|
| 47 |
-
|
| 48 |
-
set_option maxHeartbeats 800000 in
|
| 49 |
-
theorem base_pair (a b : Plan p n) (u v : Place p)
|
| 50 |
-
(K J : Space (Dir p n)) (hk : K≤primal p n) (hj : J≤primal p n)
|
| 51 |
-
(hK : Disjoint (tabSpace a u) K) (hJ : Disjoint (tabSpace b v) J)
|
| 52 |
-
(A B : CrossM p n)
|
| 53 |
-
(heq : ∀ x∈ tabSpace a u,∀ y∈tabSpace b v,x∈a u ∨ y∈b v → evmat A x y=evmat B x y) :
|
| 54 |
-
∃ M : CrossM p n,
|
| 55 |
-
(∀ x∈tabSpace a u,∀ y∈tabSpace b v,evmat M x y=evmat B x y) ∧
|
| 56 |
-
(∀ x y, x∈ (a u⊔K) ∨ y∈(b v⊔J) → evmat M x y=evmat A x y) ∧
|
| 57 |
-
(∀ i,(Mᵀ*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +
|
| 58 |
-
2*planRank a) ∧
|
| 59 |
-
(∀ i,(M*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +
|
| 60 |
-
2*planRank b) := by
|
| 61 |
-
let P := a u⊔K
|
| 62 |
-
let Q := b v⊔J
|
| 63 |
-
obtain ⟨X,hX⟩ := proj_exists P ⊥ disjoint_bot_right
|
| 64 |
-
obtain ⟨Y,hY⟩ := proj_exists Q ⊥ disjoint_bot_right
|
| 65 |
-
obtain ⟨L,hL,gL⟩ := project_table a u K hk hK
|
| 66 |
-
obtain ⟨R,hR,gR⟩ := project_table b v J hj hJ
|
| 67 |
-
let C := pullM X (1:CrossM p n) A + pullM (1-X) Y A
|
| 68 |
-
let M := C + pullM L R (B-C)
|
| 69 |
-
have h1 (x y) (hx : x∈P ∨ y∈Q) : evmat C x y=evmat A x y := by
|
| 70 |
-
rw [show C=_ from rfl,evmat_addM,evmat_pull,evmat_pull,sub_mulVec,Matrix.one_mulVec,
|
| 71 |
-
Matrix.one_mulVec]
|
| 72 |
-
rcases hx with h|h
|
| 73 |
-
· rw [hX.fixes _ h,sub_self]; simp [evmat]
|
| 74 |
-
rw [hY.fixes _ h]
|
| 75 |
-
simp [evmat,sub_dotProduct]
|
| 76 |
-
have h2 (x y) : evmat M x y=evmat C x y+
|
| 77 |
-
(evmat B (L *ᵥ x) (R *ᵥ y)-evmat C (L*ᵥ x) (R*ᵥ y)) := by
|
| 78 |
-
rw [show M=_ from rfl,evmat_addM,evmat_pull,evmat_subM]
|
| 79 |
-
have hRank : C.rank≤dim P+dim Q := by
|
| 80 |
-
apply (mrk_add_le ..).trans
|
| 81 |
-
have hx : X.rank≤dim P := rank_maps _ hX.onto
|
| 82 |
-
have hy : Y.rank≤dim Q := rank_maps _ hY.onto
|
| 83 |
-
apply Nat.add_le_add
|
| 84 |
-
· rw [pullM_def]
|
| 85 |
-
refine ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans ?_
|
| 86 |
-
rwa [Matrix.rank_transpose]
|
| 87 |
-
· rw [pullM_def]; exact (Matrix.rank_mul_le_right ..).trans hy
|
| 88 |
-
have hr (i) {a : Plan p n} (u)
|
| 89 |
-
(R : CrossM p n) (h : ∀ x∈primal p n,R*ᵥ x∈prSmall a u) :
|
| 90 |
-
(R*IP p n i).rank≤ 2*planRank a := by
|
| 91 |
-
apply le_trans (rank_maps (prSmall a u) _)
|
| 92 |
-
(prSmall_dim a u)
|
| 93 |
-
intro x
|
| 94 |
-
rw [← Matrix.mulVec_mulVec]
|
| 95 |
-
exact h _ (ip_le_primal i (show IP p n i*ᵥx∈colSp (IP p n i) from ⟨x,rfl⟩))
|
| 96 |
-
refine ⟨M, fun x hx y hy => ?_, fun x y h => ?_, fun i => ?_, fun i => ?_⟩
|
| 97 |
-
· rw [h2,hL.fixes x hx,hR.fixes y hy,add_sub_cancel]
|
| 98 |
-
· have hi : L*ᵥ x ∈ a u ∨ R *ᵥ y ∈ b v := by
|
| 99 |
-
rcases h with h|h
|
| 100 |
-
· left; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp h
|
| 101 |
-
rwa [Matrix.mulVec_add,hL.kills _ hy,hL.fixes _ (pin_le_table _ _ hx),add_zero]
|
| 102 |
-
right; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp h
|
| 103 |
-
rwa [Matrix.mulVec_add,hR.kills _ hy,hR.fixes _ (pin_le_table _ _ hx),add_zero]
|
| 104 |
-
have he : L*ᵥx ∈ P ∨ R*ᵥy∈Q := hi.imp Submodule.mem_sup_left Submodule.mem_sup_left
|
| 105 |
-
rw [h2,h1 _ _ h,h1 _ _ he,heq _ (hL.onto _) _ (hR.onto _) hi,sub_self,add_zero]
|
| 106 |
-
· unfold M
|
| 107 |
-
rw [transpose_add,Matrix.add_mul]
|
| 108 |
-
refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)
|
| 109 |
-
· exact (Matrix.rank_mul_le_left ..).trans ((Matrix.rank_transpose _).trans_le hRank)
|
| 110 |
-
rw [pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc,
|
| 111 |
-
Matrix.mul_assoc]
|
| 112 |
-
exact ((Matrix.rank_mul_le_right ..).trans (Matrix.rank_mul_le_right ..)).trans (hr i u L gL)
|
| 113 |
-
· unfold M
|
| 114 |
-
rw [Matrix.add_mul]
|
| 115 |
-
refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)
|
| 116 |
-
· exact (Matrix.rank_mul_le_left ..).trans hRank
|
| 117 |
-
rw [pullM_def,Matrix.mul_assoc]
|
| 118 |
-
exact (Matrix.rank_mul_le_right ..).trans (hr i v R gR)
|
| 119 |
-
|
| 120 |
-
end HadwigerCounterexample
|
| 121 |
-
|
| 122 |
-
end
|
| 123 |
-
|
| 124 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PrimalChannelDecomposition
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Baseline Extension -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Submodule
|
| 10 |
+
|
| 11 |
+
variable {p : Shape} {n : ℕ}
|
| 12 |
+
|
| 13 |
+
theorem project_table (a : Plan p n) (z : Place p) (Q : Space (Dir p n))
|
| 14 |
+
(hq : Q ≤ primal p n) (hd : Disjoint (tabSpace a z) Q) :
|
| 15 |
+
∃ B, ProjData (tabSpace a z) Q B ∧ ∀ x∈ primal p n, B*ᵥx∈prSmall a z := by
|
| 16 |
+
classical
|
| 17 |
+
let H := channels p n
|
| 18 |
+
let A := primal p n
|
| 19 |
+
let P := prSmall a z
|
| 20 |
+
have hp : P≤ A := prSmall_le _ _
|
| 21 |
+
have he : tabSpace a z=P ⊔ H := prSmall_table a z
|
| 22 |
+
obtain ⟨X,hX⟩ := proj_exists H A channels_disjoint.symm
|
| 23 |
+
have hj : Disjoint P (Q⊔H) := by
|
| 24 |
+
rw [disjoint_iff_inf_le]
|
| 25 |
+
rintro v ⟨hv,hv'⟩
|
| 26 |
+
obtain ⟨y,hy,w,hw,g⟩ := Submodule.mem_sup.mp hv'
|
| 27 |
+
have h := (show w=v-y by rw [←g]; abel) ▸
|
| 28 |
+
A.sub_mem (hp hv) (hq hy)
|
| 29 |
+
have hz : w∈ A ⊓ H := ⟨h,hw⟩
|
| 30 |
+
rw [channels_disjoint.eq_bot] at hz
|
| 31 |
+
have hi : w=0 := by simpa using hz
|
| 32 |
+
rw [hi,add_zero] at g
|
| 33 |
+
have ht : v∈tabSpace a z ⊓ Q :=
|
| 34 |
+
⟨he.symm ▸ Submodule.mem_sup_left hv,g ▸ hy⟩
|
| 35 |
+
rwa [hd.eq_bot] at ht
|
| 36 |
+
obtain ⟨Y,hY⟩ := proj_exists P (Q⊔H) hj
|
| 37 |
+
refine ⟨X+Y,⟨fun x => ?_,fun x hx => ?_,fun x hx => ?_⟩, fun x hx => ?_⟩
|
| 38 |
+
· rw [add_mulVec,he,add_comm]; exact add_mem_sup (hY.onto _) (hX.onto _)
|
| 39 |
+
· rw [he] at hx
|
| 40 |
+
obtain ⟨v,hv,w,hw,rfl⟩ := Submodule.mem_sup.mp hx
|
| 41 |
+
rw [add_mulVec,mulVec_add,mulVec_add,hX.kills v (hp hv),hX.fixes _ hw,hY.fixes _ hv,
|
| 42 |
+
hY.kills _ (Submodule.mem_sup_right hw),add_zero,zero_add,add_comm]
|
| 43 |
+
· rw [add_mulVec,hX.kills x (hq hx),hY.kills x (Submodule.mem_sup_left hx),zero_add]
|
| 44 |
+
· rw [add_mulVec,hX.kills x hx,zero_add]; exact hY.onto _
|
| 45 |
+
|
| 46 |
+
abbrev CrossM (p : Shape) (n : ℕ) := Mat (JointIdx p n) (JointIdx p n)
|
| 47 |
+
|
| 48 |
+
set_option maxHeartbeats 800000 in
|
| 49 |
+
theorem base_pair (a b : Plan p n) (u v : Place p)
|
| 50 |
+
(K J : Space (Dir p n)) (hk : K≤primal p n) (hj : J≤primal p n)
|
| 51 |
+
(hK : Disjoint (tabSpace a u) K) (hJ : Disjoint (tabSpace b v) J)
|
| 52 |
+
(A B : CrossM p n)
|
| 53 |
+
(heq : ∀ x∈ tabSpace a u,∀ y∈tabSpace b v,x∈a u ∨ y∈b v → evmat A x y=evmat B x y) :
|
| 54 |
+
∃ M : CrossM p n,
|
| 55 |
+
(∀ x∈tabSpace a u,∀ y∈tabSpace b v,evmat M x y=evmat B x y) ∧
|
| 56 |
+
(∀ x y, x∈ (a u⊔K) ∨ y∈(b v⊔J) → evmat M x y=evmat A x y) ∧
|
| 57 |
+
(∀ i,(Mᵀ*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +
|
| 58 |
+
2*planRank a) ∧
|
| 59 |
+
(∀ i,(M*IP p n i).rank ≤ dim (a u⊔K : Submodule _ _) + dim (b v⊔J : Submodule _ _) +
|
| 60 |
+
2*planRank b) := by
|
| 61 |
+
let P := a u⊔K
|
| 62 |
+
let Q := b v⊔J
|
| 63 |
+
obtain ⟨X,hX⟩ := proj_exists P ⊥ disjoint_bot_right
|
| 64 |
+
obtain ⟨Y,hY⟩ := proj_exists Q ⊥ disjoint_bot_right
|
| 65 |
+
obtain ⟨L,hL,gL⟩ := project_table a u K hk hK
|
| 66 |
+
obtain ⟨R,hR,gR⟩ := project_table b v J hj hJ
|
| 67 |
+
let C := pullM X (1:CrossM p n) A + pullM (1-X) Y A
|
| 68 |
+
let M := C + pullM L R (B-C)
|
| 69 |
+
have h1 (x y) (hx : x∈P ∨ y∈Q) : evmat C x y=evmat A x y := by
|
| 70 |
+
rw [show C=_ from rfl,evmat_addM,evmat_pull,evmat_pull,sub_mulVec,Matrix.one_mulVec,
|
| 71 |
+
Matrix.one_mulVec]
|
| 72 |
+
rcases hx with h|h
|
| 73 |
+
· rw [hX.fixes _ h,sub_self]; simp [evmat]
|
| 74 |
+
rw [hY.fixes _ h]
|
| 75 |
+
simp [evmat,sub_dotProduct]
|
| 76 |
+
have h2 (x y) : evmat M x y=evmat C x y+
|
| 77 |
+
(evmat B (L *ᵥ x) (R *ᵥ y)-evmat C (L*ᵥ x) (R*ᵥ y)) := by
|
| 78 |
+
rw [show M=_ from rfl,evmat_addM,evmat_pull,evmat_subM]
|
| 79 |
+
have hRank : C.rank≤dim P+dim Q := by
|
| 80 |
+
apply (mrk_add_le ..).trans
|
| 81 |
+
have hx : X.rank≤dim P := rank_maps _ hX.onto
|
| 82 |
+
have hy : Y.rank≤dim Q := rank_maps _ hY.onto
|
| 83 |
+
apply Nat.add_le_add
|
| 84 |
+
· rw [pullM_def]
|
| 85 |
+
refine ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans ?_
|
| 86 |
+
rwa [Matrix.rank_transpose]
|
| 87 |
+
· rw [pullM_def]; exact (Matrix.rank_mul_le_right ..).trans hy
|
| 88 |
+
have hr (i) {a : Plan p n} (u)
|
| 89 |
+
(R : CrossM p n) (h : ∀ x∈primal p n,R*ᵥ x∈prSmall a u) :
|
| 90 |
+
(R*IP p n i).rank≤ 2*planRank a := by
|
| 91 |
+
apply le_trans (rank_maps (prSmall a u) _)
|
| 92 |
+
(prSmall_dim a u)
|
| 93 |
+
intro x
|
| 94 |
+
rw [← Matrix.mulVec_mulVec]
|
| 95 |
+
exact h _ (ip_le_primal i (show IP p n i*ᵥx∈colSp (IP p n i) from ⟨x,rfl⟩))
|
| 96 |
+
refine ⟨M, fun x hx y hy => ?_, fun x y h => ?_, fun i => ?_, fun i => ?_⟩
|
| 97 |
+
· rw [h2,hL.fixes x hx,hR.fixes y hy,add_sub_cancel]
|
| 98 |
+
· have hi : L*ᵥ x ∈ a u ∨ R *ᵥ y ∈ b v := by
|
| 99 |
+
rcases h with h|h
|
| 100 |
+
· left; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp h
|
| 101 |
+
rwa [Matrix.mulVec_add,hL.kills _ hy,hL.fixes _ (pin_le_table _ _ hx),add_zero]
|
| 102 |
+
right; obtain ⟨x,hx,y,hy,rfl⟩ := Submodule.mem_sup.mp h
|
| 103 |
+
rwa [Matrix.mulVec_add,hR.kills _ hy,hR.fixes _ (pin_le_table _ _ hx),add_zero]
|
| 104 |
+
have he : L*ᵥx ∈ P ∨ R*ᵥy∈Q := hi.imp Submodule.mem_sup_left Submodule.mem_sup_left
|
| 105 |
+
rw [h2,h1 _ _ h,h1 _ _ he,heq _ (hL.onto _) _ (hR.onto _) hi,sub_self,add_zero]
|
| 106 |
+
· unfold M
|
| 107 |
+
rw [transpose_add,Matrix.add_mul]
|
| 108 |
+
refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)
|
| 109 |
+
· exact (Matrix.rank_mul_le_left ..).trans ((Matrix.rank_transpose _).trans_le hRank)
|
| 110 |
+
rw [pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc,
|
| 111 |
+
Matrix.mul_assoc]
|
| 112 |
+
exact ((Matrix.rank_mul_le_right ..).trans (Matrix.rank_mul_le_right ..)).trans (hr i u L gL)
|
| 113 |
+
· unfold M
|
| 114 |
+
rw [Matrix.add_mul]
|
| 115 |
+
refine (mrk_add_le ..).trans (Nat.add_le_add ?_ ?_)
|
| 116 |
+
· exact (Matrix.rank_mul_le_left ..).trans hRank
|
| 117 |
+
rw [pullM_def,Matrix.mul_assoc]
|
| 118 |
+
exact (Matrix.rank_mul_le_right ..).trans (hr i v R gR)
|
| 119 |
+
|
| 120 |
+
end HadwigerCounterexample
|
| 121 |
+
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BaselineForms.lean
CHANGED
|
@@ -1,147 +1,147 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BaselineExtension
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Baseline Forms -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
open Matrix
|
| 12 |
-
variable {p : Shape} {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
def lowCross (K : ℕ) (B : Cross p n) :=
|
| 15 |
-
∀ z i,( (B z)ᵀ * IP p n i).rank ≤ K
|
| 16 |
-
|
| 17 |
-
def fitsTable (a b : Plan p n) (B T : Cross p n) :=
|
| 18 |
-
∀ z, ∀ x∈tabSpace a z,∀ y∈tabSpace b (flipZ p z), evmat (B z) x y=evmat (T z) x y
|
| 19 |
-
|
| 20 |
-
theorem fits_recip {B T : Cross p n} {a b : Plan p n} (h : fitsTable a b B T) :
|
| 21 |
-
fitsTable b a (reciprocal p B) (reciprocal p T) := by
|
| 22 |
-
intro z x hx y hy
|
| 23 |
-
have hx' : x∈tabSpace b (flipZ p (flipZ p z)) := by rwa [flipZ_flip]
|
| 24 |
-
change evmat _ _ _=evmat _ _ _
|
| 25 |
-
unfold reciprocal
|
| 26 |
-
rw [evmat_transpose,evmat_transpose,h _ y hy x hx']
|
| 27 |
-
|
| 28 |
-
def blin (K : ℕ) := 4*K+56
|
| 29 |
-
|
| 30 |
-
set_option maxHeartbeats 800000 in
|
| 31 |
-
theorem start_form (a b : Pin p n N) (x y : UnitType p n N) (T : Cross p n)
|
| 32 |
-
(ka kb : Plan p n)
|
| 33 |
-
(hA : ∀ z,ka z≤primal p n) (hB : ∀ z,kb z≤primal p n)
|
| 34 |
-
(hd : ∀ z, Disjoint (tabSpace a.sp z) (ka z))
|
| 35 |
-
(hd' : ∀ z, Disjoint (tabSpace b.sp z) (kb z))
|
| 36 |
-
(ha : a.agree x) (hb : b.agree y) (h1 : tableFlag a b T x)
|
| 37 |
-
(h2 : tableFlag b a (reciprocal p T) y)
|
| 38 |
-
(K : ℕ) (hk : planRank a.sp ≤ K) (hk' : planRank b.sp ≤ K)
|
| 39 |
-
(hv : ∀ z, dim (ka z) ≤ 28) (hv' : ∀ z, dim (kb z) ≤ 28) :
|
| 40 |
-
∃ M : Cross p n, fitsTable a.sp b.sp M T ∧
|
| 41 |
-
rowAgree (a.sp ⊔ ka) M (actual p x y) ∧
|
| 42 |
-
rowAgree (b.sp ⊔ kb) (reciprocal p M) (actual p y x) ∧
|
| 43 |
-
lowCross (blin K) M ∧ lowCross (blin K) (reciprocal p M) := by
|
| 44 |
-
let A := actual p x y
|
| 45 |
-
have hh (z : Place p) (u v) (hu : u∈tabSpace a.sp z) (hv : v∈tabSpace b.sp (flipZ p z))
|
| 46 |
-
(h : u∈a.sp z ∨ v∈b.sp (flipZ p z)) : evmat (A z) u v=evmat (T z) u v := by
|
| 47 |
-
rcases h with h|h
|
| 48 |
-
· have h' : u ∈ a.sp (flipZ p (flipZ p z)) := by rwa [flipZ_flip]
|
| 49 |
-
have he := h2 _ v hv u h'
|
| 50 |
-
have hf := flag_actual (a:=b) y x ha (flipZ p z) v hv u h'
|
| 51 |
-
have hg := hf.trans he.symm
|
| 52 |
-
rw [← reciprocal_actual x y] at hg
|
| 53 |
-
simp only [reciprocal,flipZ_flip,evmat_transpose] at hg
|
| 54 |
-
exact hg
|
| 55 |
-
exact (flag_actual (a:=a) x y hb _ u hu v h).trans (h1 _ u hu v h).symm
|
| 56 |
-
choose M hC hD hE hF using fun z =>
|
| 57 |
-
base_pair a.sp b.sp z (flipZ p z) (ka z) (kb (flipZ p z)) (hA _) (hB _) (hd _) (hd' _)
|
| 58 |
-
(A z) (T z) (fun u hu v hv g => hh z u v hu hv g)
|
| 59 |
-
have hr (z) {a s : Plan p n} (h : planRank a≤K) (hg : ∀ z,dim (s z)≤28) :
|
| 60 |
-
dim (a z ⊔ s z : Submodule _ _) ≤ K+28 :=
|
| 61 |
-
(Submodule.finrank_add_le_finrank_add_finrank ..).trans
|
| 62 |
-
(Nat.add_le_add ((dim_le_plan a _).trans h) (hg _))
|
| 63 |
-
have hm z {L} (hl : L≤K) : dim (a.sp z ⊔ ka z : Submodule _ _)+
|
| 64 |
-
dim (b.sp (flipZ p z) ⊔ kb (flipZ p z):Submodule _ _)+2*L ≤ blin K := by
|
| 65 |
-
apply le_trans (Nat.add_le_add (Nat.add_le_add (hr z hk hv) (hr _ hk' hv'))
|
| 66 |
-
(Nat.mul_le_mul_left 2 hl))
|
| 67 |
-
unfold blin; omega
|
| 68 |
-
refine ⟨M,hC,(fun z u hu v => hD z u v (Or.inl hu)),?_,
|
| 69 |
-
fun z i => (hE z i).trans (hm z hk),?_⟩
|
| 70 |
-
· rw [← reciprocal_actual x y]
|
| 71 |
-
intro z v hv u
|
| 72 |
-
unfold reciprocal; rw [evmat_transpose,evmat_transpose]
|
| 73 |
-
apply hD
|
| 74 |
-
right
|
| 75 |
-
rw [flipZ_flip]; exact hv
|
| 76 |
-
intro z i
|
| 77 |
-
unfold reciprocal; rw [transpose_transpose]
|
| 78 |
-
exact (hF (flipZ p z) i).trans (hm _ hk')
|
| 79 |
-
|
| 80 |
-
theorem channel_eval (p : Shape) {n} (M : Cross p n) (j : Bool) (z : Place p)
|
| 81 |
-
(x : Dir p n) (y : Vec (Chan p)) :
|
| 82 |
-
dotProduct y (channelOut p M j z *ᵥ x)=evmat (M z) x (IH p n j *ᵥ y) := by
|
| 83 |
-
unfold channelOut evmat
|
| 84 |
-
rw [dotProduct_transpose_mulVec, Matrix.mulVec_mulVec]
|
| 85 |
-
|
| 86 |
-
theorem channel_same {M T : Cross p n} (i z u)
|
| 87 |
-
(h : ∀ v : Vec (Chan p), evmat (M z) u (IH p n i *ᵥ v)=evmat (T z) u (IH p n i *ᵥ v)) :
|
| 88 |
-
channelOut p M i z *ᵥ u = channelOut p T i z *ᵥ u := by
|
| 89 |
-
classical
|
| 90 |
-
funext j
|
| 91 |
-
have he v : dotProduct v (channelOut p M i z *ᵥ u)=dotProduct v (channelOut p T i z*ᵥ u) := by
|
| 92 |
-
rw [channel_eval, channel_eval, h]
|
| 93 |
-
simpa using he (Pi.single j 1)
|
| 94 |
-
|
| 95 |
-
theorem fits_channel {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)
|
| 96 |
-
(z : Place p) (x : Dir p n) (hx : x∈tabSpace a z) (j : Bool) :
|
| 97 |
-
channelOut p M j z *ᵥ x = channelOut p T j z *ᵥ x := by
|
| 98 |
-
apply channel_same j
|
| 99 |
-
intro v
|
| 100 |
-
exact h z x hx _ (channel_le_table b _ j ⟨_,rfl⟩)
|
| 101 |
-
|
| 102 |
-
theorem fits_inj {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)
|
| 103 |
-
(ht : tableInj a b T) : tableInj a b M := by
|
| 104 |
-
intro z i j v hv hh
|
| 105 |
-
apply ht z i j v hv
|
| 106 |
-
rwa [fits_channel h z _ (pin_le_table a z hv) j] at hh
|
| 107 |
-
|
| 108 |
-
private theorem cout_ev (A B : Mat (Chan p) (JointIdx p n)) (x y) :
|
| 109 |
-
evmat (Aᵀ*B) x y=dotProduct (A *ᵥ x) (B *ᵥ y) := by
|
| 110 |
-
rw [evmat,← mulVec_mulVec,dotProduct_transpose_mulVec,dotProduct_comm]
|
| 111 |
-
|
| 112 |
-
theorem fits_contract {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)
|
| 113 |
-
(i j : Bool) (x : Profile p n) (hx : x ∈ effective a i) :
|
| 114 |
-
contract p M i j x=contract p T i j x := by
|
| 115 |
-
change ∑ e : Comp p.g, _ = _
|
| 116 |
-
refine Finset.sum_congr rfl fun e _ => ?_
|
| 117 |
-
apply (box_eval_iff (tabSpace a (e,true)) (tabSpace a (e,false)) _ _).mp ?_ _
|
| 118 |
-
· have hp := lift_mem_box (IP p n i) (IP p n i) ((effective_mem.mp hx).2 e)
|
| 119 |
-
exact box_le (le_trans le_sup_left (half_le_table a _ i))
|
| 120 |
-
(le_trans le_sup_left (half_le_table a _ i)) hp
|
| 121 |
-
intro x hx y hy; rw [cout_ev, cout_ev,fits_channel h _ _ hx,fits_channel h _ _ hy]
|
| 122 |
-
|
| 123 |
-
variable {I : Type} [Fintype I]
|
| 124 |
-
|
| 125 |
-
theorem frozen_contract_key {M T : Cross p n} {a} (v : Volley p n I) (t : Tagging p I)
|
| 126 |
-
(h : rowAgree (a⊔v.keyPlan t) M T) (i : I) (j : Bool) :
|
| 127 |
-
contract p M (v.obj i) j (v.atomAt t i)=contract p T (v.obj i) j (v.atomAt t i) := by
|
| 128 |
-
classical
|
| 129 |
-
change ∑ e : Comp p.g, _ = _
|
| 130 |
-
refine Finset.sum_congr rfl fun e _ => ?_
|
| 131 |
-
by_cases he : inc e (t i)
|
| 132 |
-
· have hx b :
|
| 133 |
-
v.rayLoc i ∈ (v.keyPlan t (e,b)) := colSp_mem (P:=v.keyM t e)
|
| 134 |
-
(⟨i,he⟩ : Volley.visits p t e)
|
| 135 |
-
have hE (b : Bool) : channelOut p M j (e,b) *ᵥ v.rayLoc i =
|
| 136 |
-
channelOut p T j (e,b) *ᵥ v.rayLoc i :=
|
| 137 |
-
channel_same j _ _ (fun y => h _ _ (Submodule.mem_sup_right (hx b)) _)
|
| 138 |
-
simp only [Volley.atomAt,atom_def,he, ite_true,mom,liftM_outer,mpair_outer]
|
| 139 |
-
rw [cout_ev,cout_ev]
|
| 140 |
-
exact congrArg₂ dotProduct (hE true) (hE false)
|
| 141 |
-
simp only [Volley.atomAt,atom_def,he,ite_false,map_zero]
|
| 142 |
-
|
| 143 |
-
end HadwigerCounterexample
|
| 144 |
-
|
| 145 |
-
end
|
| 146 |
-
|
| 147 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BaselineExtension
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Baseline Forms -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open Matrix
|
| 12 |
+
variable {p : Shape} {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
def lowCross (K : ℕ) (B : Cross p n) :=
|
| 15 |
+
∀ z i,( (B z)ᵀ * IP p n i).rank ≤ K
|
| 16 |
+
|
| 17 |
+
def fitsTable (a b : Plan p n) (B T : Cross p n) :=
|
| 18 |
+
∀ z, ∀ x∈tabSpace a z,∀ y∈tabSpace b (flipZ p z), evmat (B z) x y=evmat (T z) x y
|
| 19 |
+
|
| 20 |
+
theorem fits_recip {B T : Cross p n} {a b : Plan p n} (h : fitsTable a b B T) :
|
| 21 |
+
fitsTable b a (reciprocal p B) (reciprocal p T) := by
|
| 22 |
+
intro z x hx y hy
|
| 23 |
+
have hx' : x∈tabSpace b (flipZ p (flipZ p z)) := by rwa [flipZ_flip]
|
| 24 |
+
change evmat _ _ _=evmat _ _ _
|
| 25 |
+
unfold reciprocal
|
| 26 |
+
rw [evmat_transpose,evmat_transpose,h _ y hy x hx']
|
| 27 |
+
|
| 28 |
+
def blin (K : ℕ) := 4*K+56
|
| 29 |
+
|
| 30 |
+
set_option maxHeartbeats 800000 in
|
| 31 |
+
theorem start_form (a b : Pin p n N) (x y : UnitType p n N) (T : Cross p n)
|
| 32 |
+
(ka kb : Plan p n)
|
| 33 |
+
(hA : ∀ z,ka z≤primal p n) (hB : ∀ z,kb z≤primal p n)
|
| 34 |
+
(hd : ∀ z, Disjoint (tabSpace a.sp z) (ka z))
|
| 35 |
+
(hd' : ∀ z, Disjoint (tabSpace b.sp z) (kb z))
|
| 36 |
+
(ha : a.agree x) (hb : b.agree y) (h1 : tableFlag a b T x)
|
| 37 |
+
(h2 : tableFlag b a (reciprocal p T) y)
|
| 38 |
+
(K : ℕ) (hk : planRank a.sp ≤ K) (hk' : planRank b.sp ≤ K)
|
| 39 |
+
(hv : ∀ z, dim (ka z) ≤ 28) (hv' : ∀ z, dim (kb z) ≤ 28) :
|
| 40 |
+
∃ M : Cross p n, fitsTable a.sp b.sp M T ∧
|
| 41 |
+
rowAgree (a.sp ⊔ ka) M (actual p x y) ∧
|
| 42 |
+
rowAgree (b.sp ⊔ kb) (reciprocal p M) (actual p y x) ∧
|
| 43 |
+
lowCross (blin K) M ∧ lowCross (blin K) (reciprocal p M) := by
|
| 44 |
+
let A := actual p x y
|
| 45 |
+
have hh (z : Place p) (u v) (hu : u∈tabSpace a.sp z) (hv : v∈tabSpace b.sp (flipZ p z))
|
| 46 |
+
(h : u∈a.sp z ∨ v∈b.sp (flipZ p z)) : evmat (A z) u v=evmat (T z) u v := by
|
| 47 |
+
rcases h with h|h
|
| 48 |
+
· have h' : u ∈ a.sp (flipZ p (flipZ p z)) := by rwa [flipZ_flip]
|
| 49 |
+
have he := h2 _ v hv u h'
|
| 50 |
+
have hf := flag_actual (a:=b) y x ha (flipZ p z) v hv u h'
|
| 51 |
+
have hg := hf.trans he.symm
|
| 52 |
+
rw [← reciprocal_actual x y] at hg
|
| 53 |
+
simp only [reciprocal,flipZ_flip,evmat_transpose] at hg
|
| 54 |
+
exact hg
|
| 55 |
+
exact (flag_actual (a:=a) x y hb _ u hu v h).trans (h1 _ u hu v h).symm
|
| 56 |
+
choose M hC hD hE hF using fun z =>
|
| 57 |
+
base_pair a.sp b.sp z (flipZ p z) (ka z) (kb (flipZ p z)) (hA _) (hB _) (hd _) (hd' _)
|
| 58 |
+
(A z) (T z) (fun u hu v hv g => hh z u v hu hv g)
|
| 59 |
+
have hr (z) {a s : Plan p n} (h : planRank a≤K) (hg : ∀ z,dim (s z)≤28) :
|
| 60 |
+
dim (a z ⊔ s z : Submodule _ _) ≤ K+28 :=
|
| 61 |
+
(Submodule.finrank_add_le_finrank_add_finrank ..).trans
|
| 62 |
+
(Nat.add_le_add ((dim_le_plan a _).trans h) (hg _))
|
| 63 |
+
have hm z {L} (hl : L≤K) : dim (a.sp z ⊔ ka z : Submodule _ _)+
|
| 64 |
+
dim (b.sp (flipZ p z) ⊔ kb (flipZ p z):Submodule _ _)+2*L ≤ blin K := by
|
| 65 |
+
apply le_trans (Nat.add_le_add (Nat.add_le_add (hr z hk hv) (hr _ hk' hv'))
|
| 66 |
+
(Nat.mul_le_mul_left 2 hl))
|
| 67 |
+
unfold blin; omega
|
| 68 |
+
refine ⟨M,hC,(fun z u hu v => hD z u v (Or.inl hu)),?_,
|
| 69 |
+
fun z i => (hE z i).trans (hm z hk),?_⟩
|
| 70 |
+
· rw [← reciprocal_actual x y]
|
| 71 |
+
intro z v hv u
|
| 72 |
+
unfold reciprocal; rw [evmat_transpose,evmat_transpose]
|
| 73 |
+
apply hD
|
| 74 |
+
right
|
| 75 |
+
rw [flipZ_flip]; exact hv
|
| 76 |
+
intro z i
|
| 77 |
+
unfold reciprocal; rw [transpose_transpose]
|
| 78 |
+
exact (hF (flipZ p z) i).trans (hm _ hk')
|
| 79 |
+
|
| 80 |
+
theorem channel_eval (p : Shape) {n} (M : Cross p n) (j : Bool) (z : Place p)
|
| 81 |
+
(x : Dir p n) (y : Vec (Chan p)) :
|
| 82 |
+
dotProduct y (channelOut p M j z *ᵥ x)=evmat (M z) x (IH p n j *ᵥ y) := by
|
| 83 |
+
unfold channelOut evmat
|
| 84 |
+
rw [dotProduct_transpose_mulVec, Matrix.mulVec_mulVec]
|
| 85 |
+
|
| 86 |
+
theorem channel_same {M T : Cross p n} (i z u)
|
| 87 |
+
(h : ∀ v : Vec (Chan p), evmat (M z) u (IH p n i *ᵥ v)=evmat (T z) u (IH p n i *ᵥ v)) :
|
| 88 |
+
channelOut p M i z *ᵥ u = channelOut p T i z *ᵥ u := by
|
| 89 |
+
classical
|
| 90 |
+
funext j
|
| 91 |
+
have he v : dotProduct v (channelOut p M i z *ᵥ u)=dotProduct v (channelOut p T i z*ᵥ u) := by
|
| 92 |
+
rw [channel_eval, channel_eval, h]
|
| 93 |
+
simpa using he (Pi.single j 1)
|
| 94 |
+
|
| 95 |
+
theorem fits_channel {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)
|
| 96 |
+
(z : Place p) (x : Dir p n) (hx : x∈tabSpace a z) (j : Bool) :
|
| 97 |
+
channelOut p M j z *ᵥ x = channelOut p T j z *ᵥ x := by
|
| 98 |
+
apply channel_same j
|
| 99 |
+
intro v
|
| 100 |
+
exact h z x hx _ (channel_le_table b _ j ⟨_,rfl⟩)
|
| 101 |
+
|
| 102 |
+
theorem fits_inj {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)
|
| 103 |
+
(ht : tableInj a b T) : tableInj a b M := by
|
| 104 |
+
intro z i j v hv hh
|
| 105 |
+
apply ht z i j v hv
|
| 106 |
+
rwa [fits_channel h z _ (pin_le_table a z hv) j] at hh
|
| 107 |
+
|
| 108 |
+
private theorem cout_ev (A B : Mat (Chan p) (JointIdx p n)) (x y) :
|
| 109 |
+
evmat (Aᵀ*B) x y=dotProduct (A *ᵥ x) (B *ᵥ y) := by
|
| 110 |
+
rw [evmat,← mulVec_mulVec,dotProduct_transpose_mulVec,dotProduct_comm]
|
| 111 |
+
|
| 112 |
+
theorem fits_contract {M T : Cross p n} {a b : Plan p n} (h : fitsTable a b M T)
|
| 113 |
+
(i j : Bool) (x : Profile p n) (hx : x ∈ effective a i) :
|
| 114 |
+
contract p M i j x=contract p T i j x := by
|
| 115 |
+
change ∑ e : Comp p.g, _ = _
|
| 116 |
+
refine Finset.sum_congr rfl fun e _ => ?_
|
| 117 |
+
apply (box_eval_iff (tabSpace a (e,true)) (tabSpace a (e,false)) _ _).mp ?_ _
|
| 118 |
+
· have hp := lift_mem_box (IP p n i) (IP p n i) ((effective_mem.mp hx).2 e)
|
| 119 |
+
exact box_le (le_trans le_sup_left (half_le_table a _ i))
|
| 120 |
+
(le_trans le_sup_left (half_le_table a _ i)) hp
|
| 121 |
+
intro x hx y hy; rw [cout_ev, cout_ev,fits_channel h _ _ hx,fits_channel h _ _ hy]
|
| 122 |
+
|
| 123 |
+
variable {I : Type} [Fintype I]
|
| 124 |
+
|
| 125 |
+
theorem frozen_contract_key {M T : Cross p n} {a} (v : Volley p n I) (t : Tagging p I)
|
| 126 |
+
(h : rowAgree (a⊔v.keyPlan t) M T) (i : I) (j : Bool) :
|
| 127 |
+
contract p M (v.obj i) j (v.atomAt t i)=contract p T (v.obj i) j (v.atomAt t i) := by
|
| 128 |
+
classical
|
| 129 |
+
change ∑ e : Comp p.g, _ = _
|
| 130 |
+
refine Finset.sum_congr rfl fun e _ => ?_
|
| 131 |
+
by_cases he : inc e (t i)
|
| 132 |
+
· have hx b :
|
| 133 |
+
v.rayLoc i ∈ (v.keyPlan t (e,b)) := colSp_mem (P:=v.keyM t e)
|
| 134 |
+
(⟨i,he⟩ : Volley.visits p t e)
|
| 135 |
+
have hE (b : Bool) : channelOut p M j (e,b) *ᵥ v.rayLoc i =
|
| 136 |
+
channelOut p T j (e,b) *ᵥ v.rayLoc i :=
|
| 137 |
+
channel_same j _ _ (fun y => h _ _ (Submodule.mem_sup_right (hx b)) _)
|
| 138 |
+
simp only [Volley.atomAt,atom_def,he, ite_true,mom,liftM_outer,mpair_outer]
|
| 139 |
+
rw [cout_ev,cout_ev]
|
| 140 |
+
exact congrArg₂ dotProduct (hE true) (hE false)
|
| 141 |
+
simp only [Volley.atomAt,atom_def,he,ite_false,map_zero]
|
| 142 |
+
|
| 143 |
+
end HadwigerCounterexample
|
| 144 |
+
|
| 145 |
+
end
|
| 146 |
+
|
| 147 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BasisConditioning.lean
CHANGED
|
@@ -1,113 +1,113 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.OrientationRankBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Basis Conditioning -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module LinearMap Finset Filter Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
-
|
| 13 |
-
theorem totalRank_pos {x : Profile p n} (h : x≠0) :
|
| 14 |
-
0<totalRank x := by
|
| 15 |
-
obtain ⟨i,hi⟩ := Function.ne_iff.mp h
|
| 16 |
-
apply lt_of_lt_of_le _ (Finset.single_le_sum (fun i _=>Nat.zero_le ((x i).rank))
|
| 17 |
-
(Finset.mem_univ i))
|
| 18 |
-
apply Nat.pos_of_ne_zero; intro h
|
| 19 |
-
obtain ⟨A,B,hh⟩ := mul_factor (x i) 0 h.le
|
| 20 |
-
apply hi; ext a b; rw [←hh,Matrix.mul_apply]; simp
|
| 21 |
-
|
| 22 |
-
def glintRate (K : ℕ) := bp (-((K^2:ℕ):ℝ)-3)
|
| 23 |
-
|
| 24 |
-
theorem glint_within {K d : ℕ} (h : d≤ K^2) :
|
| 25 |
-
glintRate K ≤ (1/8:ℝ)*bp (- (d:ℝ)) := by
|
| 26 |
-
unfold glintRate
|
| 27 |
-
have hh : bp (-3)=1/8 := by norm_num [bp]
|
| 28 |
-
rw [←hh,←bp_add]
|
| 29 |
-
exact bp_le (by linarith only [(show (d:ℝ) ≤ ((K^2:ℕ):ℝ) from by exact_mod_cast h)])
|
| 30 |
-
|
| 31 |
-
namespace Template
|
| 32 |
-
variable (v : Solo p)
|
| 33 |
-
|
| 34 |
-
def stains (m : Mixer p n) (f : Vec I →ₗ[F] Profile p n) (z : Knobs p.g n) : Vec I :=
|
| 35 |
-
fun i=> Tsym m (f (Pi.single i 1)) (useAtom p (v.t ()) (v.s ()) (v.f ()) z)
|
| 36 |
-
theorem staining (m : Mixer p n) (f : Vec I→ₗ[F] Profile p n) (z : Knobs p.g n) (i : Vec I) :
|
| 37 |
-
vectorPhase i (stains v m f z)=shanty v m (f i) z := by
|
| 38 |
-
classical
|
| 39 |
-
let h := LinearMap.flip (Tsym m) (useAtom p (v.t ()) (v.s ()) (v.f ()) z) ∘ₗ f
|
| 40 |
-
have ht : h i=h (∑ j: I,i j • (Pi.single j 1 : Vec I)) := by
|
| 41 |
-
have he (j:I) : i j • (Pi.single j 1 : Vec I)=Pi.single j (i j) := by
|
| 42 |
-
funext k; by_cases hh:k=j <;> simp [hh]
|
| 43 |
-
simp_rw [he]
|
| 44 |
-
rw [Finset.univ_sum_single]
|
| 45 |
-
change wsign (∑ j:I,i j*h (Pi.single j 1))=wsign (h i)
|
| 46 |
-
rw [ht,map_sum]; simp_rw [map_smul]; rfl
|
| 47 |
-
|
| 48 |
-
def luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n)) (D : AtomKey (p:=p) (v.t ())
|
| 49 |
-
N →Prop) (K : ℕ) (i : Orient p n N) :=
|
| 50 |
-
let P := offBeat v D i
|
| 51 |
-
0<pr w P ∧ ∀ (d : ℕ), d≤ K^2 → ∀ f : Vec (Fin d)→ₗ[F] Profile p n,
|
| 52 |
-
Injective f → (∀ x,totalRank (f x)≤K) → ∀ x,
|
| 53 |
-
(7/8:ℝ)*bp (-(d:ℝ)) ≤ pr (onW w P) (fun z=> stains v m f z=x)
|
| 54 |
-
|
| 55 |
-
set_option maxHeartbeats 800000 in
|
| 56 |
-
theorem glow_luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n))
|
| 57 |
-
(hw : IsLaw w)
|
| 58 |
-
(S : AtomKey (p:=p) (v.t ()) N → Prop)
|
| 59 |
-
(K : ℕ) (i : Orient p n N) (δ : ℝ) (hδ : 0<δ) (he : δ ≤ pr w (offBeat v S i))
|
| 60 |
-
(h : ∀ x, 0<totalRank x → totalRank x≤K → ¬ glow v m w S (glintRate K) δ x i) :
|
| 61 |
-
luminous v m w S K i := by
|
| 62 |
-
classical
|
| 63 |
-
let P := offBeat v S i
|
| 64 |
-
have hP : 0<pr w P := hδ.trans_le he
|
| 65 |
-
let u := onW w P; have hu : IsLaw u := on_law hw.nz hP
|
| 66 |
-
refine ⟨hP,fun d hd f hf hg x => ?_⟩
|
| 67 |
-
let s := stains v m f
|
| 68 |
-
have heq :
|
| 69 |
-
pr u (fun z => s z=x) = avg unif (fun i => vectorPhase i x*
|
| 70 |
-
avg u (fun z => vectorPhase i (s z))) := by
|
| 71 |
-
unfold pr
|
| 72 |
-
simp_rw [vector_expand]
|
| 73 |
-
rw [avg_avg]
|
| 74 |
-
apply avg_congr
|
| 75 |
-
intro i hi
|
| 76 |
-
rw [avg_mul]; ring
|
| 77 |
-
let b := bp (-(d:ℝ))
|
| 78 |
-
let Q (k : Vec (Fin d)) := vectorPhase k x * avg u (fun z => vectorPhase k (s z))
|
| 79 |
-
have hb : 0 < b := bp_pos _
|
| 80 |
-
have hh k : ind (k=0)-b/8 ≤ Q k := by
|
| 81 |
-
by_cases hk : k=0
|
| 82 |
-
· subst k
|
| 83 |
-
have hQ : Q 0=1 := by unfold Q; simp only [vectorPhase,zero_dotProduct,wsign_zero,one_mul,
|
| 84 |
-
hu.avg_const]
|
| 85 |
-
rw [ind_one (show (0:Vec (Fin d))=0 from rfl),hQ]; linarith
|
| 86 |
-
let k' := f k
|
| 87 |
-
have hT := h k' (totalRank_pos (hf.ne hk |>.trans_eq (map_zero f))) (hg k)
|
| 88 |
-
have hz : |zsumPeak p w (v.shanty m k') P| ≤ (glintRate K)*pr w P :=
|
| 89 |
-
le_of_lt (lt_of_not_ge (fun h => hT ⟨he,h⟩))
|
| 90 |
-
have ht :
|
| 91 |
-
avg u (fun z => vectorPhase k (s z))=
|
| 92 |
-
zsumPeak p w (v.shanty m k') P/pr w P := by
|
| 93 |
-
unfold s u onW; simp_rw [staining]; rw [avg_norm,subW_tot]
|
| 94 |
-
congr 1; simp [zsumPeak,avg,subW,mul_assoc,k']
|
| 95 |
-
have h1 : |Q k|≤b/8 := by
|
| 96 |
-
unfold Q; rw [ht,abs_mul,vectorPhase,wsign_abs,one_mul,abs_div,abs_of_pos hP]
|
| 97 |
-
refine le_trans ((div_le_iff₀ hP).mpr hz) ((glint_within hd).trans_eq (by unfold b; ring))
|
| 98 |
-
rw [ind_zero hk,zero_sub]; exact (abs_le.mp h1).1
|
| 99 |
-
have h0 : unif (0:Vec (Fin d))=b := by
|
| 100 |
-
unfold b; rw [unif_apply,card_space,dim_vec,bp_neg,Fintype.card_fin]
|
| 101 |
-
change _ ≤ pr u (fun z => s z=x)
|
| 102 |
-
rw [heq]
|
| 103 |
-
refine le_trans ?_ (avg_mono unif_law.nz hh)
|
| 104 |
-
rw [avg_sub,unif_law.avg_const,
|
| 105 |
-
show avg unif (fun i : Vec (Fin d)=> ind (i=0))=b from (pr_point' unif _).trans h0]
|
| 106 |
-
change 7/8*b≤_
|
| 107 |
-
linarith
|
| 108 |
-
end Template
|
| 109 |
-
end HadwigerCounterexample
|
| 110 |
-
|
| 111 |
-
end
|
| 112 |
-
|
| 113 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.OrientationRankBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Basis Conditioning -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module LinearMap Finset Filter Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
+
|
| 13 |
+
theorem totalRank_pos {x : Profile p n} (h : x≠0) :
|
| 14 |
+
0<totalRank x := by
|
| 15 |
+
obtain ⟨i,hi⟩ := Function.ne_iff.mp h
|
| 16 |
+
apply lt_of_lt_of_le _ (Finset.single_le_sum (fun i _=>Nat.zero_le ((x i).rank))
|
| 17 |
+
(Finset.mem_univ i))
|
| 18 |
+
apply Nat.pos_of_ne_zero; intro h
|
| 19 |
+
obtain ⟨A,B,hh⟩ := mul_factor (x i) 0 h.le
|
| 20 |
+
apply hi; ext a b; rw [←hh,Matrix.mul_apply]; simp
|
| 21 |
+
|
| 22 |
+
def glintRate (K : ℕ) := bp (-((K^2:ℕ):ℝ)-3)
|
| 23 |
+
|
| 24 |
+
theorem glint_within {K d : ℕ} (h : d≤ K^2) :
|
| 25 |
+
glintRate K ≤ (1/8:ℝ)*bp (- (d:ℝ)) := by
|
| 26 |
+
unfold glintRate
|
| 27 |
+
have hh : bp (-3)=1/8 := by norm_num [bp]
|
| 28 |
+
rw [←hh,←bp_add]
|
| 29 |
+
exact bp_le (by linarith only [(show (d:ℝ) ≤ ((K^2:ℕ):ℝ) from by exact_mod_cast h)])
|
| 30 |
+
|
| 31 |
+
namespace Template
|
| 32 |
+
variable (v : Solo p)
|
| 33 |
+
|
| 34 |
+
def stains (m : Mixer p n) (f : Vec I →ₗ[F] Profile p n) (z : Knobs p.g n) : Vec I :=
|
| 35 |
+
fun i=> Tsym m (f (Pi.single i 1)) (useAtom p (v.t ()) (v.s ()) (v.f ()) z)
|
| 36 |
+
theorem staining (m : Mixer p n) (f : Vec I→ₗ[F] Profile p n) (z : Knobs p.g n) (i : Vec I) :
|
| 37 |
+
vectorPhase i (stains v m f z)=shanty v m (f i) z := by
|
| 38 |
+
classical
|
| 39 |
+
let h := LinearMap.flip (Tsym m) (useAtom p (v.t ()) (v.s ()) (v.f ()) z) ∘ₗ f
|
| 40 |
+
have ht : h i=h (∑ j: I,i j • (Pi.single j 1 : Vec I)) := by
|
| 41 |
+
have he (j:I) : i j • (Pi.single j 1 : Vec I)=Pi.single j (i j) := by
|
| 42 |
+
funext k; by_cases hh:k=j <;> simp [hh]
|
| 43 |
+
simp_rw [he]
|
| 44 |
+
rw [Finset.univ_sum_single]
|
| 45 |
+
change wsign (∑ j:I,i j*h (Pi.single j 1))=wsign (h i)
|
| 46 |
+
rw [ht,map_sum]; simp_rw [map_smul]; rfl
|
| 47 |
+
|
| 48 |
+
def luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n)) (D : AtomKey (p:=p) (v.t ())
|
| 49 |
+
N →Prop) (K : ℕ) (i : Orient p n N) :=
|
| 50 |
+
let P := offBeat v D i
|
| 51 |
+
0<pr w P ∧ ∀ (d : ℕ), d≤ K^2 → ∀ f : Vec (Fin d)→ₗ[F] Profile p n,
|
| 52 |
+
Injective f → (∀ x,totalRank (f x)≤K) → ∀ x,
|
| 53 |
+
(7/8:ℝ)*bp (-(d:ℝ)) ≤ pr (onW w P) (fun z=> stains v m f z=x)
|
| 54 |
+
|
| 55 |
+
set_option maxHeartbeats 800000 in
|
| 56 |
+
theorem glow_luminous (v : Solo p) (m : Mixer p n) (w : Wgt (Knobs p.g n))
|
| 57 |
+
(hw : IsLaw w)
|
| 58 |
+
(S : AtomKey (p:=p) (v.t ()) N → Prop)
|
| 59 |
+
(K : ℕ) (i : Orient p n N) (δ : ℝ) (hδ : 0<δ) (he : δ ≤ pr w (offBeat v S i))
|
| 60 |
+
(h : ∀ x, 0<totalRank x → totalRank x≤K → ¬ glow v m w S (glintRate K) δ x i) :
|
| 61 |
+
luminous v m w S K i := by
|
| 62 |
+
classical
|
| 63 |
+
let P := offBeat v S i
|
| 64 |
+
have hP : 0<pr w P := hδ.trans_le he
|
| 65 |
+
let u := onW w P; have hu : IsLaw u := on_law hw.nz hP
|
| 66 |
+
refine ⟨hP,fun d hd f hf hg x => ?_⟩
|
| 67 |
+
let s := stains v m f
|
| 68 |
+
have heq :
|
| 69 |
+
pr u (fun z => s z=x) = avg unif (fun i => vectorPhase i x*
|
| 70 |
+
avg u (fun z => vectorPhase i (s z))) := by
|
| 71 |
+
unfold pr
|
| 72 |
+
simp_rw [vector_expand]
|
| 73 |
+
rw [avg_avg]
|
| 74 |
+
apply avg_congr
|
| 75 |
+
intro i hi
|
| 76 |
+
rw [avg_mul]; ring
|
| 77 |
+
let b := bp (-(d:ℝ))
|
| 78 |
+
let Q (k : Vec (Fin d)) := vectorPhase k x * avg u (fun z => vectorPhase k (s z))
|
| 79 |
+
have hb : 0 < b := bp_pos _
|
| 80 |
+
have hh k : ind (k=0)-b/8 ≤ Q k := by
|
| 81 |
+
by_cases hk : k=0
|
| 82 |
+
· subst k
|
| 83 |
+
have hQ : Q 0=1 := by unfold Q; simp only [vectorPhase,zero_dotProduct,wsign_zero,one_mul,
|
| 84 |
+
hu.avg_const]
|
| 85 |
+
rw [ind_one (show (0:Vec (Fin d))=0 from rfl),hQ]; linarith
|
| 86 |
+
let k' := f k
|
| 87 |
+
have hT := h k' (totalRank_pos (hf.ne hk |>.trans_eq (map_zero f))) (hg k)
|
| 88 |
+
have hz : |zsumPeak p w (v.shanty m k') P| ≤ (glintRate K)*pr w P :=
|
| 89 |
+
le_of_lt (lt_of_not_ge (fun h => hT ⟨he,h⟩))
|
| 90 |
+
have ht :
|
| 91 |
+
avg u (fun z => vectorPhase k (s z))=
|
| 92 |
+
zsumPeak p w (v.shanty m k') P/pr w P := by
|
| 93 |
+
unfold s u onW; simp_rw [staining]; rw [avg_norm,subW_tot]
|
| 94 |
+
congr 1; simp [zsumPeak,avg,subW,mul_assoc,k']
|
| 95 |
+
have h1 : |Q k|≤b/8 := by
|
| 96 |
+
unfold Q; rw [ht,abs_mul,vectorPhase,wsign_abs,one_mul,abs_div,abs_of_pos hP]
|
| 97 |
+
refine le_trans ((div_le_iff₀ hP).mpr hz) ((glint_within hd).trans_eq (by unfold b; ring))
|
| 98 |
+
rw [ind_zero hk,zero_sub]; exact (abs_le.mp h1).1
|
| 99 |
+
have h0 : unif (0:Vec (Fin d))=b := by
|
| 100 |
+
unfold b; rw [unif_apply,card_space,dim_vec,bp_neg,Fintype.card_fin]
|
| 101 |
+
change _ ≤ pr u (fun z => s z=x)
|
| 102 |
+
rw [heq]
|
| 103 |
+
refine le_trans ?_ (avg_mono unif_law.nz hh)
|
| 104 |
+
rw [avg_sub,unif_law.avg_const,
|
| 105 |
+
show avg unif (fun i : Vec (Fin d)=> ind (i=0))=b from (pr_point' unif _).trans h0]
|
| 106 |
+
change 7/8*b≤_
|
| 107 |
+
linarith
|
| 108 |
+
end Template
|
| 109 |
+
end HadwigerCounterexample
|
| 110 |
+
|
| 111 |
+
end
|
| 112 |
+
|
| 113 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BatchCharacters.lean
CHANGED
|
@@ -1,153 +1,153 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.CrossPatternCounting
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Batch Characters -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix Module LinearMap Function Finset
|
| 11 |
-
variable {I J A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]
|
| 12 |
-
variable [DecidableEq I] [DecidableEq J] [DecidableEq A] [DecidableEq B]
|
| 13 |
-
variable {n N t : ℕ}
|
| 14 |
-
|
| 15 |
-
def led (i : I) (x : Rack (I×J) N) := sectionR (fun j => (i,j)) x
|
| 16 |
-
def relay (I J : Type) [Fintype I] [Fintype J] (N) :
|
| 17 |
-
Rack (I×J) N ≃ (I → Rack J N) where
|
| 18 |
-
toFun x i := led i x
|
| 19 |
-
invFun x := (Matrix.of (fun i j => (x j.1).1 i j.2), Matrix.of (fun i j => (x j.1).2 i j.2))
|
| 20 |
-
left_inv x := by apply Prod.ext <;> rfl
|
| 21 |
-
right_inv x := funext fun _ => Prod.ext rfl rfl
|
| 22 |
-
|
| 23 |
-
theorem led_uniform (F : Wgt (I→Rack J N)) :
|
| 24 |
-
avg (unif : Wgt (Rack (I×J) N)) (fun x => F (fun i => led i x))=
|
| 25 |
-
avg (draws I unif) F := by
|
| 26 |
-
change avg unif (fun x => F (relay I J N x))=_
|
| 27 |
-
rw [← mapW_avg,unif_equiv,← draws_unif]
|
| 28 |
-
|
| 29 |
-
theorem led_piece (T : Finset I) (p : I→Rack J N→Prop) :
|
| 30 |
-
avg unif (fun x => ∏ i∈T,ind (p i (led i x))) =
|
| 31 |
-
∏ i∈T,pr unif (p i) := by
|
| 32 |
-
classical
|
| 33 |
-
let F (i : I) (z) := if i∈T then ind (p i z) else 1
|
| 34 |
-
let H : Wgt (I→ Rack J N) := prodW F
|
| 35 |
-
have he x : (∏ i∈T,ind (p i (led i x))) = H (fun i => led i x) := by
|
| 36 |
-
unfold H F prodW
|
| 37 |
-
rw [← Finset.prod_filter]; simp
|
| 38 |
-
have hf i : avg unif (F i) = if i∈T then pr unif (p i) else 1 := by
|
| 39 |
-
by_cases hh : i∈T <;> simp [F,pr,hh,unif_law.avg_const]
|
| 40 |
-
simp_rw [he]; rw [led_uniform]
|
| 41 |
-
unfold H draws
|
| 42 |
-
rw [prodW_avg]; simp_rw [hf]; rw [← Finset.prod_filter]; simp
|
| 43 |
-
|
| 44 |
-
def heard (T : A → I×J) := Finset.univ.image (Prod.fst ∘ T)
|
| 45 |
-
|
| 46 |
-
omit [Fintype I] [Fintype J] [DecidableEq A] in
|
| 47 |
-
theorem heard_fresh {T : A→I × J} {i : I} (B : PlusRack A N) (h : i∉heard T) (j : J) (k) :
|
| 48 |
-
upliftR T B k (i,j)=0 := by
|
| 49 |
-
classical
|
| 50 |
-
unfold upliftR
|
| 51 |
-
rw [Matrix.mul_apply]
|
| 52 |
-
refine Finset.sum_eq_zero fun x _ => ?_
|
| 53 |
-
have he : (i,j)≠T x := fun e => h (mem_image.mpr
|
| 54 |
-
⟨x,mem_univ _, (congrArg Prod.fst e).symm⟩)
|
| 55 |
-
simp [embedMat,he]
|
| 56 |
-
|
| 57 |
-
omit [Fintype I] [Fintype J] [DecidableEq A] in
|
| 58 |
-
private theorem led_off_r (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)
|
| 59 |
-
(h : i∉heard T) :
|
| 60 |
-
led i (x+(0,upliftR T B)) = led i x := by
|
| 61 |
-
apply Prod.ext
|
| 62 |
-
· ext; simp [led,sectionR]
|
| 63 |
-
ext
|
| 64 |
-
simp only [led,sectionR,Prod.snd_add,Matrix.add_apply,Matrix.submatrix_apply,
|
| 65 |
-
heard_fresh B h,add_zero]
|
| 66 |
-
|
| 67 |
-
omit [Fintype I] [Fintype J] [DecidableEq A] in
|
| 68 |
-
private theorem led_off_l (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)
|
| 69 |
-
(h : i∉heard T) :
|
| 70 |
-
led i (x+(upliftR T B,0)) = led i x := by
|
| 71 |
-
apply Prod.ext
|
| 72 |
-
· ext
|
| 73 |
-
simp only [led,sectionR,Prod.fst_add,Matrix.add_apply,Matrix.submatrix_apply,
|
| 74 |
-
heard_fresh B h,add_zero]
|
| 75 |
-
ext; simp [led,sectionR]
|
| 76 |
-
|
| 77 |
-
def phot (P : I→Rack J N→Prop) (x : Rack (I×J) N) :=
|
| 78 |
-
∏ i:I,ind (P i (led i x))
|
| 79 |
-
|
| 80 |
-
set_option maxHeartbeats 800000 in
|
| 81 |
-
theorem light_bound (M : Avenue I J) (P : I→Rack J N→Prop) (u : ℝ) (hu : 0 ≤ u)
|
| 82 |
-
(hp : ∀ i,bp (-u) ≤ pr unif (P i)) :
|
| 83 |
-
|avg unif (fun x => phasedBy M x*phot P x)| ≤
|
| 84 |
-
bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * ∏ i,pr unif (P i) := by
|
| 85 |
-
classical
|
| 86 |
-
obtain ⟨T,U,hTU,hA⟩ := real_peak M
|
| 87 |
-
let t := peak M
|
| 88 |
-
let L := heard T
|
| 89 |
-
let R := heard U
|
| 90 |
-
let D := L∪R
|
| 91 |
-
let S := Finset.univ \ D
|
| 92 |
-
have hd : Disjoint L R := by
|
| 93 |
-
refine Finset.disjoint_left.mpr ?_
|
| 94 |
-
intro x hx hy
|
| 95 |
-
obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hx
|
| 96 |
-
obtain ⟨j,_,he⟩ := Finset.mem_image.mp hy
|
| 97 |
-
exact hTU i j he.symm
|
| 98 |
-
let f (Z : Finset I) (x : Rack (I×J) N) := ∏ i∈Z,ind (P i (led i x))
|
| 99 |
-
have hs (V : Finset I) x : |f V x|=f V x := abs_of_nonneg (Finset.prod_nonneg (fun i _ =>
|
| 100 |
-
ind_nonneg _))
|
| 101 |
-
have heq (V : Finset I) x : |f V x|≤1 := (hs V x).trans_le
|
| 102 |
-
((Finset.prod_le_prod₀ (fun _ _ => ind_nonneg _) (fun _ _ => ind_le_one _)).trans_eq (by simp))
|
| 103 |
-
have h1 :
|
| 104 |
-
(∏ i,pr unif (P i))=(∏ i∈D,pr unif (P i))*(∏ i∈S,pr unif (P i)) := by
|
| 105 |
-
rw [←Finset.prod_union (show Disjoint D S from disjoint_sdiff),
|
| 106 |
-
Finset.union_sdiff_of_subset (Finset.subset_univ D)]
|
| 107 |
-
have hf x : phot P x=f L x*f R x*f S x := by
|
| 108 |
-
unfold phot f
|
| 109 |
-
rw [←Finset.prod_union hd,←Finset.prod_union (show Disjoint D S from disjoint_sdiff),
|
| 110 |
-
Finset.union_sdiff_of_subset (Finset.subset_univ D)]
|
| 111 |
-
have hl :
|
| 112 |
-
|avg unif (fun x => phasedBy M x*phot P x)| ≤ bp (-(N:ℝ)*t/2) * avg unif (fun x => |f S x|) := by
|
| 113 |
-
have he x : phasedBy M x*phot P x=phasedBy M x*f L x*f R x*f S x := by rw [hf]; ring
|
| 114 |
-
simp_rw [he]
|
| 115 |
-
rw [←show (M.submatrix T U).rank=t from
|
| 116 |
-
(mrk_inj.mp hA).trans (Fintype.card_fin _)]
|
| 117 |
-
|
| 118 |
-
refine layerLeak M (f L) (f R) (f S) T U (heq _) (heq _) (fun x y => ?_)
|
| 119 |
-
(fun x y => ?_) (fun x y z => ?_)
|
| 120 |
-
· refine Finset.prod_congr rfl fun i hi => ?_
|
| 121 |
-
rw [led_off_r x y (fun h => Finset.disjoint_left.mp hd hi h)]
|
| 122 |
-
· refine Finset.prod_congr rfl fun i hi => ?_
|
| 123 |
-
rw [led_off_l x y (fun h => Finset.disjoint_left.mp hd h hi)]
|
| 124 |
-
· refine Finset.prod_congr rfl fun i hi => ?_
|
| 125 |
-
have hr := (Finset.mem_sdiff.mp hi).2
|
| 126 |
-
rw [show x+(upliftR T y,upliftR U z)=x+(0,upliftR U z)+(upliftR T y,0) from
|
| 127 |
-
by rw [add_assoc]; apply congrArg; apply Prod.ext <;> simp,
|
| 128 |
-
led_off_l _ y (fun h => hr (mem_union_left _ h)),
|
| 129 |
-
led_off_r _ z (fun h => hr (mem_union_right _ h))]
|
| 130 |
-
apply hl.trans
|
| 131 |
-
simp_rw [hs]
|
| 132 |
-
rw [show avg unif (fun x => f S x)= _ from led_piece S P,h1,← mul_assoc]
|
| 133 |
-
refine mul_le_mul_of_nonneg_right ?_ (Finset.prod_nonneg fun _ _ => pr_nonneg unif_law.nz)
|
| 134 |
-
have hc : D.card ≤ 2*t := by
|
| 135 |
-
apply le_trans (Finset.card_union_le ..)
|
| 136 |
-
have hi (T : Fin t→ I × J) : (heard T).card≤t :=
|
| 137 |
-
Finset.card_image_le.trans_eq (by simp)
|
| 138 |
-
rw [two_mul]; exact add_le_add (hi T) (hi U)
|
| 139 |
-
have hQ : bp (-u*(2*(t:ℝ))) ≤ ∏ i∈D,pr unif (P i) := by
|
| 140 |
-
refine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => (bp_pos _).le) fun i _ => hp i)
|
| 141 |
-
rw [Finset.prod_const,←bp_mul_nat]
|
| 142 |
-
apply bp_le
|
| 143 |
-
apply mul_le_mul_of_nonpos_left
|
| 144 |
-
· exact_mod_cast hc
|
| 145 |
-
exact neg_nonpos.mpr hu
|
| 146 |
-
calc bp _
|
| 147 |
-
_ = bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * bp (-u*(2*t)) := by rw [←bp_add]; congr 1; unfold t; ring
|
| 148 |
-
_ ≤ _ := mul_le_mul_of_nonneg_left hQ (bp_pos _).le
|
| 149 |
-
end HadwigerCounterexample
|
| 150 |
-
|
| 151 |
-
end
|
| 152 |
-
|
| 153 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.CrossPatternCounting
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Batch Characters -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix Module LinearMap Function Finset
|
| 11 |
+
variable {I J A B : Type} [Fintype I] [Fintype J] [Fintype A] [Fintype B]
|
| 12 |
+
variable [DecidableEq I] [DecidableEq J] [DecidableEq A] [DecidableEq B]
|
| 13 |
+
variable {n N t : ℕ}
|
| 14 |
+
|
| 15 |
+
def led (i : I) (x : Rack (I×J) N) := sectionR (fun j => (i,j)) x
|
| 16 |
+
def relay (I J : Type) [Fintype I] [Fintype J] (N) :
|
| 17 |
+
Rack (I×J) N ≃ (I → Rack J N) where
|
| 18 |
+
toFun x i := led i x
|
| 19 |
+
invFun x := (Matrix.of (fun i j => (x j.1).1 i j.2), Matrix.of (fun i j => (x j.1).2 i j.2))
|
| 20 |
+
left_inv x := by apply Prod.ext <;> rfl
|
| 21 |
+
right_inv x := funext fun _ => Prod.ext rfl rfl
|
| 22 |
+
|
| 23 |
+
theorem led_uniform (F : Wgt (I→Rack J N)) :
|
| 24 |
+
avg (unif : Wgt (Rack (I×J) N)) (fun x => F (fun i => led i x))=
|
| 25 |
+
avg (draws I unif) F := by
|
| 26 |
+
change avg unif (fun x => F (relay I J N x))=_
|
| 27 |
+
rw [← mapW_avg,unif_equiv,← draws_unif]
|
| 28 |
+
|
| 29 |
+
theorem led_piece (T : Finset I) (p : I→Rack J N→Prop) :
|
| 30 |
+
avg unif (fun x => ∏ i∈T,ind (p i (led i x))) =
|
| 31 |
+
∏ i∈T,pr unif (p i) := by
|
| 32 |
+
classical
|
| 33 |
+
let F (i : I) (z) := if i∈T then ind (p i z) else 1
|
| 34 |
+
let H : Wgt (I→ Rack J N) := prodW F
|
| 35 |
+
have he x : (∏ i∈T,ind (p i (led i x))) = H (fun i => led i x) := by
|
| 36 |
+
unfold H F prodW
|
| 37 |
+
rw [← Finset.prod_filter]; simp
|
| 38 |
+
have hf i : avg unif (F i) = if i∈T then pr unif (p i) else 1 := by
|
| 39 |
+
by_cases hh : i∈T <;> simp [F,pr,hh,unif_law.avg_const]
|
| 40 |
+
simp_rw [he]; rw [led_uniform]
|
| 41 |
+
unfold H draws
|
| 42 |
+
rw [prodW_avg]; simp_rw [hf]; rw [← Finset.prod_filter]; simp
|
| 43 |
+
|
| 44 |
+
def heard (T : A → I×J) := Finset.univ.image (Prod.fst ∘ T)
|
| 45 |
+
|
| 46 |
+
omit [Fintype I] [Fintype J] [DecidableEq A] in
|
| 47 |
+
theorem heard_fresh {T : A→I × J} {i : I} (B : PlusRack A N) (h : i∉heard T) (j : J) (k) :
|
| 48 |
+
upliftR T B k (i,j)=0 := by
|
| 49 |
+
classical
|
| 50 |
+
unfold upliftR
|
| 51 |
+
rw [Matrix.mul_apply]
|
| 52 |
+
refine Finset.sum_eq_zero fun x _ => ?_
|
| 53 |
+
have he : (i,j)≠T x := fun e => h (mem_image.mpr
|
| 54 |
+
⟨x,mem_univ _, (congrArg Prod.fst e).symm⟩)
|
| 55 |
+
simp [embedMat,he]
|
| 56 |
+
|
| 57 |
+
omit [Fintype I] [Fintype J] [DecidableEq A] in
|
| 58 |
+
private theorem led_off_r (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)
|
| 59 |
+
(h : i∉heard T) :
|
| 60 |
+
led i (x+(0,upliftR T B)) = led i x := by
|
| 61 |
+
apply Prod.ext
|
| 62 |
+
· ext; simp [led,sectionR]
|
| 63 |
+
ext
|
| 64 |
+
simp only [led,sectionR,Prod.snd_add,Matrix.add_apply,Matrix.submatrix_apply,
|
| 65 |
+
heard_fresh B h,add_zero]
|
| 66 |
+
|
| 67 |
+
omit [Fintype I] [Fintype J] [DecidableEq A] in
|
| 68 |
+
private theorem led_off_l (x : Rack (I×J) N) {T : A→I×J} {i : I} (B : PlusRack A N)
|
| 69 |
+
(h : i∉heard T) :
|
| 70 |
+
led i (x+(upliftR T B,0)) = led i x := by
|
| 71 |
+
apply Prod.ext
|
| 72 |
+
· ext
|
| 73 |
+
simp only [led,sectionR,Prod.fst_add,Matrix.add_apply,Matrix.submatrix_apply,
|
| 74 |
+
heard_fresh B h,add_zero]
|
| 75 |
+
ext; simp [led,sectionR]
|
| 76 |
+
|
| 77 |
+
def phot (P : I→Rack J N→Prop) (x : Rack (I×J) N) :=
|
| 78 |
+
∏ i:I,ind (P i (led i x))
|
| 79 |
+
|
| 80 |
+
set_option maxHeartbeats 800000 in
|
| 81 |
+
theorem light_bound (M : Avenue I J) (P : I→Rack J N→Prop) (u : ℝ) (hu : 0 ≤ u)
|
| 82 |
+
(hp : ∀ i,bp (-u) ≤ pr unif (P i)) :
|
| 83 |
+
|avg unif (fun x => phasedBy M x*phot P x)| ≤
|
| 84 |
+
bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * ∏ i,pr unif (P i) := by
|
| 85 |
+
classical
|
| 86 |
+
obtain ⟨T,U,hTU,hA⟩ := real_peak M
|
| 87 |
+
let t := peak M
|
| 88 |
+
let L := heard T
|
| 89 |
+
let R := heard U
|
| 90 |
+
let D := L∪R
|
| 91 |
+
let S := Finset.univ \ D
|
| 92 |
+
have hd : Disjoint L R := by
|
| 93 |
+
refine Finset.disjoint_left.mpr ?_
|
| 94 |
+
intro x hx hy
|
| 95 |
+
obtain ⟨i,_,rfl⟩ := Finset.mem_image.mp hx
|
| 96 |
+
obtain ⟨j,_,he⟩ := Finset.mem_image.mp hy
|
| 97 |
+
exact hTU i j he.symm
|
| 98 |
+
let f (Z : Finset I) (x : Rack (I×J) N) := ∏ i∈Z,ind (P i (led i x))
|
| 99 |
+
have hs (V : Finset I) x : |f V x|=f V x := abs_of_nonneg (Finset.prod_nonneg (fun i _ =>
|
| 100 |
+
ind_nonneg _))
|
| 101 |
+
have heq (V : Finset I) x : |f V x|≤1 := (hs V x).trans_le
|
| 102 |
+
((Finset.prod_le_prod₀ (fun _ _ => ind_nonneg _) (fun _ _ => ind_le_one _)).trans_eq (by simp))
|
| 103 |
+
have h1 :
|
| 104 |
+
(∏ i,pr unif (P i))=(∏ i∈D,pr unif (P i))*(∏ i∈S,pr unif (P i)) := by
|
| 105 |
+
rw [←Finset.prod_union (show Disjoint D S from disjoint_sdiff),
|
| 106 |
+
Finset.union_sdiff_of_subset (Finset.subset_univ D)]
|
| 107 |
+
have hf x : phot P x=f L x*f R x*f S x := by
|
| 108 |
+
unfold phot f
|
| 109 |
+
rw [←Finset.prod_union hd,←Finset.prod_union (show Disjoint D S from disjoint_sdiff),
|
| 110 |
+
Finset.union_sdiff_of_subset (Finset.subset_univ D)]
|
| 111 |
+
have hl :
|
| 112 |
+
|avg unif (fun x => phasedBy M x*phot P x)| ≤ bp (-(N:ℝ)*t/2) * avg unif (fun x => |f S x|) := by
|
| 113 |
+
have he x : phasedBy M x*phot P x=phasedBy M x*f L x*f R x*f S x := by rw [hf]; ring
|
| 114 |
+
simp_rw [he]
|
| 115 |
+
rw [←show (M.submatrix T U).rank=t from
|
| 116 |
+
(mrk_inj.mp hA).trans (Fintype.card_fin _)]
|
| 117 |
+
|
| 118 |
+
refine layerLeak M (f L) (f R) (f S) T U (heq _) (heq _) (fun x y => ?_)
|
| 119 |
+
(fun x y => ?_) (fun x y z => ?_)
|
| 120 |
+
· refine Finset.prod_congr rfl fun i hi => ?_
|
| 121 |
+
rw [led_off_r x y (fun h => Finset.disjoint_left.mp hd hi h)]
|
| 122 |
+
· refine Finset.prod_congr rfl fun i hi => ?_
|
| 123 |
+
rw [led_off_l x y (fun h => Finset.disjoint_left.mp hd h hi)]
|
| 124 |
+
· refine Finset.prod_congr rfl fun i hi => ?_
|
| 125 |
+
have hr := (Finset.mem_sdiff.mp hi).2
|
| 126 |
+
rw [show x+(upliftR T y,upliftR U z)=x+(0,upliftR U z)+(upliftR T y,0) from
|
| 127 |
+
by rw [add_assoc]; apply congrArg; apply Prod.ext <;> simp,
|
| 128 |
+
led_off_l _ y (fun h => hr (mem_union_left _ h)),
|
| 129 |
+
led_off_r _ z (fun h => hr (mem_union_right _ h))]
|
| 130 |
+
apply hl.trans
|
| 131 |
+
simp_rw [hs]
|
| 132 |
+
rw [show avg unif (fun x => f S x)= _ from led_piece S P,h1,← mul_assoc]
|
| 133 |
+
refine mul_le_mul_of_nonneg_right ?_ (Finset.prod_nonneg fun _ _ => pr_nonneg unif_law.nz)
|
| 134 |
+
have hc : D.card ≤ 2*t := by
|
| 135 |
+
apply le_trans (Finset.card_union_le ..)
|
| 136 |
+
have hi (T : Fin t→ I × J) : (heard T).card≤t :=
|
| 137 |
+
Finset.card_image_le.trans_eq (by simp)
|
| 138 |
+
rw [two_mul]; exact add_le_add (hi T) (hi U)
|
| 139 |
+
have hQ : bp (-u*(2*(t:ℝ))) ≤ ∏ i∈D,pr unif (P i) := by
|
| 140 |
+
refine le_trans ?_ (Finset.prod_le_prod₀ (fun i _ => (bp_pos _).le) fun i _ => hp i)
|
| 141 |
+
rw [Finset.prod_const,←bp_mul_nat]
|
| 142 |
+
apply bp_le
|
| 143 |
+
apply mul_le_mul_of_nonpos_left
|
| 144 |
+
· exact_mod_cast hc
|
| 145 |
+
exact neg_nonpos.mpr hu
|
| 146 |
+
calc bp _
|
| 147 |
+
_ = bp ((-(N:ℝ)/2+2*u)*(peak M:ℝ)) * bp (-u*(2*t)) := by rw [←bp_add]; congr 1; unfold t; ring
|
| 148 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left hQ (bp_pos _).le
|
| 149 |
+
end HadwigerCounterexample
|
| 150 |
+
|
| 151 |
+
end
|
| 152 |
+
|
| 153 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BiasedRotationBounds.lean
CHANGED
|
@@ -1,142 +1,142 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.OrthogonalSpectrumBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Biased Rotation Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Module Submodule Function LinearMap Filter Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ}
|
| 12 |
-
|
| 13 |
-
set_option maxHeartbeats 1200000 in
|
| 14 |
-
theorem spinning (p : Shape) (w : Wgt (Knobs p.g n))
|
| 15 |
-
(f : Flit n→Wgt (Knobs p.g n)) (P : Knobs p.g n→Prop)
|
| 16 |
-
(hw : IsLaw w) (hf : ∀ i j,|f i j|≤1) (h : flowZ p w)
|
| 17 |
-
(b g δ : ℝ) (hb : 0≤b)
|
| 18 |
-
(T : Space (Vec (Fin n))) (s l : ℕ) (hk : s<n)
|
| 19 |
-
(hh : ∀ (c : Flit n) x i, |zchar p (f c) i x|≤b ∧
|
| 20 |
-
(i∉ c.plume T → zchar p (f c) i x=0))
|
| 21 |
-
(hδ : 0<δ) (ht : b*bp s < g) (hP : δ≤ pr w P)
|
| 22 |
-
(hL : 1 < l * ((g-b*bp s)*δ)^2) :
|
| 23 |
-
pr unif (fun c => g*pr w P ≤ |zsumPeak p w (f c) P|) ≤
|
| 24 |
-
bp (1+((dim T:ℝ)+l*(dim T:ℝ)-n)*s) := by
|
| 25 |
-
classical
|
| 26 |
-
let M := g-b*bp s; have hM : 0<M := sub_pos.mpr ht
|
| 27 |
-
let D c := g*pr w P ≤ |zsumPeak p w (f c) P|
|
| 28 |
-
by_contra! H
|
| 29 |
-
have progress (i : ℕ) (h' : i≤l) :
|
| 30 |
-
∃ (S : Space (Vec (Fin n))) (U : Wgt (Knobs p.g n)),
|
| 31 |
-
zsafe p w U S ∧ dim S≤ i*dim T ∧ i*(M*δ) ≤ zsumPeak p w U P ∧
|
| 32 |
-
avg w (fun x=>U x ^ 2) ≤ i := by
|
| 33 |
-
induction i with
|
| 34 |
-
| zero =>
|
| 35 |
-
refine ⟨⊥,fun _=>0,?_,?_,?_,?_⟩
|
| 36 |
-
· intro i t h; simp only [zero_mul,avg_zero]
|
| 37 |
-
· simp [dim]
|
| 38 |
-
· simp [zsumPeak,avg_zero]
|
| 39 |
-
simp only [zero_pow (by decide : 2 ≠ 0),avg_zero,Nat.cast_zero,le_refl]
|
| 40 |
-
| succ i ih =>
|
| 41 |
-
obtain ⟨S,U,hS,hU,h1,h2⟩ := ih (by omega)
|
| 42 |
-
let Q (c : Flit n) := s < dim (c.plume T ⊓ S : Space (Vec (Fin n)))
|
| 43 |
-
have hh' : ∃ c : Flit n, D c ∧ ¬ Q c := by
|
| 44 |
-
by_contra! hh
|
| 45 |
-
have hz := (pr_mono unif_law.nz (fun c (h : D c) =>
|
| 46 |
-
(hh c h).le)).trans (Move.plume_meets n s hk T S)
|
| 47 |
-
have hy : (dim S:ℝ)≤ l*(dim T:ℝ) := by
|
| 48 |
-
exact_mod_cast (hU.trans (Nat.mul_le_mul_right _ (by omega) : i*dim T ≤ l*dim T))
|
| 49 |
-
apply (not_lt_of_ge (le_trans hz (bp_le ?_))) H
|
| 50 |
-
nlinarith only [mul_le_mul_of_nonneg_right hy (Nat.cast_nonneg s : 0≤(s:ℝ))]
|
| 51 |
-
obtain ⟨c,he,hc⟩ := hh'
|
| 52 |
-
let W := c.plume T
|
| 53 |
-
have hk : dim (S ⊓ W : Space (Vec (Fin n))) ≤ s := by
|
| 54 |
-
have hh : dim (W⊓S : Space (Vec (Fin n))) ≤ s := le_of_not_gt hc
|
| 55 |
-
rw [inf_comm]; exact hh
|
| 56 |
-
obtain ⟨t,a,ha,hA,hy,hz⟩ := clear_band p w (f c) P hw (hf c) h b g hb he S W s hk (hh c)
|
| 57 |
-
let Z i := a*zim p (f c) t i
|
| 58 |
-
let C i := U i+Z i
|
| 59 |
-
have hQ : avg w (fun i=>U i * Z i)=0 := by
|
| 60 |
-
have he := hS (f c) t (fun i hi => (hA i hi).1)
|
| 61 |
-
unfold Z; simp_rw [mul_left_comm _ a,avg_mul',he,mul_zero]
|
| 62 |
-
refine ⟨S ⊔ W,C,?_,?_,?_,?_⟩
|
| 63 |
-
· intro i s hh
|
| 64 |
-
have hL := zsplit_orth p (f c) i w h t s (Finset.disjoint_left.mpr (fun j hj he =>
|
| 65 |
-
hh j he ((show W≤S⊔W from le_sup_right) (hA j hj).2)))
|
| 66 |
-
have he := hS i s (fun j hj h => hh j hj ((show S≤S⊔W from le_sup_left) h))
|
| 67 |
-
unfold C Z; simp only [add_mul,mul_assoc,avg_add,avg_mul',he,hL,mul_zero,add_zero]
|
| 68 |
-
· have h := Submodule.finrank_add_le_finrank_add_finrank S W
|
| 69 |
-
refine le_trans h ?_
|
| 70 |
-
change dim S+dim W≤_
|
| 71 |
-
unfold W; rw [Move.plume_dim c T,Nat.add_mul,one_mul]
|
| 72 |
-
omega
|
| 73 |
-
· unfold zsumPeak C; simp_rw [mul_add,avg_add]
|
| 74 |
-
change _≤zsumPeak p w U P+zsumPeak p w Z P
|
| 75 |
-
change M*pr w P ≤ zsumPeak p w Z P at hy
|
| 76 |
-
push_cast
|
| 77 |
-
nlinarith only [h1,hy,mul_le_mul_of_nonneg_left hP hM.le]
|
| 78 |
-
· have hh (i) : C i^2=U i^2+Z i^2+2*(U i*Z i) := by unfold C; ring
|
| 79 |
-
simp_rw [hh,avg_add,avg_mul',hQ,mul_zero,add_zero]
|
| 80 |
-
exact (add_le_add h2 hz).trans_eq (by push_cast; rfl)
|
| 81 |
-
obtain ⟨S,U,_,_,hu,hq⟩ := progress l (le_refl _)
|
| 82 |
-
have hh : ↑l * (M*δ) ≤ zsumPeak p w U P := hu
|
| 83 |
-
have hx :
|
| 84 |
-
zsumPeak p w U P ^2 ≤ l := by
|
| 85 |
-
apply (avg_CS hw.nz (fun i=>ind (P i)) U).trans
|
| 86 |
-
have hz (i : Knobs p.g n) : ind (P i)^2 ≤ 1 :=
|
| 87 |
-
calc ind (P i)^2 ≤ 1^2 := pow_le_pow_left₀ (ind_nonneg _) (ind_le_one _) _
|
| 88 |
-
_ = _ := one_pow _
|
| 89 |
-
exact (mul_le_mul (hw.avg_le hz) hq (avg_nonneg hw.nz (fun _ => sq_nonneg _))
|
| 90 |
-
zero_le_one).trans_eq (one_mul _)
|
| 91 |
-
have hy := pow_le_pow_left₀ (by positivity) hh 2
|
| 92 |
-
change 1<↑l*(M*δ)^2 at hL
|
| 93 |
-
have hl : 0<l := by
|
| 94 |
-
by_contra! he
|
| 95 |
-
obtain rfl : l=0 := by omega
|
| 96 |
-
norm_num at hL
|
| 97 |
-
nlinarith only [hx,hy,mul_lt_mul_of_pos_left hL
|
| 98 |
-
(Nat.cast_pos.mpr hl : (0:ℝ) < l)]
|
| 99 |
-
|
| 100 |
-
namespace Template
|
| 101 |
-
variable {K s A : ℕ}
|
| 102 |
-
theorem rotor_levels (v : Solo p) (K s a : ℕ)
|
| 103 |
-
(hs : 2*a<s) (hg : Odd p.g)
|
| 104 |
-
(δ g : ℝ) (hδ : 0<δ)
|
| 105 |
-
(hG : bp (-((p.J-s:ℕ):ℝ))*bp s < g) :
|
| 106 |
-
∀ᶠ n : ℕ in atTop, ∀ m : Mixer p n, unaryGood m K s →
|
| 107 |
-
∀ x : Profile p n, 0<totalRank x → totalRank x ≤ K →
|
| 108 |
-
∀ w : Wgt (Knobs p.g n), IsLaw w → flowZ p w →
|
| 109 |
-
∀ P : Knobs p.g n → Prop, δ ≤ pr w P →
|
| 110 |
-
pr unif (fun c => g*pr w P ≤|zsumPeak p w (v.rotor c m x) P|) ≤ bp (-(2*a:ℝ)*n) := by
|
| 111 |
-
classical
|
| 112 |
-
let b := bp (-((p.J-s:ℕ):ℝ))
|
| 113 |
-
have hb : b*bp s<g := hG
|
| 114 |
-
let t := ((g-b*bp s)*δ)^2
|
| 115 |
-
have ht : 0<t := by apply pow_pos (mul_pos (sub_pos.mpr hb) hδ)
|
| 116 |
-
obtain ⟨l,hl⟩ := exists_nat_gt (1/t)
|
| 117 |
-
let d := 2*(p.J*(p.g-1)*(2*K))
|
| 118 |
-
have ha : 0<(s:ℝ)-2*a := sub_pos.mpr (by exact_mod_cast hs)
|
| 119 |
-
have hz : Tendsto (fun n:ℕ => (↑s-2*a:ℝ)*n) atTop atTop :=
|
| 120 |
-
(tendsto_const_mul_atTop_of_pos ha).mpr tendsto_natCast_atTop_atTop
|
| 121 |
-
filter_upwards [eventually_gt_atTop s,hz.eventually (eventually_ge_atTop
|
| 122 |
-
(1+((d:ℝ)+l*d)*s))] with n hn hN m hm x hx hK w hw hh P hP
|
| 123 |
-
have he := spinning p w (fun c=>v.rotor c m x) P hw (by
|
| 124 |
-
intro i j; unfold rotor Move.zreroute shanty; rw [wsign_abs]) hh b g δ
|
| 125 |
-
(bp_pos _).le _ s l hn (fun c y i => v.rotor_budget c m x K s hg hm hK hx y i)
|
| 126 |
-
hδ hb hP ((div_lt_iff₀ ht).mp hl)
|
| 127 |
-
apply he.trans
|
| 128 |
-
apply bp_le
|
| 129 |
-
have hy :
|
| 130 |
-
dim (v.scroll m x) ≤ d :=
|
| 131 |
-
(scroll_dim v m x).trans (by unfold d; gcongr)
|
| 132 |
-
have hx : ((dim (v.scroll m x)):ℝ) ≤ d := by exact_mod_cast hy
|
| 133 |
-
change 1+((d:ℝ)+l*d)*s≤ ((s:ℝ)-2*a)*n at hN
|
| 134 |
-
have hB := mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg l : 0≤(l:ℝ))
|
| 135 |
-
nlinarith only [mul_le_mul_of_nonneg_right (add_le_add hx hB)
|
| 136 |
-
(Nat.cast_nonneg s : 0≤(s:ℝ)),hN]
|
| 137 |
-
end Template
|
| 138 |
-
end HadwigerCounterexample
|
| 139 |
-
|
| 140 |
-
end
|
| 141 |
-
|
| 142 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.OrthogonalSpectrumBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Biased Rotation Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Module Submodule Function LinearMap Filter Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ}
|
| 12 |
+
|
| 13 |
+
set_option maxHeartbeats 1200000 in
|
| 14 |
+
theorem spinning (p : Shape) (w : Wgt (Knobs p.g n))
|
| 15 |
+
(f : Flit n→Wgt (Knobs p.g n)) (P : Knobs p.g n→Prop)
|
| 16 |
+
(hw : IsLaw w) (hf : ∀ i j,|f i j|≤1) (h : flowZ p w)
|
| 17 |
+
(b g δ : ℝ) (hb : 0≤b)
|
| 18 |
+
(T : Space (Vec (Fin n))) (s l : ℕ) (hk : s<n)
|
| 19 |
+
(hh : ∀ (c : Flit n) x i, |zchar p (f c) i x|≤b ∧
|
| 20 |
+
(i∉ c.plume T → zchar p (f c) i x=0))
|
| 21 |
+
(hδ : 0<δ) (ht : b*bp s < g) (hP : δ≤ pr w P)
|
| 22 |
+
(hL : 1 < l * ((g-b*bp s)*δ)^2) :
|
| 23 |
+
pr unif (fun c => g*pr w P ≤ |zsumPeak p w (f c) P|) ≤
|
| 24 |
+
bp (1+((dim T:ℝ)+l*(dim T:ℝ)-n)*s) := by
|
| 25 |
+
classical
|
| 26 |
+
let M := g-b*bp s; have hM : 0<M := sub_pos.mpr ht
|
| 27 |
+
let D c := g*pr w P ≤ |zsumPeak p w (f c) P|
|
| 28 |
+
by_contra! H
|
| 29 |
+
have progress (i : ℕ) (h' : i≤l) :
|
| 30 |
+
∃ (S : Space (Vec (Fin n))) (U : Wgt (Knobs p.g n)),
|
| 31 |
+
zsafe p w U S ∧ dim S≤ i*dim T ∧ i*(M*δ) ≤ zsumPeak p w U P ∧
|
| 32 |
+
avg w (fun x=>U x ^ 2) ≤ i := by
|
| 33 |
+
induction i with
|
| 34 |
+
| zero =>
|
| 35 |
+
refine ⟨⊥,fun _=>0,?_,?_,?_,?_⟩
|
| 36 |
+
· intro i t h; simp only [zero_mul,avg_zero]
|
| 37 |
+
· simp [dim]
|
| 38 |
+
· simp [zsumPeak,avg_zero]
|
| 39 |
+
simp only [zero_pow (by decide : 2 ≠ 0),avg_zero,Nat.cast_zero,le_refl]
|
| 40 |
+
| succ i ih =>
|
| 41 |
+
obtain ⟨S,U,hS,hU,h1,h2⟩ := ih (by omega)
|
| 42 |
+
let Q (c : Flit n) := s < dim (c.plume T ⊓ S : Space (Vec (Fin n)))
|
| 43 |
+
have hh' : ∃ c : Flit n, D c ∧ ¬ Q c := by
|
| 44 |
+
by_contra! hh
|
| 45 |
+
have hz := (pr_mono unif_law.nz (fun c (h : D c) =>
|
| 46 |
+
(hh c h).le)).trans (Move.plume_meets n s hk T S)
|
| 47 |
+
have hy : (dim S:ℝ)≤ l*(dim T:ℝ) := by
|
| 48 |
+
exact_mod_cast (hU.trans (Nat.mul_le_mul_right _ (by omega) : i*dim T ≤ l*dim T))
|
| 49 |
+
apply (not_lt_of_ge (le_trans hz (bp_le ?_))) H
|
| 50 |
+
nlinarith only [mul_le_mul_of_nonneg_right hy (Nat.cast_nonneg s : 0≤(s:ℝ))]
|
| 51 |
+
obtain ⟨c,he,hc⟩ := hh'
|
| 52 |
+
let W := c.plume T
|
| 53 |
+
have hk : dim (S ⊓ W : Space (Vec (Fin n))) ≤ s := by
|
| 54 |
+
have hh : dim (W⊓S : Space (Vec (Fin n))) ≤ s := le_of_not_gt hc
|
| 55 |
+
rw [inf_comm]; exact hh
|
| 56 |
+
obtain ⟨t,a,ha,hA,hy,hz⟩ := clear_band p w (f c) P hw (hf c) h b g hb he S W s hk (hh c)
|
| 57 |
+
let Z i := a*zim p (f c) t i
|
| 58 |
+
let C i := U i+Z i
|
| 59 |
+
have hQ : avg w (fun i=>U i * Z i)=0 := by
|
| 60 |
+
have he := hS (f c) t (fun i hi => (hA i hi).1)
|
| 61 |
+
unfold Z; simp_rw [mul_left_comm _ a,avg_mul',he,mul_zero]
|
| 62 |
+
refine ⟨S ⊔ W,C,?_,?_,?_,?_⟩
|
| 63 |
+
· intro i s hh
|
| 64 |
+
have hL := zsplit_orth p (f c) i w h t s (Finset.disjoint_left.mpr (fun j hj he =>
|
| 65 |
+
hh j he ((show W≤S⊔W from le_sup_right) (hA j hj).2)))
|
| 66 |
+
have he := hS i s (fun j hj h => hh j hj ((show S≤S⊔W from le_sup_left) h))
|
| 67 |
+
unfold C Z; simp only [add_mul,mul_assoc,avg_add,avg_mul',he,hL,mul_zero,add_zero]
|
| 68 |
+
· have h := Submodule.finrank_add_le_finrank_add_finrank S W
|
| 69 |
+
refine le_trans h ?_
|
| 70 |
+
change dim S+dim W≤_
|
| 71 |
+
unfold W; rw [Move.plume_dim c T,Nat.add_mul,one_mul]
|
| 72 |
+
omega
|
| 73 |
+
· unfold zsumPeak C; simp_rw [mul_add,avg_add]
|
| 74 |
+
change _≤zsumPeak p w U P+zsumPeak p w Z P
|
| 75 |
+
change M*pr w P ≤ zsumPeak p w Z P at hy
|
| 76 |
+
push_cast
|
| 77 |
+
nlinarith only [h1,hy,mul_le_mul_of_nonneg_left hP hM.le]
|
| 78 |
+
· have hh (i) : C i^2=U i^2+Z i^2+2*(U i*Z i) := by unfold C; ring
|
| 79 |
+
simp_rw [hh,avg_add,avg_mul',hQ,mul_zero,add_zero]
|
| 80 |
+
exact (add_le_add h2 hz).trans_eq (by push_cast; rfl)
|
| 81 |
+
obtain ⟨S,U,_,_,hu,hq⟩ := progress l (le_refl _)
|
| 82 |
+
have hh : ↑l * (M*δ) ≤ zsumPeak p w U P := hu
|
| 83 |
+
have hx :
|
| 84 |
+
zsumPeak p w U P ^2 ≤ l := by
|
| 85 |
+
apply (avg_CS hw.nz (fun i=>ind (P i)) U).trans
|
| 86 |
+
have hz (i : Knobs p.g n) : ind (P i)^2 ≤ 1 :=
|
| 87 |
+
calc ind (P i)^2 ≤ 1^2 := pow_le_pow_left₀ (ind_nonneg _) (ind_le_one _) _
|
| 88 |
+
_ = _ := one_pow _
|
| 89 |
+
exact (mul_le_mul (hw.avg_le hz) hq (avg_nonneg hw.nz (fun _ => sq_nonneg _))
|
| 90 |
+
zero_le_one).trans_eq (one_mul _)
|
| 91 |
+
have hy := pow_le_pow_left₀ (by positivity) hh 2
|
| 92 |
+
change 1<↑l*(M*δ)^2 at hL
|
| 93 |
+
have hl : 0<l := by
|
| 94 |
+
by_contra! he
|
| 95 |
+
obtain rfl : l=0 := by omega
|
| 96 |
+
norm_num at hL
|
| 97 |
+
nlinarith only [hx,hy,mul_lt_mul_of_pos_left hL
|
| 98 |
+
(Nat.cast_pos.mpr hl : (0:ℝ) < l)]
|
| 99 |
+
|
| 100 |
+
namespace Template
|
| 101 |
+
variable {K s A : ℕ}
|
| 102 |
+
theorem rotor_levels (v : Solo p) (K s a : ℕ)
|
| 103 |
+
(hs : 2*a<s) (hg : Odd p.g)
|
| 104 |
+
(δ g : ℝ) (hδ : 0<δ)
|
| 105 |
+
(hG : bp (-((p.J-s:ℕ):ℝ))*bp s < g) :
|
| 106 |
+
∀ᶠ n : ℕ in atTop, ∀ m : Mixer p n, unaryGood m K s →
|
| 107 |
+
∀ x : Profile p n, 0<totalRank x → totalRank x ≤ K →
|
| 108 |
+
∀ w : Wgt (Knobs p.g n), IsLaw w → flowZ p w →
|
| 109 |
+
∀ P : Knobs p.g n → Prop, δ ≤ pr w P →
|
| 110 |
+
pr unif (fun c => g*pr w P ≤|zsumPeak p w (v.rotor c m x) P|) ≤ bp (-(2*a:ℝ)*n) := by
|
| 111 |
+
classical
|
| 112 |
+
let b := bp (-((p.J-s:ℕ):ℝ))
|
| 113 |
+
have hb : b*bp s<g := hG
|
| 114 |
+
let t := ((g-b*bp s)*δ)^2
|
| 115 |
+
have ht : 0<t := by apply pow_pos (mul_pos (sub_pos.mpr hb) hδ)
|
| 116 |
+
obtain ⟨l,hl⟩ := exists_nat_gt (1/t)
|
| 117 |
+
let d := 2*(p.J*(p.g-1)*(2*K))
|
| 118 |
+
have ha : 0<(s:ℝ)-2*a := sub_pos.mpr (by exact_mod_cast hs)
|
| 119 |
+
have hz : Tendsto (fun n:ℕ => (↑s-2*a:ℝ)*n) atTop atTop :=
|
| 120 |
+
(tendsto_const_mul_atTop_of_pos ha).mpr tendsto_natCast_atTop_atTop
|
| 121 |
+
filter_upwards [eventually_gt_atTop s,hz.eventually (eventually_ge_atTop
|
| 122 |
+
(1+((d:ℝ)+l*d)*s))] with n hn hN m hm x hx hK w hw hh P hP
|
| 123 |
+
have he := spinning p w (fun c=>v.rotor c m x) P hw (by
|
| 124 |
+
intro i j; unfold rotor Move.zreroute shanty; rw [wsign_abs]) hh b g δ
|
| 125 |
+
(bp_pos _).le _ s l hn (fun c y i => v.rotor_budget c m x K s hg hm hK hx y i)
|
| 126 |
+
hδ hb hP ((div_lt_iff₀ ht).mp hl)
|
| 127 |
+
apply he.trans
|
| 128 |
+
apply bp_le
|
| 129 |
+
have hy :
|
| 130 |
+
dim (v.scroll m x) ≤ d :=
|
| 131 |
+
(scroll_dim v m x).trans (by unfold d; gcongr)
|
| 132 |
+
have hx : ((dim (v.scroll m x)):ℝ) ≤ d := by exact_mod_cast hy
|
| 133 |
+
change 1+((d:ℝ)+l*d)*s≤ ((s:ℝ)-2*a)*n at hN
|
| 134 |
+
have hB := mul_le_mul_of_nonneg_left hx (Nat.cast_nonneg l : 0≤(l:ℝ))
|
| 135 |
+
nlinarith only [mul_le_mul_of_nonneg_right (add_le_add hx hB)
|
| 136 |
+
(Nat.cast_nonneg s : 0≤(s:ℝ)),hN]
|
| 137 |
+
end Template
|
| 138 |
+
end HadwigerCounterexample
|
| 139 |
+
|
| 140 |
+
end
|
| 141 |
+
|
| 142 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BilinearBlockCorrelation.lean
CHANGED
|
@@ -1,107 +1,107 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.OppositeEndpointForms
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Bilinear Block Correlation -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset LinearMap Module Matrix Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {I J A : Type} [Fintype I] [Fintype J] [Fintype A]
|
| 12 |
-
variable {n : ℕ}
|
| 13 |
-
|
| 14 |
-
def spring (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)
|
| 15 |
-
(y : Knobs p.g n) := point p s (lit f l y)
|
| 16 |
-
|
| 17 |
-
theorem spring_update (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)
|
| 18 |
-
(y : Knobs p.g n) (B) (h : f.keeps l B) (z : Vec (Fin n)) :
|
| 19 |
-
spring p l s f (update y B z)= spring p l s f (update y B 0)+
|
| 20 |
-
blockRay p n s B *ᵥ z := by
|
| 21 |
-
classical
|
| 22 |
-
have he : baseV (lit f l (update y B z))=baseV (lit f l (update y B 0))+blockA p n B *ᵥ z := by
|
| 23 |
-
funext a
|
| 24 |
-
rcases a with _|⟨d,j⟩
|
| 25 |
-
· simp [baseV,blockA,mulVec,dotProduct,embedMat]
|
| 26 |
-
by_cases hk : d=B
|
| 27 |
-
· subst d; simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,h]
|
| 28 |
-
simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,hk]
|
| 29 |
-
unfold spring point blockRay
|
| 30 |
-
rw [he,map_add,←Matrix.mulVec_mulVec,labMat_act]
|
| 31 |
-
|
| 32 |
-
private def dotLB (I : Type) [Fintype I] : Vec I →ₗ[F] Vec I→ₗ[F] F where
|
| 33 |
-
toFun := dotL
|
| 34 |
-
map_add' p q := LinearMap.ext fun i => add_dotProduct p q i
|
| 35 |
-
map_smul' a p := LinearMap.ext fun i => by
|
| 36 |
-
change dotProduct (a • p) i=a*dotProduct p i
|
| 37 |
-
rw [smul_dotProduct]; rfl
|
| 38 |
-
|
| 39 |
-
theorem spark_walsh [DecidableEq I] [DecidableEq J] (M : Mat I J) (p : Wgt (Vec I)) (q : Wgt (Vec J))
|
| 40 |
-
(hp : ∀ i, |p i|≤1) (hq : ∀ i, |q i|≤1) :
|
| 41 |
-
|avg (pairW unif unif) (fun i => wsign (evmat M i.1 i.2)*(p i.1*q i.2))| ≤
|
| 42 |
-
bp (-(M.rank:ℝ)/2) := by
|
| 43 |
-
classical
|
| 44 |
-
let Q := dotLB I
|
| 45 |
-
let L := Q ∘ₗ M.mulVecLin
|
| 46 |
-
have he (i j) : evmat M i j=L j i := dotProduct_comm ..
|
| 47 |
-
have hh : Injective Q := fun x y h => funext (fun i => by
|
| 48 |
-
have hg := LinearMap.congr_fun h (Pi.single i 1)
|
| 49 |
-
change dotProduct x (Pi.single i 1)=dotProduct y (Pi.single i 1) at hg
|
| 50 |
-
simpa using hg)
|
| 51 |
-
have ht : rk L=M.rank := by
|
| 52 |
-
have h : LinearMap.ker L=LinearMap.ker M.mulVecLin := by
|
| 53 |
-
ext x; change Q (M.mulVecLin x)=0 ↔ M.mulVecLin x=0
|
| 54 |
-
rw [← map_zero Q,hh.eq_iff]
|
| 55 |
-
have hv := L.finrank_range_add_finrank_ker
|
| 56 |
-
rw [h, ← M.mulVecLin.finrank_range_add_finrank_ker] at hv
|
| 57 |
-
exact Nat.add_right_cancel hv
|
| 58 |
-
rw [pairW_avg]
|
| 59 |
-
have hz (x : Vec I) (y : Vec J) : wsign (evmat M x y)*(p x*q y)=p x*(q y*wsign (L y x)) := by
|
| 60 |
-
rw [he]; ring
|
| 61 |
-
simp_rw [hz,avg_mul']
|
| 62 |
-
rw [←ht]
|
| 63 |
-
exact walsh_bound _ q p hq hp
|
| 64 |
-
|
| 65 |
-
set_option maxHeartbeats 800000 in
|
| 66 |
-
theorem spark_uncap (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)
|
| 67 |
-
(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)
|
| 68 |
-
(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i| ≤ 1) (hu : ∀ i,|u i|≤1) :
|
| 69 |
-
let Q i z := evmat M (spring p l s f i) (spring p j t g z)
|
| 70 |
-
|avg (pairW unif unif) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤
|
| 71 |
-
bp (-(blockRank B s t M:ℝ)/2) := by
|
| 72 |
-
classical
|
| 73 |
-
intro Q
|
| 74 |
-
let F (x : Knobs p.g n × _) := wsign (Q x.1 x.2)*(w x.1*u x.2)
|
| 75 |
-
let K := Wgt (Vec (Fin n))
|
| 76 |
-
let v : Block p.g→ K := fun _ => unif
|
| 77 |
-
have ht := update2_avg v v B F unif_law unif_law
|
| 78 |
-
have he : prodW v=unif := draws_unif.symm
|
| 79 |
-
let R := blockRay p n s B; let S:=blockRay p n t B
|
| 80 |
-
let H := pullM R S M
|
| 81 |
-
have hi (x y : Knobs p.g n) :
|
| 82 |
-
|avg (pairW (v B) (v B)) (fun i => F (update x B i.1,update y B i.2))|≤
|
| 83 |
-
bp (-(blockRank B s t M:ℝ)/2) := by
|
| 84 |
-
let X := spring p l s f (update x B 0); let Y := spring p j t g (update y B 0)
|
| 85 |
-
let A i := evmat M (R *ᵥ i) Y; let D j := evmat M X (S *ᵥ j)+evmat M X Y
|
| 86 |
-
let Z i := wsign (A i)*w (update x B i); let W j := wsign (D j)*u (update y B j)
|
| 87 |
-
have hp i j' :
|
| 88 |
-
Q (update x B i) (update y B j')= evmat H i j'+(A i+D j') := by
|
| 89 |
-
unfold Q; rw [spring_update _ _ _ _ _ _ hB,spring_update _ _ _ _ _ _ hB']
|
| 90 |
-
unfold H A D X Y; rw [evmat_pull]
|
| 91 |
-
simp only [evmat,mulVec_add,add_dotProduct,dotProduct_add,R,S]; ac_rfl
|
| 92 |
-
have hh i j : F (update x B i,update y B j)=wsign (evmat H i j)*(Z i*W j) := by
|
| 93 |
-
unfold F Z W; dsimp only; rw [hp,wsign_add,wsign_add]; ring
|
| 94 |
-
have hz i : |Z i|≤1 := by unfold Z; rw [abs_mul,wsign_abs,one_mul]; exact hw _
|
| 95 |
-
have hy i : |W i|≤1 := by unfold W; rw [abs_mul,wsign_abs,one_mul]; exact hu _
|
| 96 |
-
simp_rw [hh]
|
| 97 |
-
exact spark_walsh _ Z W hz hy
|
| 98 |
-
simp only [he] at ht
|
| 99 |
-
change |avg (pairW unif unif) F|≤_
|
| 100 |
-
rw [ht]
|
| 101 |
-
let hq := pairW_law (α:=Knobs p.g n) (β:=Knobs p.g n) unif_law unif_law
|
| 102 |
-
exact (abs_avg_le hq.nz).trans (hq.avg_le fun x => hi x.1 x.2)
|
| 103 |
-
end HadwigerCounterexample
|
| 104 |
-
|
| 105 |
-
end
|
| 106 |
-
|
| 107 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.OppositeEndpointForms
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Bilinear Block Correlation -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset LinearMap Module Matrix Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {I J A : Type} [Fintype I] [Fintype J] [Fintype A]
|
| 12 |
+
variable {n : ℕ}
|
| 13 |
+
|
| 14 |
+
def spring (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)
|
| 15 |
+
(y : Knobs p.g n) := point p s (lit f l y)
|
| 16 |
+
|
| 17 |
+
theorem spring_update (p : Shape) (l : Tag p.g) (s : Label p.b) (f : Flavor p.g)
|
| 18 |
+
(y : Knobs p.g n) (B) (h : f.keeps l B) (z : Vec (Fin n)) :
|
| 19 |
+
spring p l s f (update y B z)= spring p l s f (update y B 0)+
|
| 20 |
+
blockRay p n s B *ᵥ z := by
|
| 21 |
+
classical
|
| 22 |
+
have he : baseV (lit f l (update y B z))=baseV (lit f l (update y B 0))+blockA p n B *ᵥ z := by
|
| 23 |
+
funext a
|
| 24 |
+
rcases a with _|⟨d,j⟩
|
| 25 |
+
· simp [baseV,blockA,mulVec,dotProduct,embedMat]
|
| 26 |
+
by_cases hk : d=B
|
| 27 |
+
· subst d; simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,h]
|
| 28 |
+
simp [baseV,blockA,mulVec,dotProduct,embedMat,lit,hk]
|
| 29 |
+
unfold spring point blockRay
|
| 30 |
+
rw [he,map_add,←Matrix.mulVec_mulVec,labMat_act]
|
| 31 |
+
|
| 32 |
+
private def dotLB (I : Type) [Fintype I] : Vec I →ₗ[F] Vec I→ₗ[F] F where
|
| 33 |
+
toFun := dotL
|
| 34 |
+
map_add' p q := LinearMap.ext fun i => add_dotProduct p q i
|
| 35 |
+
map_smul' a p := LinearMap.ext fun i => by
|
| 36 |
+
change dotProduct (a • p) i=a*dotProduct p i
|
| 37 |
+
rw [smul_dotProduct]; rfl
|
| 38 |
+
|
| 39 |
+
theorem spark_walsh [DecidableEq I] [DecidableEq J] (M : Mat I J) (p : Wgt (Vec I)) (q : Wgt (Vec J))
|
| 40 |
+
(hp : ∀ i, |p i|≤1) (hq : ∀ i, |q i|≤1) :
|
| 41 |
+
|avg (pairW unif unif) (fun i => wsign (evmat M i.1 i.2)*(p i.1*q i.2))| ≤
|
| 42 |
+
bp (-(M.rank:ℝ)/2) := by
|
| 43 |
+
classical
|
| 44 |
+
let Q := dotLB I
|
| 45 |
+
let L := Q ∘ₗ M.mulVecLin
|
| 46 |
+
have he (i j) : evmat M i j=L j i := dotProduct_comm ..
|
| 47 |
+
have hh : Injective Q := fun x y h => funext (fun i => by
|
| 48 |
+
have hg := LinearMap.congr_fun h (Pi.single i 1)
|
| 49 |
+
change dotProduct x (Pi.single i 1)=dotProduct y (Pi.single i 1) at hg
|
| 50 |
+
simpa using hg)
|
| 51 |
+
have ht : rk L=M.rank := by
|
| 52 |
+
have h : LinearMap.ker L=LinearMap.ker M.mulVecLin := by
|
| 53 |
+
ext x; change Q (M.mulVecLin x)=0 ↔ M.mulVecLin x=0
|
| 54 |
+
rw [← map_zero Q,hh.eq_iff]
|
| 55 |
+
have hv := L.finrank_range_add_finrank_ker
|
| 56 |
+
rw [h, ← M.mulVecLin.finrank_range_add_finrank_ker] at hv
|
| 57 |
+
exact Nat.add_right_cancel hv
|
| 58 |
+
rw [pairW_avg]
|
| 59 |
+
have hz (x : Vec I) (y : Vec J) : wsign (evmat M x y)*(p x*q y)=p x*(q y*wsign (L y x)) := by
|
| 60 |
+
rw [he]; ring
|
| 61 |
+
simp_rw [hz,avg_mul']
|
| 62 |
+
rw [←ht]
|
| 63 |
+
exact walsh_bound _ q p hq hp
|
| 64 |
+
|
| 65 |
+
set_option maxHeartbeats 800000 in
|
| 66 |
+
theorem spark_uncap (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)
|
| 67 |
+
(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)
|
| 68 |
+
(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i| ≤ 1) (hu : ∀ i,|u i|≤1) :
|
| 69 |
+
let Q i z := evmat M (spring p l s f i) (spring p j t g z)
|
| 70 |
+
|avg (pairW unif unif) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤
|
| 71 |
+
bp (-(blockRank B s t M:ℝ)/2) := by
|
| 72 |
+
classical
|
| 73 |
+
intro Q
|
| 74 |
+
let F (x : Knobs p.g n × _) := wsign (Q x.1 x.2)*(w x.1*u x.2)
|
| 75 |
+
let K := Wgt (Vec (Fin n))
|
| 76 |
+
let v : Block p.g→ K := fun _ => unif
|
| 77 |
+
have ht := update2_avg v v B F unif_law unif_law
|
| 78 |
+
have he : prodW v=unif := draws_unif.symm
|
| 79 |
+
let R := blockRay p n s B; let S:=blockRay p n t B
|
| 80 |
+
let H := pullM R S M
|
| 81 |
+
have hi (x y : Knobs p.g n) :
|
| 82 |
+
|avg (pairW (v B) (v B)) (fun i => F (update x B i.1,update y B i.2))|≤
|
| 83 |
+
bp (-(blockRank B s t M:ℝ)/2) := by
|
| 84 |
+
let X := spring p l s f (update x B 0); let Y := spring p j t g (update y B 0)
|
| 85 |
+
let A i := evmat M (R *ᵥ i) Y; let D j := evmat M X (S *ᵥ j)+evmat M X Y
|
| 86 |
+
let Z i := wsign (A i)*w (update x B i); let W j := wsign (D j)*u (update y B j)
|
| 87 |
+
have hp i j' :
|
| 88 |
+
Q (update x B i) (update y B j')= evmat H i j'+(A i+D j') := by
|
| 89 |
+
unfold Q; rw [spring_update _ _ _ _ _ _ hB,spring_update _ _ _ _ _ _ hB']
|
| 90 |
+
unfold H A D X Y; rw [evmat_pull]
|
| 91 |
+
simp only [evmat,mulVec_add,add_dotProduct,dotProduct_add,R,S]; ac_rfl
|
| 92 |
+
have hh i j : F (update x B i,update y B j)=wsign (evmat H i j)*(Z i*W j) := by
|
| 93 |
+
unfold F Z W; dsimp only; rw [hp,wsign_add,wsign_add]; ring
|
| 94 |
+
have hz i : |Z i|≤1 := by unfold Z; rw [abs_mul,wsign_abs,one_mul]; exact hw _
|
| 95 |
+
have hy i : |W i|≤1 := by unfold W; rw [abs_mul,wsign_abs,one_mul]; exact hu _
|
| 96 |
+
simp_rw [hh]
|
| 97 |
+
exact spark_walsh _ Z W hz hy
|
| 98 |
+
simp only [he] at ht
|
| 99 |
+
change |avg (pairW unif unif) F|≤_
|
| 100 |
+
rw [ht]
|
| 101 |
+
let hq := pairW_law (α:=Knobs p.g n) (β:=Knobs p.g n) unif_law unif_law
|
| 102 |
+
exact (abs_avg_le hq.nz).trans (hq.avg_le fun x => hi x.1 x.2)
|
| 103 |
+
end HadwigerCounterexample
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
|
| 107 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BilinearCompression.lean
CHANGED
|
@@ -1,126 +1,126 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PrimalSpaceCompression
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Bilinear Compression -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Submodule Module Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
|
| 12 |
-
variable {p : Shape} {n : ℕ} {I J : Type} [Fintype I] [Fintype J]
|
| 13 |
-
|
| 14 |
-
def dqBound (p : Shape) (T H R : ℕ) := 2*(drow p T R+H)
|
| 15 |
-
|
| 16 |
-
private theorem pullM_fix (A : Mat I I) (P : Mat I I)
|
| 17 |
-
(h : ∀ x ∈ colSp P,Aᵀ *ᵥ x=x) (h' : ∀ x∈colSp Pᵀ,Aᵀ *ᵥ x=x) :
|
| 18 |
-
pullM A A P=P := by
|
| 19 |
-
rw [pullM_def,mat_mul_fix h]
|
| 20 |
-
have he := congrArg Matrix.transpose (mat_mul_fix h')
|
| 21 |
-
simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using he
|
| 22 |
-
|
| 23 |
-
private def dualSpace (M : Profile p n) (z : Place p) :=
|
| 24 |
-
colSp (if z.2 then M z.1 else (M z.1)ᵀ)
|
| 25 |
-
private theorem dualSpace_dim (M : Profile p n) (z : Place p) :
|
| 26 |
-
dim (dualSpace M z)=(M z.1).rank := by
|
| 27 |
-
cases z with
|
| 28 |
-
| mk i b =>
|
| 29 |
-
cases b; exact Matrix.rank_transpose _; rfl
|
| 30 |
-
|
| 31 |
-
private def jointShrink (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))
|
| 32 |
-
(z : Place p) :=
|
| 33 |
-
∑ i : Bool,(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+
|
| 34 |
-
liftM (IH p n i) (IH p n i) (B z i))
|
| 35 |
-
|
| 36 |
-
private theorem joint_ip (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))
|
| 37 |
-
(z : Place p) (i : Bool) :
|
| 38 |
-
jointShrink A B z * IP p n i = IP p n i * rowShrink p (A i) := by
|
| 39 |
-
classical
|
| 40 |
-
simp only [jointShrink,Fintype.sum_bool,liftM_def,Matrix.add_mul,Matrix.mul_assoc,
|
| 41 |
-
IH_IP,Matrix.mul_zero,add_zero]
|
| 42 |
-
cases i <;> simp only [IP_self,IP_cross (show true≠false by decide),
|
| 43 |
-
IP_cross (show false≠true by decide),Matrix.mul_zero,Matrix.mul_one,add_zero,zero_add]
|
| 44 |
-
|
| 45 |
-
set_option maxHeartbeats 800000 in
|
| 46 |
-
theorem shrink_pure {f : Plan p n} {M : Individual p n} {P : PureForms p n}
|
| 47 |
-
(T H R : ℕ) (ht : ∀ z i,dim (sPin f z i)≤T) (hh : ∀ z i,dim (hPin f z i)≤H)
|
| 48 |
-
(hr : ∀ i e,(M i e).rank≤R)
|
| 49 |
-
(hp : P∈pureSpace p f) (he : obsPair p P=obsI p M) :
|
| 50 |
-
∃ Q∈pureSpace p f,obsPair p Q=obsPair p P ∧ ∀ e,(Q e).rank≤dqBound p T H R := by
|
| 51 |
-
classical
|
| 52 |
-
choose A hA hL hT using fun i => shrink_both (fun z => sPin f z i) (dualSpace (M i)) T R
|
| 53 |
-
(fun z => ht z i) (fun z => by rw [dualSpace_dim]; exact hr i z.1)
|
| 54 |
-
choose B hB using fun z i => proj_exists (hPin f z i) ⊥ disjoint_bot_right
|
| 55 |
-
let D := jointShrink A B
|
| 56 |
-
have hf (z : Place p) (x : Dir p n) (hx : x∈f z) : D z *ᵥ x=x := by
|
| 57 |
-
have h1 (i : Bool) : rowShrink p (A i) *ᵥ ((IP p n i)ᵀ *ᵥ x)=(IP p n i)ᵀ *ᵥ x :=
|
| 58 |
-
hA i z _ ⟨_,hx,rfl⟩
|
| 59 |
-
have h2 (i : Bool) : B z i *ᵥ ((IH p n i)ᵀ *ᵥ x)=(IH p n i)ᵀ *ᵥ x :=
|
| 60 |
-
(hB z i).fixes _ ⟨_,hx,rfl⟩
|
| 61 |
-
unfold D jointShrink
|
| 62 |
-
simp only [Matrix.sum_mulVec,Matrix.add_mulVec,liftM_def,← Matrix.mulVec_mulVec,h1,h2]
|
| 63 |
-
exact ip_decomp x
|
| 64 |
-
have hR (z : Place p) : (D z).rank ≤ dqBound p T H R := by
|
| 65 |
-
apply le_trans (mrk_sum_le ..)
|
| 66 |
-
have hx i :
|
| 67 |
-
(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+
|
| 68 |
-
liftM (IH p n i) (IH p n i) (B z i)).rank ≤ drow p T R+H :=
|
| 69 |
-
(mrk_add_le ..).trans (add_le_add
|
| 70 |
-
((rank_lift_le ..).trans (hT i)) ((rank_lift_le ..).trans
|
| 71 |
-
((rank_maps (hPin f z i) (hB z i).onto).trans (hh z i))))
|
| 72 |
-
rw [Fintype.sum_bool,dqBound,two_mul]; exact add_le_add (hx _) (hx _)
|
| 73 |
-
let Q (e : Comp p.g) := pullM (D (e,true)) (D (e,false)) (P e)
|
| 74 |
-
have hG (i : Bool) (e : Comp p.g) : pullM (rowShrink p (A i)) (rowShrink p (A i)) (M i e)=
|
| 75 |
-
M i e := pullM_fix _ _ (hL i (e,true)) (hL i (e,false))
|
| 76 |
-
have hY (i : Bool) (e : Comp p.g) : eachF p Q i e=
|
| 77 |
-
pullM (rowShrink p (A i)) (rowShrink p (A i)) (eachF p P i e) := by
|
| 78 |
-
change pullM _ _ (Q e)=pullM _ _ (pullM _ _ _)
|
| 79 |
-
let G := IP p n i
|
| 80 |
-
have hw {I J K U V W : Type} [Fintype U] [Fintype V] [Fintype W] [Fintype I]
|
| 81 |
-
[Fintype J] [Fintype K] (L : Mat U I) (R : Mat V J)
|
| 82 |
-
(L' : Mat I K) (R' : Mat J W) (P : Mat U V) :
|
| 83 |
-
pullM L' R' (pullM L R P) = pullM (L*L') (R*R') P := by
|
| 84 |
-
unfold pullM
|
| 85 |
-
rw [liftM_comp,Matrix.transpose_mul,Matrix.transpose_mul]
|
| 86 |
-
unfold Q
|
| 87 |
-
rw [hw,hw]
|
| 88 |
-
have h (b) := joint_ip A B (e,b) i
|
| 89 |
-
rw [show D (e,true)*IP p n i=_ from h true, show D (e,false)*IP p n i=_ from h false]
|
| 90 |
-
|
| 91 |
-
refine ⟨Q,?_,?_,fun e => ?_⟩
|
| 92 |
-
· refine (pureSpace_mem _).mpr fun e => ?_
|
| 93 |
-
obtain ⟨h1,h2⟩ := box_kill.mp ((pureSpace_mem _).mp hp e)
|
| 94 |
-
unfold Q; rw [box_kill,pullM_def]; constructor
|
| 95 |
-
· intro x hx
|
| 96 |
-
simp only [transpose_mul,transpose_transpose,←Matrix.mulVec_mulVec,hf (e,true) x hx,h1 x hx,
|
| 97 |
-
mulVec_zero]
|
| 98 |
-
intro x hx
|
| 99 |
-
rw [← mulVec_mulVec,hf (e,false) x hx]
|
| 100 |
-
rw [← mulVec_mulVec,h2 x hx,mulVec_zero]
|
| 101 |
-
· rw [he,obsPair_each]
|
| 102 |
-
rw [obsPair_each] at he
|
| 103 |
-
change combineF p _=combineF p _
|
| 104 |
-
change combineF p _=combineF p _ at he
|
| 105 |
-
have he := (combineF_same ..).mp he
|
| 106 |
-
apply (combineF_same ..).mpr
|
| 107 |
-
intro i x hx
|
| 108 |
-
let y : Profile p n := fun e => liftM (rowShrink p (A i)) (rowShrink p (A i)) (x e)
|
| 109 |
-
rw [repF_rep,repF_rep]
|
| 110 |
-
have hv := he i y (shrink_X (A i) x hx)
|
| 111 |
-
rw [repF_rep,repF_rep] at hv
|
| 112 |
-
have hu (F : Individual p n) : (∑ e,mpair (F i e) (y e))=
|
| 113 |
-
∑ e,mpair (pullM (rowShrink p (A i)) (rowShrink p (A i)) (F i e)) (x e) :=
|
| 114 |
-
Finset.sum_congr rfl fun e _ => mpair_liftM ..
|
| 115 |
-
rw [hu,hu] at hv
|
| 116 |
-
simp_rw [← hY,hG] at hv
|
| 117 |
-
exact hv
|
| 118 |
-
unfold Q; rw [pullM_def]
|
| 119 |
-
exact ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans
|
| 120 |
-
(by rw [Matrix.rank_transpose]; exact hR _)
|
| 121 |
-
|
| 122 |
-
end HadwigerCounterexample
|
| 123 |
-
|
| 124 |
-
end
|
| 125 |
-
|
| 126 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PrimalSpaceCompression
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Bilinear Compression -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Submodule Module Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
variable {p : Shape} {n : ℕ} {I J : Type} [Fintype I] [Fintype J]
|
| 13 |
+
|
| 14 |
+
def dqBound (p : Shape) (T H R : ℕ) := 2*(drow p T R+H)
|
| 15 |
+
|
| 16 |
+
private theorem pullM_fix (A : Mat I I) (P : Mat I I)
|
| 17 |
+
(h : ∀ x ∈ colSp P,Aᵀ *ᵥ x=x) (h' : ∀ x∈colSp Pᵀ,Aᵀ *ᵥ x=x) :
|
| 18 |
+
pullM A A P=P := by
|
| 19 |
+
rw [pullM_def,mat_mul_fix h]
|
| 20 |
+
have he := congrArg Matrix.transpose (mat_mul_fix h')
|
| 21 |
+
simpa only [Matrix.transpose_mul,Matrix.transpose_transpose] using he
|
| 22 |
+
|
| 23 |
+
private def dualSpace (M : Profile p n) (z : Place p) :=
|
| 24 |
+
colSp (if z.2 then M z.1 else (M z.1)ᵀ)
|
| 25 |
+
private theorem dualSpace_dim (M : Profile p n) (z : Place p) :
|
| 26 |
+
dim (dualSpace M z)=(M z.1).rank := by
|
| 27 |
+
cases z with
|
| 28 |
+
| mk i b =>
|
| 29 |
+
cases b; exact Matrix.rank_transpose _; rfl
|
| 30 |
+
|
| 31 |
+
private def jointShrink (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))
|
| 32 |
+
(z : Place p) :=
|
| 33 |
+
∑ i : Bool,(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+
|
| 34 |
+
liftM (IH p n i) (IH p n i) (B z i))
|
| 35 |
+
|
| 36 |
+
private theorem joint_ip (A : Bool → Nendo p n) (B : Place p → Bool → Mat (Chan p) (Chan p))
|
| 37 |
+
(z : Place p) (i : Bool) :
|
| 38 |
+
jointShrink A B z * IP p n i = IP p n i * rowShrink p (A i) := by
|
| 39 |
+
classical
|
| 40 |
+
simp only [jointShrink,Fintype.sum_bool,liftM_def,Matrix.add_mul,Matrix.mul_assoc,
|
| 41 |
+
IH_IP,Matrix.mul_zero,add_zero]
|
| 42 |
+
cases i <;> simp only [IP_self,IP_cross (show true≠false by decide),
|
| 43 |
+
IP_cross (show false≠true by decide),Matrix.mul_zero,Matrix.mul_one,add_zero,zero_add]
|
| 44 |
+
|
| 45 |
+
set_option maxHeartbeats 800000 in
|
| 46 |
+
theorem shrink_pure {f : Plan p n} {M : Individual p n} {P : PureForms p n}
|
| 47 |
+
(T H R : ℕ) (ht : ∀ z i,dim (sPin f z i)≤T) (hh : ∀ z i,dim (hPin f z i)≤H)
|
| 48 |
+
(hr : ∀ i e,(M i e).rank≤R)
|
| 49 |
+
(hp : P∈pureSpace p f) (he : obsPair p P=obsI p M) :
|
| 50 |
+
∃ Q∈pureSpace p f,obsPair p Q=obsPair p P ∧ ∀ e,(Q e).rank≤dqBound p T H R := by
|
| 51 |
+
classical
|
| 52 |
+
choose A hA hL hT using fun i => shrink_both (fun z => sPin f z i) (dualSpace (M i)) T R
|
| 53 |
+
(fun z => ht z i) (fun z => by rw [dualSpace_dim]; exact hr i z.1)
|
| 54 |
+
choose B hB using fun z i => proj_exists (hPin f z i) ⊥ disjoint_bot_right
|
| 55 |
+
let D := jointShrink A B
|
| 56 |
+
have hf (z : Place p) (x : Dir p n) (hx : x∈f z) : D z *ᵥ x=x := by
|
| 57 |
+
have h1 (i : Bool) : rowShrink p (A i) *ᵥ ((IP p n i)ᵀ *ᵥ x)=(IP p n i)ᵀ *ᵥ x :=
|
| 58 |
+
hA i z _ ⟨_,hx,rfl⟩
|
| 59 |
+
have h2 (i : Bool) : B z i *ᵥ ((IH p n i)ᵀ *ᵥ x)=(IH p n i)ᵀ *ᵥ x :=
|
| 60 |
+
(hB z i).fixes _ ⟨_,hx,rfl⟩
|
| 61 |
+
unfold D jointShrink
|
| 62 |
+
simp only [Matrix.sum_mulVec,Matrix.add_mulVec,liftM_def,← Matrix.mulVec_mulVec,h1,h2]
|
| 63 |
+
exact ip_decomp x
|
| 64 |
+
have hR (z : Place p) : (D z).rank ≤ dqBound p T H R := by
|
| 65 |
+
apply le_trans (mrk_sum_le ..)
|
| 66 |
+
have hx i :
|
| 67 |
+
(liftM (IP p n i) (IP p n i) (rowShrink p (A i))+
|
| 68 |
+
liftM (IH p n i) (IH p n i) (B z i)).rank ≤ drow p T R+H :=
|
| 69 |
+
(mrk_add_le ..).trans (add_le_add
|
| 70 |
+
((rank_lift_le ..).trans (hT i)) ((rank_lift_le ..).trans
|
| 71 |
+
((rank_maps (hPin f z i) (hB z i).onto).trans (hh z i))))
|
| 72 |
+
rw [Fintype.sum_bool,dqBound,two_mul]; exact add_le_add (hx _) (hx _)
|
| 73 |
+
let Q (e : Comp p.g) := pullM (D (e,true)) (D (e,false)) (P e)
|
| 74 |
+
have hG (i : Bool) (e : Comp p.g) : pullM (rowShrink p (A i)) (rowShrink p (A i)) (M i e)=
|
| 75 |
+
M i e := pullM_fix _ _ (hL i (e,true)) (hL i (e,false))
|
| 76 |
+
have hY (i : Bool) (e : Comp p.g) : eachF p Q i e=
|
| 77 |
+
pullM (rowShrink p (A i)) (rowShrink p (A i)) (eachF p P i e) := by
|
| 78 |
+
change pullM _ _ (Q e)=pullM _ _ (pullM _ _ _)
|
| 79 |
+
let G := IP p n i
|
| 80 |
+
have hw {I J K U V W : Type} [Fintype U] [Fintype V] [Fintype W] [Fintype I]
|
| 81 |
+
[Fintype J] [Fintype K] (L : Mat U I) (R : Mat V J)
|
| 82 |
+
(L' : Mat I K) (R' : Mat J W) (P : Mat U V) :
|
| 83 |
+
pullM L' R' (pullM L R P) = pullM (L*L') (R*R') P := by
|
| 84 |
+
unfold pullM
|
| 85 |
+
rw [liftM_comp,Matrix.transpose_mul,Matrix.transpose_mul]
|
| 86 |
+
unfold Q
|
| 87 |
+
rw [hw,hw]
|
| 88 |
+
have h (b) := joint_ip A B (e,b) i
|
| 89 |
+
rw [show D (e,true)*IP p n i=_ from h true, show D (e,false)*IP p n i=_ from h false]
|
| 90 |
+
|
| 91 |
+
refine ⟨Q,?_,?_,fun e => ?_⟩
|
| 92 |
+
· refine (pureSpace_mem _).mpr fun e => ?_
|
| 93 |
+
obtain ⟨h1,h2⟩ := box_kill.mp ((pureSpace_mem _).mp hp e)
|
| 94 |
+
unfold Q; rw [box_kill,pullM_def]; constructor
|
| 95 |
+
· intro x hx
|
| 96 |
+
simp only [transpose_mul,transpose_transpose,←Matrix.mulVec_mulVec,hf (e,true) x hx,h1 x hx,
|
| 97 |
+
mulVec_zero]
|
| 98 |
+
intro x hx
|
| 99 |
+
rw [← mulVec_mulVec,hf (e,false) x hx]
|
| 100 |
+
rw [← mulVec_mulVec,h2 x hx,mulVec_zero]
|
| 101 |
+
· rw [he,obsPair_each]
|
| 102 |
+
rw [obsPair_each] at he
|
| 103 |
+
change combineF p _=combineF p _
|
| 104 |
+
change combineF p _=combineF p _ at he
|
| 105 |
+
have he := (combineF_same ..).mp he
|
| 106 |
+
apply (combineF_same ..).mpr
|
| 107 |
+
intro i x hx
|
| 108 |
+
let y : Profile p n := fun e => liftM (rowShrink p (A i)) (rowShrink p (A i)) (x e)
|
| 109 |
+
rw [repF_rep,repF_rep]
|
| 110 |
+
have hv := he i y (shrink_X (A i) x hx)
|
| 111 |
+
rw [repF_rep,repF_rep] at hv
|
| 112 |
+
have hu (F : Individual p n) : (∑ e,mpair (F i e) (y e))=
|
| 113 |
+
∑ e,mpair (pullM (rowShrink p (A i)) (rowShrink p (A i)) (F i e)) (x e) :=
|
| 114 |
+
Finset.sum_congr rfl fun e _ => mpair_liftM ..
|
| 115 |
+
rw [hu,hu] at hv
|
| 116 |
+
simp_rw [← hY,hG] at hv
|
| 117 |
+
exact hv
|
| 118 |
+
unfold Q; rw [pullM_def]
|
| 119 |
+
exact ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_left ..)).trans
|
| 120 |
+
(by rw [Matrix.rank_transpose]; exact hR _)
|
| 121 |
+
|
| 122 |
+
end HadwigerCounterexample
|
| 123 |
+
|
| 124 |
+
end
|
| 125 |
+
|
| 126 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryEvaluationForms.lean
CHANGED
|
@@ -1,174 +1,174 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.MixerConditions
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Binary Evaluation Forms -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix
|
| 11 |
-
variable {p : Shape} {n : ℕ}
|
| 12 |
-
|
| 13 |
-
theorem pullT {I J V U : Type} [Fintype V] [Fintype U]
|
| 14 |
-
(A : Mat V U) (P : Mat U I) (Q : Mat V J) :
|
| 15 |
-
pullM P Q Aᵀ = (pullM Q P A)ᵀ := by
|
| 16 |
-
rw [pullM_def,pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc]
|
| 17 |
-
|
| 18 |
-
theorem indexed_linear {c : Vec (MBits p)} {D D' : Draw p n} :
|
| 19 |
-
indexedSum (drawn (p:=p) (D+D')) c =
|
| 20 |
-
indexedSum (drawn D) c + indexedSum (drawn D') c := by
|
| 21 |
-
have h (i : MBits p) :
|
| 22 |
-
eitherM i.2 (orderedM (drawn (p:=p) (D+D')) i.1) =
|
| 23 |
-
eitherM i.2 (orderedM (drawn D) i.1) + eitherM i.2 (orderedM (drawn D') i.1) := by
|
| 24 |
-
rcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rfl
|
| 25 |
-
unfold indexedSum
|
| 26 |
-
simp_rw [h,smul_add,Finset.sum_add_distrib]
|
| 27 |
-
|
| 28 |
-
def obsZ (p : Shape) (n : ℕ) (s t : Label p.b) (c : Vec (MBits p)) :
|
| 29 |
-
Draw p n →ₗ[F] Mat (Fin n) (Fin n) where
|
| 30 |
-
toFun D := pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (indexedSum (drawn D) c)
|
| 31 |
-
map_add' _ _ := by rw [indexed_linear,map_add]
|
| 32 |
-
map_smul' a x := by
|
| 33 |
-
have h (i : MBits p) :
|
| 34 |
-
eitherM i.2 (orderedM (drawn (p:=p) (a•x)) i.1)=
|
| 35 |
-
a • eitherM i.2 (orderedM (drawn x) i.1) := by
|
| 36 |
-
rcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rfl
|
| 37 |
-
simp only [indexedSum,h,map_sum,map_smul,RingHom.id_apply,Finset.smul_sum]
|
| 38 |
-
exact Finset.sum_congr rfl fun i _ => smul_comm _ _ _
|
| 39 |
-
|
| 40 |
-
theorem obsZ_self (s t : Label p.b) (f : Vec Bool) (m : Mixer p n) :
|
| 41 |
-
pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (selfSum m f) = 0 := by
|
| 42 |
-
rw [selfSum,Fintype.sum_bool,map_add,map_smul,map_smul]
|
| 43 |
-
change _ • pullM _ _ (selfM p n m.mixM) + _ • pullM _ _ (selfM p n m.mixM)ᵀ = 0
|
| 44 |
-
rw [pullT,pull_self_Z,pull_self_Z]
|
| 45 |
-
simp
|
| 46 |
-
|
| 47 |
-
private theorem two_eval (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t)
|
| 48 |
-
(x : Bool → Mat (Fin n) (Fin n)) :
|
| 49 |
-
∃ A : Moment p n, ∀ b, pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)
|
| 50 |
-
(eitherM b A) = x b := by
|
| 51 |
-
let P := blockRay p n s Block.Z
|
| 52 |
-
let Q := blockRay p n t Block.Z
|
| 53 |
-
have hh : Function.Injective (fromCols P Q).mulVec := joined_block_inj hj hs _
|
| 54 |
-
obtain ⟨L,hL⟩ := prescribe_between hh hh
|
| 55 |
-
(fromBlocks (0:Mat (Fin n) (Fin n)) (x true) (x false)ᵀ (0:Mat (Fin n) (Fin n)))
|
| 56 |
-
rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hL
|
| 57 |
-
have hx : pullM P Q L = x true := congrArg Matrix.toBlocks₁₂ hL
|
| 58 |
-
have hy : pullM Q P L = (x false)ᵀ := congrArg Matrix.toBlocks₂₁ hL
|
| 59 |
-
refine ⟨L,fun b => ?_⟩
|
| 60 |
-
cases b
|
| 61 |
-
· change pullM P Q Lᵀ=x false
|
| 62 |
-
rw [pullT,hy,transpose_transpose]
|
| 63 |
-
· exact hx
|
| 64 |
-
|
| 65 |
-
theorem obsZ_surj (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t)
|
| 66 |
-
{c : Vec (MBits p)} (hc : c ≠ 0) : Function.Surjective (obsZ p n s t c) := by
|
| 67 |
-
classical
|
| 68 |
-
simp only [ne_eq,funext_iff,Pi.zero_apply,not_forall] at hc
|
| 69 |
-
obtain ⟨i,hi⟩ := hc
|
| 70 |
-
intro M
|
| 71 |
-
let y (j : MBits p) := if j=i then M else 0
|
| 72 |
-
choose A hA using fun j : MOne p => two_eval s t hj hs (fun b => y (j,b))
|
| 73 |
-
let D : Draw p n := (fun j => A (j,true), fun j => A (j,false), 0)
|
| 74 |
-
have he (j : MBits p) :
|
| 75 |
-
pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)
|
| 76 |
-
(eitherM j.2 (orderedM (drawn D) j.1)) = y j := by
|
| 77 |
-
rcases j with ⟨⟨j,_|_⟩,x⟩
|
| 78 |
-
· exact hA _ _
|
| 79 |
-
· exact hA _ _
|
| 80 |
-
refine ⟨D,?_⟩
|
| 81 |
-
simp only [obsZ,indexedSum,map_sum,map_smul,he,LinearMap.coe_mk,AddHom.coe_mk]
|
| 82 |
-
rw [Finset.sum_eq_single i]
|
| 83 |
-
· simp [y,(bit_cases (c i)).resolve_left hi]
|
| 84 |
-
· intro j _ hj; simp [y,hj]
|
| 85 |
-
simp
|
| 86 |
-
|
| 87 |
-
def selfPartial (s t : Label p.b) (f : Vec Bool) (D : Draw p n) : Mat (Fin n) (Fin n) :=
|
| 88 |
-
let A := ∑ a, (s a+t a) • D.2.2 a
|
| 89 |
-
f true • A+f false • Aᵀ
|
| 90 |
-
|
| 91 |
-
theorem pull_selfPart (s t : Label p.b) (hj : 1 ≤ p.j) (f : Vec Bool) (D : Draw p n) :
|
| 92 |
-
pullM (blockRay p n s Block.sharp) (blockRay p n t Block.sharp) (selfSum (drawn D) f) =
|
| 93 |
-
selfPartial (p:=p) s t f D := by
|
| 94 |
-
rw [selfSum, Fintype.sum_bool,map_add,map_smul,map_smul]
|
| 95 |
-
change _ • pullM _ _ (selfM p n D.2.2) + _ • pullM _ _ (selfM p n D.2.2)ᵀ = _
|
| 96 |
-
rw [pullT,pull_self_sharp _ _ _ hj,pull_self_sharp _ _ _ hj]
|
| 97 |
-
unfold selfPartial
|
| 98 |
-
congr 2
|
| 99 |
-
simp only [add_comm]
|
| 100 |
-
|
| 101 |
-
def obsHalf (p : Shape) (s t : Label p.b) (f : Vec Bool) (n : ℕ)
|
| 102 |
-
(l r : Fin (n/2)→Fin n) : Draw p n →ₗ[F] Mat (Fin (n/2)) (Fin (n/2)) where
|
| 103 |
-
toFun D := (selfPartial (p:=p) s t f D).submatrix l r
|
| 104 |
-
map_add' _ _ := by
|
| 105 |
-
simp only [selfPartial, Prod.snd_add, Pi.add_apply, smul_add, Finset.sum_add_distrib,
|
| 106 |
-
transpose_add, Matrix.submatrix_add]
|
| 107 |
-
abel
|
| 108 |
-
map_smul' a D := by
|
| 109 |
-
simp only [selfPartial,Prod.smul_snd,Pi.smul_apply,RingHom.id_apply]
|
| 110 |
-
let F (D : Draw p n) := ∑ i, (s i+t i) • D.2.2 i
|
| 111 |
-
have h :
|
| 112 |
-
∑ i, (s i+t i) • (a • D.2.2 i) = a • F D := by
|
| 113 |
-
unfold F; rw [Finset.smul_sum]; exact Finset.sum_congr rfl fun _ _ => smul_comm _ _ _
|
| 114 |
-
rw [h,Matrix.transpose_smul]
|
| 115 |
-
rw [smul_comm (f true),smul_comm (f false) a, ← smul_add]
|
| 116 |
-
rfl
|
| 117 |
-
|
| 118 |
-
/-- Uniform off-diagonal block even in transpose-character case. -/
|
| 119 |
-
theorem obsHalf_surj (s t : Label p.b) (hs : s≠t) {f : Vec Bool} (hf : f≠0) (n : ℕ)
|
| 120 |
-
{l r : Fin (n/2)→Fin n} (hl : Function.Injective l) (hr : Function.Injective r)
|
| 121 |
-
(h : ∀ i j,l i≠r j) : Function.Surjective (obsHalf p s t f n l r) := by
|
| 122 |
-
classical
|
| 123 |
-
intro M
|
| 124 |
-
obtain ⟨a,ha⟩ : ∃ a,s a+t a=1 := by
|
| 125 |
-
obtain ⟨a,ha⟩ := Function.ne_iff.mp hs
|
| 126 |
-
exact ⟨a,(bit_cases _).resolve_left (fun h => ha
|
| 127 |
-
(add_right_cancel (h.trans (char_two _).symm)))⟩
|
| 128 |
-
let m := n/2
|
| 129 |
-
let P := embedMat l
|
| 130 |
-
let Q := embedMat r
|
| 131 |
-
have hi : Function.Injective (fromCols P Q).mulVec := by
|
| 132 |
-
have he : fromCols P Q = embedMat (Sum.elim l r) := by ext i j; cases j <;> rfl
|
| 133 |
-
rw [he]; apply embedMat_inj
|
| 134 |
-
rintro (x|x) (y|y) g
|
| 135 |
-
· rw [hl g]
|
| 136 |
-
· exact (h _ _ g).elim
|
| 137 |
-
· exact (h _ _ g.symm).elim
|
| 138 |
-
· rw [hr g]
|
| 139 |
-
have hv (x y : Mat (Fin m) (Fin m)) :
|
| 140 |
-
∃ A : Mat (Fin n) (Fin n), A.submatrix l r=x ∧ Aᵀ.submatrix l r=y := by
|
| 141 |
-
obtain ⟨A,hA⟩ := prescribe_between hi hi (fromBlocks (0:Mat (Fin m) (Fin m)) x yᵀ
|
| 142 |
-
(0:Mat (Fin m) (Fin m)))
|
| 143 |
-
rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hA
|
| 144 |
-
have h1 : Pᵀ*A*Q=x := congrArg Matrix.toBlocks₁₂ hA
|
| 145 |
-
have h2 : Qᵀ*A*P=yᵀ := congrArg Matrix.toBlocks₂₁ hA
|
| 146 |
-
unfold P Q at *
|
| 147 |
-
rw [embedMat_mul,mul_embedMat] at h1 h2
|
| 148 |
-
exact ⟨A,h1,congrArg Matrix.transpose h2⟩
|
| 149 |
-
obtain ⟨x,y,hx⟩ : ∃ x y : Mat (Fin m) (Fin m), f true • x+f false • y=M := by
|
| 150 |
-
rcases bit_cases (f true) with g|g
|
| 151 |
-
· have hg : f false≠0 := fun hg => hf (funext fun i => by cases i <;> assumption)
|
| 152 |
-
exact ⟨0,M,by rw [(bit_cases _).resolve_left hg]; simp⟩
|
| 153 |
-
· exact ⟨M,0,by rw [g]; simp⟩
|
| 154 |
-
obtain ⟨A,h1,h2⟩ := hv x y
|
| 155 |
-
let D : Draw p n := (0,0,Pi.single a A)
|
| 156 |
-
have hE :
|
| 157 |
-
∑ i,(s i+t i) • D.2.2 i=A := by
|
| 158 |
-
rw [Finset.sum_eq_single a]
|
| 159 |
-
· simp [D,ha]
|
| 160 |
-
· intro i _ hi; simp [D,Pi.single_eq_of_ne hi]
|
| 161 |
-
simp
|
| 162 |
-
refine ⟨D,?_⟩
|
| 163 |
-
change (selfPartial (p:=p) s t f D).submatrix l r=M
|
| 164 |
-
unfold selfPartial
|
| 165 |
-
rw [hE]
|
| 166 |
-
change (f true • A + f false • Aᵀ).submatrix l r = _
|
| 167 |
-
change f true • A.submatrix l r + f false • Aᵀ.submatrix l r = M
|
| 168 |
-
rw [h1,h2,hx]
|
| 169 |
-
|
| 170 |
-
end HadwigerCounterexample
|
| 171 |
-
|
| 172 |
-
end
|
| 173 |
-
|
| 174 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.MixerConditions
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Binary Evaluation Forms -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix
|
| 11 |
+
variable {p : Shape} {n : ℕ}
|
| 12 |
+
|
| 13 |
+
theorem pullT {I J V U : Type} [Fintype V] [Fintype U]
|
| 14 |
+
(A : Mat V U) (P : Mat U I) (Q : Mat V J) :
|
| 15 |
+
pullM P Q Aᵀ = (pullM Q P A)ᵀ := by
|
| 16 |
+
rw [pullM_def,pullM_def,transpose_mul,transpose_mul,transpose_transpose,Matrix.mul_assoc]
|
| 17 |
+
|
| 18 |
+
theorem indexed_linear {c : Vec (MBits p)} {D D' : Draw p n} :
|
| 19 |
+
indexedSum (drawn (p:=p) (D+D')) c =
|
| 20 |
+
indexedSum (drawn D) c + indexedSum (drawn D') c := by
|
| 21 |
+
have h (i : MBits p) :
|
| 22 |
+
eitherM i.2 (orderedM (drawn (p:=p) (D+D')) i.1) =
|
| 23 |
+
eitherM i.2 (orderedM (drawn D) i.1) + eitherM i.2 (orderedM (drawn D') i.1) := by
|
| 24 |
+
rcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rfl
|
| 25 |
+
unfold indexedSum
|
| 26 |
+
simp_rw [h,smul_add,Finset.sum_add_distrib]
|
| 27 |
+
|
| 28 |
+
def obsZ (p : Shape) (n : ℕ) (s t : Label p.b) (c : Vec (MBits p)) :
|
| 29 |
+
Draw p n →ₗ[F] Mat (Fin n) (Fin n) where
|
| 30 |
+
toFun D := pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (indexedSum (drawn D) c)
|
| 31 |
+
map_add' _ _ := by rw [indexed_linear,map_add]
|
| 32 |
+
map_smul' a x := by
|
| 33 |
+
have h (i : MBits p) :
|
| 34 |
+
eitherM i.2 (orderedM (drawn (p:=p) (a•x)) i.1)=
|
| 35 |
+
a • eitherM i.2 (orderedM (drawn x) i.1) := by
|
| 36 |
+
rcases i with ⟨⟨⟨a,b,d⟩,_|_⟩,_|_⟩ <;> rfl
|
| 37 |
+
simp only [indexedSum,h,map_sum,map_smul,RingHom.id_apply,Finset.smul_sum]
|
| 38 |
+
exact Finset.sum_congr rfl fun i _ => smul_comm _ _ _
|
| 39 |
+
|
| 40 |
+
theorem obsZ_self (s t : Label p.b) (f : Vec Bool) (m : Mixer p n) :
|
| 41 |
+
pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z) (selfSum m f) = 0 := by
|
| 42 |
+
rw [selfSum,Fintype.sum_bool,map_add,map_smul,map_smul]
|
| 43 |
+
change _ • pullM _ _ (selfM p n m.mixM) + _ • pullM _ _ (selfM p n m.mixM)ᵀ = 0
|
| 44 |
+
rw [pullT,pull_self_Z,pull_self_Z]
|
| 45 |
+
simp
|
| 46 |
+
|
| 47 |
+
private theorem two_eval (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t)
|
| 48 |
+
(x : Bool → Mat (Fin n) (Fin n)) :
|
| 49 |
+
∃ A : Moment p n, ∀ b, pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)
|
| 50 |
+
(eitherM b A) = x b := by
|
| 51 |
+
let P := blockRay p n s Block.Z
|
| 52 |
+
let Q := blockRay p n t Block.Z
|
| 53 |
+
have hh : Function.Injective (fromCols P Q).mulVec := joined_block_inj hj hs _
|
| 54 |
+
obtain ⟨L,hL⟩ := prescribe_between hh hh
|
| 55 |
+
(fromBlocks (0:Mat (Fin n) (Fin n)) (x true) (x false)ᵀ (0:Mat (Fin n) (Fin n)))
|
| 56 |
+
rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hL
|
| 57 |
+
have hx : pullM P Q L = x true := congrArg Matrix.toBlocks₁₂ hL
|
| 58 |
+
have hy : pullM Q P L = (x false)ᵀ := congrArg Matrix.toBlocks₂₁ hL
|
| 59 |
+
refine ⟨L,fun b => ?_⟩
|
| 60 |
+
cases b
|
| 61 |
+
· change pullM P Q Lᵀ=x false
|
| 62 |
+
rw [pullT,hy,transpose_transpose]
|
| 63 |
+
· exact hx
|
| 64 |
+
|
| 65 |
+
theorem obsZ_surj (s t : Label p.b) (hj : 1≤p.j) (hs : s≠t)
|
| 66 |
+
{c : Vec (MBits p)} (hc : c ≠ 0) : Function.Surjective (obsZ p n s t c) := by
|
| 67 |
+
classical
|
| 68 |
+
simp only [ne_eq,funext_iff,Pi.zero_apply,not_forall] at hc
|
| 69 |
+
obtain ⟨i,hi⟩ := hc
|
| 70 |
+
intro M
|
| 71 |
+
let y (j : MBits p) := if j=i then M else 0
|
| 72 |
+
choose A hA using fun j : MOne p => two_eval s t hj hs (fun b => y (j,b))
|
| 73 |
+
let D : Draw p n := (fun j => A (j,true), fun j => A (j,false), 0)
|
| 74 |
+
have he (j : MBits p) :
|
| 75 |
+
pullM (blockRay p n s Block.Z) (blockRay p n t Block.Z)
|
| 76 |
+
(eitherM j.2 (orderedM (drawn D) j.1)) = y j := by
|
| 77 |
+
rcases j with ⟨⟨j,_|_⟩,x⟩
|
| 78 |
+
· exact hA _ _
|
| 79 |
+
· exact hA _ _
|
| 80 |
+
refine ⟨D,?_⟩
|
| 81 |
+
simp only [obsZ,indexedSum,map_sum,map_smul,he,LinearMap.coe_mk,AddHom.coe_mk]
|
| 82 |
+
rw [Finset.sum_eq_single i]
|
| 83 |
+
· simp [y,(bit_cases (c i)).resolve_left hi]
|
| 84 |
+
· intro j _ hj; simp [y,hj]
|
| 85 |
+
simp
|
| 86 |
+
|
| 87 |
+
def selfPartial (s t : Label p.b) (f : Vec Bool) (D : Draw p n) : Mat (Fin n) (Fin n) :=
|
| 88 |
+
let A := ∑ a, (s a+t a) • D.2.2 a
|
| 89 |
+
f true • A+f false • Aᵀ
|
| 90 |
+
|
| 91 |
+
theorem pull_selfPart (s t : Label p.b) (hj : 1 ≤ p.j) (f : Vec Bool) (D : Draw p n) :
|
| 92 |
+
pullM (blockRay p n s Block.sharp) (blockRay p n t Block.sharp) (selfSum (drawn D) f) =
|
| 93 |
+
selfPartial (p:=p) s t f D := by
|
| 94 |
+
rw [selfSum, Fintype.sum_bool,map_add,map_smul,map_smul]
|
| 95 |
+
change _ • pullM _ _ (selfM p n D.2.2) + _ • pullM _ _ (selfM p n D.2.2)ᵀ = _
|
| 96 |
+
rw [pullT,pull_self_sharp _ _ _ hj,pull_self_sharp _ _ _ hj]
|
| 97 |
+
unfold selfPartial
|
| 98 |
+
congr 2
|
| 99 |
+
simp only [add_comm]
|
| 100 |
+
|
| 101 |
+
def obsHalf (p : Shape) (s t : Label p.b) (f : Vec Bool) (n : ℕ)
|
| 102 |
+
(l r : Fin (n/2)→Fin n) : Draw p n →ₗ[F] Mat (Fin (n/2)) (Fin (n/2)) where
|
| 103 |
+
toFun D := (selfPartial (p:=p) s t f D).submatrix l r
|
| 104 |
+
map_add' _ _ := by
|
| 105 |
+
simp only [selfPartial, Prod.snd_add, Pi.add_apply, smul_add, Finset.sum_add_distrib,
|
| 106 |
+
transpose_add, Matrix.submatrix_add]
|
| 107 |
+
abel
|
| 108 |
+
map_smul' a D := by
|
| 109 |
+
simp only [selfPartial,Prod.smul_snd,Pi.smul_apply,RingHom.id_apply]
|
| 110 |
+
let F (D : Draw p n) := ∑ i, (s i+t i) • D.2.2 i
|
| 111 |
+
have h :
|
| 112 |
+
∑ i, (s i+t i) • (a • D.2.2 i) = a • F D := by
|
| 113 |
+
unfold F; rw [Finset.smul_sum]; exact Finset.sum_congr rfl fun _ _ => smul_comm _ _ _
|
| 114 |
+
rw [h,Matrix.transpose_smul]
|
| 115 |
+
rw [smul_comm (f true),smul_comm (f false) a, ← smul_add]
|
| 116 |
+
rfl
|
| 117 |
+
|
| 118 |
+
/-- Uniform off-diagonal block even in transpose-character case. -/
|
| 119 |
+
theorem obsHalf_surj (s t : Label p.b) (hs : s≠t) {f : Vec Bool} (hf : f≠0) (n : ℕ)
|
| 120 |
+
{l r : Fin (n/2)→Fin n} (hl : Function.Injective l) (hr : Function.Injective r)
|
| 121 |
+
(h : ∀ i j,l i≠r j) : Function.Surjective (obsHalf p s t f n l r) := by
|
| 122 |
+
classical
|
| 123 |
+
intro M
|
| 124 |
+
obtain ⟨a,ha⟩ : ∃ a,s a+t a=1 := by
|
| 125 |
+
obtain ⟨a,ha⟩ := Function.ne_iff.mp hs
|
| 126 |
+
exact ⟨a,(bit_cases _).resolve_left (fun h => ha
|
| 127 |
+
(add_right_cancel (h.trans (char_two _).symm)))⟩
|
| 128 |
+
let m := n/2
|
| 129 |
+
let P := embedMat l
|
| 130 |
+
let Q := embedMat r
|
| 131 |
+
have hi : Function.Injective (fromCols P Q).mulVec := by
|
| 132 |
+
have he : fromCols P Q = embedMat (Sum.elim l r) := by ext i j; cases j <;> rfl
|
| 133 |
+
rw [he]; apply embedMat_inj
|
| 134 |
+
rintro (x|x) (y|y) g
|
| 135 |
+
· rw [hl g]
|
| 136 |
+
· exact (h _ _ g).elim
|
| 137 |
+
· exact (h _ _ g.symm).elim
|
| 138 |
+
· rw [hr g]
|
| 139 |
+
have hv (x y : Mat (Fin m) (Fin m)) :
|
| 140 |
+
∃ A : Mat (Fin n) (Fin n), A.submatrix l r=x ∧ Aᵀ.submatrix l r=y := by
|
| 141 |
+
obtain ⟨A,hA⟩ := prescribe_between hi hi (fromBlocks (0:Mat (Fin m) (Fin m)) x yᵀ
|
| 142 |
+
(0:Mat (Fin m) (Fin m)))
|
| 143 |
+
rw [transpose_fromCols,fromRows_mul,fromRows_mul_fromCols] at hA
|
| 144 |
+
have h1 : Pᵀ*A*Q=x := congrArg Matrix.toBlocks₁₂ hA
|
| 145 |
+
have h2 : Qᵀ*A*P=yᵀ := congrArg Matrix.toBlocks₂₁ hA
|
| 146 |
+
unfold P Q at *
|
| 147 |
+
rw [embedMat_mul,mul_embedMat] at h1 h2
|
| 148 |
+
exact ⟨A,h1,congrArg Matrix.transpose h2⟩
|
| 149 |
+
obtain ⟨x,y,hx⟩ : ∃ x y : Mat (Fin m) (Fin m), f true • x+f false • y=M := by
|
| 150 |
+
rcases bit_cases (f true) with g|g
|
| 151 |
+
· have hg : f false≠0 := fun hg => hf (funext fun i => by cases i <;> assumption)
|
| 152 |
+
exact ⟨0,M,by rw [(bit_cases _).resolve_left hg]; simp⟩
|
| 153 |
+
· exact ⟨M,0,by rw [g]; simp⟩
|
| 154 |
+
obtain ⟨A,h1,h2⟩ := hv x y
|
| 155 |
+
let D : Draw p n := (0,0,Pi.single a A)
|
| 156 |
+
have hE :
|
| 157 |
+
∑ i,(s i+t i) • D.2.2 i=A := by
|
| 158 |
+
rw [Finset.sum_eq_single a]
|
| 159 |
+
· simp [D,ha]
|
| 160 |
+
· intro i _ hi; simp [D,Pi.single_eq_of_ne hi]
|
| 161 |
+
simp
|
| 162 |
+
refine ⟨D,?_⟩
|
| 163 |
+
change (selfPartial (p:=p) s t f D).submatrix l r=M
|
| 164 |
+
unfold selfPartial
|
| 165 |
+
rw [hE]
|
| 166 |
+
change (f true • A + f false • Aᵀ).submatrix l r = _
|
| 167 |
+
change f true • A.submatrix l r + f false • Aᵀ.submatrix l r = M
|
| 168 |
+
rw [h1,h2,hx]
|
| 169 |
+
|
| 170 |
+
end HadwigerCounterexample
|
| 171 |
+
|
| 172 |
+
end
|
| 173 |
+
|
| 174 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMatrices.lean
CHANGED
|
@@ -1,125 +1,125 @@
|
|
| 1 |
-
import Mathlib.Algebra.Field.ZMod
|
| 2 |
-
import Mathlib.LinearAlgebra.Matrix.Rank
|
| 3 |
-
import Mathlib.LinearAlgebra.Matrix.Trace
|
| 4 |
-
import Mathlib.FieldTheory.Finiteness
|
| 5 |
-
import Mathlib.Tactic.Ring
|
| 6 |
-
|
| 7 |
-
namespace OAI
|
| 8 |
-
|
| 9 |
-
/-! # Binary Matrices -/
|
| 10 |
-
|
| 11 |
-
noncomputable section
|
| 12 |
-
namespace HadwigerCounterexample
|
| 13 |
-
|
| 14 |
-
open scoped BigOperators
|
| 15 |
-
open Matrix
|
| 16 |
-
|
| 17 |
-
abbrev F := ZMod 2
|
| 18 |
-
abbrev Vec (I : Type) := I → F
|
| 19 |
-
abbrev Mat (I J : Type) := Matrix I J F
|
| 20 |
-
abbrev Space (V : Type) [AddCommGroup V] [Module F V] := Submodule F V
|
| 21 |
-
|
| 22 |
-
theorem bit_cases (x : F) : x = 0 ∨ x = 1 :=
|
| 23 |
-
(by decide : ∀ x : ZMod 2, x = 0 ∨ x = 1) x
|
| 24 |
-
theorem bit_sq (x : F) : x*x = x := by rcases bit_cases x with e|e <;> rw [e] <;> simp
|
| 25 |
-
theorem char_two {V : Type*} [AddCommGroup V] [Module F V] (x : V) : x+x=0 :=
|
| 26 |
-
ZModModule.add_self x
|
| 27 |
-
theorem odd_smul_bit {n : ℕ} (hn : Odd n) (x : F) : n • x = x := by
|
| 28 |
-
obtain ⟨m,rfl⟩ := hn
|
| 29 |
-
rw [add_smul, one_smul, mul_smul, two_smul,char_two,zero_add]
|
| 30 |
-
|
| 31 |
-
section Linear
|
| 32 |
-
|
| 33 |
-
variable {I J K L R S : Type} [Fintype I] [Fintype J]
|
| 34 |
-
|
| 35 |
-
def evmat (M : Mat I J) (x : Vec I) (y : Vec J) := dotProduct x (M *ᵥ y)
|
| 36 |
-
|
| 37 |
-
def mpair (M : Mat I J) : Mat I J →ₗ[F] F where
|
| 38 |
-
toFun A := ∑ i, ∑ j, M i j * A i j
|
| 39 |
-
map_add' A B := by simp only [Matrix.add_apply,mul_add,Finset.sum_add_distrib]
|
| 40 |
-
map_smul' b A := by
|
| 41 |
-
simp only [Matrix.smul_apply, smul_eq_mul,RingHom.id_apply,Finset.mul_sum,mul_left_comm b]
|
| 42 |
-
|
| 43 |
-
theorem mpair_comm (M A : Mat I J) : mpair M A = mpair A M := by
|
| 44 |
-
dsimp [mpair]
|
| 45 |
-
simp only [mul_comm]
|
| 46 |
-
|
| 47 |
-
theorem mpair_outer (M : Mat I J) (x : Vec I) (y : Vec J) :
|
| 48 |
-
mpair M (vecMulVec x y) = evmat M x y := by
|
| 49 |
-
dsimp [mpair,evmat,mulVec,dotProduct,vecMulVec]
|
| 50 |
-
simp only [Finset.mul_sum,mul_left_comm]
|
| 51 |
-
|
| 52 |
-
/-- Apply frame maps to the two factors of every tensor. -/
|
| 53 |
-
def liftM (P : Mat K I) (Q : Mat L J) : Mat I J →ₗ[F] Mat K L where
|
| 54 |
-
toFun A := P*A*Qᵀ
|
| 55 |
-
map_add' A B := by rw [Matrix.mul_add,Matrix.add_mul]
|
| 56 |
-
map_smul' b A := by simp only [Matrix.mul_smul, Matrix.smul_mul,RingHom.id_apply]
|
| 57 |
-
|
| 58 |
-
theorem liftM_def (P : Mat K I) (Q : Mat L J) (A : Mat I J) :
|
| 59 |
-
liftM P Q A = P*A*Qᵀ := rfl
|
| 60 |
-
|
| 61 |
-
theorem liftM_outer (P : Mat K I) (Q : Mat L J) (x : Vec I) (y : Vec J) :
|
| 62 |
-
liftM P Q (vecMulVec x y) = vecMulVec (P *ᵥ x) (Q *ᵥ y) := by
|
| 63 |
-
rw [liftM_def,mul_vecMulVec,vecMulVec_mul,vecMul_transpose]
|
| 64 |
-
|
| 65 |
-
variable [Fintype K] [Fintype L]
|
| 66 |
-
|
| 67 |
-
theorem liftM_comp (P : Mat K I) (Q : Mat L J) (P' : Mat R K) (Q' : Mat S L)
|
| 68 |
-
(A : Mat I J) :
|
| 69 |
-
liftM P' Q' (liftM P Q A) = liftM (P'*P) (Q'*Q) A := by
|
| 70 |
-
simp only [liftM_def, Matrix.transpose_mul,Matrix.mul_assoc]
|
| 71 |
-
|
| 72 |
-
theorem mpair_liftM (P : Mat K I) (Q : Mat L J) (M : Mat K L) (A : Mat I J) :
|
| 73 |
-
mpair M (liftM P Q A) = mpair (liftM Pᵀ Qᵀ M) A := by
|
| 74 |
-
|
| 75 |
-
simp only [liftM_def, mpair, transpose_transpose, LinearMap.coe_mk,AddHom.coe_mk,
|
| 76 |
-
Matrix.mul_apply, Finset.sum_mul, Finset.mul_sum, transpose_apply]
|
| 77 |
-
|
| 78 |
-
conv_lhs =>
|
| 79 |
-
arg 2
|
| 80 |
-
intro k
|
| 81 |
-
rw [Finset.sum_comm]
|
| 82 |
-
rw [Finset.sum_comm]
|
| 83 |
-
|
| 84 |
-
conv_rhs => rw [Finset.sum_comm]
|
| 85 |
-
refine Finset.sum_congr rfl fun j _ => ?_
|
| 86 |
-
conv_lhs =>
|
| 87 |
-
arg 2
|
| 88 |
-
intro k
|
| 89 |
-
rw [Finset.sum_comm]
|
| 90 |
-
rw [Finset.sum_comm]
|
| 91 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 92 |
-
rw [Finset.sum_comm]
|
| 93 |
-
refine Finset.sum_congr rfl fun l _ => Finset.sum_congr rfl fun k _ => ?_
|
| 94 |
-
ring
|
| 95 |
-
|
| 96 |
-
theorem mat_left_inv [DecidableEq I] {P : Mat K I} (hp : Function.Injective P.mulVec) :
|
| 97 |
-
∃ Q : Mat I K, Q*P = 1 := by
|
| 98 |
-
classical
|
| 99 |
-
have hp' : Function.Injective (P.mulVecLin) := hp
|
| 100 |
-
obtain ⟨f,hf⟩ := P.mulVecLin.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hp')
|
| 101 |
-
refine ⟨LinearMap.toMatrix' f, ?_⟩
|
| 102 |
-
apply Matrix.toLin'.injective
|
| 103 |
-
rw [Matrix.toLin'_mul]
|
| 104 |
-
simp only [Matrix.toLin'_one]
|
| 105 |
-
change ((LinearMap.toMatrix').symm _) ∘ₗ _ = _
|
| 106 |
-
rw [LinearEquiv.symm_apply_apply]
|
| 107 |
-
exact hf
|
| 108 |
-
|
| 109 |
-
theorem liftM_inj {P : Mat K I} {Q : Mat L J} (hp : Function.Injective P.mulVec)
|
| 110 |
-
(hq : Function.Injective Q.mulVec) : Function.Injective (liftM P Q) := by
|
| 111 |
-
classical
|
| 112 |
-
obtain ⟨P', hP⟩ := mat_left_inv hp
|
| 113 |
-
obtain ⟨Q', hQ⟩ := mat_left_inv hq
|
| 114 |
-
intro A B hab
|
| 115 |
-
have hh := congrArg (liftM P' Q') hab
|
| 116 |
-
rw [liftM_comp,liftM_comp,hP,hQ] at hh
|
| 117 |
-
simpa only [liftM_def, Matrix.one_mul, Matrix.transpose_one,
|
| 118 |
-
Matrix.mul_one] using hh
|
| 119 |
-
|
| 120 |
-
end Linear
|
| 121 |
-
end HadwigerCounterexample
|
| 122 |
-
|
| 123 |
-
end
|
| 124 |
-
|
| 125 |
-
end OAI
|
|
|
|
| 1 |
+
import Mathlib.Algebra.Field.ZMod
|
| 2 |
+
import Mathlib.LinearAlgebra.Matrix.Rank
|
| 3 |
+
import Mathlib.LinearAlgebra.Matrix.Trace
|
| 4 |
+
import Mathlib.FieldTheory.Finiteness
|
| 5 |
+
import Mathlib.Tactic.Ring
|
| 6 |
+
|
| 7 |
+
namespace OAI
|
| 8 |
+
|
| 9 |
+
/-! # Binary Matrices -/
|
| 10 |
+
|
| 11 |
+
noncomputable section
|
| 12 |
+
namespace HadwigerCounterexample
|
| 13 |
+
|
| 14 |
+
open scoped BigOperators
|
| 15 |
+
open Matrix
|
| 16 |
+
|
| 17 |
+
abbrev F := ZMod 2
|
| 18 |
+
abbrev Vec (I : Type) := I → F
|
| 19 |
+
abbrev Mat (I J : Type) := Matrix I J F
|
| 20 |
+
abbrev Space (V : Type) [AddCommGroup V] [Module F V] := Submodule F V
|
| 21 |
+
|
| 22 |
+
theorem bit_cases (x : F) : x = 0 ∨ x = 1 :=
|
| 23 |
+
(by decide : ∀ x : ZMod 2, x = 0 ∨ x = 1) x
|
| 24 |
+
theorem bit_sq (x : F) : x*x = x := by rcases bit_cases x with e|e <;> rw [e] <;> simp
|
| 25 |
+
theorem char_two {V : Type*} [AddCommGroup V] [Module F V] (x : V) : x+x=0 :=
|
| 26 |
+
ZModModule.add_self x
|
| 27 |
+
theorem odd_smul_bit {n : ℕ} (hn : Odd n) (x : F) : n • x = x := by
|
| 28 |
+
obtain ⟨m,rfl⟩ := hn
|
| 29 |
+
rw [add_smul, one_smul, mul_smul, two_smul,char_two,zero_add]
|
| 30 |
+
|
| 31 |
+
section Linear
|
| 32 |
+
|
| 33 |
+
variable {I J K L R S : Type} [Fintype I] [Fintype J]
|
| 34 |
+
|
| 35 |
+
def evmat (M : Mat I J) (x : Vec I) (y : Vec J) := dotProduct x (M *ᵥ y)
|
| 36 |
+
|
| 37 |
+
def mpair (M : Mat I J) : Mat I J →ₗ[F] F where
|
| 38 |
+
toFun A := ∑ i, ∑ j, M i j * A i j
|
| 39 |
+
map_add' A B := by simp only [Matrix.add_apply,mul_add,Finset.sum_add_distrib]
|
| 40 |
+
map_smul' b A := by
|
| 41 |
+
simp only [Matrix.smul_apply, smul_eq_mul,RingHom.id_apply,Finset.mul_sum,mul_left_comm b]
|
| 42 |
+
|
| 43 |
+
theorem mpair_comm (M A : Mat I J) : mpair M A = mpair A M := by
|
| 44 |
+
dsimp [mpair]
|
| 45 |
+
simp only [mul_comm]
|
| 46 |
+
|
| 47 |
+
theorem mpair_outer (M : Mat I J) (x : Vec I) (y : Vec J) :
|
| 48 |
+
mpair M (vecMulVec x y) = evmat M x y := by
|
| 49 |
+
dsimp [mpair,evmat,mulVec,dotProduct,vecMulVec]
|
| 50 |
+
simp only [Finset.mul_sum,mul_left_comm]
|
| 51 |
+
|
| 52 |
+
/-- Apply frame maps to the two factors of every tensor. -/
|
| 53 |
+
def liftM (P : Mat K I) (Q : Mat L J) : Mat I J →ₗ[F] Mat K L where
|
| 54 |
+
toFun A := P*A*Qᵀ
|
| 55 |
+
map_add' A B := by rw [Matrix.mul_add,Matrix.add_mul]
|
| 56 |
+
map_smul' b A := by simp only [Matrix.mul_smul, Matrix.smul_mul,RingHom.id_apply]
|
| 57 |
+
|
| 58 |
+
theorem liftM_def (P : Mat K I) (Q : Mat L J) (A : Mat I J) :
|
| 59 |
+
liftM P Q A = P*A*Qᵀ := rfl
|
| 60 |
+
|
| 61 |
+
theorem liftM_outer (P : Mat K I) (Q : Mat L J) (x : Vec I) (y : Vec J) :
|
| 62 |
+
liftM P Q (vecMulVec x y) = vecMulVec (P *ᵥ x) (Q *ᵥ y) := by
|
| 63 |
+
rw [liftM_def,mul_vecMulVec,vecMulVec_mul,vecMul_transpose]
|
| 64 |
+
|
| 65 |
+
variable [Fintype K] [Fintype L]
|
| 66 |
+
|
| 67 |
+
theorem liftM_comp (P : Mat K I) (Q : Mat L J) (P' : Mat R K) (Q' : Mat S L)
|
| 68 |
+
(A : Mat I J) :
|
| 69 |
+
liftM P' Q' (liftM P Q A) = liftM (P'*P) (Q'*Q) A := by
|
| 70 |
+
simp only [liftM_def, Matrix.transpose_mul,Matrix.mul_assoc]
|
| 71 |
+
|
| 72 |
+
theorem mpair_liftM (P : Mat K I) (Q : Mat L J) (M : Mat K L) (A : Mat I J) :
|
| 73 |
+
mpair M (liftM P Q A) = mpair (liftM Pᵀ Qᵀ M) A := by
|
| 74 |
+
|
| 75 |
+
simp only [liftM_def, mpair, transpose_transpose, LinearMap.coe_mk,AddHom.coe_mk,
|
| 76 |
+
Matrix.mul_apply, Finset.sum_mul, Finset.mul_sum, transpose_apply]
|
| 77 |
+
|
| 78 |
+
conv_lhs =>
|
| 79 |
+
arg 2
|
| 80 |
+
intro k
|
| 81 |
+
rw [Finset.sum_comm]
|
| 82 |
+
rw [Finset.sum_comm]
|
| 83 |
+
|
| 84 |
+
conv_rhs => rw [Finset.sum_comm]
|
| 85 |
+
refine Finset.sum_congr rfl fun j _ => ?_
|
| 86 |
+
conv_lhs =>
|
| 87 |
+
arg 2
|
| 88 |
+
intro k
|
| 89 |
+
rw [Finset.sum_comm]
|
| 90 |
+
rw [Finset.sum_comm]
|
| 91 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 92 |
+
rw [Finset.sum_comm]
|
| 93 |
+
refine Finset.sum_congr rfl fun l _ => Finset.sum_congr rfl fun k _ => ?_
|
| 94 |
+
ring
|
| 95 |
+
|
| 96 |
+
theorem mat_left_inv [DecidableEq I] {P : Mat K I} (hp : Function.Injective P.mulVec) :
|
| 97 |
+
∃ Q : Mat I K, Q*P = 1 := by
|
| 98 |
+
classical
|
| 99 |
+
have hp' : Function.Injective (P.mulVecLin) := hp
|
| 100 |
+
obtain ⟨f,hf⟩ := P.mulVecLin.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hp')
|
| 101 |
+
refine ⟨LinearMap.toMatrix' f, ?_⟩
|
| 102 |
+
apply Matrix.toLin'.injective
|
| 103 |
+
rw [Matrix.toLin'_mul]
|
| 104 |
+
simp only [Matrix.toLin'_one]
|
| 105 |
+
change ((LinearMap.toMatrix').symm _) ∘ₗ _ = _
|
| 106 |
+
rw [LinearEquiv.symm_apply_apply]
|
| 107 |
+
exact hf
|
| 108 |
+
|
| 109 |
+
theorem liftM_inj {P : Mat K I} {Q : Mat L J} (hp : Function.Injective P.mulVec)
|
| 110 |
+
(hq : Function.Injective Q.mulVec) : Function.Injective (liftM P Q) := by
|
| 111 |
+
classical
|
| 112 |
+
obtain ⟨P', hP⟩ := mat_left_inv hp
|
| 113 |
+
obtain ⟨Q', hQ⟩ := mat_left_inv hq
|
| 114 |
+
intro A B hab
|
| 115 |
+
have hh := congrArg (liftM P' Q') hab
|
| 116 |
+
rw [liftM_comp,liftM_comp,hP,hQ] at hh
|
| 117 |
+
simpa only [liftM_def, Matrix.one_mul, Matrix.transpose_one,
|
| 118 |
+
Matrix.mul_one] using hh
|
| 119 |
+
|
| 120 |
+
end Linear
|
| 121 |
+
end HadwigerCounterexample
|
| 122 |
+
|
| 123 |
+
end
|
| 124 |
+
|
| 125 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryMixingBounds.lean
CHANGED
|
@@ -1,106 +1,106 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.KeyTestCorrespondence
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Binary Mixing Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Filter Matrix Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
-
namespace Template
|
| 13 |
-
variable (v : Template p I)
|
| 14 |
-
|
| 15 |
-
def kappa := wavelength v.Abbey
|
| 16 |
-
omit [DecidableEq I] in
|
| 17 |
-
theorem kappa_pos : 0<v.kappa := wavelength_pos _
|
| 18 |
-
|
| 19 |
-
def diffsel (v : Template p I) := ∀ i j, i≠j → v.aim i=v.aim j → v.s i≠ v.s j
|
| 20 |
-
|
| 21 |
-
omit [DecidableEq I] in
|
| 22 |
-
theorem choral_live (v : Template p I) (m : Mixer p n) (hm : binaryGood m)
|
| 23 |
-
(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)
|
| 24 |
-
(i : v.Chorus) (c : Vec (v.Abbey i)) (hc : c≠0) :
|
| 25 |
-
let j := v.choral.first i; let l := v.choral.nextP i
|
| 26 |
-
∃ B, (v.f j).keeps (v.t j) B ∧ (v.f l).keeps (v.t l) B ∧
|
| 27 |
-
n≤5*blockRank B (v.s j) (v.s l) (v.chorusM m x i c) := by
|
| 28 |
-
classical
|
| 29 |
-
rcases i with i|i
|
| 30 |
-
· intro j l
|
| 31 |
-
let a : Vec (MBits p) := fun y => c (.inl y)
|
| 32 |
-
let b : Vec Bool := fun y => c (.inr y)
|
| 33 |
-
have hh : v.s j≠v.s l := hv j l (v.choral.diff (.inl i)) i.property.1
|
| 34 |
-
by_cases h : a=0
|
| 35 |
-
· refine ⟨Block.sharp,Flavor.keepSharp ..,Flavor.keepSharp ..,?_⟩
|
| 36 |
-
have he : indexedSum m a=0 := by simp [h,indexedSum]
|
| 37 |
-
rw [chorus_same]
|
| 38 |
-
change n ≤ 5*blockRank _ _ _ (indexedSum m a+selfSum m b)
|
| 39 |
-
rw [he,zero_add]
|
| 40 |
-
have hz : b≠0 := by
|
| 41 |
-
intro hb; apply hc; funext y
|
| 42 |
-
cases y
|
| 43 |
-
next l => exact congr_fun h l
|
| 44 |
-
next l => exact congr_fun hb l
|
| 45 |
-
exact (hm _ _ hh).2 b hz
|
| 46 |
-
refine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩
|
| 47 |
-
rw [chorus_same]; exact (hm _ _ hh).1 a b h
|
| 48 |
-
intro j l; refine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩
|
| 49 |
-
obtain ⟨w,hw,hh⟩ := chorus_cross v m x i c hc
|
| 50 |
-
rw [hh]; exact hx _ _ w hw
|
| 51 |
-
|
| 52 |
-
theorem resonant (v : Template p I) (m : Mixer p n) (hm : binaryGood m)
|
| 53 |
-
(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)
|
| 54 |
-
(w : I → Wgt (Knobs p.g n)) (hw : ∀ i,IsLaw (w i))
|
| 55 |
-
(C : ℝ) (hC : 0 < C) (hc : ∀ i j,w i j ≤ C*unif j)
|
| 56 |
-
(s : Script p I) :
|
| 57 |
-
∀ u : I → Wgt (Knobs p.g n),(∀ i x, |u i x|≤1) →
|
| 58 |
-
|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -
|
| 59 |
-
v.kappa * ∏ i:I,avg (w i) (u i)|≤ C^2*bp (-(n:ℝ)/10) := by
|
| 60 |
-
classical
|
| 61 |
-
refine hear_band v.choral (v.chime m x) (v.lyrics s) w hw _
|
| 62 |
-
(mul_nonneg (sq_nonneg _) (bp_pos _).le) ?_
|
| 63 |
-
intro i c hc' p q hp hq
|
| 64 |
-
obtain ⟨b,hb,hb',hz⟩ := v.choral_live m hm x hx hv i c hc'
|
| 65 |
-
simp_rw [vectorPhase,v.chime_seq]
|
| 66 |
-
exact spark_condition _ (v.chorusM m x i c) _ _ _ _ _ _ b hb hb' p q hp hq
|
| 67 |
-
_ _ (hw _) (hw _) C hC (hc _) (hc _) hz
|
| 68 |
-
|
| 69 |
-
theorem resonance_calendar (v : Template p I) (M : ℕ) (hM : 4≤ M) (C L : ℝ) (hL : 0<L) :
|
| 70 |
-
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ m : Mixer p n, binaryGood m →
|
| 71 |
-
v.diffsel → 2*num (Full p n)<N → ∀ ρ : Wgt (UnitType p n N),
|
| 72 |
-
(∀ i,ρ i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →
|
| 73 |
-
pr ρ (fun i=>¬litFire p i) ≤ bp (-(n:ℝ)*n/8) ∧
|
| 74 |
-
∀ x : UnitType p n N,litFire p x →
|
| 75 |
-
∀ w : I → Wgt (Knobs p.g n),(∀ i,IsLaw (w i)) →
|
| 76 |
-
(∀ i j,w i j≤ L*unif j) →
|
| 77 |
-
∀ (s : Script p I) (u : I→ Wgt (Knobs p.g n)),(∀ i j,|u i j|≤1) →
|
| 78 |
-
|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -
|
| 79 |
-
v.kappa*∏ i:I,avg (w i) (u i)| ≤ bp (-(1/20:ℝ)*n) := by
|
| 80 |
-
filter_upwards [litFire_calendar p C M hM,pay_nat (a:=1/10) (b:=1/20) (L^2) (by norm_num)]
|
| 81 |
-
with n hn ha N m hm hv hN ρ hρ
|
| 82 |
-
refine ⟨hn m hN ρ hρ,fun x hx w hw hh s u hu => ?_⟩
|
| 83 |
-
exact (resonant v m hm x hx hv w hw L hL hh s u hu).trans
|
| 84 |
-
(by rw [show -(↑n:ℝ)/10 = -(1/10:ℝ)*n by ring]; exact ha)
|
| 85 |
-
end Template
|
| 86 |
-
|
| 87 |
-
theorem scanCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : Digest p.g)
|
| 88 |
-
(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : z.feasible l f) :
|
| 89 |
-
∀ x,scopedScan p n l f z x≤(scanPrice p)⁻¹*unif x := by
|
| 90 |
-
intro x
|
| 91 |
-
refine (on_mon (spins_law p n).nz (scanPrice_pos p) (scan_fraction l f z hr hn h)
|
| 92 |
-
x).trans_eq ?_
|
| 93 |
-
rw [spins,← draws_unif]
|
| 94 |
-
|
| 95 |
-
theorem dialCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : F)
|
| 96 |
-
(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : canDial p l f z) :
|
| 97 |
-
∀ x,scopedBit p n l f z x≤(scanPrice p)⁻¹*unif x := by
|
| 98 |
-
intro x
|
| 99 |
-
refine (on_mon (spins_law p n).nz (scanPrice_pos p) (dial_fraction p n _ _ _ hr hn h)
|
| 100 |
-
x).trans_eq ?_
|
| 101 |
-
rw [spins,← draws_unif]
|
| 102 |
-
end HadwigerCounterexample
|
| 103 |
-
|
| 104 |
-
end
|
| 105 |
-
|
| 106 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.KeyTestCorrespondence
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Binary Mixing Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Filter Matrix Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
+
namespace Template
|
| 13 |
+
variable (v : Template p I)
|
| 14 |
+
|
| 15 |
+
def kappa := wavelength v.Abbey
|
| 16 |
+
omit [DecidableEq I] in
|
| 17 |
+
theorem kappa_pos : 0<v.kappa := wavelength_pos _
|
| 18 |
+
|
| 19 |
+
def diffsel (v : Template p I) := ∀ i j, i≠j → v.aim i=v.aim j → v.s i≠ v.s j
|
| 20 |
+
|
| 21 |
+
omit [DecidableEq I] in
|
| 22 |
+
theorem choral_live (v : Template p I) (m : Mixer p n) (hm : binaryGood m)
|
| 23 |
+
(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)
|
| 24 |
+
(i : v.Chorus) (c : Vec (v.Abbey i)) (hc : c≠0) :
|
| 25 |
+
let j := v.choral.first i; let l := v.choral.nextP i
|
| 26 |
+
∃ B, (v.f j).keeps (v.t j) B ∧ (v.f l).keeps (v.t l) B ∧
|
| 27 |
+
n≤5*blockRank B (v.s j) (v.s l) (v.chorusM m x i c) := by
|
| 28 |
+
classical
|
| 29 |
+
rcases i with i|i
|
| 30 |
+
· intro j l
|
| 31 |
+
let a : Vec (MBits p) := fun y => c (.inl y)
|
| 32 |
+
let b : Vec Bool := fun y => c (.inr y)
|
| 33 |
+
have hh : v.s j≠v.s l := hv j l (v.choral.diff (.inl i)) i.property.1
|
| 34 |
+
by_cases h : a=0
|
| 35 |
+
· refine ⟨Block.sharp,Flavor.keepSharp ..,Flavor.keepSharp ..,?_⟩
|
| 36 |
+
have he : indexedSum m a=0 := by simp [h,indexedSum]
|
| 37 |
+
rw [chorus_same]
|
| 38 |
+
change n ≤ 5*blockRank _ _ _ (indexedSum m a+selfSum m b)
|
| 39 |
+
rw [he,zero_add]
|
| 40 |
+
have hz : b≠0 := by
|
| 41 |
+
intro hb; apply hc; funext y
|
| 42 |
+
cases y
|
| 43 |
+
next l => exact congr_fun h l
|
| 44 |
+
next l => exact congr_fun hb l
|
| 45 |
+
exact (hm _ _ hh).2 b hz
|
| 46 |
+
refine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩
|
| 47 |
+
rw [chorus_same]; exact (hm _ _ hh).1 a b h
|
| 48 |
+
intro j l; refine ⟨Block.Z,Flavor.keepZ ..,Flavor.keepZ ..,?_⟩
|
| 49 |
+
obtain ⟨w,hw,hh⟩ := chorus_cross v m x i c hc
|
| 50 |
+
rw [hh]; exact hx _ _ w hw
|
| 51 |
+
|
| 52 |
+
theorem resonant (v : Template p I) (m : Mixer p n) (hm : binaryGood m)
|
| 53 |
+
(x : UnitType p n N) (hx : litFire p x) (hv : v.diffsel)
|
| 54 |
+
(w : I → Wgt (Knobs p.g n)) (hw : ∀ i,IsLaw (w i))
|
| 55 |
+
(C : ℝ) (hC : 0 < C) (hc : ∀ i j,w i j ≤ C*unif j)
|
| 56 |
+
(s : Script p I) :
|
| 57 |
+
∀ u : I → Wgt (Knobs p.g n),(∀ i x, |u i x|≤1) →
|
| 58 |
+
|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -
|
| 59 |
+
v.kappa * ∏ i:I,avg (w i) (u i)|≤ C^2*bp (-(n:ℝ)/10) := by
|
| 60 |
+
classical
|
| 61 |
+
refine hear_band v.choral (v.chime m x) (v.lyrics s) w hw _
|
| 62 |
+
(mul_nonneg (sq_nonneg _) (bp_pos _).le) ?_
|
| 63 |
+
intro i c hc' p q hp hq
|
| 64 |
+
obtain ⟨b,hb,hb',hz⟩ := v.choral_live m hm x hx hv i c hc'
|
| 65 |
+
simp_rw [vectorPhase,v.chime_seq]
|
| 66 |
+
exact spark_condition _ (v.chorusM m x i c) _ _ _ _ _ _ b hb hb' p q hp hq
|
| 67 |
+
_ _ (hw _) (hw _) C hC (hc _) (hc _) hz
|
| 68 |
+
|
| 69 |
+
theorem resonance_calendar (v : Template p I) (M : ℕ) (hM : 4≤ M) (C L : ℝ) (hL : 0<L) :
|
| 70 |
+
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ m : Mixer p n, binaryGood m →
|
| 71 |
+
v.diffsel → 2*num (Full p n)<N → ∀ ρ : Wgt (UnitType p n N),
|
| 72 |
+
(∀ i,ρ i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →
|
| 73 |
+
pr ρ (fun i=>¬litFire p i) ≤ bp (-(n:ℝ)*n/8) ∧
|
| 74 |
+
∀ x : UnitType p n N,litFire p x →
|
| 75 |
+
∀ w : I → Wgt (Knobs p.g n),(∀ i,IsLaw (w i)) →
|
| 76 |
+
(∀ i j,w i j≤ L*unif j) →
|
| 77 |
+
∀ (s : Script p I) (u : I→ Wgt (Knobs p.g n)),(∀ i j,|u i j|≤1) →
|
| 78 |
+
|avg (prodW w) (fun z => ind (v.performs s m x z)*prodW u z) -
|
| 79 |
+
v.kappa*∏ i:I,avg (w i) (u i)| ≤ bp (-(1/20:ℝ)*n) := by
|
| 80 |
+
filter_upwards [litFire_calendar p C M hM,pay_nat (a:=1/10) (b:=1/20) (L^2) (by norm_num)]
|
| 81 |
+
with n hn ha N m hm hv hN ρ hρ
|
| 82 |
+
refine ⟨hn m hN ρ hρ,fun x hx w hw hh s u hu => ?_⟩
|
| 83 |
+
exact (resonant v m hm x hx hv w hw L hL hh s u hu).trans
|
| 84 |
+
(by rw [show -(↑n:ℝ)/10 = -(1/10:ℝ)*n by ring]; exact ha)
|
| 85 |
+
end Template
|
| 86 |
+
|
| 87 |
+
theorem scanCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : Digest p.g)
|
| 88 |
+
(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : z.feasible l f) :
|
| 89 |
+
∀ x,scopedScan p n l f z x≤(scanPrice p)⁻¹*unif x := by
|
| 90 |
+
intro x
|
| 91 |
+
refine (on_mon (spins_law p n).nz (scanPrice_pos p) (scan_fraction l f z hr hn h)
|
| 92 |
+
x).trans_eq ?_
|
| 93 |
+
rw [spins,← draws_unif]
|
| 94 |
+
|
| 95 |
+
theorem dialCap (p : Shape) {n : ℕ} (l : Tag p.g) (z : F)
|
| 96 |
+
(f : Flavor p.g) (hr : 1 ≤ p.r) (hn : 2*p.r≤n) (h : canDial p l f z) :
|
| 97 |
+
∀ x,scopedBit p n l f z x≤(scanPrice p)⁻¹*unif x := by
|
| 98 |
+
intro x
|
| 99 |
+
refine (on_mon (spins_law p n).nz (scanPrice_pos p) (dial_fraction p n _ _ _ hr hn h)
|
| 100 |
+
x).trans_eq ?_
|
| 101 |
+
rw [spins,← draws_unif]
|
| 102 |
+
end HadwigerCounterexample
|
| 103 |
+
|
| 104 |
+
end
|
| 105 |
+
|
| 106 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryPrescriptions.lean
CHANGED
|
@@ -1,265 +1,265 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RealizationConditions
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.MixerConditions
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Binary Prescriptions -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
open Matrix Finset
|
| 13 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]
|
| 14 |
-
|
| 15 |
-
/-- list for a cross edge -/
|
| 16 |
-
def aiming (a b : I → Bool) (i j : Bool) :=
|
| 17 |
-
Finset.univ.filter (fun x => a x=i ∧ b x=j)
|
| 18 |
-
|
| 19 |
-
/-- within-endpoint L/R bit tests. Read only a x=a y, x≠y.
|
| 20 |
-
(tests between ordered points; no double counting since L,R and
|
| 21 |
-
both orientations are in the mixer hypothesis). -/
|
| 22 |
-
abbrev Script (p : Shape) (I : Type) := I → I → Vec (MOne p)
|
| 23 |
-
|
| 24 |
-
namespace Volley
|
| 25 |
-
variable (v : Volley p n I)
|
| 26 |
-
def reads (s : Script p I) (m : Mixer p n) :=
|
| 27 |
-
∀ x y : I,x≠y → v.obj x=v.obj y →
|
| 28 |
-
∀ i : MOne p, s x y i = evmat (orderedM m i) (v.rayAt x) (v.rayAt y)
|
| 29 |
-
end Volley
|
| 30 |
-
|
| 31 |
-
def prescribedB (p : Shape) (t : Tagging p I) (s : Script p I) (x y : I) :=
|
| 32 |
-
∑ i : Fin p.J,∑ e : Comp p.g, ∑ f : Comp p.g, if inc e (t x) ∧ inc f (t y) then
|
| 33 |
-
s x y ((i,e,f),true)*s x y ((i,e,f),false) else 0
|
| 34 |
-
|
| 35 |
-
noncomputable def prescribedT (p : Shape) (t : Tagging p I) (d : Vec I)
|
| 36 |
-
(h : Mat I I) (s : Script p I) (x y : I) : F :=
|
| 37 |
-
@ite _ (x=y) (Classical.propDecidable _) (d x)
|
| 38 |
-
(h x y+(prescribedB p t s x y+prescribedB p t s y x))
|
| 39 |
-
|
| 40 |
-
def fulfills (p : Shape) (t : Tagging p I) (d f : Vec I) (u : Mat I I)
|
| 41 |
-
(s : Script p I) (a b : I → Bool) :=
|
| 42 |
-
∀ (x : I) (j : Bool),
|
| 43 |
-
d x+ (∑ i∈aiming a b (a x) j, prescribedT p t d u s i x) =
|
| 44 |
-
if j=b x then 0 else f x
|
| 45 |
-
|
| 46 |
-
namespace Volley
|
| 47 |
-
variable {v : Volley p n I}
|
| 48 |
-
|
| 49 |
-
omit [Fintype I] in
|
| 50 |
-
private theorem B1_eval {s : Script p I} (t : Tagging p I) (m : Mixer p n)
|
| 51 |
-
(ha : v.reads s m) {x y : I} (hg : x ≠ y) (hh : v.obj x=v.obj y) :
|
| 52 |
-
B1 m (v.atomAt t x) (v.atomAt t y)=prescribedB p t s x y := by
|
| 53 |
-
classical
|
| 54 |
-
change ∑ i : Fin p.J, _ = _
|
| 55 |
-
refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun e _ =>
|
| 56 |
-
Finset.sum_congr rfl fun f _ => ?_
|
| 57 |
-
by_cases he : inc e (t x)
|
| 58 |
-
· by_cases hf : inc f (t y)
|
| 59 |
-
· rw [ite_eq_left ⟨he,hf⟩,ha x y hg hh,ha x y hg hh]
|
| 60 |
-
simp only [atomAt,atom_def,he,hf,ite_true,mom,liftM_outer,pair_outers]
|
| 61 |
-
rfl
|
| 62 |
-
rw [ite_eq_right (show ¬ (_ ∧ _) from fun h => hf h.2)]
|
| 63 |
-
simp only [atomAt,atom_def,hf,ite_false,map_zero]
|
| 64 |
-
rw [ite_eq_right (show ¬ (_ ∧ _) from fun h => he h.1)]
|
| 65 |
-
simp only [atomAt,atom_def,he,ite_false]
|
| 66 |
-
rw [mpair_comm,map_zero]
|
| 67 |
-
|
| 68 |
-
theorem grads_by_script (t : Tagging p I) (m : Mixer p n) (w : Volley p n I)
|
| 69 |
-
(y : UnitType p n N) {d f : Vec I} {u : Mat I I} {s : Script p I}
|
| 70 |
-
(h : fulfills p t d f u s v.obj w.obj) (hs : v.reads s m)
|
| 71 |
-
(hd : ∀ x,role p n (v.atomAt t x)=d x)
|
| 72 |
-
(hf : ∀ x,innerP p y (w.obj x) (w.atomAt t x)=f x)
|
| 73 |
-
(hu : ∀ x y : I,T0 p n (v.atomAt t x) (v.atomAt t y)=u x y) :
|
| 74 |
-
v.attackGrad w t m y := by
|
| 75 |
-
classical
|
| 76 |
-
intro x j
|
| 77 |
-
rw [grad_val,hd,hf,sumAt,map_sum,LinearMap.sum_apply]
|
| 78 |
-
rw [← h x j]; congr 1
|
| 79 |
-
refine Finset.sum_congr rfl fun i hi => ?_
|
| 80 |
-
unfold prescribedT
|
| 81 |
-
split
|
| 82 |
-
· rename_i he
|
| 83 |
-
subst x
|
| 84 |
-
rw [T_diag,hd]
|
| 85 |
-
rename_i he
|
| 86 |
-
have hx := (Finset.mem_filter.mp hi).2.1
|
| 87 |
-
rw [Tsym_val,hu, B1_eval t m hs he hx,B1_eval t m hs (Ne.symm he) hx.symm]
|
| 88 |
-
end Volley
|
| 89 |
-
|
| 90 |
-
/-- Solve symmetric row sums at one endpoint. Couple via opposite
|
| 91 |
-
same-target pmiss/role sum equality. Only the resulting necessary
|
| 92 |
-
(common d+f sum) is used as input here. -/
|
| 93 |
-
private theorem binary_plan (a b : I→Bool) (i : Bool) (d f : Vec I)
|
| 94 |
-
(h : (∑ j∈aiming a b i true,(d j+f j))=∑ j∈aiming a b i false,(d j+f j))
|
| 95 |
-
(h' : ∀ j,(aiming a b i j).Nonempty) :
|
| 96 |
-
∃ M : Mat I I, Mᵀ=M ∧ (∀ x,M x x=d x) ∧ ∀ j : Bool,∀ x∈Finset.univ.filter (fun l => a l=i),
|
| 97 |
-
(∑ l∈aiming a b i j,M l x) = d x+(if j=b x then 0 else f x) := by
|
| 98 |
-
classical
|
| 99 |
-
let S := aiming a b i
|
| 100 |
-
let X : Mat I Bool := Matrix.of (fun i j => if i∈S j then 1 else 0)
|
| 101 |
-
let V : Mat I Bool := Matrix.of (fun x j => d x + (if j=b x then 0 else f x))
|
| 102 |
-
let D := Matrix.diagonal d
|
| 103 |
-
let Y := V+D*X
|
| 104 |
-
obtain ⟨L,hL⟩ := mat_left_inv (P:=X) (by
|
| 105 |
-
intro x y he
|
| 106 |
-
funext j
|
| 107 |
-
obtain ⟨v,hv⟩ := h' j
|
| 108 |
-
have ha := (Finset.mem_filter.mp hv).2
|
| 109 |
-
have heq (x) : (X *ᵥ x) v=x j := by
|
| 110 |
-
unfold X Matrix.mulVec dotProduct
|
| 111 |
-
rw [Finset.sum_eq_single j]
|
| 112 |
-
· simp [hv,S]
|
| 113 |
-
· intro k _ hk; simp [S,aiming,ha,hk.symm]
|
| 114 |
-
simp
|
| 115 |
-
rw [← heq x,← heq y,he])
|
| 116 |
-
let B := Xᵀ*Y
|
| 117 |
-
have hg (j k : Bool) : B j k=if j=k then 0 else (∑ l∈S j,(d l+f l)) := by
|
| 118 |
-
have hi {l : I} (hh : l∈S j) : a l=i ∧ b l=j := (Finset.mem_filter.mp hh).2
|
| 119 |
-
have hy {l : I} (hL : l∈S j) :
|
| 120 |
-
Y l k= (if j=k then 0 else d l+f l) := by
|
| 121 |
-
unfold Y V X; rw [Matrix.add_apply,Matrix.of_apply,Matrix.diagonal_mul,Matrix.of_apply]
|
| 122 |
-
by_cases h : j=k
|
| 123 |
-
· subst k
|
| 124 |
-
simp only [(hi hL).2,hL,ite_true,add_zero,mul_one,char_two]
|
| 125 |
-
have hv : l∉S k := fun hw => h ((hi hL).2.symm.trans (Finset.mem_filter.mp hw).2.2)
|
| 126 |
-
simp [h,Ne.symm h,(hi hL).2,hv]
|
| 127 |
-
have ht (l : I) : X l j*Y l k= if l∈S j then Y l k else 0 := by
|
| 128 |
-
by_cases hv : l∈S j <;> simp [X,hv]
|
| 129 |
-
unfold B; rw [Matrix.mul_apply]
|
| 130 |
-
simp_rw [Matrix.transpose_apply,ht,← Finset.sum_filter]
|
| 131 |
-
rw [show Finset.univ.filter (fun x => x∈S j)=S j from (by simp)]
|
| 132 |
-
by_cases g : j=k
|
| 133 |
-
· rw [ite_eq_left g]
|
| 134 |
-
exact Finset.sum_eq_zero fun l hl => (hy hl).trans (ite_eq_left g)
|
| 135 |
-
rw [ite_eq_right g]
|
| 136 |
-
exact Finset.sum_congr rfl fun l hl => (hy hl).trans (ite_eq_right g)
|
| 137 |
-
have ha (j : Bool) : B j j=0 := by rw [hg,ite_eq_left rfl]
|
| 138 |
-
have hB : Bᵀ=B := by
|
| 139 |
-
ext j k
|
| 140 |
-
rw [Matrix.transpose_apply,hg,hg]
|
| 141 |
-
cases j <;> cases k
|
| 142 |
-
all_goals simp
|
| 143 |
-
· exact h
|
| 144 |
-
exact h.symm
|
| 145 |
-
let W := Lᵀ*B*L
|
| 146 |
-
have hW : Wᵀ=W := by unfold W; simp only [transpose_mul,transpose_transpose,hB,Matrix.mul_assoc]
|
| 147 |
-
have hw (x : I) : W x x=0 := by
|
| 148 |
-
unfold W
|
| 149 |
-
have hf : B false true=B true false := congr_fun (congr_fun hB true) false
|
| 150 |
-
simp only [Matrix.mul_apply,Fintype.sum_bool,Matrix.transpose_apply,ha,mul_zero,zero_add,
|
| 151 |
-
add_zero,hf]
|
| 152 |
-
rw [mul_right_comm (L false x), show L true x * B true false * L false x=
|
| 153 |
-
L false x * L true x * B true false from (by ring),char_two]
|
| 154 |
-
let Z := Y*L+(Y*L)ᵀ + W
|
| 155 |
-
have he : (D+Z)*X=V := by
|
| 156 |
-
have he : (Y*L)ᵀ*X=W*X := by
|
| 157 |
-
unfold W
|
| 158 |
-
have hh : Yᵀ * X=B := by
|
| 159 |
-
have ht : Bᵀ=Yᵀ*X := by unfold B; rw [Matrix.transpose_mul,transpose_transpose]
|
| 160 |
-
rw [← ht,hB]
|
| 161 |
-
rw [Matrix.transpose_mul,Matrix.mul_assoc Lᵀ Yᵀ X,hh,Matrix.mul_assoc _ L X,hL,
|
| 162 |
-
Matrix.mul_one]
|
| 163 |
-
unfold Z
|
| 164 |
-
rw [Matrix.add_mul,Matrix.add_mul,Matrix.add_mul,Matrix.mul_assoc Y L X,hL,
|
| 165 |
-
Matrix.mul_one,he,add_assoc Y,char_two,add_zero]
|
| 166 |
-
unfold Y
|
| 167 |
-
rw [add_left_comm,char_two,add_zero]
|
| 168 |
-
refine ⟨D+Z,?_,?_,fun j x hx => ?_⟩
|
| 169 |
-
· unfold Z D
|
| 170 |
-
simp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]
|
| 171 |
-
ac_rfl
|
| 172 |
-
· intro x
|
| 173 |
-
unfold D Z
|
| 174 |
-
simp only [Matrix.add_apply,Matrix.diagonal_apply_eq,Matrix.transpose_apply,hw,
|
| 175 |
-
char_two,add_zero]
|
| 176 |
-
let Q := D+Z
|
| 177 |
-
have hq : Qᵀ=Q := by
|
| 178 |
-
unfold Q Z D
|
| 179 |
-
simp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]
|
| 180 |
-
ac_rfl
|
| 181 |
-
have h1 : (Q * X) x j= _ := congr_fun (congr_fun he x) j
|
| 182 |
-
rw [Matrix.mul_apply] at h1
|
| 183 |
-
have hy : ∑ l∈S j, Q l x =∑ l, Q x l * X l j := by
|
| 184 |
-
conv_rhs => unfold X
|
| 185 |
-
simp only [Matrix.of_apply,mul_ite,mul_one,mul_zero, ←Finset.sum_filter]
|
| 186 |
-
rw [show Finset.univ.filter (fun x => x∈ S j)=S j from (by simp)]
|
| 187 |
-
exact Finset.sum_congr rfl fun l _ => congr_fun (congr_fun hq x) l
|
| 188 |
-
exact hy.trans h1
|
| 189 |
-
|
| 190 |
-
omit [Fintype I] in
|
| 191 |
-
private theorem scripted (p : Shape) (t : Tagging p I) (g : I→I→F)
|
| 192 |
-
(h : 2≤p.g) (hJ : 1 ≤ p.J) :
|
| 193 |
-
∃ s : Script p I,∀ x y,prescribedB p t s x y=g x y := by
|
| 194 |
-
classical
|
| 195 |
-
have hh (x : I) : ∃ i : Comp p.g,inc i (t x) := by
|
| 196 |
-
have he := card_star (t x)
|
| 197 |
-
have hi : Nonempty (TagStar (t x)) := Fintype.card_pos_iff.mp (by omega)
|
| 198 |
-
obtain ⟨⟨i,h⟩⟩ := hi
|
| 199 |
-
exact ⟨i,h⟩
|
| 200 |
-
choose q hq using hh
|
| 201 |
-
let i0 : Fin p.J := ⟨0,hJ⟩
|
| 202 |
-
let s : Script p I := fun x y i =>
|
| 203 |
-
if i.1=(i0,q x,q y) then if i.2 then g x y else 1 else 0
|
| 204 |
-
refine ⟨s,fun x y => ?_⟩
|
| 205 |
-
unfold prescribedB
|
| 206 |
-
rw [Finset.sum_eq_single i0]
|
| 207 |
-
· rw [Finset.sum_eq_single (q x)]
|
| 208 |
-
· rw [Finset.sum_eq_single (q y)]
|
| 209 |
-
· simp [s,hq]
|
| 210 |
-
· intro i _ hi; simp [s,hi]
|
| 211 |
-
simp
|
| 212 |
-
· intro i _ hi; simp [s,hi]
|
| 213 |
-
simp
|
| 214 |
-
· intro i _ hi; simp [s,hi]
|
| 215 |
-
simp
|
| 216 |
-
|
| 217 |
-
set_option maxHeartbeats 600000 in
|
| 218 |
-
theorem choose_script (p : Shape) (t : Tagging p I) (a b : I→Bool)
|
| 219 |
-
(d : Vec I)
|
| 220 |
-
(f : Vec I)
|
| 221 |
-
(d' : Vec I)
|
| 222 |
-
(h : ∀ i : Bool,(∑ x∈aiming a b i true,(d' x+f x)) =
|
| 223 |
-
∑ x∈aiming a b i false,(d' x+f x))
|
| 224 |
-
(ha : ∀ i j : Bool, ∑ x∈aiming a b i j,(d x+d' x)=1)
|
| 225 |
-
(hc : ∀ i j : Bool,(aiming a b i j).Nonempty)
|
| 226 |
-
(u : Mat I I) (hu : uᵀ=u)
|
| 227 |
-
(hg : 2≤p.g) (hi : 1≤p.J) :
|
| 228 |
-
∃ s : Script p I, fulfills p t d f u s a b := by
|
| 229 |
-
classical
|
| 230 |
-
have hh (i j : Bool) :
|
| 231 |
-
(∑ x∈aiming a b i j,(d x+f x))=1+ ∑ x∈aiming a b i j,(d' x+f x) := by
|
| 232 |
-
rw [←ha,← Finset.sum_add_distrib]
|
| 233 |
-
refine Finset.sum_congr rfl fun x _ => ?_
|
| 234 |
-
rw [add_assoc,←add_assoc (d' x),char_two,zero_add]
|
| 235 |
-
choose M hM hD hA using fun i : Bool => binary_plan a b i d f (by rw [hh,hh,h]) (hc i)
|
| 236 |
-
let F' := Fintype.equivFin I
|
| 237 |
-
let g (x y : I) := if F' x < F' y then M (a x) x y+u x y else 0
|
| 238 |
-
obtain ⟨s,hs⟩ := scripted p t g hg hi
|
| 239 |
-
have hf (x y : I) (h : a x=a y) : prescribedT p t d u s x y=M (a x) x y := by
|
| 240 |
-
unfold prescribedT
|
| 241 |
-
split
|
| 242 |
-
· rename_i he
|
| 243 |
-
subst y
|
| 244 |
-
exact (hD _ _).symm
|
| 245 |
-
rename_i he
|
| 246 |
-
rw [hs x y, hs y x]
|
| 247 |
-
rcases lt_or_gt_of_ne (show F' x ≠ F' y from fun h => he (F'.injective h)) with e|e
|
| 248 |
-
· simp only [g, ite_eq_left e,ite_eq_right (not_lt.mpr e.le),add_zero]
|
| 249 |
-
rw [add_left_comm,char_two,add_zero]
|
| 250 |
-
simp only [g,ite_eq_left e,ite_eq_right (not_lt.mpr e.le),zero_add]
|
| 251 |
-
rw [←h,show u y x=u x y from congr_fun (congr_fun hu x) y,
|
| 252 |
-
show M (a x) y x=M (a x) x y from congr_fun (congr_fun (hM (a x)) x) y]
|
| 253 |
-
rw [add_left_comm,char_two,add_zero]
|
| 254 |
-
refine ⟨s,fun x j => ?_⟩
|
| 255 |
-
let S := aiming a b (a x) j
|
| 256 |
-
have he : ∑ i∈S,prescribedT p t d u s i x=∑ i∈S,M (a x) i x :=
|
| 257 |
-
Finset.sum_congr rfl fun i hi => by
|
| 258 |
-
have hm : a i=a x := (Finset.mem_filter.mp hi).2.1
|
| 259 |
-
rw [hf i x hm,hm]
|
| 260 |
-
rw [he,hA (a x) j x (by simp), ← add_assoc, char_two,zero_add]
|
| 261 |
-
end HadwigerCounterexample
|
| 262 |
-
|
| 263 |
-
end
|
| 264 |
-
|
| 265 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RealizationConditions
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.MixerConditions
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Binary Prescriptions -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
open Matrix Finset
|
| 13 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]
|
| 14 |
+
|
| 15 |
+
/-- list for a cross edge -/
|
| 16 |
+
def aiming (a b : I → Bool) (i j : Bool) :=
|
| 17 |
+
Finset.univ.filter (fun x => a x=i ∧ b x=j)
|
| 18 |
+
|
| 19 |
+
/-- within-endpoint L/R bit tests. Read only a x=a y, x≠y.
|
| 20 |
+
(tests between ordered points; no double counting since L,R and
|
| 21 |
+
both orientations are in the mixer hypothesis). -/
|
| 22 |
+
abbrev Script (p : Shape) (I : Type) := I → I → Vec (MOne p)
|
| 23 |
+
|
| 24 |
+
namespace Volley
|
| 25 |
+
variable (v : Volley p n I)
|
| 26 |
+
def reads (s : Script p I) (m : Mixer p n) :=
|
| 27 |
+
∀ x y : I,x≠y → v.obj x=v.obj y →
|
| 28 |
+
∀ i : MOne p, s x y i = evmat (orderedM m i) (v.rayAt x) (v.rayAt y)
|
| 29 |
+
end Volley
|
| 30 |
+
|
| 31 |
+
def prescribedB (p : Shape) (t : Tagging p I) (s : Script p I) (x y : I) :=
|
| 32 |
+
∑ i : Fin p.J,∑ e : Comp p.g, ∑ f : Comp p.g, if inc e (t x) ∧ inc f (t y) then
|
| 33 |
+
s x y ((i,e,f),true)*s x y ((i,e,f),false) else 0
|
| 34 |
+
|
| 35 |
+
noncomputable def prescribedT (p : Shape) (t : Tagging p I) (d : Vec I)
|
| 36 |
+
(h : Mat I I) (s : Script p I) (x y : I) : F :=
|
| 37 |
+
@ite _ (x=y) (Classical.propDecidable _) (d x)
|
| 38 |
+
(h x y+(prescribedB p t s x y+prescribedB p t s y x))
|
| 39 |
+
|
| 40 |
+
def fulfills (p : Shape) (t : Tagging p I) (d f : Vec I) (u : Mat I I)
|
| 41 |
+
(s : Script p I) (a b : I → Bool) :=
|
| 42 |
+
∀ (x : I) (j : Bool),
|
| 43 |
+
d x+ (∑ i∈aiming a b (a x) j, prescribedT p t d u s i x) =
|
| 44 |
+
if j=b x then 0 else f x
|
| 45 |
+
|
| 46 |
+
namespace Volley
|
| 47 |
+
variable {v : Volley p n I}
|
| 48 |
+
|
| 49 |
+
omit [Fintype I] in
|
| 50 |
+
private theorem B1_eval {s : Script p I} (t : Tagging p I) (m : Mixer p n)
|
| 51 |
+
(ha : v.reads s m) {x y : I} (hg : x ≠ y) (hh : v.obj x=v.obj y) :
|
| 52 |
+
B1 m (v.atomAt t x) (v.atomAt t y)=prescribedB p t s x y := by
|
| 53 |
+
classical
|
| 54 |
+
change ∑ i : Fin p.J, _ = _
|
| 55 |
+
refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun e _ =>
|
| 56 |
+
Finset.sum_congr rfl fun f _ => ?_
|
| 57 |
+
by_cases he : inc e (t x)
|
| 58 |
+
· by_cases hf : inc f (t y)
|
| 59 |
+
· rw [ite_eq_left ⟨he,hf⟩,ha x y hg hh,ha x y hg hh]
|
| 60 |
+
simp only [atomAt,atom_def,he,hf,ite_true,mom,liftM_outer,pair_outers]
|
| 61 |
+
rfl
|
| 62 |
+
rw [ite_eq_right (show ¬ (_ ∧ _) from fun h => hf h.2)]
|
| 63 |
+
simp only [atomAt,atom_def,hf,ite_false,map_zero]
|
| 64 |
+
rw [ite_eq_right (show ¬ (_ ∧ _) from fun h => he h.1)]
|
| 65 |
+
simp only [atomAt,atom_def,he,ite_false]
|
| 66 |
+
rw [mpair_comm,map_zero]
|
| 67 |
+
|
| 68 |
+
theorem grads_by_script (t : Tagging p I) (m : Mixer p n) (w : Volley p n I)
|
| 69 |
+
(y : UnitType p n N) {d f : Vec I} {u : Mat I I} {s : Script p I}
|
| 70 |
+
(h : fulfills p t d f u s v.obj w.obj) (hs : v.reads s m)
|
| 71 |
+
(hd : ∀ x,role p n (v.atomAt t x)=d x)
|
| 72 |
+
(hf : ∀ x,innerP p y (w.obj x) (w.atomAt t x)=f x)
|
| 73 |
+
(hu : ∀ x y : I,T0 p n (v.atomAt t x) (v.atomAt t y)=u x y) :
|
| 74 |
+
v.attackGrad w t m y := by
|
| 75 |
+
classical
|
| 76 |
+
intro x j
|
| 77 |
+
rw [grad_val,hd,hf,sumAt,map_sum,LinearMap.sum_apply]
|
| 78 |
+
rw [← h x j]; congr 1
|
| 79 |
+
refine Finset.sum_congr rfl fun i hi => ?_
|
| 80 |
+
unfold prescribedT
|
| 81 |
+
split
|
| 82 |
+
· rename_i he
|
| 83 |
+
subst x
|
| 84 |
+
rw [T_diag,hd]
|
| 85 |
+
rename_i he
|
| 86 |
+
have hx := (Finset.mem_filter.mp hi).2.1
|
| 87 |
+
rw [Tsym_val,hu, B1_eval t m hs he hx,B1_eval t m hs (Ne.symm he) hx.symm]
|
| 88 |
+
end Volley
|
| 89 |
+
|
| 90 |
+
/-- Solve symmetric row sums at one endpoint. Couple via opposite
|
| 91 |
+
same-target pmiss/role sum equality. Only the resulting necessary
|
| 92 |
+
(common d+f sum) is used as input here. -/
|
| 93 |
+
private theorem binary_plan (a b : I→Bool) (i : Bool) (d f : Vec I)
|
| 94 |
+
(h : (∑ j∈aiming a b i true,(d j+f j))=∑ j∈aiming a b i false,(d j+f j))
|
| 95 |
+
(h' : ∀ j,(aiming a b i j).Nonempty) :
|
| 96 |
+
∃ M : Mat I I, Mᵀ=M ∧ (∀ x,M x x=d x) ∧ ∀ j : Bool,∀ x∈Finset.univ.filter (fun l => a l=i),
|
| 97 |
+
(∑ l∈aiming a b i j,M l x) = d x+(if j=b x then 0 else f x) := by
|
| 98 |
+
classical
|
| 99 |
+
let S := aiming a b i
|
| 100 |
+
let X : Mat I Bool := Matrix.of (fun i j => if i∈S j then 1 else 0)
|
| 101 |
+
let V : Mat I Bool := Matrix.of (fun x j => d x + (if j=b x then 0 else f x))
|
| 102 |
+
let D := Matrix.diagonal d
|
| 103 |
+
let Y := V+D*X
|
| 104 |
+
obtain ⟨L,hL⟩ := mat_left_inv (P:=X) (by
|
| 105 |
+
intro x y he
|
| 106 |
+
funext j
|
| 107 |
+
obtain ⟨v,hv⟩ := h' j
|
| 108 |
+
have ha := (Finset.mem_filter.mp hv).2
|
| 109 |
+
have heq (x) : (X *ᵥ x) v=x j := by
|
| 110 |
+
unfold X Matrix.mulVec dotProduct
|
| 111 |
+
rw [Finset.sum_eq_single j]
|
| 112 |
+
· simp [hv,S]
|
| 113 |
+
· intro k _ hk; simp [S,aiming,ha,hk.symm]
|
| 114 |
+
simp
|
| 115 |
+
rw [← heq x,← heq y,he])
|
| 116 |
+
let B := Xᵀ*Y
|
| 117 |
+
have hg (j k : Bool) : B j k=if j=k then 0 else (∑ l∈S j,(d l+f l)) := by
|
| 118 |
+
have hi {l : I} (hh : l∈S j) : a l=i ∧ b l=j := (Finset.mem_filter.mp hh).2
|
| 119 |
+
have hy {l : I} (hL : l∈S j) :
|
| 120 |
+
Y l k= (if j=k then 0 else d l+f l) := by
|
| 121 |
+
unfold Y V X; rw [Matrix.add_apply,Matrix.of_apply,Matrix.diagonal_mul,Matrix.of_apply]
|
| 122 |
+
by_cases h : j=k
|
| 123 |
+
· subst k
|
| 124 |
+
simp only [(hi hL).2,hL,ite_true,add_zero,mul_one,char_two]
|
| 125 |
+
have hv : l∉S k := fun hw => h ((hi hL).2.symm.trans (Finset.mem_filter.mp hw).2.2)
|
| 126 |
+
simp [h,Ne.symm h,(hi hL).2,hv]
|
| 127 |
+
have ht (l : I) : X l j*Y l k= if l∈S j then Y l k else 0 := by
|
| 128 |
+
by_cases hv : l∈S j <;> simp [X,hv]
|
| 129 |
+
unfold B; rw [Matrix.mul_apply]
|
| 130 |
+
simp_rw [Matrix.transpose_apply,ht,← Finset.sum_filter]
|
| 131 |
+
rw [show Finset.univ.filter (fun x => x∈S j)=S j from (by simp)]
|
| 132 |
+
by_cases g : j=k
|
| 133 |
+
· rw [ite_eq_left g]
|
| 134 |
+
exact Finset.sum_eq_zero fun l hl => (hy hl).trans (ite_eq_left g)
|
| 135 |
+
rw [ite_eq_right g]
|
| 136 |
+
exact Finset.sum_congr rfl fun l hl => (hy hl).trans (ite_eq_right g)
|
| 137 |
+
have ha (j : Bool) : B j j=0 := by rw [hg,ite_eq_left rfl]
|
| 138 |
+
have hB : Bᵀ=B := by
|
| 139 |
+
ext j k
|
| 140 |
+
rw [Matrix.transpose_apply,hg,hg]
|
| 141 |
+
cases j <;> cases k
|
| 142 |
+
all_goals simp
|
| 143 |
+
· exact h
|
| 144 |
+
exact h.symm
|
| 145 |
+
let W := Lᵀ*B*L
|
| 146 |
+
have hW : Wᵀ=W := by unfold W; simp only [transpose_mul,transpose_transpose,hB,Matrix.mul_assoc]
|
| 147 |
+
have hw (x : I) : W x x=0 := by
|
| 148 |
+
unfold W
|
| 149 |
+
have hf : B false true=B true false := congr_fun (congr_fun hB true) false
|
| 150 |
+
simp only [Matrix.mul_apply,Fintype.sum_bool,Matrix.transpose_apply,ha,mul_zero,zero_add,
|
| 151 |
+
add_zero,hf]
|
| 152 |
+
rw [mul_right_comm (L false x), show L true x * B true false * L false x=
|
| 153 |
+
L false x * L true x * B true false from (by ring),char_two]
|
| 154 |
+
let Z := Y*L+(Y*L)ᵀ + W
|
| 155 |
+
have he : (D+Z)*X=V := by
|
| 156 |
+
have he : (Y*L)ᵀ*X=W*X := by
|
| 157 |
+
unfold W
|
| 158 |
+
have hh : Yᵀ * X=B := by
|
| 159 |
+
have ht : Bᵀ=Yᵀ*X := by unfold B; rw [Matrix.transpose_mul,transpose_transpose]
|
| 160 |
+
rw [← ht,hB]
|
| 161 |
+
rw [Matrix.transpose_mul,Matrix.mul_assoc Lᵀ Yᵀ X,hh,Matrix.mul_assoc _ L X,hL,
|
| 162 |
+
Matrix.mul_one]
|
| 163 |
+
unfold Z
|
| 164 |
+
rw [Matrix.add_mul,Matrix.add_mul,Matrix.add_mul,Matrix.mul_assoc Y L X,hL,
|
| 165 |
+
Matrix.mul_one,he,add_assoc Y,char_two,add_zero]
|
| 166 |
+
unfold Y
|
| 167 |
+
rw [add_left_comm,char_two,add_zero]
|
| 168 |
+
refine ⟨D+Z,?_,?_,fun j x hx => ?_⟩
|
| 169 |
+
· unfold Z D
|
| 170 |
+
simp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]
|
| 171 |
+
ac_rfl
|
| 172 |
+
· intro x
|
| 173 |
+
unfold D Z
|
| 174 |
+
simp only [Matrix.add_apply,Matrix.diagonal_apply_eq,Matrix.transpose_apply,hw,
|
| 175 |
+
char_two,add_zero]
|
| 176 |
+
let Q := D+Z
|
| 177 |
+
have hq : Qᵀ=Q := by
|
| 178 |
+
unfold Q Z D
|
| 179 |
+
simp only [transpose_add,Matrix.diagonal_transpose,transpose_transpose,hW]
|
| 180 |
+
ac_rfl
|
| 181 |
+
have h1 : (Q * X) x j= _ := congr_fun (congr_fun he x) j
|
| 182 |
+
rw [Matrix.mul_apply] at h1
|
| 183 |
+
have hy : ∑ l∈S j, Q l x =∑ l, Q x l * X l j := by
|
| 184 |
+
conv_rhs => unfold X
|
| 185 |
+
simp only [Matrix.of_apply,mul_ite,mul_one,mul_zero, ←Finset.sum_filter]
|
| 186 |
+
rw [show Finset.univ.filter (fun x => x∈ S j)=S j from (by simp)]
|
| 187 |
+
exact Finset.sum_congr rfl fun l _ => congr_fun (congr_fun hq x) l
|
| 188 |
+
exact hy.trans h1
|
| 189 |
+
|
| 190 |
+
omit [Fintype I] in
|
| 191 |
+
private theorem scripted (p : Shape) (t : Tagging p I) (g : I→I→F)
|
| 192 |
+
(h : 2≤p.g) (hJ : 1 ≤ p.J) :
|
| 193 |
+
∃ s : Script p I,∀ x y,prescribedB p t s x y=g x y := by
|
| 194 |
+
classical
|
| 195 |
+
have hh (x : I) : ∃ i : Comp p.g,inc i (t x) := by
|
| 196 |
+
have he := card_star (t x)
|
| 197 |
+
have hi : Nonempty (TagStar (t x)) := Fintype.card_pos_iff.mp (by omega)
|
| 198 |
+
obtain ⟨⟨i,h⟩⟩ := hi
|
| 199 |
+
exact ⟨i,h⟩
|
| 200 |
+
choose q hq using hh
|
| 201 |
+
let i0 : Fin p.J := ⟨0,hJ⟩
|
| 202 |
+
let s : Script p I := fun x y i =>
|
| 203 |
+
if i.1=(i0,q x,q y) then if i.2 then g x y else 1 else 0
|
| 204 |
+
refine ⟨s,fun x y => ?_⟩
|
| 205 |
+
unfold prescribedB
|
| 206 |
+
rw [Finset.sum_eq_single i0]
|
| 207 |
+
· rw [Finset.sum_eq_single (q x)]
|
| 208 |
+
· rw [Finset.sum_eq_single (q y)]
|
| 209 |
+
· simp [s,hq]
|
| 210 |
+
· intro i _ hi; simp [s,hi]
|
| 211 |
+
simp
|
| 212 |
+
· intro i _ hi; simp [s,hi]
|
| 213 |
+
simp
|
| 214 |
+
· intro i _ hi; simp [s,hi]
|
| 215 |
+
simp
|
| 216 |
+
|
| 217 |
+
set_option maxHeartbeats 600000 in
|
| 218 |
+
theorem choose_script (p : Shape) (t : Tagging p I) (a b : I→Bool)
|
| 219 |
+
(d : Vec I)
|
| 220 |
+
(f : Vec I)
|
| 221 |
+
(d' : Vec I)
|
| 222 |
+
(h : ∀ i : Bool,(∑ x∈aiming a b i true,(d' x+f x)) =
|
| 223 |
+
∑ x∈aiming a b i false,(d' x+f x))
|
| 224 |
+
(ha : ∀ i j : Bool, ∑ x∈aiming a b i j,(d x+d' x)=1)
|
| 225 |
+
(hc : ∀ i j : Bool,(aiming a b i j).Nonempty)
|
| 226 |
+
(u : Mat I I) (hu : uᵀ=u)
|
| 227 |
+
(hg : 2≤p.g) (hi : 1≤p.J) :
|
| 228 |
+
∃ s : Script p I, fulfills p t d f u s a b := by
|
| 229 |
+
classical
|
| 230 |
+
have hh (i j : Bool) :
|
| 231 |
+
(∑ x∈aiming a b i j,(d x+f x))=1+ ∑ x∈aiming a b i j,(d' x+f x) := by
|
| 232 |
+
rw [←ha,← Finset.sum_add_distrib]
|
| 233 |
+
refine Finset.sum_congr rfl fun x _ => ?_
|
| 234 |
+
rw [add_assoc,←add_assoc (d' x),char_two,zero_add]
|
| 235 |
+
choose M hM hD hA using fun i : Bool => binary_plan a b i d f (by rw [hh,hh,h]) (hc i)
|
| 236 |
+
let F' := Fintype.equivFin I
|
| 237 |
+
let g (x y : I) := if F' x < F' y then M (a x) x y+u x y else 0
|
| 238 |
+
obtain ⟨s,hs⟩ := scripted p t g hg hi
|
| 239 |
+
have hf (x y : I) (h : a x=a y) : prescribedT p t d u s x y=M (a x) x y := by
|
| 240 |
+
unfold prescribedT
|
| 241 |
+
split
|
| 242 |
+
· rename_i he
|
| 243 |
+
subst y
|
| 244 |
+
exact (hD _ _).symm
|
| 245 |
+
rename_i he
|
| 246 |
+
rw [hs x y, hs y x]
|
| 247 |
+
rcases lt_or_gt_of_ne (show F' x ≠ F' y from fun h => he (F'.injective h)) with e|e
|
| 248 |
+
· simp only [g, ite_eq_left e,ite_eq_right (not_lt.mpr e.le),add_zero]
|
| 249 |
+
rw [add_left_comm,char_two,add_zero]
|
| 250 |
+
simp only [g,ite_eq_left e,ite_eq_right (not_lt.mpr e.le),zero_add]
|
| 251 |
+
rw [←h,show u y x=u x y from congr_fun (congr_fun hu x) y,
|
| 252 |
+
show M (a x) y x=M (a x) x y from congr_fun (congr_fun (hM (a x)) x) y]
|
| 253 |
+
rw [add_left_comm,char_two,add_zero]
|
| 254 |
+
refine ⟨s,fun x j => ?_⟩
|
| 255 |
+
let S := aiming a b (a x) j
|
| 256 |
+
have he : ∑ i∈S,prescribedT p t d u s i x=∑ i∈S,M (a x) i x :=
|
| 257 |
+
Finset.sum_congr rfl fun i hi => by
|
| 258 |
+
have hm : a i=a x := (Finset.mem_filter.mp hi).2.1
|
| 259 |
+
rw [hf i x hm,hm]
|
| 260 |
+
rw [he,hA (a x) j x (by simp), ← add_assoc, char_two,zero_add]
|
| 261 |
+
end HadwigerCounterexample
|
| 262 |
+
|
| 263 |
+
end
|
| 264 |
+
|
| 265 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BinaryStatusComparison.lean
CHANGED
|
@@ -1,143 +1,143 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteOptionLabels
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Binary Status Comparison -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Filter Function Submodule Module LinearMap
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B J H : Type} [Fintype A] [Fintype B] [Fintype J]
|
| 12 |
-
|
| 13 |
-
theorem disagreement_bound (w : Wgt A) (hw : ∀ x,0 ≤ w x) (f g h:A→ H) :
|
| 14 |
-
pr w (fun i=> f i≠ h i) ≤ pr w (fun i=>f i≠ g i) + pr w (fun i=>g i≠h i) :=
|
| 15 |
-
let p (i:A) := f i≠g i∨g i≠h i
|
| 16 |
-
((pr_mono hw fun i h=>show p i from Classical.byContradiction (fun hi => h (Eq.trans
|
| 17 |
-
(not_not.mp (mt Or.inl hi)) (not_not.mp (mt Or.inr hi))))).trans (pr_or_le hw))
|
| 18 |
-
|
| 19 |
-
def majority (w : Wgt A) (f : A→F) :=
|
| 20 |
-
if 1/2≤ pr w (fun i=>f i=0) then (0:F) else 1
|
| 21 |
-
|
| 22 |
-
theorem majority_bound (w : Wgt A) (hw:IsLaw w) (f : A→F) :
|
| 23 |
-
1/2 ≤ pr w (fun i=> f i= majority w f) := by
|
| 24 |
-
classical
|
| 25 |
-
unfold majority
|
| 26 |
-
split
|
| 27 |
-
next h => exact h
|
| 28 |
-
next h =>
|
| 29 |
-
have hi i : f i=1 ↔ ¬f i=0 :=
|
| 30 |
-
⟨fun hh=>by rw [hh]; exact one_ne_zero,fun hh=>(bit_cases _).resolve_left hh⟩
|
| 31 |
-
simp_rw [hi,pr_not,hw.total]
|
| 32 |
-
exact le_of_lt (by linarith only [h])
|
| 33 |
-
|
| 34 |
-
theorem majority_charge (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)
|
| 35 |
-
(f:A→F) (g:B→F) :
|
| 36 |
-
pr p (fun i=> f i≠majority q g)≤2 * pr (pairW p q) (fun i=> f i.1≠g i.2) := by
|
| 37 |
-
classical
|
| 38 |
-
let Q i:= g i=majority q g; let P i:= f i≠majority q g
|
| 39 |
-
let v:= pairW p q
|
| 40 |
-
have hm (z:A×B) (h:P z.1∧Q z.2): f z.1≠g z.2 := h.2 ▸ h.1
|
| 41 |
-
have hh : pr p P*pr q Q ≤ pr v (fun i=>f i.1≠g i.2) :=
|
| 42 |
-
(pairW_pr ..).symm.le.trans (pr_mono (pairW_law hp hq).nz hm)
|
| 43 |
-
have hx:=majority_bound q hq g
|
| 44 |
-
have hh' := mul_le_mul_of_nonneg_left hx (pr_nonneg (p:=P) hp.nz)
|
| 45 |
-
change _* (1/2) ≤ _*pr q Q at hh'
|
| 46 |
-
change pr p P≤2*pr v _
|
| 47 |
-
linarith only [hh,hh']
|
| 48 |
-
|
| 49 |
-
theorem reflect_cost (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)
|
| 50 |
-
(f:A→H) (g:B→H) (k:H) :
|
| 51 |
-
pr q (fun i=>g i≠k)≤ pr (pairW p q) (fun i=>f i.1≠g i.2)+pr p (fun i=>f i≠k) := by
|
| 52 |
-
let w:=pairW p q
|
| 53 |
-
let t i:= g i≠k; let s i:= f i≠k
|
| 54 |
-
have hi : pr q t=pr w (fun i=> t i.2) := by simpa [hp.total] using
|
| 55 |
-
(pairW_pr p q (fun _=>True) t).symm
|
| 56 |
-
have hj : pr p s=pr w (fun i=>s i.1) := by simpa [hq.total] using
|
| 57 |
-
(pairW_pr p q s (fun _=>True)).symm
|
| 58 |
-
let P (i:A×B):= f i.1 ≠ g i.2
|
| 59 |
-
rw [hi,hj]
|
| 60 |
-
have hh (i:A×B) (h:t i.2): P i∨ s i.1 := by
|
| 61 |
-
by_cases he:P i
|
| 62 |
-
· exact Or.inl he
|
| 63 |
-
exact Or.inr (fun hc=> h ((not_not.mp he).symm.trans hc))
|
| 64 |
-
exact (pr_mono (pairW_law hp hq).nz hh).trans (pr_or_le (pairW_law hp hq).nz)
|
| 65 |
-
|
| 66 |
-
namespace StatusAnalysis
|
| 67 |
-
namespace DualAnalysis
|
| 68 |
-
variable {p:Shape} {d e: Rates} {r K:ℕ}
|
| 69 |
-
abbrev Pulsar (p:Shape) (r:ℕ):= Tag p.g → F → Fin r→F
|
| 70 |
-
variable (u:Terrain p r) (s:Gazette p r d) (t:Gazette p r e)
|
| 71 |
-
|
| 72 |
-
def shot (i:Nodes) (x:Appearance p) (a:RhymeSet (d i)) (f:Pulsar p r) :=
|
| 73 |
-
avg (u x.l x.q) (fun j=>pr (s i x j) (fun v=> a.soot x v ≠f x.l x.q j))
|
| 74 |
-
def praise (u:Terrain p r) (s:Gazette p r d) (i:Nodes)
|
| 75 |
-
(A:Finset (Label p.b)) (a:RhymeSet (d i)) (f:Pulsar p r) (ε:ℝ) :=
|
| 76 |
-
∀ x:Appearance p,x.s∉A →x.apt → shot u s i x a f≤ε
|
| 77 |
-
def counsel (i:Grid) (A B:Finset (Label p.b))
|
| 78 |
-
(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ) :=
|
| 79 |
-
∀ x:Zodiac p,x.common → x.s true∉A →x.s false∉ B →charge u x s t i a b≤ε
|
| 80 |
-
|
| 81 |
-
def amazes (p:Shape) (z:Label p.b) (l: Tag p.g) (q:F):Appearance p:=⟨l,z,Flavor.full,q⟩
|
| 82 |
-
def amends (p:Shape) (x y:Appearance p): Zodiac p :=
|
| 83 |
-
{l:=x.l
|
| 84 |
-
q:=x.q
|
| 85 |
-
s i:=if i then x.s else y.s
|
| 86 |
-
f i:=if i then x.f else y.f}
|
| 87 |
-
theorem amendsB (x y: Appearance p)(h:x.l=y.l)(ht:x.q=y.q):
|
| 88 |
-
(amends p x y).aspect false=y := by cases x; cases y; simp_all [amends,Zodiac.aspect]
|
| 89 |
-
|
| 90 |
-
theorem splitCounsel (i:Grid) (A B:Finset (Label p.b))
|
| 91 |
-
(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ)
|
| 92 |
-
(h:counsel u s t i A B a b ε) (x y:Appearance p)
|
| 93 |
-
(hx:x.s∉A) (hy:y.s∉B) (he:x.apt) (hf:y.apt) (hg:x.l=y.l) (hk:x.q=y.q) :
|
| 94 |
-
avg (u x.l x.q) (fun j=>pr (pairW (s i.1 x j) (t i.2 y j)) (fun k=>a.soot x k.1 ≠
|
| 95 |
-
b.soot y k.2))≤ε := by
|
| 96 |
-
classical
|
| 97 |
-
let Z:=amends p x y
|
| 98 |
-
have hQ : Z.aspect false=y := amendsB _ _ hg hk
|
| 99 |
-
have hP : Z.aspect true=x := rfl
|
| 100 |
-
have hm : Z.common := by intro i;cases i; rw [hQ];exact hf; rw [hP];exact he
|
| 101 |
-
have hi:= h Z hm hx hy
|
| 102 |
-
unfold charge circlet pr couplePage at hi
|
| 103 |
-
rw [mixW_avg,hQ,hP] at hi
|
| 104 |
-
exact hi
|
| 105 |
-
|
| 106 |
-
set_option maxHeartbeats 800000 in
|
| 107 |
-
theorem paeans {β δ:ℝ} (hu:origami p r u δ)(hs:reports p r u s β δ)(ht:reports p r u t β δ)
|
| 108 |
-
(i:Grid) (A B:Finset (Label p.b)) (hx:A.card<Fintype.card (Label p.b))
|
| 109 |
-
(hy:B.card<Fintype.card (Label p.b)) (hg:3≤p.g)
|
| 110 |
-
(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε:ℝ) (he:0≤ε)
|
| 111 |
-
(h:counsel u s t i A B a b ε) :
|
| 112 |
-
∃ f:Pulsar p r, praise u s i.1 A a f (3*ε) ∧ praise u t i.2 B b f (3*ε) := by
|
| 113 |
-
classical
|
| 114 |
-
obtain ⟨x,hx⟩:=any_label A hx
|
| 115 |
-
obtain ⟨y,hy⟩:=any_label B hy
|
| 116 |
-
let Z:= amazes p y
|
| 117 |
-
let f l q j:= majority (t i.2 (Z l q) j) (b.soot (Z l q))
|
| 118 |
-
have hl:praise u s i.1 A a f (2*ε) := by
|
| 119 |
-
intro z hz hhq
|
| 120 |
-
let w:= Z z.l z.q
|
| 121 |
-
have ht' := generic_apt p hg w rfl
|
| 122 |
-
have hh := splitCounsel u s t i A B a b ε h z w hz hy hhq ht' rfl rfl
|
| 123 |
-
refine le_trans (avg_mono (hu.1 z.l z.q).nz (fun j=> majority_charge (s i.1 z j) (t i.2 w j)
|
| 124 |
-
(hs.law _ _ hhq _) (ht.law _ _ ht' _) (a.soot z) (b.soot w))) ?_
|
| 125 |
-
rw [avg_mul']
|
| 126 |
-
exact mul_le_mul_of_nonneg_left hh (by norm_num)
|
| 127 |
-
refine ⟨f,fun w hw hx=>(hl _ hw hx).trans (by linarith only [he]), fun w hw hv=>?_⟩
|
| 128 |
-
let z:=amazes p x w.l w.q
|
| 129 |
-
have hf : z.apt:=generic_apt _ hg _ rfl
|
| 130 |
-
have hx0:= splitCounsel u s t i A B a b ε h z w hx hw hf hv rfl rfl
|
| 131 |
-
have hl0:=hl z hx hf
|
| 132 |
-
let W:=u w.l w.q
|
| 133 |
-
have heq j:= reflect_cost (s i.1 z j) (t i.2 w j) (hs.law _ _ hf j) (ht.law _ _ hv j)
|
| 134 |
-
(a.soot z) (b.soot w) (f w.l w.q j)
|
| 135 |
-
apply (avg_mono (hu.1 w.l w.q).nz heq).trans
|
| 136 |
-
rw [avg_add]; exact (add_le_add hx0 hl0).trans_eq (by ring)
|
| 137 |
-
end DualAnalysis
|
| 138 |
-
end StatusAnalysis
|
| 139 |
-
end HadwigerCounterexample
|
| 140 |
-
|
| 141 |
-
end
|
| 142 |
-
|
| 143 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteOptionLabels
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Binary Status Comparison -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Filter Function Submodule Module LinearMap
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B J H : Type} [Fintype A] [Fintype B] [Fintype J]
|
| 12 |
+
|
| 13 |
+
theorem disagreement_bound (w : Wgt A) (hw : ∀ x,0 ≤ w x) (f g h:A→ H) :
|
| 14 |
+
pr w (fun i=> f i≠ h i) ≤ pr w (fun i=>f i≠ g i) + pr w (fun i=>g i≠h i) :=
|
| 15 |
+
let p (i:A) := f i≠g i∨g i≠h i
|
| 16 |
+
((pr_mono hw fun i h=>show p i from Classical.byContradiction (fun hi => h (Eq.trans
|
| 17 |
+
(not_not.mp (mt Or.inl hi)) (not_not.mp (mt Or.inr hi))))).trans (pr_or_le hw))
|
| 18 |
+
|
| 19 |
+
def majority (w : Wgt A) (f : A→F) :=
|
| 20 |
+
if 1/2≤ pr w (fun i=>f i=0) then (0:F) else 1
|
| 21 |
+
|
| 22 |
+
theorem majority_bound (w : Wgt A) (hw:IsLaw w) (f : A→F) :
|
| 23 |
+
1/2 ≤ pr w (fun i=> f i= majority w f) := by
|
| 24 |
+
classical
|
| 25 |
+
unfold majority
|
| 26 |
+
split
|
| 27 |
+
next h => exact h
|
| 28 |
+
next h =>
|
| 29 |
+
have hi i : f i=1 ↔ ¬f i=0 :=
|
| 30 |
+
⟨fun hh=>by rw [hh]; exact one_ne_zero,fun hh=>(bit_cases _).resolve_left hh⟩
|
| 31 |
+
simp_rw [hi,pr_not,hw.total]
|
| 32 |
+
exact le_of_lt (by linarith only [h])
|
| 33 |
+
|
| 34 |
+
theorem majority_charge (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)
|
| 35 |
+
(f:A→F) (g:B→F) :
|
| 36 |
+
pr p (fun i=> f i≠majority q g)≤2 * pr (pairW p q) (fun i=> f i.1≠g i.2) := by
|
| 37 |
+
classical
|
| 38 |
+
let Q i:= g i=majority q g; let P i:= f i≠majority q g
|
| 39 |
+
let v:= pairW p q
|
| 40 |
+
have hm (z:A×B) (h:P z.1∧Q z.2): f z.1≠g z.2 := h.2 ▸ h.1
|
| 41 |
+
have hh : pr p P*pr q Q ≤ pr v (fun i=>f i.1≠g i.2) :=
|
| 42 |
+
(pairW_pr ..).symm.le.trans (pr_mono (pairW_law hp hq).nz hm)
|
| 43 |
+
have hx:=majority_bound q hq g
|
| 44 |
+
have hh' := mul_le_mul_of_nonneg_left hx (pr_nonneg (p:=P) hp.nz)
|
| 45 |
+
change _* (1/2) ≤ _*pr q Q at hh'
|
| 46 |
+
change pr p P≤2*pr v _
|
| 47 |
+
linarith only [hh,hh']
|
| 48 |
+
|
| 49 |
+
theorem reflect_cost (p:Wgt A) (q:Wgt B) (hp:IsLaw p) (hq:IsLaw q)
|
| 50 |
+
(f:A→H) (g:B→H) (k:H) :
|
| 51 |
+
pr q (fun i=>g i≠k)≤ pr (pairW p q) (fun i=>f i.1≠g i.2)+pr p (fun i=>f i≠k) := by
|
| 52 |
+
let w:=pairW p q
|
| 53 |
+
let t i:= g i≠k; let s i:= f i≠k
|
| 54 |
+
have hi : pr q t=pr w (fun i=> t i.2) := by simpa [hp.total] using
|
| 55 |
+
(pairW_pr p q (fun _=>True) t).symm
|
| 56 |
+
have hj : pr p s=pr w (fun i=>s i.1) := by simpa [hq.total] using
|
| 57 |
+
(pairW_pr p q s (fun _=>True)).symm
|
| 58 |
+
let P (i:A×B):= f i.1 ≠ g i.2
|
| 59 |
+
rw [hi,hj]
|
| 60 |
+
have hh (i:A×B) (h:t i.2): P i∨ s i.1 := by
|
| 61 |
+
by_cases he:P i
|
| 62 |
+
· exact Or.inl he
|
| 63 |
+
exact Or.inr (fun hc=> h ((not_not.mp he).symm.trans hc))
|
| 64 |
+
exact (pr_mono (pairW_law hp hq).nz hh).trans (pr_or_le (pairW_law hp hq).nz)
|
| 65 |
+
|
| 66 |
+
namespace StatusAnalysis
|
| 67 |
+
namespace DualAnalysis
|
| 68 |
+
variable {p:Shape} {d e: Rates} {r K:ℕ}
|
| 69 |
+
abbrev Pulsar (p:Shape) (r:ℕ):= Tag p.g → F → Fin r→F
|
| 70 |
+
variable (u:Terrain p r) (s:Gazette p r d) (t:Gazette p r e)
|
| 71 |
+
|
| 72 |
+
def shot (i:Nodes) (x:Appearance p) (a:RhymeSet (d i)) (f:Pulsar p r) :=
|
| 73 |
+
avg (u x.l x.q) (fun j=>pr (s i x j) (fun v=> a.soot x v ≠f x.l x.q j))
|
| 74 |
+
def praise (u:Terrain p r) (s:Gazette p r d) (i:Nodes)
|
| 75 |
+
(A:Finset (Label p.b)) (a:RhymeSet (d i)) (f:Pulsar p r) (ε:ℝ) :=
|
| 76 |
+
∀ x:Appearance p,x.s∉A →x.apt → shot u s i x a f≤ε
|
| 77 |
+
def counsel (i:Grid) (A B:Finset (Label p.b))
|
| 78 |
+
(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ) :=
|
| 79 |
+
∀ x:Zodiac p,x.common → x.s true∉A →x.s false∉ B →charge u x s t i a b≤ε
|
| 80 |
+
|
| 81 |
+
def amazes (p:Shape) (z:Label p.b) (l: Tag p.g) (q:F):Appearance p:=⟨l,z,Flavor.full,q⟩
|
| 82 |
+
def amends (p:Shape) (x y:Appearance p): Zodiac p :=
|
| 83 |
+
{l:=x.l
|
| 84 |
+
q:=x.q
|
| 85 |
+
s i:=if i then x.s else y.s
|
| 86 |
+
f i:=if i then x.f else y.f}
|
| 87 |
+
theorem amendsB (x y: Appearance p)(h:x.l=y.l)(ht:x.q=y.q):
|
| 88 |
+
(amends p x y).aspect false=y := by cases x; cases y; simp_all [amends,Zodiac.aspect]
|
| 89 |
+
|
| 90 |
+
theorem splitCounsel (i:Grid) (A B:Finset (Label p.b))
|
| 91 |
+
(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε :ℝ)
|
| 92 |
+
(h:counsel u s t i A B a b ε) (x y:Appearance p)
|
| 93 |
+
(hx:x.s∉A) (hy:y.s∉B) (he:x.apt) (hf:y.apt) (hg:x.l=y.l) (hk:x.q=y.q) :
|
| 94 |
+
avg (u x.l x.q) (fun j=>pr (pairW (s i.1 x j) (t i.2 y j)) (fun k=>a.soot x k.1 ≠
|
| 95 |
+
b.soot y k.2))≤ε := by
|
| 96 |
+
classical
|
| 97 |
+
let Z:=amends p x y
|
| 98 |
+
have hQ : Z.aspect false=y := amendsB _ _ hg hk
|
| 99 |
+
have hP : Z.aspect true=x := rfl
|
| 100 |
+
have hm : Z.common := by intro i;cases i; rw [hQ];exact hf; rw [hP];exact he
|
| 101 |
+
have hi:= h Z hm hx hy
|
| 102 |
+
unfold charge circlet pr couplePage at hi
|
| 103 |
+
rw [mixW_avg,hQ,hP] at hi
|
| 104 |
+
exact hi
|
| 105 |
+
|
| 106 |
+
set_option maxHeartbeats 800000 in
|
| 107 |
+
theorem paeans {β δ:ℝ} (hu:origami p r u δ)(hs:reports p r u s β δ)(ht:reports p r u t β δ)
|
| 108 |
+
(i:Grid) (A B:Finset (Label p.b)) (hx:A.card<Fintype.card (Label p.b))
|
| 109 |
+
(hy:B.card<Fintype.card (Label p.b)) (hg:3≤p.g)
|
| 110 |
+
(a : RhymeSet (d i.1)) (b : RhymeSet (e i.2)) (ε:ℝ) (he:0≤ε)
|
| 111 |
+
(h:counsel u s t i A B a b ε) :
|
| 112 |
+
∃ f:Pulsar p r, praise u s i.1 A a f (3*ε) ∧ praise u t i.2 B b f (3*ε) := by
|
| 113 |
+
classical
|
| 114 |
+
obtain ⟨x,hx⟩:=any_label A hx
|
| 115 |
+
obtain ⟨y,hy⟩:=any_label B hy
|
| 116 |
+
let Z:= amazes p y
|
| 117 |
+
let f l q j:= majority (t i.2 (Z l q) j) (b.soot (Z l q))
|
| 118 |
+
have hl:praise u s i.1 A a f (2*ε) := by
|
| 119 |
+
intro z hz hhq
|
| 120 |
+
let w:= Z z.l z.q
|
| 121 |
+
have ht' := generic_apt p hg w rfl
|
| 122 |
+
have hh := splitCounsel u s t i A B a b ε h z w hz hy hhq ht' rfl rfl
|
| 123 |
+
refine le_trans (avg_mono (hu.1 z.l z.q).nz (fun j=> majority_charge (s i.1 z j) (t i.2 w j)
|
| 124 |
+
(hs.law _ _ hhq _) (ht.law _ _ ht' _) (a.soot z) (b.soot w))) ?_
|
| 125 |
+
rw [avg_mul']
|
| 126 |
+
exact mul_le_mul_of_nonneg_left hh (by norm_num)
|
| 127 |
+
refine ⟨f,fun w hw hx=>(hl _ hw hx).trans (by linarith only [he]), fun w hw hv=>?_⟩
|
| 128 |
+
let z:=amazes p x w.l w.q
|
| 129 |
+
have hf : z.apt:=generic_apt _ hg _ rfl
|
| 130 |
+
have hx0:= splitCounsel u s t i A B a b ε h z w hx hw hf hv rfl rfl
|
| 131 |
+
have hl0:=hl z hx hf
|
| 132 |
+
let W:=u w.l w.q
|
| 133 |
+
have heq j:= reflect_cost (s i.1 z j) (t i.2 w j) (hs.law _ _ hf j) (ht.law _ _ hv j)
|
| 134 |
+
(a.soot z) (b.soot w) (f w.l w.q j)
|
| 135 |
+
apply (avg_mono (hu.1 w.l w.q).nz heq).trans
|
| 136 |
+
rw [avg_add]; exact (add_le_add hx0 hl0).trans_eq (by ring)
|
| 137 |
+
end DualAnalysis
|
| 138 |
+
end StatusAnalysis
|
| 139 |
+
end HadwigerCounterexample
|
| 140 |
+
|
| 141 |
+
end
|
| 142 |
+
|
| 143 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BooleanLabels.lean
CHANGED
|
@@ -1,151 +1,151 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.MomentCoordinates
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.MatrixFactorization
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Boolean Labels -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
open Matrix Finset
|
| 12 |
-
variable {b : ℕ}
|
| 13 |
-
|
| 14 |
-
def monoBit (s : Label b) (S : Finset (Fin b)) := ∏ i ∈ S, s i
|
| 15 |
-
|
| 16 |
-
theorem mono_insert (s : Label b) (S : Finset (Fin b)) (i) :
|
| 17 |
-
monoBit s (insert i S) = s i * monoBit s S := by
|
| 18 |
-
by_cases h : i∈S
|
| 19 |
-
· rw [insert_eq_of_mem h]
|
| 20 |
-
unfold monoBit
|
| 21 |
-
rw [← Finset.mul_prod_erase _ _ h,← mul_assoc,bit_sq]
|
| 22 |
-
· simp [monoBit,h]
|
| 23 |
-
|
| 24 |
-
theorem mono_union (s : Label b) (S T : Finset (Fin b)) :
|
| 25 |
-
monoBit s (S∪T)= monoBit s S*monoBit s T := by
|
| 26 |
-
induction S using Finset.induction with
|
| 27 |
-
| empty => simp [monoBit]
|
| 28 |
-
| insert i S h ih =>
|
| 29 |
-
rw [insert_union,mono_insert,mono_insert,ih,mul_assoc]
|
| 30 |
-
|
| 31 |
-
/-- Independence up to degree j for at most j+1 labels, in coefficient form. -/
|
| 32 |
-
theorem selector_indep (L : Finset (Label b)) (c : Label b → F) (j : ℕ)
|
| 33 |
-
(h : L.card ≤ j+1) (hf : ∀ S : Finset (Fin b), S.card ≤ j →
|
| 34 |
-
∑ s ∈ L,c s*monoBit s S=0) : ∀ i∈L,c i=0 := by
|
| 35 |
-
classical
|
| 36 |
-
intro s hs
|
| 37 |
-
induction L using Finset.strongInductionOn generalizing c j with | _ L ih
|
| 38 |
-
by_cases hL : ∃ i∈L,i≠s
|
| 39 |
-
· obtain ⟨t,ht,hst⟩ := hL
|
| 40 |
-
obtain ⟨i,hi⟩ : ∃ i : Fin b,t i≠s i := Function.ne_iff.mp hst
|
| 41 |
-
let d (u : Label b) := (u i-t i) * c u
|
| 42 |
-
have hg : j>0 := by have he := Finset.one_lt_card.mpr ⟨t,ht,s,hs,hst⟩; omega
|
| 43 |
-
have he : (L.erase t).card ≤ (j-1)+1 := by
|
| 44 |
-
have he := card_erase_add_one ht; omega
|
| 45 |
-
have hw (U : Finset (Fin b)) (hu : U.card ≤ j-1) :
|
| 46 |
-
∑ s ∈ L.erase t,d s*monoBit s U=0 := by
|
| 47 |
-
have heq (s : Label b) :
|
| 48 |
-
d s * monoBit s U = c s * monoBit s (insert i U) - t i*(c s*monoBit s U) := by
|
| 49 |
-
unfold d; rw [mono_insert]; ring
|
| 50 |
-
rw [show ∑ s ∈ L.erase t,d s*monoBit s U = ∑ s ∈ L,d s*monoBit s U by
|
| 51 |
-
conv_rhs => rw [← Finset.add_sum_erase _ _ ht]
|
| 52 |
-
simp [d]]
|
| 53 |
-
simp_rw [heq, Finset.sum_sub_distrib,← Finset.mul_sum]
|
| 54 |
-
have hj : (insert i U).card ≤ j := by
|
| 55 |
-
by_cases hh : i∈U
|
| 56 |
-
· rw [insert_eq_of_mem hh]; omega
|
| 57 |
-
· rw [card_insert_of_notMem hh]; omega
|
| 58 |
-
rw [hf _ hj, hf _ (by omega),mul_zero,sub_zero]
|
| 59 |
-
have hu := ih (L.erase t) (erase_ssubset ht) d (j-1) he hw
|
| 60 |
-
(Finset.mem_erase.mpr ⟨hst.symm,hs⟩)
|
| 61 |
-
exact (mul_eq_zero.mp hu).resolve_left (sub_ne_zero.mpr hi.symm)
|
| 62 |
-
· have he : L={s} := by
|
| 63 |
-
ext x; constructor
|
| 64 |
-
· intro hx; exact mem_singleton.mpr (Classical.byContradiction fun h => hL ⟨x,hx,h⟩)
|
| 65 |
-
intro hx; rwa [mem_singleton.mp hx]
|
| 66 |
-
have hh := hf ∅ (by simp)
|
| 67 |
-
simpa [he,monoBit] using hh
|
| 68 |
-
|
| 69 |
-
variable {p : Shape} {n : ℕ}
|
| 70 |
-
|
| 71 |
-
def hankel (M : Moment p n) :=
|
| 72 |
-
∀ (i k : AIdx p.g n) (a b c d : SelIdx p.b p.j),
|
| 73 |
-
a.val ∪ b.val = c.val ∪ d.val → M (a,i) (b,k) = M (c,i) (d,k)
|
| 74 |
-
|
| 75 |
-
def diagBase (M : Moment p n) :=
|
| 76 |
-
∀ (i : AIdx p.g n) (a b : SelIdx p.b p.j), M (a,i) (b,i) = M (a,none) (b,i)
|
| 77 |
-
|
| 78 |
-
theorem point_eval (p : Shape) (s : Label p.b) (z : Base p.g n)
|
| 79 |
-
(r : SelIdx p.b p.j) (i : AIdx p.g n) : point p s z (r,i) = monoBit s r.val * baseV z i :=
|
| 80 |
-
rfl
|
| 81 |
-
|
| 82 |
-
theorem Wspace_hank {M : Moment p n} (h : M∈Wspace p n) : hankel M := by
|
| 83 |
-
intro i k a b c d hab
|
| 84 |
-
unfold Wspace at h
|
| 85 |
-
induction h using Submodule.span_induction with
|
| 86 |
-
| mem M hm =>
|
| 87 |
-
obtain ⟨s,z,rfl⟩ := hm
|
| 88 |
-
have h (a b : SelIdx p.b p.j) :
|
| 89 |
-
mom p s z (a,i) (b,k) = monoBit s (a.val ∪ b.val) * (baseV z i*baseV z k) := by
|
| 90 |
-
simp only [mom,vecMulVec_apply,point_eval,mono_union]; ring
|
| 91 |
-
rw [h,h,hab]
|
| 92 |
-
| zero => rfl
|
| 93 |
-
| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]
|
| 94 |
-
| smul v x _ hx => simp only [Matrix.smul_apply,hx]
|
| 95 |
-
|
| 96 |
-
theorem Wspace_diag {M : Moment p n} (h : M∈Wspace p n) : diagBase M := by
|
| 97 |
-
intro i a b
|
| 98 |
-
unfold Wspace at h
|
| 99 |
-
induction h using Submodule.span_induction with
|
| 100 |
-
| mem M hm =>
|
| 101 |
-
obtain ⟨s,z,rfl⟩ := hm
|
| 102 |
-
simp only [mom,vecMulVec_apply,point_eval,baseV]
|
| 103 |
-
rw [mul_mul_mul_comm,bit_sq]
|
| 104 |
-
have hn : Option.elim' (1:F) z none = 1 := rfl
|
| 105 |
-
rw [hn]
|
| 106 |
-
ring
|
| 107 |
-
| zero => rfl
|
| 108 |
-
| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]
|
| 109 |
-
| smul v x _ hx => simp only [Matrix.smul_apply,hx]
|
| 110 |
-
|
| 111 |
-
abbrev BaseMat (p : Shape) (n : ℕ) := Mat (AIdx p.g n) (AIdx p.g n)
|
| 112 |
-
|
| 113 |
-
def labMat (p : Shape) (n) (s : Label p.b) :
|
| 114 |
-
Mat (Row p n) (AIdx p.g n) :=
|
| 115 |
-
Matrix.of (fun v i => if v.2=i then monoBit s v.1.val else 0)
|
| 116 |
-
|
| 117 |
-
theorem labMat_act (s) (z : Vec (AIdx p.g n)) :
|
| 118 |
-
labMat p n s *ᵥ z = putLab p n s z := by
|
| 119 |
-
funext i
|
| 120 |
-
simp [Matrix.mulVec,dotProduct,labMat,putLab,monoBit,selV]
|
| 121 |
-
|
| 122 |
-
def mput (p : Shape) (s : Label p.b) {n} :
|
| 123 |
-
BaseMat p n →ₗ[F] Moment p n := liftM (labMat p n s) (labMat p n s)
|
| 124 |
-
|
| 125 |
-
theorem mput_apply (s) (Z : BaseMat p n) (i j) : mput p s Z i j =
|
| 126 |
-
monoBit s i.1.val*monoBit s j.1.val*Z i.2 j.2 := by
|
| 127 |
-
classical
|
| 128 |
-
simp [mput,liftM_def,Matrix.mul_apply,transpose_apply,labMat, mul_comm,mul_left_comm,mul_assoc]
|
| 129 |
-
|
| 130 |
-
theorem mput_hank (s) (Z : BaseMat p n) : hankel (mput p s Z) := by
|
| 131 |
-
intro i j a b c d h
|
| 132 |
-
rw [mput_apply,mput_apply]
|
| 133 |
-
simp_rw [← mono_union,h]
|
| 134 |
-
|
| 135 |
-
/-- Short label-tagged rays give a direct family of copies of the affine-vector space. -/
|
| 136 |
-
theorem ray_indep (L : Finset (Label p.b)) (Z : Label p.b → Vec (AIdx p.g n))
|
| 137 |
-
(hj : L.card ≤ p.j+1) (he : ∑ i∈L, putLab p n i (Z i) = 0) :
|
| 138 |
-
∀ i∈L, Z i=0 := by
|
| 139 |
-
have hg (u : AIdx p.g n) (i : Label p.b) (hi : i ∈ L) :
|
| 140 |
-
Z i u=0 := by
|
| 141 |
-
refine selector_indep L (fun i => Z i u) p.j hj ?_ i hi
|
| 142 |
-
intro S hS
|
| 143 |
-
have hh := congr_fun he ((⟨S,hS⟩ : SelIdx p.b p.j),u)
|
| 144 |
-
simpa [putLab,Finset.sum_apply,monoBit,selV,mul_comm] using hh
|
| 145 |
-
exact fun i hi => funext (fun u => hg u i hi)
|
| 146 |
-
|
| 147 |
-
end HadwigerCounterexample
|
| 148 |
-
|
| 149 |
-
end
|
| 150 |
-
|
| 151 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.MomentCoordinates
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.MatrixFactorization
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Boolean Labels -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open Matrix Finset
|
| 12 |
+
variable {b : ℕ}
|
| 13 |
+
|
| 14 |
+
def monoBit (s : Label b) (S : Finset (Fin b)) := ∏ i ∈ S, s i
|
| 15 |
+
|
| 16 |
+
theorem mono_insert (s : Label b) (S : Finset (Fin b)) (i) :
|
| 17 |
+
monoBit s (insert i S) = s i * monoBit s S := by
|
| 18 |
+
by_cases h : i∈S
|
| 19 |
+
· rw [insert_eq_of_mem h]
|
| 20 |
+
unfold monoBit
|
| 21 |
+
rw [← Finset.mul_prod_erase _ _ h,← mul_assoc,bit_sq]
|
| 22 |
+
· simp [monoBit,h]
|
| 23 |
+
|
| 24 |
+
theorem mono_union (s : Label b) (S T : Finset (Fin b)) :
|
| 25 |
+
monoBit s (S∪T)= monoBit s S*monoBit s T := by
|
| 26 |
+
induction S using Finset.induction with
|
| 27 |
+
| empty => simp [monoBit]
|
| 28 |
+
| insert i S h ih =>
|
| 29 |
+
rw [insert_union,mono_insert,mono_insert,ih,mul_assoc]
|
| 30 |
+
|
| 31 |
+
/-- Independence up to degree j for at most j+1 labels, in coefficient form. -/
|
| 32 |
+
theorem selector_indep (L : Finset (Label b)) (c : Label b → F) (j : ℕ)
|
| 33 |
+
(h : L.card ≤ j+1) (hf : ∀ S : Finset (Fin b), S.card ≤ j →
|
| 34 |
+
∑ s ∈ L,c s*monoBit s S=0) : ∀ i∈L,c i=0 := by
|
| 35 |
+
classical
|
| 36 |
+
intro s hs
|
| 37 |
+
induction L using Finset.strongInductionOn generalizing c j with | _ L ih
|
| 38 |
+
by_cases hL : ∃ i∈L,i≠s
|
| 39 |
+
· obtain ⟨t,ht,hst⟩ := hL
|
| 40 |
+
obtain ⟨i,hi⟩ : ∃ i : Fin b,t i≠s i := Function.ne_iff.mp hst
|
| 41 |
+
let d (u : Label b) := (u i-t i) * c u
|
| 42 |
+
have hg : j>0 := by have he := Finset.one_lt_card.mpr ⟨t,ht,s,hs,hst⟩; omega
|
| 43 |
+
have he : (L.erase t).card ≤ (j-1)+1 := by
|
| 44 |
+
have he := card_erase_add_one ht; omega
|
| 45 |
+
have hw (U : Finset (Fin b)) (hu : U.card ≤ j-1) :
|
| 46 |
+
∑ s ∈ L.erase t,d s*monoBit s U=0 := by
|
| 47 |
+
have heq (s : Label b) :
|
| 48 |
+
d s * monoBit s U = c s * monoBit s (insert i U) - t i*(c s*monoBit s U) := by
|
| 49 |
+
unfold d; rw [mono_insert]; ring
|
| 50 |
+
rw [show ∑ s ∈ L.erase t,d s*monoBit s U = ∑ s ∈ L,d s*monoBit s U by
|
| 51 |
+
conv_rhs => rw [← Finset.add_sum_erase _ _ ht]
|
| 52 |
+
simp [d]]
|
| 53 |
+
simp_rw [heq, Finset.sum_sub_distrib,← Finset.mul_sum]
|
| 54 |
+
have hj : (insert i U).card ≤ j := by
|
| 55 |
+
by_cases hh : i∈U
|
| 56 |
+
· rw [insert_eq_of_mem hh]; omega
|
| 57 |
+
· rw [card_insert_of_notMem hh]; omega
|
| 58 |
+
rw [hf _ hj, hf _ (by omega),mul_zero,sub_zero]
|
| 59 |
+
have hu := ih (L.erase t) (erase_ssubset ht) d (j-1) he hw
|
| 60 |
+
(Finset.mem_erase.mpr ⟨hst.symm,hs⟩)
|
| 61 |
+
exact (mul_eq_zero.mp hu).resolve_left (sub_ne_zero.mpr hi.symm)
|
| 62 |
+
· have he : L={s} := by
|
| 63 |
+
ext x; constructor
|
| 64 |
+
· intro hx; exact mem_singleton.mpr (Classical.byContradiction fun h => hL ⟨x,hx,h⟩)
|
| 65 |
+
intro hx; rwa [mem_singleton.mp hx]
|
| 66 |
+
have hh := hf ∅ (by simp)
|
| 67 |
+
simpa [he,monoBit] using hh
|
| 68 |
+
|
| 69 |
+
variable {p : Shape} {n : ℕ}
|
| 70 |
+
|
| 71 |
+
def hankel (M : Moment p n) :=
|
| 72 |
+
∀ (i k : AIdx p.g n) (a b c d : SelIdx p.b p.j),
|
| 73 |
+
a.val ∪ b.val = c.val ∪ d.val → M (a,i) (b,k) = M (c,i) (d,k)
|
| 74 |
+
|
| 75 |
+
def diagBase (M : Moment p n) :=
|
| 76 |
+
∀ (i : AIdx p.g n) (a b : SelIdx p.b p.j), M (a,i) (b,i) = M (a,none) (b,i)
|
| 77 |
+
|
| 78 |
+
theorem point_eval (p : Shape) (s : Label p.b) (z : Base p.g n)
|
| 79 |
+
(r : SelIdx p.b p.j) (i : AIdx p.g n) : point p s z (r,i) = monoBit s r.val * baseV z i :=
|
| 80 |
+
rfl
|
| 81 |
+
|
| 82 |
+
theorem Wspace_hank {M : Moment p n} (h : M∈Wspace p n) : hankel M := by
|
| 83 |
+
intro i k a b c d hab
|
| 84 |
+
unfold Wspace at h
|
| 85 |
+
induction h using Submodule.span_induction with
|
| 86 |
+
| mem M hm =>
|
| 87 |
+
obtain ⟨s,z,rfl⟩ := hm
|
| 88 |
+
have h (a b : SelIdx p.b p.j) :
|
| 89 |
+
mom p s z (a,i) (b,k) = monoBit s (a.val ∪ b.val) * (baseV z i*baseV z k) := by
|
| 90 |
+
simp only [mom,vecMulVec_apply,point_eval,mono_union]; ring
|
| 91 |
+
rw [h,h,hab]
|
| 92 |
+
| zero => rfl
|
| 93 |
+
| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]
|
| 94 |
+
| smul v x _ hx => simp only [Matrix.smul_apply,hx]
|
| 95 |
+
|
| 96 |
+
theorem Wspace_diag {M : Moment p n} (h : M∈Wspace p n) : diagBase M := by
|
| 97 |
+
intro i a b
|
| 98 |
+
unfold Wspace at h
|
| 99 |
+
induction h using Submodule.span_induction with
|
| 100 |
+
| mem M hm =>
|
| 101 |
+
obtain ⟨s,z,rfl⟩ := hm
|
| 102 |
+
simp only [mom,vecMulVec_apply,point_eval,baseV]
|
| 103 |
+
rw [mul_mul_mul_comm,bit_sq]
|
| 104 |
+
have hn : Option.elim' (1:F) z none = 1 := rfl
|
| 105 |
+
rw [hn]
|
| 106 |
+
ring
|
| 107 |
+
| zero => rfl
|
| 108 |
+
| add x y _ _ hx hy => simp only [Matrix.add_apply,hx,hy]
|
| 109 |
+
| smul v x _ hx => simp only [Matrix.smul_apply,hx]
|
| 110 |
+
|
| 111 |
+
abbrev BaseMat (p : Shape) (n : ℕ) := Mat (AIdx p.g n) (AIdx p.g n)
|
| 112 |
+
|
| 113 |
+
def labMat (p : Shape) (n) (s : Label p.b) :
|
| 114 |
+
Mat (Row p n) (AIdx p.g n) :=
|
| 115 |
+
Matrix.of (fun v i => if v.2=i then monoBit s v.1.val else 0)
|
| 116 |
+
|
| 117 |
+
theorem labMat_act (s) (z : Vec (AIdx p.g n)) :
|
| 118 |
+
labMat p n s *ᵥ z = putLab p n s z := by
|
| 119 |
+
funext i
|
| 120 |
+
simp [Matrix.mulVec,dotProduct,labMat,putLab,monoBit,selV]
|
| 121 |
+
|
| 122 |
+
def mput (p : Shape) (s : Label p.b) {n} :
|
| 123 |
+
BaseMat p n →ₗ[F] Moment p n := liftM (labMat p n s) (labMat p n s)
|
| 124 |
+
|
| 125 |
+
theorem mput_apply (s) (Z : BaseMat p n) (i j) : mput p s Z i j =
|
| 126 |
+
monoBit s i.1.val*monoBit s j.1.val*Z i.2 j.2 := by
|
| 127 |
+
classical
|
| 128 |
+
simp [mput,liftM_def,Matrix.mul_apply,transpose_apply,labMat, mul_comm,mul_left_comm,mul_assoc]
|
| 129 |
+
|
| 130 |
+
theorem mput_hank (s) (Z : BaseMat p n) : hankel (mput p s Z) := by
|
| 131 |
+
intro i j a b c d h
|
| 132 |
+
rw [mput_apply,mput_apply]
|
| 133 |
+
simp_rw [← mono_union,h]
|
| 134 |
+
|
| 135 |
+
/-- Short label-tagged rays give a direct family of copies of the affine-vector space. -/
|
| 136 |
+
theorem ray_indep (L : Finset (Label p.b)) (Z : Label p.b → Vec (AIdx p.g n))
|
| 137 |
+
(hj : L.card ≤ p.j+1) (he : ∑ i∈L, putLab p n i (Z i) = 0) :
|
| 138 |
+
∀ i∈L, Z i=0 := by
|
| 139 |
+
have hg (u : AIdx p.g n) (i : Label p.b) (hi : i ∈ L) :
|
| 140 |
+
Z i u=0 := by
|
| 141 |
+
refine selector_indep L (fun i => Z i u) p.j hj ?_ i hi
|
| 142 |
+
intro S hS
|
| 143 |
+
have hh := congr_fun he ((⟨S,hS⟩ : SelIdx p.b p.j),u)
|
| 144 |
+
simpa [putLab,Finset.sum_apply,monoBit,selV,mul_comm] using hh
|
| 145 |
+
exact fun i hi => funext (fun u => hg u i hi)
|
| 146 |
+
|
| 147 |
+
end HadwigerCounterexample
|
| 148 |
+
|
| 149 |
+
end
|
| 150 |
+
|
| 151 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/BoundedQueryTemplates.lean
CHANGED
|
@@ -1,134 +1,134 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.IndependentColumnBatches
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.CollisionInequality
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Bounded Query Templates -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
open Matrix Module LinearMap Function
|
| 12 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 13 |
-
|
| 14 |
-
structure Template (p : Shape) (I : Type) where
|
| 15 |
-
aim : I→Bool
|
| 16 |
-
t : Tagging p I
|
| 17 |
-
s : I→Label p.b
|
| 18 |
-
f : I→Flavor p.g
|
| 19 |
-
|
| 20 |
-
abbrev Inputs (p : Shape) (n : ℕ) (I : Type) := I → Knobs p.g n
|
| 21 |
-
|
| 22 |
-
namespace Template
|
| 23 |
-
variable (v : Template p I)
|
| 24 |
-
|
| 25 |
-
def draw (y : Inputs p n I) : Volley p n I where
|
| 26 |
-
obj := v.aim
|
| 27 |
-
sel := v.s
|
| 28 |
-
par i := lit (v.f i) (v.t i) (y i)
|
| 29 |
-
|
| 30 |
-
def state (q : I→F) (n : ℕ) : Wgt (Inputs p n I) :=
|
| 31 |
-
prodW (fun i : I => scopedBit p n (v.t i) (v.f i) (q i))
|
| 32 |
-
omit [Fintype I] [DecidableEq I] in
|
| 33 |
-
theorem draw_legal (y : Inputs p n I) : (v.draw y).legal v.t :=
|
| 34 |
-
fun _ => lit_allows _ _ _
|
| 35 |
-
end Template
|
| 36 |
-
|
| 37 |
-
abbrev KeySlots (p : Shape) (t : Tagging p I) := Σ i, TagStar (t i)
|
| 38 |
-
|
| 39 |
-
def scatter (t : Tagging p I) (N : ℕ) : Keys (p:=p) t N ≃ Rack (KeySlots p t) N where
|
| 40 |
-
toFun x := (Matrix.of (fun j i => x i.1 i.2 true j),Matrix.of (fun j i => x i.1 i.2 false j))
|
| 41 |
-
invFun x := fun i j b => if b then x.1.col ⟨i,j⟩ else x.2.col ⟨i,j⟩
|
| 42 |
-
left_inv x := by funext i j b; cases b <;> rfl
|
| 43 |
-
right_inv x := by apply Prod.ext <;> rfl
|
| 44 |
-
|
| 45 |
-
def globPort (p : Shape) (t : Tagging p I) (q : I→Bool) :
|
| 46 |
-
Route (KeySlots p t) (Ports p) :=
|
| 47 |
-
fun x => (q x.1,x.2.val)
|
| 48 |
-
|
| 49 |
-
def nomAsk (t : Tagging p I) (v : Volley p n I) :
|
| 50 |
-
NomQuery p n (globPort p t v.obj) :=
|
| 51 |
-
fun _ => Matrix.of (fun i j => v.rayAt j.val.1 i)
|
| 52 |
-
|
| 53 |
-
omit [Fintype I] [DecidableEq I] in
|
| 54 |
-
theorem peek_keys (t : Tagging p I) (v : Volley p n I) (x : UnitType p n N) :
|
| 55 |
-
peekR p (globPort p t v.obj) (nomAsk t v) (nomAsk t v) (mergeR p x) =
|
| 56 |
-
scatter t N (v.keys t x) := by
|
| 57 |
-
apply Prod.ext
|
| 58 |
-
· ext i j; rfl
|
| 59 |
-
· ext i j; rfl
|
| 60 |
-
|
| 61 |
-
theorem raw_keys (t : Tagging p I) (v : Volley p n I) (m : Mixer p n) {N : ℕ}
|
| 62 |
-
(hN : 2*num (Full p n)<N) (ha : ∀ i, Injective (nomAsk t v i).mulVec) :
|
| 63 |
-
let r := raw m N
|
| 64 |
-
mapW (pairW r r) ((scatter t N) ∘ v.keys t) = rackStation (database m (nomAsk t v) (nomAsk t v)) N := by
|
| 65 |
-
classical
|
| 66 |
-
let g := globPort p t v.obj
|
| 67 |
-
let A := nomAsk t v
|
| 68 |
-
have hh := law_peekR m hN ha ha
|
| 69 |
-
rw [← law_mergeR m N, mapW_nested] at hh
|
| 70 |
-
refine Eq.trans ?_ hh
|
| 71 |
-
congr 1
|
| 72 |
-
|
| 73 |
-
def ownPort (t : Tagging p I) : Route (KeySlots p t) (Comp p.g) := fun x => x.2.val
|
| 74 |
-
def ownMap (t : Tagging p I) (q : I→F) : GeoM (ownPort (p:=p) t) :=
|
| 75 |
-
fun _ => Matrix.diagonal (fun i => q i.val.1)
|
| 76 |
-
def ownPart (t : Tagging p I) (q : I→F) {N : ℕ}
|
| 77 |
-
(x : Keys (p:=p) t N) :=
|
| 78 |
-
gramPart (ownMap (p:=p) t q) (scatter t N x)
|
| 79 |
-
def lawNu (p : Shape) (N : ℕ) (t : Tagging p I) (q : I→F) :
|
| 80 |
-
Wgt (Keys (p:=p) t N) := unifOn (ownPart (p:=p) t q)
|
| 81 |
-
|
| 82 |
-
theorem lawNu_rack (t : Tagging p I) (q : I→F) :
|
| 83 |
-
mapW (lawNu p N t q) (scatter t N) = rackWave (ownMap t q) N :=
|
| 84 |
-
on_equiv ..
|
| 85 |
-
|
| 86 |
-
def ownOne (p : Shape) {N : ℕ} (l : Tag p.g) (q : F) (x : AtomKey (p:=p) l N) :=
|
| 87 |
-
∀ i,dotProduct (x i true) (x i false) = q
|
| 88 |
-
def lawOmega (p : Shape) (N : ℕ) (l : Tag p.g) (q : F) :
|
| 89 |
-
Wgt (AtomKey (p:=p) l N) := unifOn (ownOne p l q)
|
| 90 |
-
|
| 91 |
-
omit [Fintype I] in
|
| 92 |
-
theorem ownPart_def (t : Tagging p I) (q : I→F) {N : ℕ} (x : Keys (p:=p) t N) :
|
| 93 |
-
ownPart (p:=p) t q x ↔
|
| 94 |
-
(∀ i, ownOne p (t i) (q i) (x i)) ∧
|
| 95 |
-
∀ (i j : I) (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)), i≠j →
|
| 96 |
-
dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false)=0 := by
|
| 97 |
-
classical
|
| 98 |
-
let Q := ownPort (p:=p) t
|
| 99 |
-
unfold ownPart
|
| 100 |
-
rw [part_scores]
|
| 101 |
-
have he i j (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)) :
|
| 102 |
-
let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩
|
| 103 |
-
let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩
|
| 104 |
-
scoreR (scatter t N x) a b=dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false) := rfl
|
| 105 |
-
constructor
|
| 106 |
-
· intro h
|
| 107 |
-
constructor
|
| 108 |
-
· rintro i ⟨e,hi⟩
|
| 109 |
-
let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩
|
| 110 |
-
exact (he i i e hi hi).symm.trans ((h e a a).trans (Matrix.diagonal_apply_eq ..))
|
| 111 |
-
intro i j e hi hj heq
|
| 112 |
-
let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩
|
| 113 |
-
let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩
|
| 114 |
-
have hh : a≠b := fun h => heq (congrArg (fun x:Port Q e => x.val.1) h)
|
| 115 |
-
exact (he i j e hi hj).symm.trans ((h e a b).trans (Matrix.diagonal_apply_ne _ hh))
|
| 116 |
-
· rintro ⟨h,h'⟩ e ⟨⟨i,v⟩,ha⟩ ⟨⟨j,w⟩,hb⟩
|
| 117 |
-
rcases v with ⟨v,hv⟩; rcases w with ⟨w,hw⟩
|
| 118 |
-
change v = e at ha; change w=e at hb
|
| 119 |
-
subst v; subst w
|
| 120 |
-
let a : Port Q e := ⟨⟨i,⟨e,hv⟩⟩,rfl⟩
|
| 121 |
-
let b : Port Q e := ⟨⟨j,⟨e,hw⟩⟩,rfl⟩
|
| 122 |
-
by_cases he : i=j
|
| 123 |
-
· subst j
|
| 124 |
-
refine (show scoreR (scatter t N x) a.val a.val=_ from h i
|
| 125 |
-
exact (Matrix.diagonal_apply_eq (fun j : Port Q e => q j.val.1) a).symm
|
| 126 |
-
have hh : a≠b := fun h => he (congrArg (fun x:Port Q e => x.val.1) h)
|
| 127 |
-
refine Eq.trans (h' i j e hv hw he) ?_
|
| 128 |
-
exact (Matrix.diagonal_apply_ne (fun j : Port Q e => q j.val.1) hh).symm
|
| 129 |
-
|
| 130 |
-
end HadwigerCounterexample
|
| 131 |
-
|
| 132 |
-
end
|
| 133 |
-
|
| 134 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.IndependentColumnBatches
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.CollisionInequality
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Bounded Query Templates -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open Matrix Module LinearMap Function
|
| 12 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 13 |
+
|
| 14 |
+
structure Template (p : Shape) (I : Type) where
|
| 15 |
+
aim : I→Bool
|
| 16 |
+
t : Tagging p I
|
| 17 |
+
s : I→Label p.b
|
| 18 |
+
f : I→Flavor p.g
|
| 19 |
+
|
| 20 |
+
abbrev Inputs (p : Shape) (n : ℕ) (I : Type) := I → Knobs p.g n
|
| 21 |
+
|
| 22 |
+
namespace Template
|
| 23 |
+
variable (v : Template p I)
|
| 24 |
+
|
| 25 |
+
def draw (y : Inputs p n I) : Volley p n I where
|
| 26 |
+
obj := v.aim
|
| 27 |
+
sel := v.s
|
| 28 |
+
par i := lit (v.f i) (v.t i) (y i)
|
| 29 |
+
|
| 30 |
+
def state (q : I→F) (n : ℕ) : Wgt (Inputs p n I) :=
|
| 31 |
+
prodW (fun i : I => scopedBit p n (v.t i) (v.f i) (q i))
|
| 32 |
+
omit [Fintype I] [DecidableEq I] in
|
| 33 |
+
theorem draw_legal (y : Inputs p n I) : (v.draw y).legal v.t :=
|
| 34 |
+
fun _ => lit_allows _ _ _
|
| 35 |
+
end Template
|
| 36 |
+
|
| 37 |
+
abbrev KeySlots (p : Shape) (t : Tagging p I) := Σ i, TagStar (t i)
|
| 38 |
+
|
| 39 |
+
def scatter (t : Tagging p I) (N : ℕ) : Keys (p:=p) t N ≃ Rack (KeySlots p t) N where
|
| 40 |
+
toFun x := (Matrix.of (fun j i => x i.1 i.2 true j),Matrix.of (fun j i => x i.1 i.2 false j))
|
| 41 |
+
invFun x := fun i j b => if b then x.1.col ⟨i,j⟩ else x.2.col ⟨i,j⟩
|
| 42 |
+
left_inv x := by funext i j b; cases b <;> rfl
|
| 43 |
+
right_inv x := by apply Prod.ext <;> rfl
|
| 44 |
+
|
| 45 |
+
def globPort (p : Shape) (t : Tagging p I) (q : I→Bool) :
|
| 46 |
+
Route (KeySlots p t) (Ports p) :=
|
| 47 |
+
fun x => (q x.1,x.2.val)
|
| 48 |
+
|
| 49 |
+
def nomAsk (t : Tagging p I) (v : Volley p n I) :
|
| 50 |
+
NomQuery p n (globPort p t v.obj) :=
|
| 51 |
+
fun _ => Matrix.of (fun i j => v.rayAt j.val.1 i)
|
| 52 |
+
|
| 53 |
+
omit [Fintype I] [DecidableEq I] in
|
| 54 |
+
theorem peek_keys (t : Tagging p I) (v : Volley p n I) (x : UnitType p n N) :
|
| 55 |
+
peekR p (globPort p t v.obj) (nomAsk t v) (nomAsk t v) (mergeR p x) =
|
| 56 |
+
scatter t N (v.keys t x) := by
|
| 57 |
+
apply Prod.ext
|
| 58 |
+
· ext i j; rfl
|
| 59 |
+
· ext i j; rfl
|
| 60 |
+
|
| 61 |
+
theorem raw_keys (t : Tagging p I) (v : Volley p n I) (m : Mixer p n) {N : ℕ}
|
| 62 |
+
(hN : 2*num (Full p n)<N) (ha : ∀ i, Injective (nomAsk t v i).mulVec) :
|
| 63 |
+
let r := raw m N
|
| 64 |
+
mapW (pairW r r) ((scatter t N) ∘ v.keys t) = rackStation (database m (nomAsk t v) (nomAsk t v)) N := by
|
| 65 |
+
classical
|
| 66 |
+
let g := globPort p t v.obj
|
| 67 |
+
let A := nomAsk t v
|
| 68 |
+
have hh := law_peekR m hN ha ha
|
| 69 |
+
rw [← law_mergeR m N, mapW_nested] at hh
|
| 70 |
+
refine Eq.trans ?_ hh
|
| 71 |
+
congr 1
|
| 72 |
+
|
| 73 |
+
def ownPort (t : Tagging p I) : Route (KeySlots p t) (Comp p.g) := fun x => x.2.val
|
| 74 |
+
def ownMap (t : Tagging p I) (q : I→F) : GeoM (ownPort (p:=p) t) :=
|
| 75 |
+
fun _ => Matrix.diagonal (fun i => q i.val.1)
|
| 76 |
+
def ownPart (t : Tagging p I) (q : I→F) {N : ℕ}
|
| 77 |
+
(x : Keys (p:=p) t N) :=
|
| 78 |
+
gramPart (ownMap (p:=p) t q) (scatter t N x)
|
| 79 |
+
def lawNu (p : Shape) (N : ℕ) (t : Tagging p I) (q : I→F) :
|
| 80 |
+
Wgt (Keys (p:=p) t N) := unifOn (ownPart (p:=p) t q)
|
| 81 |
+
|
| 82 |
+
theorem lawNu_rack (t : Tagging p I) (q : I→F) :
|
| 83 |
+
mapW (lawNu p N t q) (scatter t N) = rackWave (ownMap t q) N :=
|
| 84 |
+
on_equiv ..
|
| 85 |
+
|
| 86 |
+
def ownOne (p : Shape) {N : ℕ} (l : Tag p.g) (q : F) (x : AtomKey (p:=p) l N) :=
|
| 87 |
+
∀ i,dotProduct (x i true) (x i false) = q
|
| 88 |
+
def lawOmega (p : Shape) (N : ℕ) (l : Tag p.g) (q : F) :
|
| 89 |
+
Wgt (AtomKey (p:=p) l N) := unifOn (ownOne p l q)
|
| 90 |
+
|
| 91 |
+
omit [Fintype I] in
|
| 92 |
+
theorem ownPart_def (t : Tagging p I) (q : I→F) {N : ℕ} (x : Keys (p:=p) t N) :
|
| 93 |
+
ownPart (p:=p) t q x ↔
|
| 94 |
+
(∀ i, ownOne p (t i) (q i) (x i)) ∧
|
| 95 |
+
∀ (i j : I) (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)), i≠j →
|
| 96 |
+
dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false)=0 := by
|
| 97 |
+
classical
|
| 98 |
+
let Q := ownPort (p:=p) t
|
| 99 |
+
unfold ownPart
|
| 100 |
+
rw [part_scores]
|
| 101 |
+
have he i j (e : Comp p.g) (hi : inc e (t i)) (hj : inc e (t j)) :
|
| 102 |
+
let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩
|
| 103 |
+
let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩
|
| 104 |
+
scoreR (scatter t N x) a b=dotProduct (x i ⟨e,hi⟩ true) (x j ⟨e,hj⟩ false) := rfl
|
| 105 |
+
constructor
|
| 106 |
+
· intro h
|
| 107 |
+
constructor
|
| 108 |
+
· rintro i ⟨e,hi⟩
|
| 109 |
+
let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩
|
| 110 |
+
exact (he i i e hi hi).symm.trans ((h e a a).trans (Matrix.diagonal_apply_eq ..))
|
| 111 |
+
intro i j e hi hj heq
|
| 112 |
+
let a : Port Q e := ⟨⟨i,⟨e,hi⟩⟩,rfl⟩
|
| 113 |
+
let b : Port Q e := ⟨⟨j,⟨e,hj⟩⟩,rfl⟩
|
| 114 |
+
have hh : a≠b := fun h => heq (congrArg (fun x:Port Q e => x.val.1) h)
|
| 115 |
+
exact (he i j e hi hj).symm.trans ((h e a b).trans (Matrix.diagonal_apply_ne _ hh))
|
| 116 |
+
· rintro ⟨h,h'⟩ e ⟨⟨i,v⟩,ha⟩ ⟨⟨j,w⟩,hb⟩
|
| 117 |
+
rcases v with ⟨v,hv⟩; rcases w with ⟨w,hw⟩
|
| 118 |
+
change v = e at ha; change w=e at hb
|
| 119 |
+
subst v; subst w
|
| 120 |
+
let a : Port Q e := ⟨⟨i,⟨e,hv⟩⟩,rfl⟩
|
| 121 |
+
let b : Port Q e := ⟨⟨j,⟨e,hw⟩⟩,rfl⟩
|
| 122 |
+
by_cases he : i=j
|
| 123 |
+
· subst j
|
| 124 |
+
refine (show scoreR (scatter t N x) a.val a.val=_ from h i ⟨e,hv⟩).trans ?_
|
| 125 |
+
exact (Matrix.diagonal_apply_eq (fun j : Port Q e => q j.val.1) a).symm
|
| 126 |
+
have hh : a≠b := fun h => he (congrArg (fun x:Port Q e => x.val.1) h)
|
| 127 |
+
refine Eq.trans (h' i j e hv hw he) ?_
|
| 128 |
+
exact (Matrix.diagonal_apply_ne (fun j : Port Q e => q j.val.1) hh).symm
|
| 129 |
+
|
| 130 |
+
end HadwigerCounterexample
|
| 131 |
+
|
| 132 |
+
end
|
| 133 |
+
|
| 134 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CellPositivityScales.lean
CHANGED
|
@@ -1,177 +1,177 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.SurrogateStatusLaws
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Cell Positivity Scales -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
variable {p:Shape} {n N K M r : ℕ}
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
open Template
|
| 14 |
-
variable {b : PreparationParameters}
|
| 15 |
-
|
| 16 |
-
namespace Appearance
|
| 17 |
-
variable (x : Appearance p) {s0 : ℕ}
|
| 18 |
-
|
| 19 |
-
theorem readCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 20 |
-
(ε : ℝ) (hε : 0<ε) :
|
| 21 |
-
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 22 |
-
∀ Y : Silhouette p N r,pr (raw m N) (fun o=> x.apt∧¬ x.close Y o ε)≤bp (-(1/16:ℝ)*n) := by
|
| 23 |
-
classical
|
| 24 |
-
have hp:=h.enter.first
|
| 25 |
-
by_cases ha : x.apt
|
| 26 |
-
· let δ : ℝ := ε/(r+1:ℝ)
|
| 27 |
-
have hδ : 0<δ:=by unfold δ; positivity
|
| 28 |
-
filter_upwards [flat_recital x.trot M hp.hM hp.hJ δ hδ,eventually_ge_atTop (2*p.r),
|
| 29 |
-
pay_nat (a:=1/8) (b:=1/16) (num (Fin r)) (by norm_num)] with n hn ht hB N m hN Y
|
| 30 |
-
let w:= x.wit n; let v:= raw m N
|
| 31 |
-
have hw : IsLaw w:= witLaw ha hp.hR ht
|
| 32 |
-
let P (i : Fin r) (o : Orient p n N):=
|
| 33 |
-
δ≤ |x.empirical Y o i - x.reference Y i|
|
| 34 |
-
have hk (i : Fin r) : pr v (P i) ≤ bp (-(1/8:ℝ)*n) := by
|
| 35 |
-
let S (z) := ind (Y x.l x.q z=i)
|
| 36 |
-
have hf z : |S z|≤1 := by unfold S; rw [abs_of_nonneg (ind_nonneg _)]; exact ind_le_one _
|
| 37 |
-
refine hn m w x.q hw (normW_carried (subW_carried _ _))
|
| 38 |
-
(scopedZ_bit p n _ _ _ hw) hN S hf
|
| 39 |
-
have he (o : Orient p n N) (h : x.apt∧¬x.close Y o ε) : ∃ i,P i o := by
|
| 40 |
-
by_contra! hh
|
| 41 |
-
apply h.2
|
| 42 |
-
unfold close varOne
|
| 43 |
-
calc _ ≤ ∑ i : Fin r,δ:= Finset.sum_le_sum fun i _=>le_trans (abs_sub_comm ..).le
|
| 44 |
-
(le_of_not_ge (hh i))
|
| 45 |
-
_ ≤ ε := by
|
| 46 |
-
simp; unfold δ
|
| 47 |
-
calc _ ≤ ((r:ℝ)+1)* (ε/(r+1:ℝ)) := mul_le_mul_of_nonneg_right (by linarith) hδ.le
|
| 48 |
-
_ = ε := by field_simp
|
| 49 |
-
have hv : IsLaw v:= raw_law m hN
|
| 50 |
-
exact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz P)).trans
|
| 51 |
-
(((Finset.sum_le_sum fun i _=>hk i).trans_eq (by simp [num])).trans hB)
|
| 52 |
-
filter_upwards with n N m hN Y
|
| 53 |
-
simp_rw [show (x.apt)=False from eq_false ha,false_and,pr_false]; exact (bp_pos _).le
|
| 54 |
-
|
| 55 |
-
def foil (x : Appearance p) (Y : Silhouette p N r) (o : Orient p n N)
|
| 56 |
-
(m : Mixer p n) (K : ℕ) (δ : ℝ) :=
|
| 57 |
-
∀ (z:Digest p.g) (i:Fin r), z.feasible x.l x.f → z.sumBit=x.q →
|
| 58 |
-
δ ≤ x.reference Y i → Template.patrol x.trot m (scopedScan p n x.l x.f z)
|
| 59 |
-
(fun y => Y x.l x.q y=i) K x.q o
|
| 60 |
-
|
| 61 |
-
theorem foilCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 62 |
-
(δ:ℝ) (hδ:0<δ) :
|
| 63 |
-
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 64 |
-
unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,
|
| 65 |
-
pr (raw m N) (fun i=>¬x.foil Y i m b.pins δ)≤bp (-(1/18:ℝ)*n) := by
|
| 66 |
-
classical
|
| 67 |
-
have ht:=h.enter.first
|
| 68 |
-
let A:= Digest p.g × Fin r
|
| 69 |
-
let Q n (m:Mixer p n) (Y:Silhouette p (M*n) r) (a : A) (o : Orient p n (M*n)) :=
|
| 70 |
-
a.1.feasible x.l x.f ∧ a.1.sumBit=x.q ∧ δ≤x.reference Y a.2 ∧
|
| 71 |
-
¬Template.patrol x.trot m (scopedScan p n x.l x.f a.1)
|
| 72 |
-
(fun y=>Y x.l x.q y=a.2) b.pins x.q o
|
| 73 |
-
have hg (a:A) :
|
| 74 |
-
∀ᶠ n:ℕ in atTop,let N:=M*n;∀ m:Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 75 |
-
unaryGood m b.pins s0→∀ Y:Silhouette p N r,
|
| 76 |
-
pr (raw m N) (Q n m Y a) ≤ bp (-(1/16:ℝ)*n) := by
|
| 77 |
-
by_cases hf : a.1.feasible x.l x.f ∧ a.1.sumBit=x.q
|
| 78 |
-
· filter_upwards [patrolled x.trot M ht.hM ht.hg ht.hJ a.1 hf.1 ht.hR δ hδ h.profiles
|
| 79 |
-
h.gleaming] with n hn N m hN hM Y
|
| 80 |
-
by_cases he : δ ≤ x.reference Y a.2
|
| 81 |
-
· let S : AtomKey (p:=p) (x.trot.t ()) (M*n) →Prop := fun i=>Y x.l x.q i=a.2
|
| 82 |
-
let v:=scopedScan p n (x.trot.t ()) (x.trot.f ()) a.1
|
| 83 |
-
have hx : δ ≤ pr (lawOmega p (M*n) (x.trot.t ()) a.1.sumBit) S := by
|
| 84 |
-
rw [hf.2]; exact he
|
| 85 |
-
have hh (i:Orient p n (M*n)) (h:Q n m Y a i) :
|
| 86 |
-
¬Template.patrol x.trot m v S b.pins a.1.sumBit i := hf.2 ▸ h.2.2.2
|
| 87 |
-
exact (pr_mono (raw_law m hN).nz hh).trans (hn m hM hN S hx)
|
| 88 |
-
have hg : Q n m Y a=fun _=> False :=
|
| 89 |
-
funext fun i=> eq_false (fun h=>he h.2.2.1)
|
| 90 |
-
change pr (raw m (M*n)) (Q n m Y a) ≤ _
|
| 91 |
-
rw [hg,pr_false]; exact (bp_pos _).le
|
| 92 |
-
filter_upwards with n N m hN hg Y
|
| 93 |
-
have hh : Q n m Y a=fun _=> False :=
|
| 94 |
-
funext fun i=> eq_false (fun h=> hf ⟨h.1,h.2.1⟩)
|
| 95 |
-
change pr (raw m (M*n)) (Q n m Y a) ≤ _
|
| 96 |
-
rw [hh,pr_false]; exact (bp_pos _).le
|
| 97 |
-
filter_upwards [eventually_all.mpr hg,pay_nat (a:=1/16) (b:=1/18) (num A) (by norm_num)]
|
| 98 |
-
with n hn hB N m hN hM Y
|
| 99 |
-
have he o (h : ¬x.foil Y o m b.pins δ) : ∃ i, Q n m Y i o := by
|
| 100 |
-
unfold foil at h
|
| 101 |
-
push Not at h
|
| 102 |
-
obtain ⟨z,i,h⟩:=h
|
| 103 |
-
exact ⟨(z,i),h⟩
|
| 104 |
-
let v:=raw m N
|
| 105 |
-
have hv : IsLaw v:=raw_law m hN
|
| 106 |
-
exact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz _)).trans
|
| 107 |
-
(((Finset.sum_le_sum fun i _=>hn i m hN hM Y).trans_eq (by simp [num])).trans hB)
|
| 108 |
-
end Appearance
|
| 109 |
-
|
| 110 |
-
def smoothSilk (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)
|
| 111 |
-
(m:Mixer p n) (K:ℕ) (o:Orient p n N) :=
|
| 112 |
-
∀ x : Appearance p,(x.apt → x.close Y o ε) ∧ x.foil Y o m K δ
|
| 113 |
-
|
| 114 |
-
variable {s0 : ℕ}
|
| 115 |
-
|
| 116 |
-
def gauze (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)
|
| 117 |
-
(m:Mixer p n) (K:ℕ) (o:UnitType p n N) :=
|
| 118 |
-
∀ i,smoothSilk p ε δ Y m K (onSide o i)
|
| 119 |
-
|
| 120 |
-
private theorem silken (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 121 |
-
(ε δ : ℝ) (he:0<ε) (hd:0<δ) :
|
| 122 |
-
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 123 |
-
unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,
|
| 124 |
-
pr (raw m N) (fun i=>¬smoothSilk p ε δ Y m b.pins i)≤bp (-(1/20:ℝ)*n) := by
|
| 125 |
-
classical
|
| 126 |
-
let A:= Appearance p
|
| 127 |
-
filter_upwards [eventually_all.mpr (fun x:A=>x.foilCap r M h δ hd),
|
| 128 |
-
eventually_all.mpr (fun x:A=>x.readCap r M h ε he),
|
| 129 |
-
pay_nat (a:=1/18) (b:=1/20) (num A*2) (by norm_num)] with n hn ht hB N m hN hM Y
|
| 130 |
-
let v:=raw m N
|
| 131 |
-
have hv : IsLaw v:=raw_law m hN
|
| 132 |
-
let P (x:A) (o:Orient p n N) :=
|
| 133 |
-
(x.apt ∧ ¬x.close Y o ε)∨ ¬x.foil Y o m b.pins δ
|
| 134 |
-
have hk x : pr v (P x) ≤ 2*bp (-(1/18:ℝ)*n) := by
|
| 135 |
-
rw [two_mul]; apply (pr_or_le hv.nz).trans
|
| 136 |
-
refine add_le_add ((ht x m hN Y).trans (bp_le ?_)) (hn x m hN hM Y)
|
| 137 |
-
linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]
|
| 138 |
-
have hi o (h : ¬smoothSilk p ε δ Y m b.pins o) : ∃ i, P i o := by
|
| 139 |
-
unfold smoothSilk at h
|
| 140 |
-
obtain ⟨i,h⟩:= Classical.not_forall.mp h
|
| 141 |
-
exact ⟨i,by unfold P; tauto⟩
|
| 142 |
-
refine ((pr_mono hv.nz hi).trans (pr_exists_le hv.nz _)).trans
|
| 143 |
-
(((Finset.sum_le_sum fun i _=>hk i).trans_eq ?_).trans hB)
|
| 144 |
-
simp [num,mul_assoc]
|
| 145 |
-
|
| 146 |
-
theorem gauzeCalendar (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 147 |
-
(ε δ:ℝ) (he:0<ε) (hd:0<δ) :
|
| 148 |
-
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,∀ u : Wgt (UnitType p n N),
|
| 149 |
-
PreparationParameters.Align b s0 p M n m u → ∀ Y: Silhouette p N r,
|
| 150 |
-
pr u (fun i=>¬gauze p ε δ Y m b.pins i)≤bp (-(1/100:ℝ)*n) := by
|
| 151 |
-
classical
|
| 152 |
-
filter_upwards [silken p r M h ε δ he hd,pay_nat (a:=1/20-1/32) (b:=1/100) 2
|
| 153 |
-
(by norm_num)] with n hn ht N m u hu Y
|
| 154 |
-
let P (o:Orient p n N) := ¬smoothSilk p ε δ Y m b.pins o
|
| 155 |
-
let Q (i:Bool) (o:UnitType p n N):=P (onSide o i)
|
| 156 |
-
have hc : bySide p u m (bp ((1/32:ℝ)*n)) := fun i=> by
|
| 157 |
-
have hh:= hu.drain
|
| 158 |
-
cases i; exact hh.2.2.1; exact hh.2.1
|
| 159 |
-
have hf : ∀ i,pr u (Q i) ≤bp (-((1/20:ℝ)-1/32)*n) := by
|
| 160 |
-
intro i
|
| 161 |
-
let x := fun o:UnitType p n N=>onSide o i
|
| 162 |
-
change pr u (fun i=>P (x i)) ≤_
|
| 163 |
-
rw [←mapW_pr]
|
| 164 |
-
exact (pr_cap (hc i) P).trans ((mul_le_mul_of_nonneg_left
|
| 165 |
-
(hn m hu.cols hu.hymn Y) (bp_pos _).le).trans_eq (by rw [←bp_add]; congr 1; ring))
|
| 166 |
-
have he o (h : ¬gauze p ε δ Y m b.pins o) : ∃ i,Q i o := Classical.not_forall.mp h
|
| 167 |
-
have hv : IsLaw u:=hu.drain.1
|
| 168 |
-
rw [two_mul] at ht
|
| 169 |
-
refine ((pr_mono hv.nz he).trans ((pr_exists_le hv.nz _).trans ?_))
|
| 170 |
-
rw [Fintype.sum_bool]; exact (add_le_add (hf _) (hf _)).trans ht
|
| 171 |
-
|
| 172 |
-
end StatusAnalysis
|
| 173 |
-
end HadwigerCounterexample
|
| 174 |
-
|
| 175 |
-
end
|
| 176 |
-
|
| 177 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.SurrogateStatusLaws
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Cell Positivity Scales -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
variable {p:Shape} {n N K M r : ℕ}
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
open Template
|
| 14 |
+
variable {b : PreparationParameters}
|
| 15 |
+
|
| 16 |
+
namespace Appearance
|
| 17 |
+
variable (x : Appearance p) {s0 : ℕ}
|
| 18 |
+
|
| 19 |
+
theorem readCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 20 |
+
(ε : ℝ) (hε : 0<ε) :
|
| 21 |
+
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 22 |
+
∀ Y : Silhouette p N r,pr (raw m N) (fun o=> x.apt∧¬ x.close Y o ε)≤bp (-(1/16:ℝ)*n) := by
|
| 23 |
+
classical
|
| 24 |
+
have hp:=h.enter.first
|
| 25 |
+
by_cases ha : x.apt
|
| 26 |
+
· let δ : ℝ := ε/(r+1:ℝ)
|
| 27 |
+
have hδ : 0<δ:=by unfold δ; positivity
|
| 28 |
+
filter_upwards [flat_recital x.trot M hp.hM hp.hJ δ hδ,eventually_ge_atTop (2*p.r),
|
| 29 |
+
pay_nat (a:=1/8) (b:=1/16) (num (Fin r)) (by norm_num)] with n hn ht hB N m hN Y
|
| 30 |
+
let w:= x.wit n; let v:= raw m N
|
| 31 |
+
have hw : IsLaw w:= witLaw ha hp.hR ht
|
| 32 |
+
let P (i : Fin r) (o : Orient p n N):=
|
| 33 |
+
δ≤ |x.empirical Y o i - x.reference Y i|
|
| 34 |
+
have hk (i : Fin r) : pr v (P i) ≤ bp (-(1/8:ℝ)*n) := by
|
| 35 |
+
let S (z) := ind (Y x.l x.q z=i)
|
| 36 |
+
have hf z : |S z|≤1 := by unfold S; rw [abs_of_nonneg (ind_nonneg _)]; exact ind_le_one _
|
| 37 |
+
refine hn m w x.q hw (normW_carried (subW_carried _ _))
|
| 38 |
+
(scopedZ_bit p n _ _ _ hw) hN S hf
|
| 39 |
+
have he (o : Orient p n N) (h : x.apt∧¬x.close Y o ε) : ∃ i,P i o := by
|
| 40 |
+
by_contra! hh
|
| 41 |
+
apply h.2
|
| 42 |
+
unfold close varOne
|
| 43 |
+
calc _ ≤ ∑ i : Fin r,δ:= Finset.sum_le_sum fun i _=>le_trans (abs_sub_comm ..).le
|
| 44 |
+
(le_of_not_ge (hh i))
|
| 45 |
+
_ ≤ ε := by
|
| 46 |
+
simp; unfold δ
|
| 47 |
+
calc _ ≤ ((r:ℝ)+1)* (ε/(r+1:ℝ)) := mul_le_mul_of_nonneg_right (by linarith) hδ.le
|
| 48 |
+
_ = ε := by field_simp
|
| 49 |
+
have hv : IsLaw v:= raw_law m hN
|
| 50 |
+
exact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz P)).trans
|
| 51 |
+
(((Finset.sum_le_sum fun i _=>hk i).trans_eq (by simp [num])).trans hB)
|
| 52 |
+
filter_upwards with n N m hN Y
|
| 53 |
+
simp_rw [show (x.apt)=False from eq_false ha,false_and,pr_false]; exact (bp_pos _).le
|
| 54 |
+
|
| 55 |
+
def foil (x : Appearance p) (Y : Silhouette p N r) (o : Orient p n N)
|
| 56 |
+
(m : Mixer p n) (K : ℕ) (δ : ℝ) :=
|
| 57 |
+
∀ (z:Digest p.g) (i:Fin r), z.feasible x.l x.f → z.sumBit=x.q →
|
| 58 |
+
δ ≤ x.reference Y i → Template.patrol x.trot m (scopedScan p n x.l x.f z)
|
| 59 |
+
(fun y => Y x.l x.q y=i) K x.q o
|
| 60 |
+
|
| 61 |
+
theorem foilCap (x : Appearance p) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 62 |
+
(δ:ℝ) (hδ:0<δ) :
|
| 63 |
+
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 64 |
+
unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,
|
| 65 |
+
pr (raw m N) (fun i=>¬x.foil Y i m b.pins δ)≤bp (-(1/18:ℝ)*n) := by
|
| 66 |
+
classical
|
| 67 |
+
have ht:=h.enter.first
|
| 68 |
+
let A:= Digest p.g × Fin r
|
| 69 |
+
let Q n (m:Mixer p n) (Y:Silhouette p (M*n) r) (a : A) (o : Orient p n (M*n)) :=
|
| 70 |
+
a.1.feasible x.l x.f ∧ a.1.sumBit=x.q ∧ δ≤x.reference Y a.2 ∧
|
| 71 |
+
¬Template.patrol x.trot m (scopedScan p n x.l x.f a.1)
|
| 72 |
+
(fun y=>Y x.l x.q y=a.2) b.pins x.q o
|
| 73 |
+
have hg (a:A) :
|
| 74 |
+
∀ᶠ n:ℕ in atTop,let N:=M*n;∀ m:Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 75 |
+
unaryGood m b.pins s0→∀ Y:Silhouette p N r,
|
| 76 |
+
pr (raw m N) (Q n m Y a) ≤ bp (-(1/16:ℝ)*n) := by
|
| 77 |
+
by_cases hf : a.1.feasible x.l x.f ∧ a.1.sumBit=x.q
|
| 78 |
+
· filter_upwards [patrolled x.trot M ht.hM ht.hg ht.hJ a.1 hf.1 ht.hR δ hδ h.profiles
|
| 79 |
+
h.gleaming] with n hn N m hN hM Y
|
| 80 |
+
by_cases he : δ ≤ x.reference Y a.2
|
| 81 |
+
· let S : AtomKey (p:=p) (x.trot.t ()) (M*n) →Prop := fun i=>Y x.l x.q i=a.2
|
| 82 |
+
let v:=scopedScan p n (x.trot.t ()) (x.trot.f ()) a.1
|
| 83 |
+
have hx : δ ≤ pr (lawOmega p (M*n) (x.trot.t ()) a.1.sumBit) S := by
|
| 84 |
+
rw [hf.2]; exact he
|
| 85 |
+
have hh (i:Orient p n (M*n)) (h:Q n m Y a i) :
|
| 86 |
+
¬Template.patrol x.trot m v S b.pins a.1.sumBit i := hf.2 ▸ h.2.2.2
|
| 87 |
+
exact (pr_mono (raw_law m hN).nz hh).trans (hn m hM hN S hx)
|
| 88 |
+
have hg : Q n m Y a=fun _=> False :=
|
| 89 |
+
funext fun i=> eq_false (fun h=>he h.2.2.1)
|
| 90 |
+
change pr (raw m (M*n)) (Q n m Y a) ≤ _
|
| 91 |
+
rw [hg,pr_false]; exact (bp_pos _).le
|
| 92 |
+
filter_upwards with n N m hN hg Y
|
| 93 |
+
have hh : Q n m Y a=fun _=> False :=
|
| 94 |
+
funext fun i=> eq_false (fun h=> hf ⟨h.1,h.2.1⟩)
|
| 95 |
+
change pr (raw m (M*n)) (Q n m Y a) ≤ _
|
| 96 |
+
rw [hh,pr_false]; exact (bp_pos _).le
|
| 97 |
+
filter_upwards [eventually_all.mpr hg,pay_nat (a:=1/16) (b:=1/18) (num A) (by norm_num)]
|
| 98 |
+
with n hn hB N m hN hM Y
|
| 99 |
+
have he o (h : ¬x.foil Y o m b.pins δ) : ∃ i, Q n m Y i o := by
|
| 100 |
+
unfold foil at h
|
| 101 |
+
push Not at h
|
| 102 |
+
obtain ⟨z,i,h⟩:=h
|
| 103 |
+
exact ⟨(z,i),h⟩
|
| 104 |
+
let v:=raw m N
|
| 105 |
+
have hv : IsLaw v:=raw_law m hN
|
| 106 |
+
exact ((pr_mono hv.nz he).trans (pr_exists_le hv.nz _)).trans
|
| 107 |
+
(((Finset.sum_le_sum fun i _=>hn i m hN hM Y).trans_eq (by simp [num])).trans hB)
|
| 108 |
+
end Appearance
|
| 109 |
+
|
| 110 |
+
def smoothSilk (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)
|
| 111 |
+
(m:Mixer p n) (K:ℕ) (o:Orient p n N) :=
|
| 112 |
+
∀ x : Appearance p,(x.apt → x.close Y o ε) ∧ x.foil Y o m K δ
|
| 113 |
+
|
| 114 |
+
variable {s0 : ℕ}
|
| 115 |
+
|
| 116 |
+
def gauze (p : Shape) (ε δ:ℝ) (Y:Silhouette p N r)
|
| 117 |
+
(m:Mixer p n) (K:ℕ) (o:UnitType p n N) :=
|
| 118 |
+
∀ i,smoothSilk p ε δ Y m K (onSide o i)
|
| 119 |
+
|
| 120 |
+
private theorem silken (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 121 |
+
(ε δ : ℝ) (he:0<ε) (hd:0<δ) :
|
| 122 |
+
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,2*num (Full p n)<(N:ℝ) →
|
| 123 |
+
unaryGood m b.pins s0 → ∀ Y: Silhouette p N r,
|
| 124 |
+
pr (raw m N) (fun i=>¬smoothSilk p ε δ Y m b.pins i)≤bp (-(1/20:ℝ)*n) := by
|
| 125 |
+
classical
|
| 126 |
+
let A:= Appearance p
|
| 127 |
+
filter_upwards [eventually_all.mpr (fun x:A=>x.foilCap r M h δ hd),
|
| 128 |
+
eventually_all.mpr (fun x:A=>x.readCap r M h ε he),
|
| 129 |
+
pay_nat (a:=1/18) (b:=1/20) (num A*2) (by norm_num)] with n hn ht hB N m hN hM Y
|
| 130 |
+
let v:=raw m N
|
| 131 |
+
have hv : IsLaw v:=raw_law m hN
|
| 132 |
+
let P (x:A) (o:Orient p n N) :=
|
| 133 |
+
(x.apt ∧ ¬x.close Y o ε)∨ ¬x.foil Y o m b.pins δ
|
| 134 |
+
have hk x : pr v (P x) ≤ 2*bp (-(1/18:ℝ)*n) := by
|
| 135 |
+
rw [two_mul]; apply (pr_or_le hv.nz).trans
|
| 136 |
+
refine add_le_add ((ht x m hN Y).trans (bp_le ?_)) (hn x m hN hM Y)
|
| 137 |
+
linarith [(Nat.cast_nonneg n :0≤(n:ℝ))]
|
| 138 |
+
have hi o (h : ¬smoothSilk p ε δ Y m b.pins o) : ∃ i, P i o := by
|
| 139 |
+
unfold smoothSilk at h
|
| 140 |
+
obtain ⟨i,h⟩:= Classical.not_forall.mp h
|
| 141 |
+
exact ⟨i,by unfold P; tauto⟩
|
| 142 |
+
refine ((pr_mono hv.nz hi).trans (pr_exists_le hv.nz _)).trans
|
| 143 |
+
(((Finset.sum_le_sum fun i _=>hk i).trans_eq ?_).trans hB)
|
| 144 |
+
simp [num,mul_assoc]
|
| 145 |
+
|
| 146 |
+
theorem gauzeCalendar (p : Shape) (r M : ℕ) (h : AnalyticParameters p M b s0)
|
| 147 |
+
(ε δ:ℝ) (he:0<ε) (hd:0<δ) :
|
| 148 |
+
∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ m : Mixer p n,∀ u : Wgt (UnitType p n N),
|
| 149 |
+
PreparationParameters.Align b s0 p M n m u → ∀ Y: Silhouette p N r,
|
| 150 |
+
pr u (fun i=>¬gauze p ε δ Y m b.pins i)≤bp (-(1/100:ℝ)*n) := by
|
| 151 |
+
classical
|
| 152 |
+
filter_upwards [silken p r M h ε δ he hd,pay_nat (a:=1/20-1/32) (b:=1/100) 2
|
| 153 |
+
(by norm_num)] with n hn ht N m u hu Y
|
| 154 |
+
let P (o:Orient p n N) := ¬smoothSilk p ε δ Y m b.pins o
|
| 155 |
+
let Q (i:Bool) (o:UnitType p n N):=P (onSide o i)
|
| 156 |
+
have hc : bySide p u m (bp ((1/32:ℝ)*n)) := fun i=> by
|
| 157 |
+
have hh:= hu.drain
|
| 158 |
+
cases i; exact hh.2.2.1; exact hh.2.1
|
| 159 |
+
have hf : ∀ i,pr u (Q i) ≤bp (-((1/20:ℝ)-1/32)*n) := by
|
| 160 |
+
intro i
|
| 161 |
+
let x := fun o:UnitType p n N=>onSide o i
|
| 162 |
+
change pr u (fun i=>P (x i)) ≤_
|
| 163 |
+
rw [←mapW_pr]
|
| 164 |
+
exact (pr_cap (hc i) P).trans ((mul_le_mul_of_nonneg_left
|
| 165 |
+
(hn m hu.cols hu.hymn Y) (bp_pos _).le).trans_eq (by rw [←bp_add]; congr 1; ring))
|
| 166 |
+
have he o (h : ¬gauze p ε δ Y m b.pins o) : ∃ i,Q i o := Classical.not_forall.mp h
|
| 167 |
+
have hv : IsLaw u:=hu.drain.1
|
| 168 |
+
rw [two_mul] at ht
|
| 169 |
+
refine ((pr_mono hv.nz he).trans ((pr_exists_le hv.nz _).trans ?_))
|
| 170 |
+
rw [Fintype.sum_bool]; exact (add_le_add (hf _) (hf _)).trans ht
|
| 171 |
+
|
| 172 |
+
end StatusAnalysis
|
| 173 |
+
end HadwigerCounterexample
|
| 174 |
+
|
| 175 |
+
end
|
| 176 |
+
|
| 177 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CellPruning.lean
CHANGED
|
@@ -1,128 +1,128 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioning
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.ConditionalProductLaws
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Cell Pruning -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
open Finset
|
| 12 |
-
variable {A B I J : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J]
|
| 13 |
-
|
| 14 |
-
theorem sum_pr_tag (w : Wgt A) (P : A → Prop) (f : A→I) :
|
| 15 |
-
∑ i:I,pr w (fun x => P x ∧ f x=i) = pr w P := by
|
| 16 |
-
classical
|
| 17 |
-
unfold pr
|
| 18 |
-
rw [← avg_sum]
|
| 19 |
-
refine avg_congr fun x _ => ?_
|
| 20 |
-
simp only [ind_and, ← Finset.mul_sum]
|
| 21 |
-
rw [Finset.sum_eq_single (f x)]
|
| 22 |
-
· rw [ind_one rfl,mul_one]
|
| 23 |
-
· intro j _ hj; exact ind_zero hj.symm
|
| 24 |
-
simp
|
| 25 |
-
|
| 26 |
-
/-- implication needed only almost surely for finite measures. -/
|
| 27 |
-
theorem pr_on_mono {w : Wgt A} (hw : ∀ x,0≤w x) {P Q : A→Prop}
|
| 28 |
-
(h : ∀ x,w x≠0→ P x→ Q x) : pr w P ≤ pr w Q :=
|
| 29 |
-
Finset.sum_le_sum (fun x _ => by
|
| 30 |
-
by_cases he : w x=0
|
| 31 |
-
· simp [he]
|
| 32 |
-
exact mul_le_mul_of_nonneg_left (ind_mono (h x he)) (hw x))
|
| 33 |
-
|
| 34 |
-
theorem sum_pr_cells (w : Wgt (A × B)) (P : A × B → Prop) (f : A→I) (g : B→J) :
|
| 35 |
-
∑ i:I,∑ j:J,pr w (fun x => P x ∧ f x.1=i ∧ g x.2=j) = pr w P := by
|
| 36 |
-
classical
|
| 37 |
-
rw [← sum_pr_tag w P (fun x => (f x.1,g x.2)), Fintype.sum_prod_type]
|
| 38 |
-
simp only [Prod.mk.injEq]
|
| 39 |
-
|
| 40 |
-
/-- restore the full pair-event probability in a specified cell. -/
|
| 41 |
-
theorem pair_restore (u : Wgt A) (v : Wgt B) (P : A → Prop) (Q : B → Prop)
|
| 42 |
-
(hP : 0 < pr u P) (hQ : 0 < pr v Q)
|
| 43 |
-
(c : A × B → Prop) :
|
| 44 |
-
pr (pairW u v) (fun x => P x.1 ∧ Q x.2 ∧ c x)=
|
| 45 |
-
pr u P * pr v Q * pr (pairW (onW u P) (onW v Q)) c := by
|
| 46 |
-
classical
|
| 47 |
-
let D := pr u P * pr v Q
|
| 48 |
-
let d := pairW (onW u P) (onW v Q)
|
| 49 |
-
change avg _ _ = D*avg d _
|
| 50 |
-
unfold avg
|
| 51 |
-
rw [Finset.mul_sum]
|
| 52 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 53 |
-
simp only [pairW,d,onW_val,D,ind_and]
|
| 54 |
-
field_simp
|
| 55 |
-
|
| 56 |
-
def memberC (p : A→Prop) (f : A→I) (i : I) (x : A) := p x ∧ f x=i
|
| 57 |
-
|
| 58 |
-
/-- heavy cells criterion. Loss charged to τ times opposite mass
|
| 59 |
-
rather than τ alone (key q fixed). -/
|
| 60 |
-
theorem prune_pairs (w : Wgt A) (v : Wgt B) (hw : SubLaw w) (hv : SubLaw v)
|
| 61 |
-
(P : A → Prop) (Q : B→Prop) (f : A→I) (g : B→J)
|
| 62 |
-
(C : A×B→Prop) (H T : ℝ) (hH : 0≤H) (hT : 0<T)
|
| 63 |
-
{L : ℝ} (hi : (Fintype.card I : ℝ) ≤ L)
|
| 64 |
-
(hj : (Fintype.card J : ℝ) ≤ L)
|
| 65 |
-
(h : ∀ i j,T ≤ pr w (memberC P f i) → T ≤ pr v (memberC Q g j) →
|
| 66 |
-
H≤ pr (pairW (onW w (memberC P f i)) (onW v (memberC Q g j))) C) :
|
| 67 |
-
H * (pr w P * pr v Q) ≤ pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) +
|
| 68 |
-
(H*T*L)*(pr w P+pr v Q) := by
|
| 69 |
-
classical
|
| 70 |
-
let a (i:I) := pr w (memberC P f i)
|
| 71 |
-
let b (i:J) := pr v (memberC Q g i)
|
| 72 |
-
let d (i:I) (j:J) := pr (pairW w v) (fun x => memberC P f i x.1 ∧ memberC Q g j x.2 ∧ C x)
|
| 73 |
-
have ha i : 0≤a i := pr_nonneg hw.nz
|
| 74 |
-
have hb i : 0≤b i := pr_nonneg hv.nz
|
| 75 |
-
have he i j : H*(a i*b j) ≤ d i j+ H*T*b j + H*T*a i := by
|
| 76 |
-
have hz : 0≤ d i j := pr_nonneg (subLaw_pair hw hv).nz
|
| 77 |
-
have ha' := mul_nonneg (mul_nonneg hH hT.le) (ha i)
|
| 78 |
-
have hb' := mul_nonneg (mul_nonneg hH hT.le) (hb j)
|
| 79 |
-
by_cases ht : T ≤ a i
|
| 80 |
-
· by_cases hh : T ≤ b j
|
| 81 |
-
· have hc := mul_le_mul_of_nonneg_right (h i j ht hh) (mul_nonneg (ha i) (hb j))
|
| 82 |
-
have h1 := pair_restore w v _ _ (lt_of_lt_of_le hT ht) (lt_of_lt_of_le hT hh) C
|
| 83 |
-
refine hc.trans ?_
|
| 84 |
-
rw [mul_comm (pr _ C)]
|
| 85 |
-
change _ ≤ d i j + _ + _
|
| 86 |
-
unfold d
|
| 87 |
-
rw [h1]
|
| 88 |
-
change _ ≤ a i*b j * _ + _+_
|
| 89 |
-
linarith
|
| 90 |
-
· have hg := mul_le_mul_of_nonneg_left (le_of_not_ge hh) (mul_nonneg hH (ha i))
|
| 91 |
-
calc H*(a i*b j) ≤ H*T*a i := by linarith only [hg]
|
| 92 |
-
_ ≤ _ := by linarith only [hb',hz]
|
| 93 |
-
have hg := mul_le_mul_of_nonneg_left (le_of_not_ge ht) (mul_nonneg hH (hb j))
|
| 94 |
-
calc H*(a i*b j) ≤ H*T*b j := by linarith only [hg]
|
| 95 |
-
_ ≤ _ := by linarith only [ha',hz]
|
| 96 |
-
have hA : pr w P=∑ i,a i := (sum_pr_tag w P f).symm
|
| 97 |
-
have hB : pr v Q=∑ j,b j := (sum_pr_tag v Q g).symm
|
| 98 |
-
have hC :
|
| 99 |
-
pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) = ∑ i,∑ j,d i j := by
|
| 100 |
-
rw [← sum_pr_cells (pairW w v) _ f g]
|
| 101 |
-
refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_
|
| 102 |
-
unfold d; congr 1; unfold memberC; ext; tauto
|
| 103 |
-
have h1 : H * (pr w P * pr v Q)=∑ i,∑ j,H*(a i*b j) := by
|
| 104 |
-
rw [hA,hB]
|
| 105 |
-
simp only [Finset.sum_mul,Finset.mul_sum]
|
| 106 |
-
exact Finset.sum_comm;
|
| 107 |
-
have h2 : ∑ i:I,∑ j:J,H*T*b j=(Fintype.card I:ℝ)*(H*T*pr v Q) := by
|
| 108 |
-
simp only [← Finset.mul_sum,←hB,Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
|
| 109 |
-
ring
|
| 110 |
-
have h3 : ∑ i:I,∑ j:J,H*T*a i=(Fintype.card J:ℝ)*(H*T*pr w P) := by
|
| 111 |
-
rw [Finset.sum_comm]
|
| 112 |
-
simp only [← Finset.mul_sum,←hA,Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
|
| 113 |
-
ring
|
| 114 |
-
rw [h1]
|
| 115 |
-
refine (Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => he i j).trans ?_
|
| 116 |
-
simp only [Finset.sum_add_distrib]
|
| 117 |
-
rw [h2,h3,← hC]
|
| 118 |
-
have hh := mul_le_mul_of_nonneg_right hj (show 0≤H*T*pr w P from
|
| 119 |
-
mul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hw.nz))
|
| 120 |
-
have hh' := mul_le_mul_of_nonneg_right hi (show 0≤H*T*pr v Q from
|
| 121 |
-
mul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hv.nz))
|
| 122 |
-
linarith only [hh,hh']
|
| 123 |
-
|
| 124 |
-
end HadwigerCounterexample
|
| 125 |
-
|
| 126 |
-
end
|
| 127 |
-
|
| 128 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioning
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.ConditionalProductLaws
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Cell Pruning -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open Finset
|
| 12 |
+
variable {A B I J : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J]
|
| 13 |
+
|
| 14 |
+
theorem sum_pr_tag (w : Wgt A) (P : A → Prop) (f : A→I) :
|
| 15 |
+
∑ i:I,pr w (fun x => P x ∧ f x=i) = pr w P := by
|
| 16 |
+
classical
|
| 17 |
+
unfold pr
|
| 18 |
+
rw [← avg_sum]
|
| 19 |
+
refine avg_congr fun x _ => ?_
|
| 20 |
+
simp only [ind_and, ← Finset.mul_sum]
|
| 21 |
+
rw [Finset.sum_eq_single (f x)]
|
| 22 |
+
· rw [ind_one rfl,mul_one]
|
| 23 |
+
· intro j _ hj; exact ind_zero hj.symm
|
| 24 |
+
simp
|
| 25 |
+
|
| 26 |
+
/-- implication needed only almost surely for finite measures. -/
|
| 27 |
+
theorem pr_on_mono {w : Wgt A} (hw : ∀ x,0≤w x) {P Q : A→Prop}
|
| 28 |
+
(h : ∀ x,w x≠0→ P x→ Q x) : pr w P ≤ pr w Q :=
|
| 29 |
+
Finset.sum_le_sum (fun x _ => by
|
| 30 |
+
by_cases he : w x=0
|
| 31 |
+
· simp [he]
|
| 32 |
+
exact mul_le_mul_of_nonneg_left (ind_mono (h x he)) (hw x))
|
| 33 |
+
|
| 34 |
+
theorem sum_pr_cells (w : Wgt (A × B)) (P : A × B → Prop) (f : A→I) (g : B→J) :
|
| 35 |
+
∑ i:I,∑ j:J,pr w (fun x => P x ∧ f x.1=i ∧ g x.2=j) = pr w P := by
|
| 36 |
+
classical
|
| 37 |
+
rw [← sum_pr_tag w P (fun x => (f x.1,g x.2)), Fintype.sum_prod_type]
|
| 38 |
+
simp only [Prod.mk.injEq]
|
| 39 |
+
|
| 40 |
+
/-- restore the full pair-event probability in a specified cell. -/
|
| 41 |
+
theorem pair_restore (u : Wgt A) (v : Wgt B) (P : A → Prop) (Q : B → Prop)
|
| 42 |
+
(hP : 0 < pr u P) (hQ : 0 < pr v Q)
|
| 43 |
+
(c : A × B → Prop) :
|
| 44 |
+
pr (pairW u v) (fun x => P x.1 ∧ Q x.2 ∧ c x)=
|
| 45 |
+
pr u P * pr v Q * pr (pairW (onW u P) (onW v Q)) c := by
|
| 46 |
+
classical
|
| 47 |
+
let D := pr u P * pr v Q
|
| 48 |
+
let d := pairW (onW u P) (onW v Q)
|
| 49 |
+
change avg _ _ = D*avg d _
|
| 50 |
+
unfold avg
|
| 51 |
+
rw [Finset.mul_sum]
|
| 52 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 53 |
+
simp only [pairW,d,onW_val,D,ind_and]
|
| 54 |
+
field_simp
|
| 55 |
+
|
| 56 |
+
def memberC (p : A→Prop) (f : A→I) (i : I) (x : A) := p x ∧ f x=i
|
| 57 |
+
|
| 58 |
+
/-- heavy cells criterion. Loss charged to τ times opposite mass
|
| 59 |
+
rather than τ alone (key q fixed). -/
|
| 60 |
+
theorem prune_pairs (w : Wgt A) (v : Wgt B) (hw : SubLaw w) (hv : SubLaw v)
|
| 61 |
+
(P : A → Prop) (Q : B→Prop) (f : A→I) (g : B→J)
|
| 62 |
+
(C : A×B→Prop) (H T : ℝ) (hH : 0≤H) (hT : 0<T)
|
| 63 |
+
{L : ℝ} (hi : (Fintype.card I : ℝ) ≤ L)
|
| 64 |
+
(hj : (Fintype.card J : ℝ) ≤ L)
|
| 65 |
+
(h : ∀ i j,T ≤ pr w (memberC P f i) → T ≤ pr v (memberC Q g j) →
|
| 66 |
+
H≤ pr (pairW (onW w (memberC P f i)) (onW v (memberC Q g j))) C) :
|
| 67 |
+
H * (pr w P * pr v Q) ≤ pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) +
|
| 68 |
+
(H*T*L)*(pr w P+pr v Q) := by
|
| 69 |
+
classical
|
| 70 |
+
let a (i:I) := pr w (memberC P f i)
|
| 71 |
+
let b (i:J) := pr v (memberC Q g i)
|
| 72 |
+
let d (i:I) (j:J) := pr (pairW w v) (fun x => memberC P f i x.1 ∧ memberC Q g j x.2 ∧ C x)
|
| 73 |
+
have ha i : 0≤a i := pr_nonneg hw.nz
|
| 74 |
+
have hb i : 0≤b i := pr_nonneg hv.nz
|
| 75 |
+
have he i j : H*(a i*b j) ≤ d i j+ H*T*b j + H*T*a i := by
|
| 76 |
+
have hz : 0≤ d i j := pr_nonneg (subLaw_pair hw hv).nz
|
| 77 |
+
have ha' := mul_nonneg (mul_nonneg hH hT.le) (ha i)
|
| 78 |
+
have hb' := mul_nonneg (mul_nonneg hH hT.le) (hb j)
|
| 79 |
+
by_cases ht : T ≤ a i
|
| 80 |
+
· by_cases hh : T ≤ b j
|
| 81 |
+
· have hc := mul_le_mul_of_nonneg_right (h i j ht hh) (mul_nonneg (ha i) (hb j))
|
| 82 |
+
have h1 := pair_restore w v _ _ (lt_of_lt_of_le hT ht) (lt_of_lt_of_le hT hh) C
|
| 83 |
+
refine hc.trans ?_
|
| 84 |
+
rw [mul_comm (pr _ C)]
|
| 85 |
+
change _ ≤ d i j + _ + _
|
| 86 |
+
unfold d
|
| 87 |
+
rw [h1]
|
| 88 |
+
change _ ≤ a i*b j * _ + _+_
|
| 89 |
+
linarith
|
| 90 |
+
· have hg := mul_le_mul_of_nonneg_left (le_of_not_ge hh) (mul_nonneg hH (ha i))
|
| 91 |
+
calc H*(a i*b j) ≤ H*T*a i := by linarith only [hg]
|
| 92 |
+
_ ≤ _ := by linarith only [hb',hz]
|
| 93 |
+
have hg := mul_le_mul_of_nonneg_left (le_of_not_ge ht) (mul_nonneg hH (hb j))
|
| 94 |
+
calc H*(a i*b j) ≤ H*T*b j := by linarith only [hg]
|
| 95 |
+
_ ≤ _ := by linarith only [ha',hz]
|
| 96 |
+
have hA : pr w P=∑ i,a i := (sum_pr_tag w P f).symm
|
| 97 |
+
have hB : pr v Q=∑ j,b j := (sum_pr_tag v Q g).symm
|
| 98 |
+
have hC :
|
| 99 |
+
pr (pairW w v) (fun x => P x.1 ∧ Q x.2 ∧ C x) = ∑ i,∑ j,d i j := by
|
| 100 |
+
rw [← sum_pr_cells (pairW w v) _ f g]
|
| 101 |
+
refine Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => ?_
|
| 102 |
+
unfold d; congr 1; unfold memberC; ext; tauto
|
| 103 |
+
have h1 : H * (pr w P * pr v Q)=∑ i,∑ j,H*(a i*b j) := by
|
| 104 |
+
rw [hA,hB]
|
| 105 |
+
simp only [Finset.sum_mul,Finset.mul_sum]
|
| 106 |
+
exact Finset.sum_comm;
|
| 107 |
+
have h2 : ∑ i:I,∑ j:J,H*T*b j=(Fintype.card I:ℝ)*(H*T*pr v Q) := by
|
| 108 |
+
simp only [← Finset.mul_sum,←hB,Finset.sum_const, Finset.card_univ, nsmul_eq_mul]
|
| 109 |
+
ring
|
| 110 |
+
have h3 : ∑ i:I,∑ j:J,H*T*a i=(Fintype.card J:ℝ)*(H*T*pr w P) := by
|
| 111 |
+
rw [Finset.sum_comm]
|
| 112 |
+
simp only [← Finset.mul_sum,←hA,Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
|
| 113 |
+
ring
|
| 114 |
+
rw [h1]
|
| 115 |
+
refine (Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => he i j).trans ?_
|
| 116 |
+
simp only [Finset.sum_add_distrib]
|
| 117 |
+
rw [h2,h3,← hC]
|
| 118 |
+
have hh := mul_le_mul_of_nonneg_right hj (show 0≤H*T*pr w P from
|
| 119 |
+
mul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hw.nz))
|
| 120 |
+
have hh' := mul_le_mul_of_nonneg_right hi (show 0≤H*T*pr v Q from
|
| 121 |
+
mul_nonneg (mul_nonneg hH hT.le) (pr_nonneg hv.nz))
|
| 122 |
+
linarith only [hh,hh']
|
| 123 |
+
|
| 124 |
+
end HadwigerCounterexample
|
| 125 |
+
|
| 126 |
+
end
|
| 127 |
+
|
| 128 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFactorization.lean
CHANGED
|
@@ -1,144 +1,144 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BilinearCompression
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Channel Factorization -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Submodule Module
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ}
|
| 12 |
-
variable {I J : Type} [Fintype I] [Fintype J]
|
| 13 |
-
|
| 14 |
-
/-- Pairing rank after imposing orthogonality constraints. -/
|
| 15 |
-
theorem biorth_exists (S T : Space (Vec I)) (r : ℕ)
|
| 16 |
-
(h : r+dim S+dim T≤Fintype.card I) :
|
| 17 |
-
∃ A B : Mat I (Fin r), colSp A≤ annih S ∧ colSp B≤ annih T ∧ Aᵀ*B=1 := by
|
| 18 |
-
classical
|
| 19 |
-
let V := annih S
|
| 20 |
-
let W := annih T
|
| 21 |
-
let M := (pack V)ᵀ * pack W
|
| 22 |
-
let t := M.rank
|
| 23 |
-
have ht : r≤t := by
|
| 24 |
-
have h1 := rank_ge_mul (pack V)ᵀ (pack W)
|
| 25 |
-
rw [Matrix.rank_transpose,mrk_inj.mp (pack_inj V),mrk_inj.mp (pack_inj W),
|
| 26 |
-
Fintype.card_fin,Fintype.card_fin] at h1
|
| 27 |
-
have h2 : dim S+dim V=Fintype.card I := annih_dim S
|
| 28 |
-
have h3 : dim T+dim W=Fintype.card I := annih_dim T
|
| 29 |
-
have he (a b c d t r e : ℕ) (h : r+a+b ≤ e) (hx : a+c=e) (hy : b+d=e) (ht : c+d≤t+e) :
|
| 30 |
-
r≤t := by omega
|
| 31 |
-
exact he _ _ _ _ _ _ _ h h2 h3 h1
|
| 32 |
-
obtain ⟨A,B,hA,hB,hM⟩ := rank_product M
|
| 33 |
-
obtain ⟨L,hL⟩ := mat_left_inv hA
|
| 34 |
-
obtain ⟨R,hR⟩ := mat_left_inv (P:=Bᵀ) (transpose_surj_iff.mp (by rw [Matrix.transpose_transpose]; exact hB))
|
| 35 |
-
let E := embedMat (Fin.castLE ht)
|
| 36 |
-
refine ⟨pack V * (Lᵀ * E),pack W*(Rᵀ*E),?_,?_,?_⟩
|
| 37 |
-
· rintro x ⟨x,rfl⟩
|
| 38 |
-
rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]
|
| 39 |
-
exact (pack_mem_iff ..).mpr ⟨_,rfl⟩
|
| 40 |
-
· rintro x ⟨x,rfl⟩
|
| 41 |
-
rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]
|
| 42 |
-
exact (pack_mem_iff ..).mpr ⟨_,rfl⟩
|
| 43 |
-
have he : L*M*Rᵀ=1 := by
|
| 44 |
-
have hg : B*Rᵀ=1 := by
|
| 45 |
-
simpa only [Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.transpose_one] using
|
| 46 |
-
congrArg Matrix.transpose hR
|
| 47 |
-
refine (congrArg (fun X => L*X*Rᵀ) hM).symm.trans ?_
|
| 48 |
-
rw [← Matrix.mul_assoc L,hL,Matrix.one_mul,hg]
|
| 49 |
-
have heq : Eᵀ * E=1 := embedMat_self (Fin.castLE_injective ht)
|
| 50 |
-
rw [Matrix.transpose_mul,Matrix.transpose_mul,Matrix.transpose_transpose]
|
| 51 |
-
calc _ = Eᵀ*(L*M*Rᵀ)*E := by simp only [M,Matrix.mul_assoc]
|
| 52 |
-
_ = _ := by rw [he,Matrix.mul_one,heq]
|
| 53 |
-
|
| 54 |
-
/-- split desired respective bounded-rank bilinear form -/
|
| 55 |
-
theorem pure_chan_split (M : Mat J J) (S T : Space (Vec I)) (X Y : Space (Vec J))
|
| 56 |
-
(h : M∈box (annih X) (annih Y)) (ht : M.rank+dim S+dim T ≤ Fintype.card I) :
|
| 57 |
-
∃ A ∈ box (annih S) (annih X),∃ B∈box (annih T) (annih Y), Aᵀ * B=M := by
|
| 58 |
-
classical
|
| 59 |
-
obtain ⟨P,Q,hP,hQ,hM⟩ := rank_product M
|
| 60 |
-
obtain ⟨A,B,hA,hB,he⟩ := biorth_exists S T M.rank ht
|
| 61 |
-
obtain ⟨hx,hy⟩ := box_kill.mp h
|
| 62 |
-
refine ⟨A * Pᵀ,?_,B*Q,?_,?_⟩
|
| 63 |
-
· rw [box_kill]
|
| 64 |
-
constructor
|
| 65 |
-
· intro x hx; rw [Matrix.transpose_mul,← Matrix.mulVec_mulVec,(colSp_kill ..).mp hA x hx,
|
| 66 |
-
Matrix.mulVec_zero]
|
| 67 |
-
intro x hv
|
| 68 |
-
have hv' : Pᵀ *ᵥ x=0 := by
|
| 69 |
-
have hqi := (transpose_surj_iff (P:=Qᵀ)).mp (by rw [Matrix.transpose_transpose]; exact hQ)
|
| 70 |
-
apply hqi
|
| 71 |
-
rw [Matrix.mulVec_mulVec,← Matrix.transpose_mul,hM,hx x hv,Matrix.mulVec_zero]
|
| 72 |
-
rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]
|
| 73 |
-
· rw [box_kill]
|
| 74 |
-
constructor
|
| 75 |
-
· intro x hv; rw [Matrix.transpose_mul,←Matrix.mulVec_mulVec,(colSp_kill ..).mp hB x hv,
|
| 76 |
-
Matrix.mulVec_zero]
|
| 77 |
-
intro y hv
|
| 78 |
-
have hv' : Q *ᵥ y=0 := by
|
| 79 |
-
apply hP
|
| 80 |
-
rw [Matrix.mulVec_mulVec,hM,hy y hv,mulVec_zero]
|
| 81 |
-
rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]
|
| 82 |
-
· rw [Matrix.transpose_mul,Matrix.transpose_transpose,← Matrix.mul_assoc _ B, Matrix.mul_assoc P,
|
| 83 |
-
he,Matrix.mul_one,hM]
|
| 84 |
-
|
| 85 |
-
/-- The final channel change for fixed B endpoint. -/
|
| 86 |
-
theorem chan_factor {f b : Plan p n} {P : PureForms p n} {C : ChanOut p n} {j : Bool}
|
| 87 |
-
(H T K : ℕ) (hc : outSmall H C) (hK : ∀ z,dim (hPin b z j)≤K)
|
| 88 |
-
(hh : T+2*(K+2*H)≤p.h)
|
| 89 |
-
(hP : P∈pureSpace p f) (ht : ∀ e,(P e).rank≤T) :
|
| 90 |
-
∃ D∈deltaSpace p f b j,obsPair p (chanInner p (C+D) (C+D))=
|
| 91 |
-
obsPair p (chanInner p C C)+obsPair p P := by
|
| 92 |
-
classical
|
| 93 |
-
let S (z : Place p) := hPin b (flipZ p z) j ⊔ priOut p C (flipZ p z)
|
| 94 |
-
have h (z : Place p) : dim (S z) ≤ K+2*H :=
|
| 95 |
-
(Submodule.finrank_add_le_finrank_add_finrank ..).trans
|
| 96 |
-
(add_le_add (hK _) (dim_priOut hc _))
|
| 97 |
-
choose A hA B hB hQ using fun e : Comp p.g =>
|
| 98 |
-
pure_chan_split (P e) (S (e,true)) (S (e,false)) (f (e,true)) (f (e,false))
|
| 99 |
-
((pureSpace_mem _).mp hP e) ((add_le_add
|
| 100 |
-
(add_le_add (ht e) (h (e,true))) (h (e,false))).trans
|
| 101 |
-
(by
|
| 102 |
-
rw [Fintype.card_fin]
|
| 103 |
-
rwa [two_mul, ← add_assoc] at hh))
|
| 104 |
-
let D : ChanOut p n := fun z => if z.2 then A z.1 else B z.1
|
| 105 |
-
have h1 (z : Place p) : D z∈box (annih (S z)) (annih (f z)) := by
|
| 106 |
-
cases z with | mk e c => cases c; exact hB e; exact hA e
|
| 107 |
-
refine ⟨D,(deltaSpace_mem _).mpr ?_,?_⟩
|
| 108 |
-
· intro z
|
| 109 |
-
refine box_le ?_ le_rfl (h1 z)
|
| 110 |
-
intro x hx
|
| 111 |
-
rw [annih_mem]
|
| 112 |
-
exact fun y hy => (annih_mem ..).mp hx y (Submodule.mem_sup_left hy)
|
| 113 |
-
have hg : chanInner p D D=P := funext (fun e => hQ e)
|
| 114 |
-
have he (z : Place p) (i l : Bool) (x y : Ray p n) :
|
| 115 |
-
dotProduct ((C (flipZ p z)*IP p n i) *ᵥ x) ((D z*IP p n l)*ᵥ y)=0 := by
|
| 116 |
-
have hq : ((C (flipZ p z)*IP p n i) *ᵥ x) ∈ S z :=
|
| 117 |
-
Submodule.mem_sup_right (le_priOut C _ i ⟨x,rfl⟩)
|
| 118 |
-
have hl : ((D z * IP p n l)*ᵥ y) ∈ annih (S z) := by
|
| 119 |
-
rw [←Matrix.mulVec_mulVec]
|
| 120 |
-
exact ((box_mem ..).mp (h1 z)).1 ⟨_,rfl⟩
|
| 121 |
-
rw [dotProduct_comm]
|
| 122 |
-
exact (annih_mem ..).mp hl _ hq
|
| 123 |
-
have hd : obsPair p (chanDeriv p C D)=0 := by
|
| 124 |
-
rw [←obsI_each]
|
| 125 |
-
have hz : eachF p (chanDeriv p C D)=0 := by
|
| 126 |
-
unfold chanDeriv; rw [map_add]
|
| 127 |
-
funext i e
|
| 128 |
-
rw [Pi.add_apply,Pi.add_apply,each_chan_val,each_chan_val]
|
| 129 |
-
refine evmat_ext fun x y => ?_
|
| 130 |
-
rw [evmat_addM,ev_duom,ev_duom]
|
| 131 |
-
have hh1 := he (e,false) i i x y
|
| 132 |
-
have hh2 := he (e,true) i i y x
|
| 133 |
-
simp only [flipZ,Bool.not_false,Bool.not_true] at hh1 hh2
|
| 134 |
-
rw [hh1,
|
| 135 |
-
dotProduct_comm ((D (e,true) * IP p n i) *ᵥ _),hh2]
|
| 136 |
-
simp [evmat]
|
| 137 |
-
rw [hz,map_zero]
|
| 138 |
-
rw [obsPair_chan_change,hd,add_zero,hg]
|
| 139 |
-
|
| 140 |
-
end HadwigerCounterexample
|
| 141 |
-
|
| 142 |
-
end
|
| 143 |
-
|
| 144 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BilinearCompression
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Channel Factorization -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Submodule Module
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ}
|
| 12 |
+
variable {I J : Type} [Fintype I] [Fintype J]
|
| 13 |
+
|
| 14 |
+
/-- Pairing rank after imposing orthogonality constraints. -/
|
| 15 |
+
theorem biorth_exists (S T : Space (Vec I)) (r : ℕ)
|
| 16 |
+
(h : r+dim S+dim T≤Fintype.card I) :
|
| 17 |
+
∃ A B : Mat I (Fin r), colSp A≤ annih S ∧ colSp B≤ annih T ∧ Aᵀ*B=1 := by
|
| 18 |
+
classical
|
| 19 |
+
let V := annih S
|
| 20 |
+
let W := annih T
|
| 21 |
+
let M := (pack V)ᵀ * pack W
|
| 22 |
+
let t := M.rank
|
| 23 |
+
have ht : r≤t := by
|
| 24 |
+
have h1 := rank_ge_mul (pack V)ᵀ (pack W)
|
| 25 |
+
rw [Matrix.rank_transpose,mrk_inj.mp (pack_inj V),mrk_inj.mp (pack_inj W),
|
| 26 |
+
Fintype.card_fin,Fintype.card_fin] at h1
|
| 27 |
+
have h2 : dim S+dim V=Fintype.card I := annih_dim S
|
| 28 |
+
have h3 : dim T+dim W=Fintype.card I := annih_dim T
|
| 29 |
+
have he (a b c d t r e : ℕ) (h : r+a+b ≤ e) (hx : a+c=e) (hy : b+d=e) (ht : c+d≤t+e) :
|
| 30 |
+
r≤t := by omega
|
| 31 |
+
exact he _ _ _ _ _ _ _ h h2 h3 h1
|
| 32 |
+
obtain ⟨A,B,hA,hB,hM⟩ := rank_product M
|
| 33 |
+
obtain ⟨L,hL⟩ := mat_left_inv hA
|
| 34 |
+
obtain ⟨R,hR⟩ := mat_left_inv (P:=Bᵀ) (transpose_surj_iff.mp (by rw [Matrix.transpose_transpose]; exact hB))
|
| 35 |
+
let E := embedMat (Fin.castLE ht)
|
| 36 |
+
refine ⟨pack V * (Lᵀ * E),pack W*(Rᵀ*E),?_,?_,?_⟩
|
| 37 |
+
· rintro x ⟨x,rfl⟩
|
| 38 |
+
rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]
|
| 39 |
+
exact (pack_mem_iff ..).mpr ⟨_,rfl⟩
|
| 40 |
+
· rintro x ⟨x,rfl⟩
|
| 41 |
+
rw [Matrix.mulVecLin_apply,← Matrix.mulVec_mulVec]
|
| 42 |
+
exact (pack_mem_iff ..).mpr ⟨_,rfl⟩
|
| 43 |
+
have he : L*M*Rᵀ=1 := by
|
| 44 |
+
have hg : B*Rᵀ=1 := by
|
| 45 |
+
simpa only [Matrix.transpose_mul, Matrix.transpose_transpose, Matrix.transpose_one] using
|
| 46 |
+
congrArg Matrix.transpose hR
|
| 47 |
+
refine (congrArg (fun X => L*X*Rᵀ) hM).symm.trans ?_
|
| 48 |
+
rw [← Matrix.mul_assoc L,hL,Matrix.one_mul,hg]
|
| 49 |
+
have heq : Eᵀ * E=1 := embedMat_self (Fin.castLE_injective ht)
|
| 50 |
+
rw [Matrix.transpose_mul,Matrix.transpose_mul,Matrix.transpose_transpose]
|
| 51 |
+
calc _ = Eᵀ*(L*M*Rᵀ)*E := by simp only [M,Matrix.mul_assoc]
|
| 52 |
+
_ = _ := by rw [he,Matrix.mul_one,heq]
|
| 53 |
+
|
| 54 |
+
/-- split desired respective bounded-rank bilinear form -/
|
| 55 |
+
theorem pure_chan_split (M : Mat J J) (S T : Space (Vec I)) (X Y : Space (Vec J))
|
| 56 |
+
(h : M∈box (annih X) (annih Y)) (ht : M.rank+dim S+dim T ≤ Fintype.card I) :
|
| 57 |
+
∃ A ∈ box (annih S) (annih X),∃ B∈box (annih T) (annih Y), Aᵀ * B=M := by
|
| 58 |
+
classical
|
| 59 |
+
obtain ⟨P,Q,hP,hQ,hM⟩ := rank_product M
|
| 60 |
+
obtain ⟨A,B,hA,hB,he⟩ := biorth_exists S T M.rank ht
|
| 61 |
+
obtain ⟨hx,hy⟩ := box_kill.mp h
|
| 62 |
+
refine ⟨A * Pᵀ,?_,B*Q,?_,?_⟩
|
| 63 |
+
· rw [box_kill]
|
| 64 |
+
constructor
|
| 65 |
+
· intro x hx; rw [Matrix.transpose_mul,← Matrix.mulVec_mulVec,(colSp_kill ..).mp hA x hx,
|
| 66 |
+
Matrix.mulVec_zero]
|
| 67 |
+
intro x hv
|
| 68 |
+
have hv' : Pᵀ *ᵥ x=0 := by
|
| 69 |
+
have hqi := (transpose_surj_iff (P:=Qᵀ)).mp (by rw [Matrix.transpose_transpose]; exact hQ)
|
| 70 |
+
apply hqi
|
| 71 |
+
rw [Matrix.mulVec_mulVec,← Matrix.transpose_mul,hM,hx x hv,Matrix.mulVec_zero]
|
| 72 |
+
rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]
|
| 73 |
+
· rw [box_kill]
|
| 74 |
+
constructor
|
| 75 |
+
· intro x hv; rw [Matrix.transpose_mul,←Matrix.mulVec_mulVec,(colSp_kill ..).mp hB x hv,
|
| 76 |
+
Matrix.mulVec_zero]
|
| 77 |
+
intro y hv
|
| 78 |
+
have hv' : Q *ᵥ y=0 := by
|
| 79 |
+
apply hP
|
| 80 |
+
rw [Matrix.mulVec_mulVec,hM,hy y hv,mulVec_zero]
|
| 81 |
+
rw [←Matrix.mulVec_mulVec,hv',mulVec_zero]
|
| 82 |
+
· rw [Matrix.transpose_mul,Matrix.transpose_transpose,← Matrix.mul_assoc _ B, Matrix.mul_assoc P,
|
| 83 |
+
he,Matrix.mul_one,hM]
|
| 84 |
+
|
| 85 |
+
/-- The final channel change for fixed B endpoint. -/
|
| 86 |
+
theorem chan_factor {f b : Plan p n} {P : PureForms p n} {C : ChanOut p n} {j : Bool}
|
| 87 |
+
(H T K : ℕ) (hc : outSmall H C) (hK : ∀ z,dim (hPin b z j)≤K)
|
| 88 |
+
(hh : T+2*(K+2*H)≤p.h)
|
| 89 |
+
(hP : P∈pureSpace p f) (ht : ∀ e,(P e).rank≤T) :
|
| 90 |
+
∃ D∈deltaSpace p f b j,obsPair p (chanInner p (C+D) (C+D))=
|
| 91 |
+
obsPair p (chanInner p C C)+obsPair p P := by
|
| 92 |
+
classical
|
| 93 |
+
let S (z : Place p) := hPin b (flipZ p z) j ⊔ priOut p C (flipZ p z)
|
| 94 |
+
have h (z : Place p) : dim (S z) ≤ K+2*H :=
|
| 95 |
+
(Submodule.finrank_add_le_finrank_add_finrank ..).trans
|
| 96 |
+
(add_le_add (hK _) (dim_priOut hc _))
|
| 97 |
+
choose A hA B hB hQ using fun e : Comp p.g =>
|
| 98 |
+
pure_chan_split (P e) (S (e,true)) (S (e,false)) (f (e,true)) (f (e,false))
|
| 99 |
+
((pureSpace_mem _).mp hP e) ((add_le_add
|
| 100 |
+
(add_le_add (ht e) (h (e,true))) (h (e,false))).trans
|
| 101 |
+
(by
|
| 102 |
+
rw [Fintype.card_fin]
|
| 103 |
+
rwa [two_mul, ← add_assoc] at hh))
|
| 104 |
+
let D : ChanOut p n := fun z => if z.2 then A z.1 else B z.1
|
| 105 |
+
have h1 (z : Place p) : D z∈box (annih (S z)) (annih (f z)) := by
|
| 106 |
+
cases z with | mk e c => cases c; exact hB e; exact hA e
|
| 107 |
+
refine ⟨D,(deltaSpace_mem _).mpr ?_,?_⟩
|
| 108 |
+
· intro z
|
| 109 |
+
refine box_le ?_ le_rfl (h1 z)
|
| 110 |
+
intro x hx
|
| 111 |
+
rw [annih_mem]
|
| 112 |
+
exact fun y hy => (annih_mem ..).mp hx y (Submodule.mem_sup_left hy)
|
| 113 |
+
have hg : chanInner p D D=P := funext (fun e => hQ e)
|
| 114 |
+
have he (z : Place p) (i l : Bool) (x y : Ray p n) :
|
| 115 |
+
dotProduct ((C (flipZ p z)*IP p n i) *ᵥ x) ((D z*IP p n l)*ᵥ y)=0 := by
|
| 116 |
+
have hq : ((C (flipZ p z)*IP p n i) *ᵥ x) ∈ S z :=
|
| 117 |
+
Submodule.mem_sup_right (le_priOut C _ i ⟨x,rfl⟩)
|
| 118 |
+
have hl : ((D z * IP p n l)*ᵥ y) ∈ annih (S z) := by
|
| 119 |
+
rw [←Matrix.mulVec_mulVec]
|
| 120 |
+
exact ((box_mem ..).mp (h1 z)).1 ⟨_,rfl⟩
|
| 121 |
+
rw [dotProduct_comm]
|
| 122 |
+
exact (annih_mem ..).mp hl _ hq
|
| 123 |
+
have hd : obsPair p (chanDeriv p C D)=0 := by
|
| 124 |
+
rw [←obsI_each]
|
| 125 |
+
have hz : eachF p (chanDeriv p C D)=0 := by
|
| 126 |
+
unfold chanDeriv; rw [map_add]
|
| 127 |
+
funext i e
|
| 128 |
+
rw [Pi.add_apply,Pi.add_apply,each_chan_val,each_chan_val]
|
| 129 |
+
refine evmat_ext fun x y => ?_
|
| 130 |
+
rw [evmat_addM,ev_duom,ev_duom]
|
| 131 |
+
have hh1 := he (e,false) i i x y
|
| 132 |
+
have hh2 := he (e,true) i i y x
|
| 133 |
+
simp only [flipZ,Bool.not_false,Bool.not_true] at hh1 hh2
|
| 134 |
+
rw [hh1,
|
| 135 |
+
dotProduct_comm ((D (e,true) * IP p n i) *ᵥ _),hh2]
|
| 136 |
+
simp [evmat]
|
| 137 |
+
rw [hz,map_zero]
|
| 138 |
+
rw [obsPair_chan_change,hd,add_zero,hg]
|
| 139 |
+
|
| 140 |
+
end HadwigerCounterexample
|
| 141 |
+
|
| 142 |
+
end
|
| 143 |
+
|
| 144 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ChannelFrameLaws.lean
CHANGED
|
@@ -1,186 +1,186 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.SumRankBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Channel Frame Laws -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Module Submodule Finset Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
|
| 12 |
-
variable {A B : Type} [Fintype A] [Fintype B]
|
| 13 |
-
|
| 14 |
-
theorem map_pair_law {C D : Type} [Fintype C] [Fintype D]
|
| 15 |
-
(w : Wgt A) (v : Wgt B) (f : A→C) (g : B→D) :
|
| 16 |
-
mapW (pairW w v) (Prod.map f g)=pairW (mapW w f) (mapW v g) := by
|
| 17 |
-
funext x
|
| 18 |
-
unfold mapW pairW
|
| 19 |
-
simp only [Prod.ext_iff]
|
| 20 |
-
exact pairW_pr w v (fun y => f y=x.1) (fun y => g y=x.2)
|
| 21 |
-
|
| 22 |
-
theorem mapW_nested {C : Type} (w : Wgt A) (f : A→B) (g : B→C) :
|
| 23 |
-
mapW (mapW w f) g=mapW w (g ∘ f) :=
|
| 24 |
-
funext fun _ => mapW_pr _ _ _
|
| 25 |
-
|
| 26 |
-
omit [Fintype B] in
|
| 27 |
-
theorem mapW_repeat {I : Type} [Fintype I] [DecidableEq I]
|
| 28 |
-
(w : I→ Wgt A) (f : I→ A→B) :
|
| 29 |
-
mapW (prodW w) (fun x i => f i (x i))=prodW (fun i => mapW (w i) (f i)) := by
|
| 30 |
-
funext x
|
| 31 |
-
unfold mapW
|
| 32 |
-
simp_rw [funext_iff]
|
| 33 |
-
exact prodW_pr _ (fun i y => f i y=x i)
|
| 34 |
-
|
| 35 |
-
omit [Fintype B] in
|
| 36 |
-
theorem mapW_pr_eq (e : A≃A) (f : A→B) (u : B≃B) (h : ∀ x,f (e x)=u (f x))
|
| 37 |
-
(w : Wgt A) (hw : ∀ x, w (e x)=w x) (x : B) : mapW w f (u x)=mapW w f x := by
|
| 38 |
-
have he := avg_bij e w (fun y => ind (f y=u x))
|
| 39 |
-
simp_rw [hw,h,u.injective.eq_iff] at he
|
| 40 |
-
exact he.symm
|
| 41 |
-
|
| 42 |
-
private theorem pmax_test {x : A} (p : A → Prop) {w : Wgt A} (hw : SubLaw w)
|
| 43 |
-
(h : ∀ y, p y → w y=w x) {m : ℝ} (hm : 0 < m)
|
| 44 |
-
(hp : m ≤ pr unif p) [Nonempty A] :
|
| 45 |
-
w x ≤ m⁻¹ * unif x := by
|
| 46 |
-
have hh : pr w p=w x*nbr p := by
|
| 47 |
-
simp only [pr,avg,nbr,tot,Finset.mul_sum]
|
| 48 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 49 |
-
by_cases he : p i
|
| 50 |
-
· rw [h i he]
|
| 51 |
-
rw [ind_zero he,mul_zero,mul_zero]
|
| 52 |
-
have h1 := (pr_le_tot (p:=p) hw.nz).trans hw.total
|
| 53 |
-
rw [hh] at h1
|
| 54 |
-
have hU : 0 < (Fintype.card A : ℝ) := by exact_mod_cast Fintype.card_pos
|
| 55 |
-
rw [pr_unif (A:=A)] at hp
|
| 56 |
-
have hi := (le_div_iff₀ hU).mp hp
|
| 57 |
-
rw [unif_apply]
|
| 58 |
-
field_simp
|
| 59 |
-
nlinarith only [h1,hi,mul_le_mul_of_nonneg_left hi (hw.nz x)]
|
| 60 |
-
|
| 61 |
-
theorem gram_norm_quarter {I J L : Type} [Fintype I] [Fintype J] [Fintype L]
|
| 62 |
-
[DecidableEq I] [DecidableEq J] [DecidableEq L] (G : Mat I J)
|
| 63 |
-
(h : num I + num J-num L ≤ -1) :
|
| 64 |
-
bp (-num I * num J)/4 ≤ pr unif (gramGood (U:=L) G) := by
|
| 65 |
-
have hn := (gram_norm G (by linarith : num I+num J≤num L)).2
|
| 66 |
-
rw [pair_unif]
|
| 67 |
-
refine le_trans ?_ hn
|
| 68 |
-
have he {x : ℝ} (hx : x ≤ -1) : (1/2 : ℝ)≤ 1-bp x := by
|
| 69 |
-
have ht := bp_le hx
|
| 70 |
-
rw [bp_neg,bp_one] at ht
|
| 71 |
-
linarith only [ht]
|
| 72 |
-
let d := bp (-num I*num J)
|
| 73 |
-
change d/4 ≤ d* _ * _
|
| 74 |
-
have hk : 0 < d := bp_pos _
|
| 75 |
-
have h1 := he (x:= num I-num L) (by
|
| 76 |
-
have hg : 0≤num J := Nat.cast_nonneg _
|
| 77 |
-
linarith)
|
| 78 |
-
calc d/4 = d*(1/2)*(1/2) := by ring
|
| 79 |
-
_ ≤ _ := mul_le_mul (mul_le_mul_of_nonneg_left h1 hk.le) (he h) (by norm_num)
|
| 80 |
-
(mul_nonneg hk.le (le_trans (by norm_num) h1))
|
| 81 |
-
|
| 82 |
-
variable {I J U : Type} [Fintype I] [Fintype J] [Fintype U]
|
| 83 |
-
variable [DecidableEq I] [DecidableEq J] [DecidableEq U]
|
| 84 |
-
|
| 85 |
-
theorem gramObsCap {C : Mat (I⊕J) (I⊕J) → Prop}
|
| 86 |
-
(hc : ∃ x : Mat U (I⊕J) × _, FramesAt C x)
|
| 87 |
-
(T : Mat (I⊕J) J) (ht : Function.Injective T.mulVec)
|
| 88 |
-
(hN : 2*num J-num U≤ -1) :
|
| 89 |
-
let w := unifOn (FramesAt C)
|
| 90 |
-
∀ x : Mat U J × Mat U J,
|
| 91 |
-
mapW w (observe T T) x ≤ (4*bp (num J*num J))*pairW unif unif x := by
|
| 92 |
-
classical
|
| 93 |
-
let w := unifOn (FramesAt (U:=U) C)
|
| 94 |
-
have hw := unifOn_law hc
|
| 95 |
-
let f := observe T T (U:=U)
|
| 96 |
-
let v := mapW w f
|
| 97 |
-
have hv : IsLaw v := mapW_law hw f
|
| 98 |
-
have hg :
|
| 99 |
-
carried v (fun x : Mat U J × _ => Injective x.1.mulVec ∧ Injective x.2.mulVec) := by
|
| 100 |
-
refine mapW_carried (unifOn_carried _) (fun x hx => ?_)
|
| 101 |
-
exact ⟨inj_comp_mat _ _ hx.2.1 ht,inj_comp_mat _ _ hx.2.2 ht⟩
|
| 102 |
-
dsimp only
|
| 103 |
-
intro x
|
| 104 |
-
rw [← pair_unif]
|
| 105 |
-
by_cases h : v x≠0
|
| 106 |
-
· let G := (x.1ᵀ*x.2 : Mat J J)
|
| 107 |
-
have hx : gramGood G x := ⟨rfl,Classical.byContradiction fun he => h (hg x he)⟩
|
| 108 |
-
let m := bp (-num J*num J)/4
|
| 109 |
-
have he (y : Mat U J × Mat U J) (hy : gramGood G y) : v y=v x := by
|
| 110 |
-
obtain ⟨L,hL⟩ := move_exists G x y hx hy
|
| 111 |
-
let e := L.perm (I⊕J) (I⊕J)
|
| 112 |
-
have hl (y) : f (e y)=(L.perm J J) (f y) :=
|
| 113 |
-
Prod.ext (Matrix.mul_assoc ..) (Matrix.mul_assoc ..)
|
| 114 |
-
have hp y : w (e y)=w y := by
|
| 115 |
-
unfold w; rw [unifOn_val, unifOn_val]
|
| 116 |
-
congr 2
|
| 117 |
-
exact propext (L.invar C y).symm
|
| 118 |
-
exact hL ▸ mapW_pr_eq e f (L.perm J J) hl w hp x
|
| 119 |
-
have hi := pmax_test (gramGood (U:=U) G) hv.sub he (m:=m)
|
| 120 |
-
(div_pos (bp_pos _) (by norm_num)) (gram_norm_quarter G (by linarith only [hN]))
|
| 121 |
-
apply hi.trans
|
| 122 |
-
unfold m; rw [neg_mul,bp_neg]; field_simp
|
| 123 |
-
exact le_rfl
|
| 124 |
-
· change v x ≤ _
|
| 125 |
-
rw [not_ne_iff.mp h]
|
| 126 |
-
exact mul_nonneg (mul_nonneg (by norm_num) (bp_pos _).le) (unif_subLaw.nz _)
|
| 127 |
-
|
| 128 |
-
variable {p : Shape} {n N : ℕ}
|
| 129 |
-
abbrev HMat (p : Shape) (N : ℕ) := Mat (Fin N) (Chan p)
|
| 130 |
-
abbrev HFrame (p : Shape) (N : ℕ) := HMat p N × HMat p N
|
| 131 |
-
abbrev HCube (p : Shape) (N : ℕ) := Comp p.g → HFrame p N
|
| 132 |
-
|
| 133 |
-
def hchan (p : Shape) {n N} (x : Oframe p n N) : HFrame p N :=
|
| 134 |
-
(channel x.1,channel x.2)
|
| 135 |
-
def hcube (p : Shape) {n N} (x : Orient p n N) : HCube p N := fun z => hchan p (x z)
|
| 136 |
-
def lawH (p : Shape) (N : ℕ) : Wgt (HCube p N) :=
|
| 137 |
-
prodW (fun (_ : Comp p.g) => pairW unif unif)
|
| 138 |
-
|
| 139 |
-
def intoChan (p : Shape) (n) : Mat (Full p n) (Chan p) := embedMat (.inr ·)
|
| 140 |
-
|
| 141 |
-
theorem intoChan_inj : Injective (intoChan p n).mulVec :=
|
| 142 |
-
embedMat_inj Sum.inr_injective
|
| 143 |
-
theorem intoChan_val (p : Shape) {n N} (x : Mat (Fin N) (Full p n)) :
|
| 144 |
-
x * intoChan p n=channel x := by rw [intoChan,mul_embedMat]; rfl
|
| 145 |
-
theorem hchan_val (p : Shape) {n N} :
|
| 146 |
-
hchan p (n:=n) (N:=N) = observe (intoChan p n) (intoChan p n) := by
|
| 147 |
-
funext x
|
| 148 |
-
exact Prod.ext (intoChan_val ..).symm (intoChan_val ..).symm
|
| 149 |
-
|
| 150 |
-
def chanPrice (p : Shape) : ℝ :=
|
| 151 |
-
(4*bp ((p.h:ℝ)*p.h))^(Fintype.card (Comp p.g))
|
| 152 |
-
|
| 153 |
-
theorem hchan_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1) :
|
| 154 |
-
let w := unifOn (FramesAt (U:=Fin N) (gramCond m))
|
| 155 |
-
∀ x : HFrame p N,mapW w (hchan p) x≤(4*bp ((p.h:ℝ)*p.h))*pairW unif unif x := by
|
| 156 |
-
classical
|
| 157 |
-
have he : 2*num (Full p n)-num (Fin N)≤ -1 := by simpa [num] using hN
|
| 158 |
-
have hh : ∃ x : Oframe p n N, FramesAt (gramCond m) x :=
|
| 159 |
-
framesAt_exists (gramCond_exists m) (by linarith only [he])
|
| 160 |
-
rw [hchan_val]
|
| 161 |
-
have hr : num (Chan p) ≤ num (Full p n) := by
|
| 162 |
-
have hf : Fintype.card (Row p n) + Fintype.card (Chan p)=Fintype.card (Full p n) :=
|
| 163 |
-
(Fintype.card_sum ..).symm
|
| 164 |
-
exact_mod_cast (show Fintype.card (Chan p)≤Fintype.card (Full p n) by omega)
|
| 165 |
-
have hk := gramObsCap hh (intoChan p n) intoChan_inj (by linarith only [he,hr])
|
| 166 |
-
rw [show num (Chan p)=(p.h:ℝ) from (by simp [num,Chan])] at hk
|
| 167 |
-
exact hk
|
| 168 |
-
|
| 169 |
-
theorem hcube_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1)
|
| 170 |
-
(x : HCube p N) : mapW (raw m N) (hcube p) x ≤ chanPrice p*lawH p N x := by
|
| 171 |
-
let w := unifOn (FramesAt (U:=Fin N) (gramCond m))
|
| 172 |
-
have hh i := hchan_cap m hN (x i)
|
| 173 |
-
change mapW (prodW (fun (_ : Comp p.g) => w)) _ x ≤ _
|
| 174 |
-
unfold hcube
|
| 175 |
-
rw [mapW_repeat (w:=fun (_:Comp p.g) => w) (f:=fun i => hchan p (n:=n) (N:=N))]
|
| 176 |
-
refine le_trans (Finset.prod_le_prod₀ ?_ fun i _ => hh i) ?_
|
| 177 |
-
· intro i _
|
| 178 |
-
exact pr_nonneg (unifOn_sub _).nz
|
| 179 |
-
rw [Finset.prod_mul_distrib]
|
| 180 |
-
simp [chanPrice,lawH,prodW]
|
| 181 |
-
|
| 182 |
-
end HadwigerCounterexample
|
| 183 |
-
|
| 184 |
-
end
|
| 185 |
-
|
| 186 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.SumRankBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Channel Frame Laws -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Module Submodule Finset Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
variable {A B : Type} [Fintype A] [Fintype B]
|
| 13 |
+
|
| 14 |
+
theorem map_pair_law {C D : Type} [Fintype C] [Fintype D]
|
| 15 |
+
(w : Wgt A) (v : Wgt B) (f : A→C) (g : B→D) :
|
| 16 |
+
mapW (pairW w v) (Prod.map f g)=pairW (mapW w f) (mapW v g) := by
|
| 17 |
+
funext x
|
| 18 |
+
unfold mapW pairW
|
| 19 |
+
simp only [Prod.ext_iff]
|
| 20 |
+
exact pairW_pr w v (fun y => f y=x.1) (fun y => g y=x.2)
|
| 21 |
+
|
| 22 |
+
theorem mapW_nested {C : Type} (w : Wgt A) (f : A→B) (g : B→C) :
|
| 23 |
+
mapW (mapW w f) g=mapW w (g ∘ f) :=
|
| 24 |
+
funext fun _ => mapW_pr _ _ _
|
| 25 |
+
|
| 26 |
+
omit [Fintype B] in
|
| 27 |
+
theorem mapW_repeat {I : Type} [Fintype I] [DecidableEq I]
|
| 28 |
+
(w : I→ Wgt A) (f : I→ A→B) :
|
| 29 |
+
mapW (prodW w) (fun x i => f i (x i))=prodW (fun i => mapW (w i) (f i)) := by
|
| 30 |
+
funext x
|
| 31 |
+
unfold mapW
|
| 32 |
+
simp_rw [funext_iff]
|
| 33 |
+
exact prodW_pr _ (fun i y => f i y=x i)
|
| 34 |
+
|
| 35 |
+
omit [Fintype B] in
|
| 36 |
+
theorem mapW_pr_eq (e : A≃A) (f : A→B) (u : B≃B) (h : ∀ x,f (e x)=u (f x))
|
| 37 |
+
(w : Wgt A) (hw : ∀ x, w (e x)=w x) (x : B) : mapW w f (u x)=mapW w f x := by
|
| 38 |
+
have he := avg_bij e w (fun y => ind (f y=u x))
|
| 39 |
+
simp_rw [hw,h,u.injective.eq_iff] at he
|
| 40 |
+
exact he.symm
|
| 41 |
+
|
| 42 |
+
private theorem pmax_test {x : A} (p : A → Prop) {w : Wgt A} (hw : SubLaw w)
|
| 43 |
+
(h : ∀ y, p y → w y=w x) {m : ℝ} (hm : 0 < m)
|
| 44 |
+
(hp : m ≤ pr unif p) [Nonempty A] :
|
| 45 |
+
w x ≤ m⁻¹ * unif x := by
|
| 46 |
+
have hh : pr w p=w x*nbr p := by
|
| 47 |
+
simp only [pr,avg,nbr,tot,Finset.mul_sum]
|
| 48 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 49 |
+
by_cases he : p i
|
| 50 |
+
· rw [h i he]
|
| 51 |
+
rw [ind_zero he,mul_zero,mul_zero]
|
| 52 |
+
have h1 := (pr_le_tot (p:=p) hw.nz).trans hw.total
|
| 53 |
+
rw [hh] at h1
|
| 54 |
+
have hU : 0 < (Fintype.card A : ℝ) := by exact_mod_cast Fintype.card_pos
|
| 55 |
+
rw [pr_unif (A:=A)] at hp
|
| 56 |
+
have hi := (le_div_iff₀ hU).mp hp
|
| 57 |
+
rw [unif_apply]
|
| 58 |
+
field_simp
|
| 59 |
+
nlinarith only [h1,hi,mul_le_mul_of_nonneg_left hi (hw.nz x)]
|
| 60 |
+
|
| 61 |
+
theorem gram_norm_quarter {I J L : Type} [Fintype I] [Fintype J] [Fintype L]
|
| 62 |
+
[DecidableEq I] [DecidableEq J] [DecidableEq L] (G : Mat I J)
|
| 63 |
+
(h : num I + num J-num L ≤ -1) :
|
| 64 |
+
bp (-num I * num J)/4 ≤ pr unif (gramGood (U:=L) G) := by
|
| 65 |
+
have hn := (gram_norm G (by linarith : num I+num J≤num L)).2
|
| 66 |
+
rw [pair_unif]
|
| 67 |
+
refine le_trans ?_ hn
|
| 68 |
+
have he {x : ℝ} (hx : x ≤ -1) : (1/2 : ℝ)≤ 1-bp x := by
|
| 69 |
+
have ht := bp_le hx
|
| 70 |
+
rw [bp_neg,bp_one] at ht
|
| 71 |
+
linarith only [ht]
|
| 72 |
+
let d := bp (-num I*num J)
|
| 73 |
+
change d/4 ≤ d* _ * _
|
| 74 |
+
have hk : 0 < d := bp_pos _
|
| 75 |
+
have h1 := he (x:= num I-num L) (by
|
| 76 |
+
have hg : 0≤num J := Nat.cast_nonneg _
|
| 77 |
+
linarith)
|
| 78 |
+
calc d/4 = d*(1/2)*(1/2) := by ring
|
| 79 |
+
_ ≤ _ := mul_le_mul (mul_le_mul_of_nonneg_left h1 hk.le) (he h) (by norm_num)
|
| 80 |
+
(mul_nonneg hk.le (le_trans (by norm_num) h1))
|
| 81 |
+
|
| 82 |
+
variable {I J U : Type} [Fintype I] [Fintype J] [Fintype U]
|
| 83 |
+
variable [DecidableEq I] [DecidableEq J] [DecidableEq U]
|
| 84 |
+
|
| 85 |
+
theorem gramObsCap {C : Mat (I⊕J) (I⊕J) → Prop}
|
| 86 |
+
(hc : ∃ x : Mat U (I⊕J) × _, FramesAt C x)
|
| 87 |
+
(T : Mat (I⊕J) J) (ht : Function.Injective T.mulVec)
|
| 88 |
+
(hN : 2*num J-num U≤ -1) :
|
| 89 |
+
let w := unifOn (FramesAt C)
|
| 90 |
+
∀ x : Mat U J × Mat U J,
|
| 91 |
+
mapW w (observe T T) x ≤ (4*bp (num J*num J))*pairW unif unif x := by
|
| 92 |
+
classical
|
| 93 |
+
let w := unifOn (FramesAt (U:=U) C)
|
| 94 |
+
have hw := unifOn_law hc
|
| 95 |
+
let f := observe T T (U:=U)
|
| 96 |
+
let v := mapW w f
|
| 97 |
+
have hv : IsLaw v := mapW_law hw f
|
| 98 |
+
have hg :
|
| 99 |
+
carried v (fun x : Mat U J × _ => Injective x.1.mulVec ∧ Injective x.2.mulVec) := by
|
| 100 |
+
refine mapW_carried (unifOn_carried _) (fun x hx => ?_)
|
| 101 |
+
exact ⟨inj_comp_mat _ _ hx.2.1 ht,inj_comp_mat _ _ hx.2.2 ht⟩
|
| 102 |
+
dsimp only
|
| 103 |
+
intro x
|
| 104 |
+
rw [← pair_unif]
|
| 105 |
+
by_cases h : v x≠0
|
| 106 |
+
· let G := (x.1ᵀ*x.2 : Mat J J)
|
| 107 |
+
have hx : gramGood G x := ⟨rfl,Classical.byContradiction fun he => h (hg x he)⟩
|
| 108 |
+
let m := bp (-num J*num J)/4
|
| 109 |
+
have he (y : Mat U J × Mat U J) (hy : gramGood G y) : v y=v x := by
|
| 110 |
+
obtain ⟨L,hL⟩ := move_exists G x y hx hy
|
| 111 |
+
let e := L.perm (I⊕J) (I⊕J)
|
| 112 |
+
have hl (y) : f (e y)=(L.perm J J) (f y) :=
|
| 113 |
+
Prod.ext (Matrix.mul_assoc ..) (Matrix.mul_assoc ..)
|
| 114 |
+
have hp y : w (e y)=w y := by
|
| 115 |
+
unfold w; rw [unifOn_val, unifOn_val]
|
| 116 |
+
congr 2
|
| 117 |
+
exact propext (L.invar C y).symm
|
| 118 |
+
exact hL ▸ mapW_pr_eq e f (L.perm J J) hl w hp x
|
| 119 |
+
have hi := pmax_test (gramGood (U:=U) G) hv.sub he (m:=m)
|
| 120 |
+
(div_pos (bp_pos _) (by norm_num)) (gram_norm_quarter G (by linarith only [hN]))
|
| 121 |
+
apply hi.trans
|
| 122 |
+
unfold m; rw [neg_mul,bp_neg]; field_simp
|
| 123 |
+
exact le_rfl
|
| 124 |
+
· change v x ≤ _
|
| 125 |
+
rw [not_ne_iff.mp h]
|
| 126 |
+
exact mul_nonneg (mul_nonneg (by norm_num) (bp_pos _).le) (unif_subLaw.nz _)
|
| 127 |
+
|
| 128 |
+
variable {p : Shape} {n N : ℕ}
|
| 129 |
+
abbrev HMat (p : Shape) (N : ℕ) := Mat (Fin N) (Chan p)
|
| 130 |
+
abbrev HFrame (p : Shape) (N : ℕ) := HMat p N × HMat p N
|
| 131 |
+
abbrev HCube (p : Shape) (N : ℕ) := Comp p.g → HFrame p N
|
| 132 |
+
|
| 133 |
+
def hchan (p : Shape) {n N} (x : Oframe p n N) : HFrame p N :=
|
| 134 |
+
(channel x.1,channel x.2)
|
| 135 |
+
def hcube (p : Shape) {n N} (x : Orient p n N) : HCube p N := fun z => hchan p (x z)
|
| 136 |
+
def lawH (p : Shape) (N : ℕ) : Wgt (HCube p N) :=
|
| 137 |
+
prodW (fun (_ : Comp p.g) => pairW unif unif)
|
| 138 |
+
|
| 139 |
+
def intoChan (p : Shape) (n) : Mat (Full p n) (Chan p) := embedMat (.inr ·)
|
| 140 |
+
|
| 141 |
+
theorem intoChan_inj : Injective (intoChan p n).mulVec :=
|
| 142 |
+
embedMat_inj Sum.inr_injective
|
| 143 |
+
theorem intoChan_val (p : Shape) {n N} (x : Mat (Fin N) (Full p n)) :
|
| 144 |
+
x * intoChan p n=channel x := by rw [intoChan,mul_embedMat]; rfl
|
| 145 |
+
theorem hchan_val (p : Shape) {n N} :
|
| 146 |
+
hchan p (n:=n) (N:=N) = observe (intoChan p n) (intoChan p n) := by
|
| 147 |
+
funext x
|
| 148 |
+
exact Prod.ext (intoChan_val ..).symm (intoChan_val ..).symm
|
| 149 |
+
|
| 150 |
+
def chanPrice (p : Shape) : ℝ :=
|
| 151 |
+
(4*bp ((p.h:ℝ)*p.h))^(Fintype.card (Comp p.g))
|
| 152 |
+
|
| 153 |
+
theorem hchan_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1) :
|
| 154 |
+
let w := unifOn (FramesAt (U:=Fin N) (gramCond m))
|
| 155 |
+
∀ x : HFrame p N,mapW w (hchan p) x≤(4*bp ((p.h:ℝ)*p.h))*pairW unif unif x := by
|
| 156 |
+
classical
|
| 157 |
+
have he : 2*num (Full p n)-num (Fin N)≤ -1 := by simpa [num] using hN
|
| 158 |
+
have hh : ∃ x : Oframe p n N, FramesAt (gramCond m) x :=
|
| 159 |
+
framesAt_exists (gramCond_exists m) (by linarith only [he])
|
| 160 |
+
rw [hchan_val]
|
| 161 |
+
have hr : num (Chan p) ≤ num (Full p n) := by
|
| 162 |
+
have hf : Fintype.card (Row p n) + Fintype.card (Chan p)=Fintype.card (Full p n) :=
|
| 163 |
+
(Fintype.card_sum ..).symm
|
| 164 |
+
exact_mod_cast (show Fintype.card (Chan p)≤Fintype.card (Full p n) by omega)
|
| 165 |
+
have hk := gramObsCap hh (intoChan p n) intoChan_inj (by linarith only [he,hr])
|
| 166 |
+
rw [show num (Chan p)=(p.h:ℝ) from (by simp [num,Chan])] at hk
|
| 167 |
+
exact hk
|
| 168 |
+
|
| 169 |
+
theorem hcube_cap (m : Mixer p n) (hN : 2*num (Full p n)-N≤ -1)
|
| 170 |
+
(x : HCube p N) : mapW (raw m N) (hcube p) x ≤ chanPrice p*lawH p N x := by
|
| 171 |
+
let w := unifOn (FramesAt (U:=Fin N) (gramCond m))
|
| 172 |
+
have hh i := hchan_cap m hN (x i)
|
| 173 |
+
change mapW (prodW (fun (_ : Comp p.g) => w)) _ x ≤ _
|
| 174 |
+
unfold hcube
|
| 175 |
+
rw [mapW_repeat (w:=fun (_:Comp p.g) => w) (f:=fun i => hchan p (n:=n) (N:=N))]
|
| 176 |
+
refine le_trans (Finset.prod_le_prod₀ ?_ fun i _ => hh i) ?_
|
| 177 |
+
· intro i _
|
| 178 |
+
exact pr_nonneg (unifOn_sub _).nz
|
| 179 |
+
rw [Finset.prod_mul_distrib]
|
| 180 |
+
simp [chanPrice,lawH,prodW]
|
| 181 |
+
|
| 182 |
+
end HadwigerCounterexample
|
| 183 |
+
|
| 184 |
+
end
|
| 185 |
+
|
| 186 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CollisionInequality.lean
CHANGED
|
@@ -1,204 +1,204 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.UnaryRecords
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.ConstructionScales
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Collision Inequality -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix Module Finset Filter
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {p : Shape} {n N : ℕ}
|
| 13 |
-
variable {I A B : Type} [Fintype I] [Fintype A] [Fintype B]
|
| 14 |
-
|
| 15 |
-
def density (v w : Wgt I) := fun x => w x/v x
|
| 16 |
-
def overlap (v a b : Wgt I) :=
|
| 17 |
-
avg v (fun x => density v a x*density v b x)
|
| 18 |
-
|
| 19 |
-
theorem overlap_count (P : I→Prop) (p q : Wgt I) (h : ∀ x, 0 ≤ p x) (h' : ∀ x, 0≤ q x) :
|
| 20 |
-
overlap (unifOn P) p q ≤ (Fintype.card I:ℝ) * (∑ i, p i*q i) := by
|
| 21 |
-
classical
|
| 22 |
-
simp only [overlap,density, avg,Finset.mul_sum]
|
| 23 |
-
refine Finset.sum_le_sum fun i _ => ?_
|
| 24 |
-
have hg := mul_nonneg (h i) (h' i)
|
| 25 |
-
have hw : 0 ≤ (↑(Fintype.card I) : ℝ) := Nat.cast_nonneg _
|
| 26 |
-
by_cases he : P i
|
| 27 |
-
· have hh : 0 < nbr P := by
|
| 28 |
-
have hpos : 0 < Fintype.card {x//P x} := Fintype.card_pos_iff.mpr ⟨⟨i,he⟩⟩
|
| 29 |
-
rw [nbr_eq_card]; exact_mod_cast hpos
|
| 30 |
-
have hd : unifOn P i * (p i/unifOn P i * (q i / unifOn P i))=nbr P*(p i*q i) := by
|
| 31 |
-
rw [unifOn_val,ind_one he]
|
| 32 |
-
field_simp
|
| 33 |
-
rw [hd]
|
| 34 |
-
apply mul_le_mul_of_nonneg_right _ hg
|
| 35 |
-
rw [nbr_eq_card]
|
| 36 |
-
exact_mod_cast Fintype.card_le_of_injective _ (@Subtype.val_injective _ P)
|
| 37 |
-
rw [unifOn_carried P i he,zero_mul]
|
| 38 |
-
exact mul_nonneg hw hg
|
| 39 |
-
|
| 40 |
-
namespace Volley
|
| 41 |
-
|
| 42 |
-
/-- law of accepted keys as an unnormalized histogram -/
|
| 43 |
-
def hist (v : A → Volley p n I) (t : Tagging p I)
|
| 44 |
-
(μ : Wgt (UnitType p n N)) (rho' : Wgt A) (U : A → UnitType p n N → Prop) :
|
| 45 |
-
Wgt (Keys (p:=p) t N) :=
|
| 46 |
-
fun u => avg rho' (fun a => pr μ (fun x => U a x ∧ (v a).keys t x=u))
|
| 47 |
-
|
| 48 |
-
set_option maxHeartbeats 800000 in
|
| 49 |
-
private theorem record_sum (v w : Volley p n I) {t : Tagging p I} (m : Mixer p n)
|
| 50 |
-
{a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}
|
| 51 |
-
(U V : UnitType p n N → Prop)
|
| 52 |
-
(ha : ∀ x, U x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 53 |
-
(hb : ∀ x, V x → b.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 54 |
-
{ζ : ℝ} {q : ℕ}
|
| 55 |
-
(h : ∀ x,U x → ∀ y,V y → v.keys t x=w.keys t y → v.promised w t m a.sp b.sp x y)
|
| 56 |
-
(hv : v.avoids a.sp q) (hw : w.avoids b.sp q)
|
| 57 |
-
(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004)
|
| 58 |
-
(hμ : SubLaw μ) (hδ : SubLaw δ)
|
| 59 |
-
(hA : a.clear ζ μ) (hB : b.clear ζ δ)
|
| 60 |
-
(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)
|
| 61 |
-
(L : ℝ)
|
| 62 |
-
(hLf : bp (dim (Ledger (v.frozen a.sp t))) ≤ L)
|
| 63 |
-
(hLg : bp (dim (Ledger (w.frozen b.sp t))) ≤ L) :
|
| 64 |
-
hit N *
|
| 65 |
-
(∑ u : Keys (p:=p) t N, pr μ (fun x => U x ∧ v.keys t x=u) *
|
| 66 |
-
pr δ (fun x => V x ∧ w.keys t x=u)) ≤
|
| 67 |
-
pr (pairW μ δ) (fun x => (rawHoles m).conflict x.1 x.2)+
|
| 68 |
-
2*(hit N*tau N (kslots p I)*L) := by
|
| 69 |
-
classical
|
| 70 |
-
let X := UnitType p n N
|
| 71 |
-
let T := Keys (p:=p) t N
|
| 72 |
-
let K (u : T) (x : X) := U x ∧ v.keys t x=u
|
| 73 |
-
let K' (u : T) (x : X) := V x ∧ w.keys t x=u
|
| 74 |
-
let H := hit N*tau N (kslots p I)*L
|
| 75 |
-
let P := pairW μ δ
|
| 76 |
-
let C (x : X × X) := (rawHoles m).conflict x.1 x.2
|
| 77 |
-
let G (u : T) (x : X × X) := K u x.1 ∧ K' u x.2 ∧ C x
|
| 78 |
-
rw [Finset.mul_sum]
|
| 79 |
-
have hh (i : Keys (p:=p) t N) :
|
| 80 |
-
hit N * (pr μ (K i) * pr δ (K' i))≤ pr P (G i)+H*(pr μ (K i)+pr δ (K' i)) := by
|
| 81 |
-
apply record_hit v w m (K i) (K' i) i _ _ _ hv hw hz hK hμ hδ hA hB hN hT L hLf hLg
|
| 82 |
-
· exact fun x h => ⟨(ha x h.1).1,(ha x h.1).2,h.2⟩
|
| 83 |
-
· exact fun x h => ⟨(hb x h.1).1,(hb x h.1).2,h.2⟩
|
| 84 |
-
exact fun x hx y hy => h x hx.1 y hy.1 (hx.2.trans hy.2.symm)
|
| 85 |
-
refine (Finset.sum_le_sum fun i _ => hh i).trans ?_
|
| 86 |
-
rw [Finset.sum_add_distrib]
|
| 87 |
-
have hi : (∑ i : Keys (p:=p) t N, pr P (G i)) ≤ pr P C := by
|
| 88 |
-
rw [← sum_pr_tag P C (v.keys t ∘ Prod.fst)]
|
| 89 |
-
exact Finset.sum_le_sum fun i _ => pr_mono (subLaw_pair hμ hδ).nz (fun x h => ⟨h.2.2,h.1.2⟩)
|
| 90 |
-
refine add_le_add hi ?_
|
| 91 |
-
have hU : (∑ i : Keys (p:=p) t N, pr μ (K i))≤1 :=
|
| 92 |
-
(sum_pr_tag μ U (v.keys t)).trans_le ((pr_le_tot hμ.nz).trans hμ.total)
|
| 93 |
-
have hV : (∑ i : Keys (p:=p) t N, pr δ (K' i))≤1 :=
|
| 94 |
-
(sum_pr_tag δ V (w.keys t)).trans_le ((pr_le_tot hδ.nz).trans hδ.total)
|
| 95 |
-
have hz : 0 ≤ H := mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le) ((bp_pos _).le.trans hLf)
|
| 96 |
-
rw [← Finset.mul_sum,Finset.sum_add_distrib,mul_comm 2]
|
| 97 |
-
exact mul_le_mul_of_nonneg_left (by linarith only [hU,hV]) hz
|
| 98 |
-
|
| 99 |
-
set_option maxHeartbeats 1200000 in
|
| 100 |
-
theorem collision (v : A→Volley p n I) (w : B→Volley p n I)
|
| 101 |
-
{t : Tagging p I} (m : Mixer p n)
|
| 102 |
-
{a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}
|
| 103 |
-
(rhoA : Wgt A) (rhoB : Wgt B)
|
| 104 |
-
(U : A → UnitType p n N → Prop) (V : B → UnitType p n N → Prop)
|
| 105 |
-
(ha : ∀ i x, U i x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 106 |
-
(hb : ∀ i x, V i x → b.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 107 |
-
{ζ : ℝ} {q K : ℕ}
|
| 108 |
-
(h : ∀ i j x,U i x → ∀ y,V j y → (v i).keys t x=(w j).keys t y →
|
| 109 |
-
(v i).promised (w j) t m a.sp b.sp x y)
|
| 110 |
-
(hv : ∀ i, (v i).avoids a.sp q) (hw : ∀ i, (w i).avoids b.sp q)
|
| 111 |
-
(hκ : planRank a.sp≤K) (hκ' : planRank b.sp≤K)
|
| 112 |
-
(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004) (hslots : kslots p I≤kmax p)
|
| 113 |
-
(hμ : SubLaw μ) (hδ : SubLaw δ) (hu : SubLaw rhoA) (hu' : SubLaw rhoB)
|
| 114 |
-
(hA : a.clear ζ μ) (hB : b.clear ζ δ)
|
| 115 |
-
(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)
|
| 116 |
-
(hL : (K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N)
|
| 117 |
-
(J : Keys (p:=p) t N → Prop) :
|
| 118 |
-
overlap (unifOn J) (hist v t μ rhoA U) (hist w t δ rhoB V) ≤
|
| 119 |
-
bp (((kslots p I:ℝ)+0.02)*N)*pr (pairW μ δ) (fun x =>
|
| 120 |
-
(rawHoles m).conflict x.1 x.2) + 2*bp (-0.005*N) := by
|
| 121 |
-
classical
|
| 122 |
-
let k := kslots p I
|
| 123 |
-
let L := bp (0.005*N)
|
| 124 |
-
let C := fun (x : UnitType p n N × _) => (rawHoles m).conflict x.1 x.2
|
| 125 |
-
let X := hist v t μ rhoA U
|
| 126 |
-
let Y := hist w t δ rhoB V
|
| 127 |
-
let H := hit N*tau N k*L
|
| 128 |
-
let D := pr (pairW μ δ) C
|
| 129 |
-
let α (u : Keys (p:=p) t N) i := pr μ (fun x => U i x ∧ (v i).keys t x=u)
|
| 130 |
-
let β (u : Keys (p:=p) t N) i := pr δ (fun x => V i x ∧ (w i).keys t x=u)
|
| 131 |
-
have hX u : 0≤ X u := avg_nonneg hu.nz (fun i => pr_nonneg hμ.nz)
|
| 132 |
-
have hY u : 0≤ Y u := avg_nonneg hu'.nz (fun i => pr_nonneg hδ.nz)
|
| 133 |
-
have hW (f : Plan p n) (hk : planRank f ≤ K) (v : Volley p n I) (hv : v.avoids f q) :
|
| 134 |
-
bp (dim (Ledger (v.frozen f t)))≤L := by
|
| 135 |
-
apply bp_le
|
| 136 |
-
rw [ledger_dim]
|
| 137 |
-
push_cast
|
| 138 |
-
have ht : (planRank (v.frozen f t) : ℝ) ≤ K+(kmax p:ℝ) := by
|
| 139 |
-
have hh := plan_add_rank f (v.keyPlan t)
|
| 140 |
-
rw [key_slots t hv] at hh
|
| 141 |
-
exact_mod_cast (show planRank (f⊔v.keyPlan t) ≤ K+kmax p from
|
| 142 |
-
hh.symm ▸ add_le_add hk hslots)
|
| 143 |
-
exact le_trans (mul_le_mul_of_nonneg_right ht (Nat.cast_nonneg _)) hL
|
| 144 |
-
have hf (x : A × B) :
|
| 145 |
-
hit N * (∑ u : Keys (p:=p) t N, α u x.1*β u x.2) ≤ D+ 2*H :=
|
| 146 |
-
record_sum (v x.1) (w x.2) m (U _) (V _) (ha x.1) (hb x.2) (h x.1 x.2)
|
| 147 |
-
(hv x.1) (hw x.2) hz hK hμ hδ hA hB hN hT L (hW a.sp hκ _ (hv _)) (hW _ hκ' _ (hw _))
|
| 148 |
-
have hh : hit N * (∑ u : Keys (p:=p) t N,X u * Y u) ≤ D + 2*H := by
|
| 149 |
-
let F := pairW rhoA rhoB
|
| 150 |
-
have hh' : 0 ≤ D+2*H := by
|
| 151 |
-
apply add_nonneg (pr_nonneg (subLaw_pair hμ hδ).nz)
|
| 152 |
-
exact mul_nonneg (by norm_num) (mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le)
|
| 153 |
-
(bp_pos _).le)
|
| 154 |
-
have hl := (subLaw_pair hu hu').avg_le hh' hf
|
| 155 |
-
rw [avg_mul',avg_sum] at hl
|
| 156 |
-
have ht (u : Keys (p:=p) t N) :
|
| 157 |
-
X u*Y u=avg F (fun x : A×B => α u x.1*β u x.2) := (pairW_separate ..).symm
|
| 158 |
-
simp_rw [ht]; exact hl
|
| 159 |
-
apply (overlap_count J X Y hX hY).trans
|
| 160 |
-
rw [card_space,dim_keys,Nat.cast_mul]
|
| 161 |
-
let Z := bp (((k:ℝ)+0.02)*N)
|
| 162 |
-
have he : Z*hit N = bp ((k:ℝ)*N) := by
|
| 163 |
-
unfold Z hit; rw [← bp_add]; congr 1; ring
|
| 164 |
-
have he' : Z*H = bp (-0.005*N) := by
|
| 165 |
-
unfold H; rw [← mul_assoc,← mul_assoc,he]
|
| 166 |
-
unfold L tau
|
| 167 |
-
rw [← bp_add,← bp_add]; congr 1; ring
|
| 168 |
-
change bp ((k:ℝ)*N)*_≤ Z*D+_
|
| 169 |
-
rw [← he, mul_assoc,← he']
|
| 170 |
-
refine (mul_le_mul_of_nonneg_left hh (bp_pos _).le).trans_eq ?_
|
| 171 |
-
ring
|
| 172 |
-
end Volley
|
| 173 |
-
|
| 174 |
-
theorem collision_scales (p : Shape) (K : ℕ) :
|
| 175 |
-
∀ᶠ M : ℕ in atTop,∀ᶠ n : ℕ in atTop, let N := M*n;
|
| 176 |
-
100≤N ∧ (dim (CheckGram p n):ℝ) ≤ 0.01*N ∧
|
| 177 |
-
(K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N := by
|
| 178 |
-
filter_upwards [columns_budget p (δ:=0.01) (by norm_num)
|
| 179 |
-
(16*(ncComp p:ℝ)*p.h) 0 (by positivity) (by norm_num),
|
| 180 |
-
columns_budget p (δ:=0.005) (by norm_num)
|
| 181 |
-
(2*(K+(kmax p:ℝ))) 0 (by positivity) (by norm_num),eventually_ge_atTop 1] with M hM hB hg
|
| 182 |
-
filter_upwards [eventually_ge_atTop 100] with n hn
|
| 183 |
-
specialize hM n (by omega)
|
| 184 |
-
specialize hB n (by omega)
|
| 185 |
-
have hN : 100 ≤ M*n := by nlinarith
|
| 186 |
-
refine ⟨hN,?_,?_⟩
|
| 187 |
-
· rw [checkgram_dim]
|
| 188 |
-
simp only [Nat.cast_mul,Nat.cast_ofNat]; unfold num at hM
|
| 189 |
-
have hi : (↑(Fintype.card (Row p n)):ℝ)≤Fintype.card (Full p n) := by
|
| 190 |
-
have he : Fintype.card (Full p n)=_+_ := Fintype.card_sum ..
|
| 191 |
-
exact_mod_cast (show Fintype.card (Row p n)≤Fintype.card (Full p n) from he.symm ▸
|
| 192 |
-
Nat.le_add_right ..)
|
| 193 |
-
rw [add_zero] at hM
|
| 194 |
-
rw [Nat.cast_mul] at hM
|
| 195 |
-
exact le_trans (mul_le_mul_of_nonneg_left hi (by positivity)) hM
|
| 196 |
-
rw [show num (JointIdx p n) = 2*num (Full p n) from (by
|
| 197 |
-
unfold num JointIdx; rw [Fintype.card_sum]; push_cast; ring)]
|
| 198 |
-
linarith only [hB]
|
| 199 |
-
|
| 200 |
-
end HadwigerCounterexample
|
| 201 |
-
|
| 202 |
-
end
|
| 203 |
-
|
| 204 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.UnaryRecords
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.ConstructionScales
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Collision Inequality -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix Module Finset Filter
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {p : Shape} {n N : ℕ}
|
| 13 |
+
variable {I A B : Type} [Fintype I] [Fintype A] [Fintype B]
|
| 14 |
+
|
| 15 |
+
def density (v w : Wgt I) := fun x => w x/v x
|
| 16 |
+
def overlap (v a b : Wgt I) :=
|
| 17 |
+
avg v (fun x => density v a x*density v b x)
|
| 18 |
+
|
| 19 |
+
theorem overlap_count (P : I→Prop) (p q : Wgt I) (h : ∀ x, 0 ≤ p x) (h' : ∀ x, 0≤ q x) :
|
| 20 |
+
overlap (unifOn P) p q ≤ (Fintype.card I:ℝ) * (∑ i, p i*q i) := by
|
| 21 |
+
classical
|
| 22 |
+
simp only [overlap,density, avg,Finset.mul_sum]
|
| 23 |
+
refine Finset.sum_le_sum fun i _ => ?_
|
| 24 |
+
have hg := mul_nonneg (h i) (h' i)
|
| 25 |
+
have hw : 0 ≤ (↑(Fintype.card I) : ℝ) := Nat.cast_nonneg _
|
| 26 |
+
by_cases he : P i
|
| 27 |
+
· have hh : 0 < nbr P := by
|
| 28 |
+
have hpos : 0 < Fintype.card {x//P x} := Fintype.card_pos_iff.mpr ⟨⟨i,he⟩⟩
|
| 29 |
+
rw [nbr_eq_card]; exact_mod_cast hpos
|
| 30 |
+
have hd : unifOn P i * (p i/unifOn P i * (q i / unifOn P i))=nbr P*(p i*q i) := by
|
| 31 |
+
rw [unifOn_val,ind_one he]
|
| 32 |
+
field_simp
|
| 33 |
+
rw [hd]
|
| 34 |
+
apply mul_le_mul_of_nonneg_right _ hg
|
| 35 |
+
rw [nbr_eq_card]
|
| 36 |
+
exact_mod_cast Fintype.card_le_of_injective _ (@Subtype.val_injective _ P)
|
| 37 |
+
rw [unifOn_carried P i he,zero_mul]
|
| 38 |
+
exact mul_nonneg hw hg
|
| 39 |
+
|
| 40 |
+
namespace Volley
|
| 41 |
+
|
| 42 |
+
/-- law of accepted keys as an unnormalized histogram -/
|
| 43 |
+
def hist (v : A → Volley p n I) (t : Tagging p I)
|
| 44 |
+
(μ : Wgt (UnitType p n N)) (rho' : Wgt A) (U : A → UnitType p n N → Prop) :
|
| 45 |
+
Wgt (Keys (p:=p) t N) :=
|
| 46 |
+
fun u => avg rho' (fun a => pr μ (fun x => U a x ∧ (v a).keys t x=u))
|
| 47 |
+
|
| 48 |
+
set_option maxHeartbeats 800000 in
|
| 49 |
+
private theorem record_sum (v w : Volley p n I) {t : Tagging p I} (m : Mixer p n)
|
| 50 |
+
{a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}
|
| 51 |
+
(U V : UnitType p n N → Prop)
|
| 52 |
+
(ha : ∀ x, U x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 53 |
+
(hb : ∀ x, V x → b.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 54 |
+
{ζ : ℝ} {q : ℕ}
|
| 55 |
+
(h : ∀ x,U x → ∀ y,V y → v.keys t x=w.keys t y → v.promised w t m a.sp b.sp x y)
|
| 56 |
+
(hv : v.avoids a.sp q) (hw : w.avoids b.sp q)
|
| 57 |
+
(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004)
|
| 58 |
+
(hμ : SubLaw μ) (hδ : SubLaw δ)
|
| 59 |
+
(hA : a.clear ζ μ) (hB : b.clear ζ δ)
|
| 60 |
+
(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)
|
| 61 |
+
(L : ℝ)
|
| 62 |
+
(hLf : bp (dim (Ledger (v.frozen a.sp t))) ≤ L)
|
| 63 |
+
(hLg : bp (dim (Ledger (w.frozen b.sp t))) ≤ L) :
|
| 64 |
+
hit N *
|
| 65 |
+
(∑ u : Keys (p:=p) t N, pr μ (fun x => U x ∧ v.keys t x=u) *
|
| 66 |
+
pr δ (fun x => V x ∧ w.keys t x=u)) ≤
|
| 67 |
+
pr (pairW μ δ) (fun x => (rawHoles m).conflict x.1 x.2)+
|
| 68 |
+
2*(hit N*tau N (kslots p I)*L) := by
|
| 69 |
+
classical
|
| 70 |
+
let X := UnitType p n N
|
| 71 |
+
let T := Keys (p:=p) t N
|
| 72 |
+
let K (u : T) (x : X) := U x ∧ v.keys t x=u
|
| 73 |
+
let K' (u : T) (x : X) := V x ∧ w.keys t x=u
|
| 74 |
+
let H := hit N*tau N (kslots p I)*L
|
| 75 |
+
let P := pairW μ δ
|
| 76 |
+
let C (x : X × X) := (rawHoles m).conflict x.1 x.2
|
| 77 |
+
let G (u : T) (x : X × X) := K u x.1 ∧ K' u x.2 ∧ C x
|
| 78 |
+
rw [Finset.mul_sum]
|
| 79 |
+
have hh (i : Keys (p:=p) t N) :
|
| 80 |
+
hit N * (pr μ (K i) * pr δ (K' i))≤ pr P (G i)+H*(pr μ (K i)+pr δ (K' i)) := by
|
| 81 |
+
apply record_hit v w m (K i) (K' i) i _ _ _ hv hw hz hK hμ hδ hA hB hN hT L hLf hLg
|
| 82 |
+
· exact fun x h => ⟨(ha x h.1).1,(ha x h.1).2,h.2⟩
|
| 83 |
+
· exact fun x h => ⟨(hb x h.1).1,(hb x h.1).2,h.2⟩
|
| 84 |
+
exact fun x hx y hy => h x hx.1 y hy.1 (hx.2.trans hy.2.symm)
|
| 85 |
+
refine (Finset.sum_le_sum fun i _ => hh i).trans ?_
|
| 86 |
+
rw [Finset.sum_add_distrib]
|
| 87 |
+
have hi : (∑ i : Keys (p:=p) t N, pr P (G i)) ≤ pr P C := by
|
| 88 |
+
rw [← sum_pr_tag P C (v.keys t ∘ Prod.fst)]
|
| 89 |
+
exact Finset.sum_le_sum fun i _ => pr_mono (subLaw_pair hμ hδ).nz (fun x h => ⟨h.2.2,h.1.2⟩)
|
| 90 |
+
refine add_le_add hi ?_
|
| 91 |
+
have hU : (∑ i : Keys (p:=p) t N, pr μ (K i))≤1 :=
|
| 92 |
+
(sum_pr_tag μ U (v.keys t)).trans_le ((pr_le_tot hμ.nz).trans hμ.total)
|
| 93 |
+
have hV : (∑ i : Keys (p:=p) t N, pr δ (K' i))≤1 :=
|
| 94 |
+
(sum_pr_tag δ V (w.keys t)).trans_le ((pr_le_tot hδ.nz).trans hδ.total)
|
| 95 |
+
have hz : 0 ≤ H := mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le) ((bp_pos _).le.trans hLf)
|
| 96 |
+
rw [← Finset.mul_sum,Finset.sum_add_distrib,mul_comm 2]
|
| 97 |
+
exact mul_le_mul_of_nonneg_left (by linarith only [hU,hV]) hz
|
| 98 |
+
|
| 99 |
+
set_option maxHeartbeats 1200000 in
|
| 100 |
+
theorem collision (v : A→Volley p n I) (w : B→Volley p n I)
|
| 101 |
+
{t : Tagging p I} (m : Mixer p n)
|
| 102 |
+
{a b : Pin p n N} {μ δ : Wgt (UnitType p n N)}
|
| 103 |
+
(rhoA : Wgt A) (rhoB : Wgt B)
|
| 104 |
+
(U : A → UnitType p n N → Prop) (V : B → UnitType p n N → Prop)
|
| 105 |
+
(ha : ∀ i x, U i x → a.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 106 |
+
(hb : ∀ i x, V i x → b.agree x ∧ (∀ i,frameLaw m (onSide x i)))
|
| 107 |
+
{ζ : ℝ} {q K : ℕ}
|
| 108 |
+
(h : ∀ i j x,U i x → ∀ y,V j y → (v i).keys t x=(w j).keys t y →
|
| 109 |
+
(v i).promised (w j) t m a.sp b.sp x y)
|
| 110 |
+
(hv : ∀ i, (v i).avoids a.sp q) (hw : ∀ i, (w i).avoids b.sp q)
|
| 111 |
+
(hκ : planRank a.sp≤K) (hκ' : planRank b.sp≤K)
|
| 112 |
+
(hz : ζ ≤ 0.004) (hK : ζ*(kslots p I) ≤ 0.004) (hslots : kslots p I≤kmax p)
|
| 113 |
+
(hμ : SubLaw μ) (hδ : SubLaw δ) (hu : SubLaw rhoA) (hu' : SubLaw rhoB)
|
| 114 |
+
(hA : a.clear ζ μ) (hB : b.clear ζ δ)
|
| 115 |
+
(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ) ≤ 0.01*N)
|
| 116 |
+
(hL : (K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N)
|
| 117 |
+
(J : Keys (p:=p) t N → Prop) :
|
| 118 |
+
overlap (unifOn J) (hist v t μ rhoA U) (hist w t δ rhoB V) ≤
|
| 119 |
+
bp (((kslots p I:ℝ)+0.02)*N)*pr (pairW μ δ) (fun x =>
|
| 120 |
+
(rawHoles m).conflict x.1 x.2) + 2*bp (-0.005*N) := by
|
| 121 |
+
classical
|
| 122 |
+
let k := kslots p I
|
| 123 |
+
let L := bp (0.005*N)
|
| 124 |
+
let C := fun (x : UnitType p n N × _) => (rawHoles m).conflict x.1 x.2
|
| 125 |
+
let X := hist v t μ rhoA U
|
| 126 |
+
let Y := hist w t δ rhoB V
|
| 127 |
+
let H := hit N*tau N k*L
|
| 128 |
+
let D := pr (pairW μ δ) C
|
| 129 |
+
let α (u : Keys (p:=p) t N) i := pr μ (fun x => U i x ∧ (v i).keys t x=u)
|
| 130 |
+
let β (u : Keys (p:=p) t N) i := pr δ (fun x => V i x ∧ (w i).keys t x=u)
|
| 131 |
+
have hX u : 0≤ X u := avg_nonneg hu.nz (fun i => pr_nonneg hμ.nz)
|
| 132 |
+
have hY u : 0≤ Y u := avg_nonneg hu'.nz (fun i => pr_nonneg hδ.nz)
|
| 133 |
+
have hW (f : Plan p n) (hk : planRank f ≤ K) (v : Volley p n I) (hv : v.avoids f q) :
|
| 134 |
+
bp (dim (Ledger (v.frozen f t)))≤L := by
|
| 135 |
+
apply bp_le
|
| 136 |
+
rw [ledger_dim]
|
| 137 |
+
push_cast
|
| 138 |
+
have ht : (planRank (v.frozen f t) : ℝ) ≤ K+(kmax p:ℝ) := by
|
| 139 |
+
have hh := plan_add_rank f (v.keyPlan t)
|
| 140 |
+
rw [key_slots t hv] at hh
|
| 141 |
+
exact_mod_cast (show planRank (f⊔v.keyPlan t) ≤ K+kmax p from
|
| 142 |
+
hh.symm ▸ add_le_add hk hslots)
|
| 143 |
+
exact le_trans (mul_le_mul_of_nonneg_right ht (Nat.cast_nonneg _)) hL
|
| 144 |
+
have hf (x : A × B) :
|
| 145 |
+
hit N * (∑ u : Keys (p:=p) t N, α u x.1*β u x.2) ≤ D+ 2*H :=
|
| 146 |
+
record_sum (v x.1) (w x.2) m (U _) (V _) (ha x.1) (hb x.2) (h x.1 x.2)
|
| 147 |
+
(hv x.1) (hw x.2) hz hK hμ hδ hA hB hN hT L (hW a.sp hκ _ (hv _)) (hW _ hκ' _ (hw _))
|
| 148 |
+
have hh : hit N * (∑ u : Keys (p:=p) t N,X u * Y u) ≤ D + 2*H := by
|
| 149 |
+
let F := pairW rhoA rhoB
|
| 150 |
+
have hh' : 0 ≤ D+2*H := by
|
| 151 |
+
apply add_nonneg (pr_nonneg (subLaw_pair hμ hδ).nz)
|
| 152 |
+
exact mul_nonneg (by norm_num) (mul_nonneg (mul_nonneg (bp_pos _).le (bp_pos _).le)
|
| 153 |
+
(bp_pos _).le)
|
| 154 |
+
have hl := (subLaw_pair hu hu').avg_le hh' hf
|
| 155 |
+
rw [avg_mul',avg_sum] at hl
|
| 156 |
+
have ht (u : Keys (p:=p) t N) :
|
| 157 |
+
X u*Y u=avg F (fun x : A×B => α u x.1*β u x.2) := (pairW_separate ..).symm
|
| 158 |
+
simp_rw [ht]; exact hl
|
| 159 |
+
apply (overlap_count J X Y hX hY).trans
|
| 160 |
+
rw [card_space,dim_keys,Nat.cast_mul]
|
| 161 |
+
let Z := bp (((k:ℝ)+0.02)*N)
|
| 162 |
+
have he : Z*hit N = bp ((k:ℝ)*N) := by
|
| 163 |
+
unfold Z hit; rw [← bp_add]; congr 1; ring
|
| 164 |
+
have he' : Z*H = bp (-0.005*N) := by
|
| 165 |
+
unfold H; rw [← mul_assoc,← mul_assoc,he]
|
| 166 |
+
unfold L tau
|
| 167 |
+
rw [← bp_add,← bp_add]; congr 1; ring
|
| 168 |
+
change bp ((k:ℝ)*N)*_≤ Z*D+_
|
| 169 |
+
rw [← he, mul_assoc,← he']
|
| 170 |
+
refine (mul_le_mul_of_nonneg_left hh (bp_pos _).le).trans_eq ?_
|
| 171 |
+
ring
|
| 172 |
+
end Volley
|
| 173 |
+
|
| 174 |
+
theorem collision_scales (p : Shape) (K : ℕ) :
|
| 175 |
+
∀ᶠ M : ℕ in atTop,∀ᶠ n : ℕ in atTop, let N := M*n;
|
| 176 |
+
100≤N ∧ (dim (CheckGram p n):ℝ) ≤ 0.01*N ∧
|
| 177 |
+
(K+(kmax p:ℝ))*num (JointIdx p n) ≤ 0.005*N := by
|
| 178 |
+
filter_upwards [columns_budget p (δ:=0.01) (by norm_num)
|
| 179 |
+
(16*(ncComp p:ℝ)*p.h) 0 (by positivity) (by norm_num),
|
| 180 |
+
columns_budget p (δ:=0.005) (by norm_num)
|
| 181 |
+
(2*(K+(kmax p:ℝ))) 0 (by positivity) (by norm_num),eventually_ge_atTop 1] with M hM hB hg
|
| 182 |
+
filter_upwards [eventually_ge_atTop 100] with n hn
|
| 183 |
+
specialize hM n (by omega)
|
| 184 |
+
specialize hB n (by omega)
|
| 185 |
+
have hN : 100 ≤ M*n := by nlinarith
|
| 186 |
+
refine ⟨hN,?_,?_⟩
|
| 187 |
+
· rw [checkgram_dim]
|
| 188 |
+
simp only [Nat.cast_mul,Nat.cast_ofNat]; unfold num at hM
|
| 189 |
+
have hi : (↑(Fintype.card (Row p n)):ℝ)≤Fintype.card (Full p n) := by
|
| 190 |
+
have he : Fintype.card (Full p n)=_+_ := Fintype.card_sum ..
|
| 191 |
+
exact_mod_cast (show Fintype.card (Row p n)≤Fintype.card (Full p n) from he.symm ▸
|
| 192 |
+
Nat.le_add_right ..)
|
| 193 |
+
rw [add_zero] at hM
|
| 194 |
+
rw [Nat.cast_mul] at hM
|
| 195 |
+
exact le_trans (mul_le_mul_of_nonneg_left hi (by positivity)) hM
|
| 196 |
+
rw [show num (JointIdx p n) = 2*num (Full p n) from (by
|
| 197 |
+
unfold num JointIdx; rw [Fintype.card_sum]; push_cast; ring)]
|
| 198 |
+
linarith only [hB]
|
| 199 |
+
|
| 200 |
+
end HadwigerCounterexample
|
| 201 |
+
|
| 202 |
+
end
|
| 203 |
+
|
| 204 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitionRefinement.lean
CHANGED
|
@@ -1,79 +1,79 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RectangleComparisons
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Common Partition Refinement -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
variable {p:Shape} {n N K M r : ℕ}
|
| 12 |
-
|
| 13 |
-
def refines {r r':ℕ} (Y:Silhouette p N r) (Y':Silhouette p N r') :=
|
| 14 |
-
∀ l q, ∃ f:Fin r→Fin r',∀ x,Y' l q x=f (Y l q x)
|
| 15 |
-
|
| 16 |
-
theorem self_refine (Y:Silhouette p N r): refines Y Y :=
|
| 17 |
-
fun _ _=> ⟨id,fun _=>rfl⟩
|
| 18 |
-
theorem refines_next {r s t:ℕ} {Y:Silhouette p N r} {X:Silhouette p N s}
|
| 19 |
-
{Z:Silhouette p N t} (h : refines Y X) (hg : refines X Z) :
|
| 20 |
-
refines Y Z := by
|
| 21 |
-
intro l q
|
| 22 |
-
obtain ⟨f,hf⟩:=h l q; obtain ⟨g,hg⟩:=hg l q
|
| 23 |
-
refine ⟨g∘ f,fun x => ?_⟩; rw [hg,hf]; rfl
|
| 24 |
-
|
| 25 |
-
variable {A B : Type} [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B]
|
| 26 |
-
|
| 27 |
-
def bouquet (f : A→ℕ) := Fintype.card ((i:A)→ Fin (f i))
|
| 28 |
-
def bundleY (f:A→ℕ) (w: (i:A)→ Silhouette p N (f i)) :
|
| 29 |
-
Silhouette p N (bouquet f) :=
|
| 30 |
-
fun l q x=> Fintype.equivFin ((i:A)→ Fin (f i)) (fun i=> w i l q x)
|
| 31 |
-
theorem bundle_refines (f:A→ℕ) (w:(i:A)→ Silhouette p N (f i)) :
|
| 32 |
-
∀ i,refines (bundleY f w) (w i) := by
|
| 33 |
-
intro i l q
|
| 34 |
-
let e:= Fintype.equivFin ((i:A)→Fin (f i))
|
| 35 |
-
exact ⟨fun x=> e.symm x i,fun x=>(congr_fun (e.symm_apply_apply (fun i=> w i l q x)) i).symm⟩
|
| 36 |
-
|
| 37 |
-
def duoY {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :
|
| 38 |
-
Silhouette p N (r*s) :=
|
| 39 |
-
open scoped Classical in fun i q x => finProdFinEquiv (Y i q x,X i q x)
|
| 40 |
-
theorem duo_good {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :
|
| 41 |
-
refines (duoY Y X) Y ∧ refines (duoY Y X) X := by
|
| 42 |
-
let e : Fin r × Fin s ≃ Fin (r*s):=finProdFinEquiv
|
| 43 |
-
constructor
|
| 44 |
-
· intro i j; exact ⟨fun k=>(e.symm k).1,fun x=> (congrArg Prod.fst
|
| 45 |
-
(e.symm_apply_apply (Y i j x,X i j x))).symm⟩
|
| 46 |
-
intro i j; exact ⟨fun k=>(e.symm k).2,fun x=> (congrArg Prod.snd
|
| 47 |
-
(e.symm_apply_apply (Y i j x,X i j x))).symm⟩
|
| 48 |
-
|
| 49 |
-
namespace StatusAnalysis
|
| 50 |
-
variable (v : Template p A)
|
| 51 |
-
|
| 52 |
-
def paletteSize (A B : Type) [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] := Fintype.card (B × A → Bool)
|
| 53 |
-
theorem buildPalette (N : ℕ) (q : A → F) (w : B → Template.Paint v N) :
|
| 54 |
-
∃ Y : Silhouette p N (paletteSize A B),∀ i,pigments q Y (w i) := by
|
| 55 |
-
classical
|
| 56 |
-
let E := Fintype.equivFin (B × A→Bool)
|
| 57 |
-
let H (l) (q:F) (x : AtomKey (p:=p) l N) (i:B) (j:A) :=
|
| 58 |
-
if h:v.t j=l then decide ((w i).flies j (h ▸ x)) else false
|
| 59 |
-
let Y : Silhouette p N (paletteSize A B) :=
|
| 60 |
-
fun l q x=> E (fun i=> H l q x i.1 i.2)
|
| 61 |
-
refine ⟨Y,fun i j=>⟨fun x=>(E.symm x (i,j)),fun x=>?_⟩⟩
|
| 62 |
-
change _ ↔ E.symm (E (fun i => H (v.t j) (q j) x i.1 i.2)) (i,j)=true
|
| 63 |
-
rw [Equiv.symm_apply_apply]
|
| 64 |
-
unfold H; rw [dite_eq_left rfl]; simp
|
| 65 |
-
|
| 66 |
-
omit [Fintype A] [DecidableEq A] in
|
| 67 |
-
theorem finerPigment {v : Template p A} {r s:ℕ} (Y : Silhouette p N r)
|
| 68 |
-
(Y' : Silhouette p N s) (h : refines Y' Y) {q} (w : Template.Paint v N)
|
| 69 |
-
(hh : pigments q Y w) : pigments q Y' w := by
|
| 70 |
-
intro i
|
| 71 |
-
obtain ⟨g,hg⟩:=hh i; obtain ⟨f,hf⟩:=h (v.t i) (q i)
|
| 72 |
-
exact ⟨g∘ f,fun x=> (hg x).trans (by rw [hf]; rfl)⟩
|
| 73 |
-
|
| 74 |
-
end StatusAnalysis
|
| 75 |
-
end HadwigerCounterexample
|
| 76 |
-
|
| 77 |
-
end
|
| 78 |
-
|
| 79 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RectangleComparisons
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Common Partition Refinement -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
variable {p:Shape} {n N K M r : ℕ}
|
| 12 |
+
|
| 13 |
+
def refines {r r':ℕ} (Y:Silhouette p N r) (Y':Silhouette p N r') :=
|
| 14 |
+
∀ l q, ∃ f:Fin r→Fin r',∀ x,Y' l q x=f (Y l q x)
|
| 15 |
+
|
| 16 |
+
theorem self_refine (Y:Silhouette p N r): refines Y Y :=
|
| 17 |
+
fun _ _=> ⟨id,fun _=>rfl⟩
|
| 18 |
+
theorem refines_next {r s t:ℕ} {Y:Silhouette p N r} {X:Silhouette p N s}
|
| 19 |
+
{Z:Silhouette p N t} (h : refines Y X) (hg : refines X Z) :
|
| 20 |
+
refines Y Z := by
|
| 21 |
+
intro l q
|
| 22 |
+
obtain ⟨f,hf⟩:=h l q; obtain ⟨g,hg⟩:=hg l q
|
| 23 |
+
refine ⟨g∘ f,fun x => ?_⟩; rw [hg,hf]; rfl
|
| 24 |
+
|
| 25 |
+
variable {A B : Type} [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B]
|
| 26 |
+
|
| 27 |
+
def bouquet (f : A→ℕ) := Fintype.card ((i:A)→ Fin (f i))
|
| 28 |
+
def bundleY (f:A→ℕ) (w: (i:A)→ Silhouette p N (f i)) :
|
| 29 |
+
Silhouette p N (bouquet f) :=
|
| 30 |
+
fun l q x=> Fintype.equivFin ((i:A)→ Fin (f i)) (fun i=> w i l q x)
|
| 31 |
+
theorem bundle_refines (f:A→ℕ) (w:(i:A)→ Silhouette p N (f i)) :
|
| 32 |
+
∀ i,refines (bundleY f w) (w i) := by
|
| 33 |
+
intro i l q
|
| 34 |
+
let e:= Fintype.equivFin ((i:A)→Fin (f i))
|
| 35 |
+
exact ⟨fun x=> e.symm x i,fun x=>(congr_fun (e.symm_apply_apply (fun i=> w i l q x)) i).symm⟩
|
| 36 |
+
|
| 37 |
+
def duoY {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :
|
| 38 |
+
Silhouette p N (r*s) :=
|
| 39 |
+
open scoped Classical in fun i q x => finProdFinEquiv (Y i q x,X i q x)
|
| 40 |
+
theorem duo_good {r s} (Y : Silhouette p N r) (X : Silhouette p N s) :
|
| 41 |
+
refines (duoY Y X) Y ∧ refines (duoY Y X) X := by
|
| 42 |
+
let e : Fin r × Fin s ≃ Fin (r*s):=finProdFinEquiv
|
| 43 |
+
constructor
|
| 44 |
+
· intro i j; exact ⟨fun k=>(e.symm k).1,fun x=> (congrArg Prod.fst
|
| 45 |
+
(e.symm_apply_apply (Y i j x,X i j x))).symm⟩
|
| 46 |
+
intro i j; exact ⟨fun k=>(e.symm k).2,fun x=> (congrArg Prod.snd
|
| 47 |
+
(e.symm_apply_apply (Y i j x,X i j x))).symm⟩
|
| 48 |
+
|
| 49 |
+
namespace StatusAnalysis
|
| 50 |
+
variable (v : Template p A)
|
| 51 |
+
|
| 52 |
+
def paletteSize (A B : Type) [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] := Fintype.card (B × A → Bool)
|
| 53 |
+
theorem buildPalette (N : ℕ) (q : A → F) (w : B → Template.Paint v N) :
|
| 54 |
+
∃ Y : Silhouette p N (paletteSize A B),∀ i,pigments q Y (w i) := by
|
| 55 |
+
classical
|
| 56 |
+
let E := Fintype.equivFin (B × A→Bool)
|
| 57 |
+
let H (l) (q:F) (x : AtomKey (p:=p) l N) (i:B) (j:A) :=
|
| 58 |
+
if h:v.t j=l then decide ((w i).flies j (h ▸ x)) else false
|
| 59 |
+
let Y : Silhouette p N (paletteSize A B) :=
|
| 60 |
+
fun l q x=> E (fun i=> H l q x i.1 i.2)
|
| 61 |
+
refine ⟨Y,fun i j=>⟨fun x=>(E.symm x (i,j)),fun x=>?_⟩⟩
|
| 62 |
+
change _ ↔ E.symm (E (fun i => H (v.t j) (q j) x i.1 i.2)) (i,j)=true
|
| 63 |
+
rw [Equiv.symm_apply_apply]
|
| 64 |
+
unfold H; rw [dite_eq_left rfl]; simp
|
| 65 |
+
|
| 66 |
+
omit [Fintype A] [DecidableEq A] in
|
| 67 |
+
theorem finerPigment {v : Template p A} {r s:ℕ} (Y : Silhouette p N r)
|
| 68 |
+
(Y' : Silhouette p N s) (h : refines Y' Y) {q} (w : Template.Paint v N)
|
| 69 |
+
(hh : pigments q Y w) : pigments q Y' w := by
|
| 70 |
+
intro i
|
| 71 |
+
obtain ⟨g,hg⟩:=hh i; obtain ⟨f,hf⟩:=h (v.t i) (q i)
|
| 72 |
+
exact ⟨g∘ f,fun x=> (hg x).trans (by rw [hf]; rfl)⟩
|
| 73 |
+
|
| 74 |
+
end StatusAnalysis
|
| 75 |
+
end HadwigerCounterexample
|
| 76 |
+
|
| 77 |
+
end
|
| 78 |
+
|
| 79 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CommonPartitions.lean
CHANGED
|
@@ -1,119 +1,119 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ProjectionError
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Common Partitions -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Module Matrix Filter Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B I J X : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J] [Fintype X]
|
| 12 |
-
variable (u : Wgt A) (w : Wgt I) (v : Wgt J)
|
| 13 |
-
|
| 14 |
-
set_option maxHeartbeats 800000 in
|
| 15 |
-
theorem rollup [Nonempty B] (hw : IsLaw w) (hv : IsLaw v) (hu : IsLaw u)
|
| 16 |
-
(f : I×B→Wgt A) (g : J×B→Wgt A) (h k : I×J→ B) (R : ℝ) (hr : 0<R)
|
| 17 |
-
(hg : ∀ i x, |g i x|≤R)
|
| 18 |
-
(p : A→X) (ε : ℝ) (hx : wanes (pairW w unif) u f p ε) :
|
| 19 |
-
avg (pairW w v) (fun i=> |rebate u (f (i.1,h i)) (g (i.2,k i)) p|) ≤
|
| 20 |
-
num B ^ 2 * (R*ε) := by
|
| 21 |
-
classical
|
| 22 |
-
let H (i : I × B) (j : J × B) := |rebate u (f i) (g j) p|
|
| 23 |
-
let T := num B
|
| 24 |
-
have ht : 0<T := by unfold T num; positivity
|
| 25 |
-
have he j :
|
| 26 |
-
avg (pairW w (unif : Wgt B)) (fun i=> H i j)≤ R*ε := by
|
| 27 |
-
let g' (i:A) := g j i/R
|
| 28 |
-
have hh (i) : |g' i|≤1 := by
|
| 29 |
-
unfold g'; rw [abs_div,abs_of_pos hr,div_le_one hr]; exact hg _ _
|
| 30 |
-
have hz (i) :
|
| 31 |
-
H i j=R* |dip u (fun x=> f i x-banner u p (f i) x) g'| := by
|
| 32 |
-
unfold H; rw [rebate_calc _ _ _ _ hu.nz]
|
| 33 |
-
unfold g' dip; simp_rw [←mul_div_assoc,avg_div]
|
| 34 |
-
rw [abs_div,abs_of_pos hr]; field_simp
|
| 35 |
-
simp_rw [hz,avg_mul']; exact mul_le_mul_of_nonneg_left (hx g' hh) hr.le
|
| 36 |
-
have hh i j :
|
| 37 |
-
H (i,h (i,j)) (j,k (i,j))≤ ∑ b : B,∑ c : B,H (i,b) (j,c) :=
|
| 38 |
-
(Finset.single_le_sum (f:=fun x=> H (i,h (i,j)) (j,x)) (fun _ _ => abs_nonneg _) (mem_univ (k (i,j)))).trans
|
| 39 |
-
(Finset.single_le_sum (f:=fun x => ∑ c:B,H (i,x) (j,c)) (fun _ _=> Finset.sum_nonneg (fun _ _=>abs_nonneg _)) (mem_univ (h (i,j))))
|
| 40 |
-
have hi j c :
|
| 41 |
-
avg w (fun i=>∑ b : B,H (i,b) (j,c))≤ T*(R*ε) := by
|
| 42 |
-
have hg : ∀ i : I,(∑ b:B,H (i,b) (j,c))=T*avg unif (fun b=> H (i,b) (j,c)) := by
|
| 43 |
-
intro i; simp only [avg,unif_apply,← Finset.mul_sum]
|
| 44 |
-
change _ = T*(T⁻¹ * _)
|
| 45 |
-
rw [←mul_assoc,mul_inv_cancel₀ ht.ne',one_mul]
|
| 46 |
-
simp_rw [hg,avg_mul']
|
| 47 |
-
refine mul_le_mul_of_nonneg_left ?_ ht.le; rw [← pairW_avg w unif (fun p : I×B=>H p (j,c))]
|
| 48 |
-
exact he _
|
| 49 |
-
change avg (pairW w v) _ ≤ T^2*(R*ε)
|
| 50 |
-
rw [pairW_avg,avg_avg]
|
| 51 |
-
refine hv.avg_le fun j=> ?_
|
| 52 |
-
have hz i : ∑ b:B,∑ c:B,H (i,b) (j,c)=∑ c:B,∑ b:B,H (i,b) (j,c) :=
|
| 53 |
-
Finset.sum_comm
|
| 54 |
-
apply (avg_mono hw.nz (fun i => (hh i j).trans_eq (hz i))).trans
|
| 55 |
-
rw [avg_sum]
|
| 56 |
-
exact (Finset.sum_le_sum fun i _=>hi j i).trans_eq (by
|
| 57 |
-
simp only [sum_const,nsmul_eq_mul,Finset.card_univ,T,num]; ring)
|
| 58 |
-
|
| 59 |
-
set_option maxHeartbeats 1200000 in
|
| 60 |
-
theorem global_net (R ε : ℝ) (hr : 0<R) (hε : 0<ε) :
|
| 61 |
-
∃ δ : ℝ,0<δ ∧ ∀ r : ℕ,∃ l : ℕ,∀ (I J A : Type) [Fintype I] [Fintype J] [Fintype A]
|
| 62 |
-
(w : Wgt I) (v : Wgt J) (u : Wgt A), IsLaw w→IsLaw v →IsLaw u →
|
| 63 |
-
∀ (P : I→Wgt A→Prop) (Q : J→Wgt A→Prop), (∀ i,roster (P i) r δ) →
|
| 64 |
-
(∀ i,roster (Q i) r δ) →
|
| 65 |
-
∃ k : ℕ,k ≤ l∧ ∃ p:A→Fin k,
|
| 66 |
-
∀ f g:I × J→Wgt A,(∀ i,P i.1 (f i)) → (∀ i,Q i.2 (g i)) →
|
| 67 |
-
avg (pairW w v) (fun i => |rebate u (mcut R u (f i)) (mcut R u (g i)) p|)≤ ε := by
|
| 68 |
-
classical
|
| 69 |
-
let δ := ε/(8*R)
|
| 70 |
-
have hd : 0<δ := by positivity
|
| 71 |
-
refine ⟨δ,hd,fun r=>?_⟩
|
| 72 |
-
let B:=Fin (r+1); let t:=num B
|
| 73 |
-
have ht : 0<t := by unfold t num; positivity
|
| 74 |
-
let c:=ε/(2*(t^2)*R)
|
| 75 |
-
have hc : 0<c := by positivity
|
| 76 |
-
obtain ⟨l,hl⟩:= erosive R c hr.le hc
|
| 77 |
-
refine ⟨l,fun I J A _ _ _ w v u hw hv hu P Q hp hq=>?_⟩
|
| 78 |
-
choose s hs h1 using fun i=> roster_clip R u hu hr.le (P i) r δ (hp i)
|
| 79 |
-
choose y hy h2 using fun i=> roster_clip R u hu hr.le (Q i) r δ (hq i)
|
| 80 |
-
let F : I×B→Wgt A := uncurry s
|
| 81 |
-
let G : J×B→Wgt A := uncurry y
|
| 82 |
-
obtain ⟨m,hm,p,hP⟩:= hl A (I×B) (pairW w unif) u F (pairW_law hw unif_law) hu (fun i j=> hs _ _ _)
|
| 83 |
-
refine ⟨m,hm,p,fun f g hf hg=>?_⟩
|
| 84 |
-
let f' (i : I×J):= mcut R u (f i)
|
| 85 |
-
let g' (i : I×J):= mcut R u (g i)
|
| 86 |
-
choose a hA using fun i:I×J => h1 i.1 (f i) (hf i)
|
| 87 |
-
choose b hB using fun i:I×J => h2 i.2 (g i) (hg i)
|
| 88 |
-
let H (i:I×J) := |rebate u (F (i.1,a i)) (G (i.2,b i)) p|
|
| 89 |
-
let D:=pairW w v; have hD:= pairW_law hw hv
|
| 90 |
-
have he := rollup u w v hw hv hu F G a b R hr (fun i j=> hy _ _ _) p c hP
|
| 91 |
-
have hb : 0≤2*R := by linarith only [hr]
|
| 92 |
-
have hi (i:I×J) : |rebate u (f' i) (g' i) p|≤ H i+(δ*(4*R)) := by
|
| 93 |
-
let A' := F (i.1,a i); let B' := G (i.2,b i)
|
| 94 |
-
have h1 (j) : |g' i j|≤R := by
|
| 95 |
-
rw [abs_of_nonneg ((mcut_range _ _ _ hr.le j).1)]
|
| 96 |
-
exact (mcut_range _ _ _ hr.le j).2
|
| 97 |
-
have h3 : |rebate u (f' i) (g' i) p - rebate u A' (g' i) p|≤ δ*(2*R) := by
|
| 98 |
-
exact (rebate_cost u _ _ A' p hu.nz R hr.le h1).trans (mul_le_mul_of_nonneg_right (hA i) hb)
|
| 99 |
-
have h4 : |rebate u A' (g' i) p - rebate u A' B' p|≤δ*(2*R) := by
|
| 100 |
-
rw [rebate_sym u A',rebate_sym u A']
|
| 101 |
-
exact (rebate_cost u _ _ B' p hu.nz R hr.le (fun i=>hs _ _ _)).trans
|
| 102 |
-
(mul_le_mul_of_nonneg_right (hB i) hb)
|
| 103 |
-
let U:=rebate u A' B' p
|
| 104 |
-
let X:=rebate u (f' i) (g' i) p
|
| 105 |
-
have hz:= (abs_sub_le X (rebate u A' (g' i) p) U).trans (add_le_add h3 h4)
|
| 106 |
-
calc |X| = |(X-U)+U| := by rw [sub_add_cancel]
|
| 107 |
-
_ ≤ _ := ((abs_add_le _ _).trans (add_le_add_left hz _)).trans_eq (by
|
| 108 |
-
change _+ |U| = |U|+δ*(4*R)
|
| 109 |
-
ring)
|
| 110 |
-
refine (avg_mono hD.nz hi).trans ?_
|
| 111 |
-
rw [avg_add,hD.avg_const]
|
| 112 |
-
exact (add_le_add_left he _).trans_eq (by
|
| 113 |
-
change t^2*(R*c)+δ*(4*R)=_
|
| 114 |
-
unfold δ c; field_simp; ring)
|
| 115 |
-
end HadwigerCounterexample
|
| 116 |
-
|
| 117 |
-
end
|
| 118 |
-
|
| 119 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ProjectionError
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Common Partitions -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Module Matrix Filter Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B I J X : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J] [Fintype X]
|
| 12 |
+
variable (u : Wgt A) (w : Wgt I) (v : Wgt J)
|
| 13 |
+
|
| 14 |
+
set_option maxHeartbeats 800000 in
|
| 15 |
+
theorem rollup [Nonempty B] (hw : IsLaw w) (hv : IsLaw v) (hu : IsLaw u)
|
| 16 |
+
(f : I×B→Wgt A) (g : J×B→Wgt A) (h k : I×J→ B) (R : ℝ) (hr : 0<R)
|
| 17 |
+
(hg : ∀ i x, |g i x|≤R)
|
| 18 |
+
(p : A→X) (ε : ℝ) (hx : wanes (pairW w unif) u f p ε) :
|
| 19 |
+
avg (pairW w v) (fun i=> |rebate u (f (i.1,h i)) (g (i.2,k i)) p|) ≤
|
| 20 |
+
num B ^ 2 * (R*ε) := by
|
| 21 |
+
classical
|
| 22 |
+
let H (i : I × B) (j : J × B) := |rebate u (f i) (g j) p|
|
| 23 |
+
let T := num B
|
| 24 |
+
have ht : 0<T := by unfold T num; positivity
|
| 25 |
+
have he j :
|
| 26 |
+
avg (pairW w (unif : Wgt B)) (fun i=> H i j)≤ R*ε := by
|
| 27 |
+
let g' (i:A) := g j i/R
|
| 28 |
+
have hh (i) : |g' i|≤1 := by
|
| 29 |
+
unfold g'; rw [abs_div,abs_of_pos hr,div_le_one hr]; exact hg _ _
|
| 30 |
+
have hz (i) :
|
| 31 |
+
H i j=R* |dip u (fun x=> f i x-banner u p (f i) x) g'| := by
|
| 32 |
+
unfold H; rw [rebate_calc _ _ _ _ hu.nz]
|
| 33 |
+
unfold g' dip; simp_rw [←mul_div_assoc,avg_div]
|
| 34 |
+
rw [abs_div,abs_of_pos hr]; field_simp
|
| 35 |
+
simp_rw [hz,avg_mul']; exact mul_le_mul_of_nonneg_left (hx g' hh) hr.le
|
| 36 |
+
have hh i j :
|
| 37 |
+
H (i,h (i,j)) (j,k (i,j))≤ ∑ b : B,∑ c : B,H (i,b) (j,c) :=
|
| 38 |
+
(Finset.single_le_sum (f:=fun x=> H (i,h (i,j)) (j,x)) (fun _ _ => abs_nonneg _) (mem_univ (k (i,j)))).trans
|
| 39 |
+
(Finset.single_le_sum (f:=fun x => ∑ c:B,H (i,x) (j,c)) (fun _ _=> Finset.sum_nonneg (fun _ _=>abs_nonneg _)) (mem_univ (h (i,j))))
|
| 40 |
+
have hi j c :
|
| 41 |
+
avg w (fun i=>∑ b : B,H (i,b) (j,c))≤ T*(R*ε) := by
|
| 42 |
+
have hg : ∀ i : I,(∑ b:B,H (i,b) (j,c))=T*avg unif (fun b=> H (i,b) (j,c)) := by
|
| 43 |
+
intro i; simp only [avg,unif_apply,← Finset.mul_sum]
|
| 44 |
+
change _ = T*(T⁻¹ * _)
|
| 45 |
+
rw [←mul_assoc,mul_inv_cancel₀ ht.ne',one_mul]
|
| 46 |
+
simp_rw [hg,avg_mul']
|
| 47 |
+
refine mul_le_mul_of_nonneg_left ?_ ht.le; rw [← pairW_avg w unif (fun p : I×B=>H p (j,c))]
|
| 48 |
+
exact he _
|
| 49 |
+
change avg (pairW w v) _ ≤ T^2*(R*ε)
|
| 50 |
+
rw [pairW_avg,avg_avg]
|
| 51 |
+
refine hv.avg_le fun j=> ?_
|
| 52 |
+
have hz i : ∑ b:B,∑ c:B,H (i,b) (j,c)=∑ c:B,∑ b:B,H (i,b) (j,c) :=
|
| 53 |
+
Finset.sum_comm
|
| 54 |
+
apply (avg_mono hw.nz (fun i => (hh i j).trans_eq (hz i))).trans
|
| 55 |
+
rw [avg_sum]
|
| 56 |
+
exact (Finset.sum_le_sum fun i _=>hi j i).trans_eq (by
|
| 57 |
+
simp only [sum_const,nsmul_eq_mul,Finset.card_univ,T,num]; ring)
|
| 58 |
+
|
| 59 |
+
set_option maxHeartbeats 1200000 in
|
| 60 |
+
theorem global_net (R ε : ℝ) (hr : 0<R) (hε : 0<ε) :
|
| 61 |
+
∃ δ : ℝ,0<δ ∧ ∀ r : ℕ,∃ l : ℕ,∀ (I J A : Type) [Fintype I] [Fintype J] [Fintype A]
|
| 62 |
+
(w : Wgt I) (v : Wgt J) (u : Wgt A), IsLaw w→IsLaw v →IsLaw u →
|
| 63 |
+
∀ (P : I→Wgt A→Prop) (Q : J→Wgt A→Prop), (∀ i,roster (P i) r δ) →
|
| 64 |
+
(∀ i,roster (Q i) r δ) →
|
| 65 |
+
∃ k : ℕ,k ≤ l∧ ∃ p:A→Fin k,
|
| 66 |
+
∀ f g:I × J→Wgt A,(∀ i,P i.1 (f i)) → (∀ i,Q i.2 (g i)) →
|
| 67 |
+
avg (pairW w v) (fun i => |rebate u (mcut R u (f i)) (mcut R u (g i)) p|)≤ ε := by
|
| 68 |
+
classical
|
| 69 |
+
let δ := ε/(8*R)
|
| 70 |
+
have hd : 0<δ := by positivity
|
| 71 |
+
refine ⟨δ,hd,fun r=>?_⟩
|
| 72 |
+
let B:=Fin (r+1); let t:=num B
|
| 73 |
+
have ht : 0<t := by unfold t num; positivity
|
| 74 |
+
let c:=ε/(2*(t^2)*R)
|
| 75 |
+
have hc : 0<c := by positivity
|
| 76 |
+
obtain ⟨l,hl⟩:= erosive R c hr.le hc
|
| 77 |
+
refine ⟨l,fun I J A _ _ _ w v u hw hv hu P Q hp hq=>?_⟩
|
| 78 |
+
choose s hs h1 using fun i=> roster_clip R u hu hr.le (P i) r δ (hp i)
|
| 79 |
+
choose y hy h2 using fun i=> roster_clip R u hu hr.le (Q i) r δ (hq i)
|
| 80 |
+
let F : I×B→Wgt A := uncurry s
|
| 81 |
+
let G : J×B→Wgt A := uncurry y
|
| 82 |
+
obtain ⟨m,hm,p,hP⟩:= hl A (I×B) (pairW w unif) u F (pairW_law hw unif_law) hu (fun i j=> hs _ _ _)
|
| 83 |
+
refine ⟨m,hm,p,fun f g hf hg=>?_⟩
|
| 84 |
+
let f' (i : I×J):= mcut R u (f i)
|
| 85 |
+
let g' (i : I×J):= mcut R u (g i)
|
| 86 |
+
choose a hA using fun i:I×J => h1 i.1 (f i) (hf i)
|
| 87 |
+
choose b hB using fun i:I×J => h2 i.2 (g i) (hg i)
|
| 88 |
+
let H (i:I×J) := |rebate u (F (i.1,a i)) (G (i.2,b i)) p|
|
| 89 |
+
let D:=pairW w v; have hD:= pairW_law hw hv
|
| 90 |
+
have he := rollup u w v hw hv hu F G a b R hr (fun i j=> hy _ _ _) p c hP
|
| 91 |
+
have hb : 0≤2*R := by linarith only [hr]
|
| 92 |
+
have hi (i:I×J) : |rebate u (f' i) (g' i) p|≤ H i+(δ*(4*R)) := by
|
| 93 |
+
let A' := F (i.1,a i); let B' := G (i.2,b i)
|
| 94 |
+
have h1 (j) : |g' i j|≤R := by
|
| 95 |
+
rw [abs_of_nonneg ((mcut_range _ _ _ hr.le j).1)]
|
| 96 |
+
exact (mcut_range _ _ _ hr.le j).2
|
| 97 |
+
have h3 : |rebate u (f' i) (g' i) p - rebate u A' (g' i) p|≤ δ*(2*R) := by
|
| 98 |
+
exact (rebate_cost u _ _ A' p hu.nz R hr.le h1).trans (mul_le_mul_of_nonneg_right (hA i) hb)
|
| 99 |
+
have h4 : |rebate u A' (g' i) p - rebate u A' B' p|≤δ*(2*R) := by
|
| 100 |
+
rw [rebate_sym u A',rebate_sym u A']
|
| 101 |
+
exact (rebate_cost u _ _ B' p hu.nz R hr.le (fun i=>hs _ _ _)).trans
|
| 102 |
+
(mul_le_mul_of_nonneg_right (hB i) hb)
|
| 103 |
+
let U:=rebate u A' B' p
|
| 104 |
+
let X:=rebate u (f' i) (g' i) p
|
| 105 |
+
have hz:= (abs_sub_le X (rebate u A' (g' i) p) U).trans (add_le_add h3 h4)
|
| 106 |
+
calc |X| = |(X-U)+U| := by rw [sub_add_cancel]
|
| 107 |
+
_ ≤ _ := ((abs_add_le _ _).trans (add_le_add_left hz _)).trans_eq (by
|
| 108 |
+
change _+ |U| = |U|+δ*(4*R)
|
| 109 |
+
ring)
|
| 110 |
+
refine (avg_mono hD.nz hi).trans ?_
|
| 111 |
+
rw [avg_add,hD.avg_const]
|
| 112 |
+
exact (add_le_add_left he _).trans_eq (by
|
| 113 |
+
change t^2*(R*c)+δ*(4*R)=_
|
| 114 |
+
unfold δ c; field_simp; ring)
|
| 115 |
+
end HadwigerCounterexample
|
| 116 |
+
|
| 117 |
+
end
|
| 118 |
+
|
| 119 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CommonPredictions.lean
CHANGED
|
@@ -1,112 +1,112 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PointAtomVanishing
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBounds
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Common Predictions -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix Module LinearMap Function Finset Submodule
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {p : Shape} {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
abbrev Augur (p : Shape) (N : ℕ) := ∀ t : Tag p.g,F→AtomKey (p:=p) t N→F
|
| 15 |
-
def mismatch (p : Shape) {n N : ℕ} (g : Augur p N) (F : Pdual p n) (l : Tag p.g)
|
| 16 |
-
(s : Label p.b) (f : Flavor p.g) (x : Orient p n N) (y : Knobs p.g n) :=
|
| 17 |
-
F (useAtom p l s f y)≠ g l (dialed p l f y) (keyOne p l s (lit f l y) x)
|
| 18 |
-
def postulates (p : Shape) (o : Orient p n N)
|
| 19 |
-
(g : Augur p N) (w : Pdual p n) (E : Finset (Label p.b)) (δ : ℝ) :=
|
| 20 |
-
∀ s,s∉E→∀ l f, pr (spins p n) (fun i => mismatch p g w l s f o i)≤δ
|
| 21 |
-
|
| 22 |
-
def yoke (p : Shape) (m : Mixer p n) (x : UnitType p n N) (i : Bool)
|
| 23 |
-
(u : Profile p n) (α : F) : Pdual p n :=
|
| 24 |
-
innerP p x i + (Tsym m u + α • role p n)
|
| 25 |
-
|
| 26 |
-
def claimed (p : Shape) (x : UnitType p n N)
|
| 27 |
-
(g : Bool→Augur p N) (m : Mixer p n)
|
| 28 |
-
(w : Bool→Profile p n) (α : Bool→F) (L : Bool → Finset (Label p.b)) (δ : ℝ) :=
|
| 29 |
-
∀ i,postulates p (onSide x i) (g i) (yoke p m x i (w i) (α i)) (L i) δ
|
| 30 |
-
|
| 31 |
-
def silent (w : Pdual p n) := ∀ x, x∈Xspace p n → w x=0
|
| 32 |
-
|
| 33 |
-
def fixStar (p : Shape) (n : ℕ) (l : Tag p.g) :
|
| 34 |
-
Moment p n →ₗ[F] Profile p n :=
|
| 35 |
-
cut p n ∘ₗ LinearMap.single F (fun _ : Tag p.g => Moment p n) l
|
| 36 |
-
theorem fix_one (p : Shape) (n : ℕ) (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :
|
| 37 |
-
atom p l s z=fixStar p n l (mom p s z) := rfl
|
| 38 |
-
|
| 39 |
-
theorem atom_silent {w : Pdual p n}
|
| 40 |
-
(h : ∀ l s z,allows l z → w (atom p l s z)=0) : silent w := by
|
| 41 |
-
classical
|
| 42 |
-
intro x hx
|
| 43 |
-
obtain ⟨u,hu,rfl⟩ := mem_X.mp hx
|
| 44 |
-
have he l : Wtag p n l≤LinearMap.ker (w∘ₗfixStar p n l) := by
|
| 45 |
-
refine Submodule.span_le.mpr ?_
|
| 46 |
-
rintro x ⟨s,z,hz,rfl⟩
|
| 47 |
-
exact h l s z hz
|
| 48 |
-
have ht : (cut p n u)=∑ i : Tag p.g,fixStar p n i (u i) := by
|
| 49 |
-
have hh := Finset.univ_sum_single u
|
| 50 |
-
unfold fixStar
|
| 51 |
-
simp_rw [LinearMap.comp_apply, ← map_sum (cut p n)]
|
| 52 |
-
exact congrArg (cut p n) (Eq.symm hh)
|
| 53 |
-
rw [ht,map_sum]; exact Finset.sum_eq_zero fun i _=>he _ (hu i)
|
| 54 |
-
|
| 55 |
-
theorem shared_base (p : Shape) (hn : 2*p.r≤n) (hr : 1 ≤ p.r) (hg : 0 < p.g) :
|
| 56 |
-
∃ (z : Base p.g n) (s : Label p.b), (∀ l, allows l z) ∧ eta p n (mom p s z)=1 := by
|
| 57 |
-
classical
|
| 58 |
-
let l : Tag p.g := ⟨0,hg⟩
|
| 59 |
-
let f : Flavor p.g:= Flavor.sharedOnly
|
| 60 |
-
let i := (Sum.inr () : ProbeIdx p.g)
|
| 61 |
-
let v : Digest p.g := Pi.single i 1
|
| 62 |
-
have hx : v.feasible l f := by
|
| 63 |
-
rintro (x|⟨⟩) _
|
| 64 |
-
· exact Pi.single_eq_of_ne (by simp [i]) _
|
| 65 |
-
exact (‹¬_› trivial).elim
|
| 66 |
-
have he := exists_of_pr_pos (spins_law p n).nz
|
| 67 |
-
((scanPrice_pos p).trans_le (scan_fraction (n:=n) l f v hr hn hx))
|
| 68 |
-
obtain ⟨x,h,_⟩ := he
|
| 69 |
-
refine ⟨lit f l x,0,fun i d t h k => ite_eq_right (by simp [f,Flavor.keeps]),?_⟩
|
| 70 |
-
rw [←etaScan,h]; simp [v,Digest.sumBit,Digest.diagO,i]
|
| 71 |
-
|
| 72 |
-
theorem atom_union (p : Shape) (n : ℕ) (z : Base p.g n) (s : Label p.b) :
|
| 73 |
-
∑ i:Tag p.g,atom p i s z=0 := by
|
| 74 |
-
simp_rw [atom,←map_sum (cut p n)]
|
| 75 |
-
rw [Finset.univ_sum_single (fun i : Tag p.g => mom p s z)]
|
| 76 |
-
funext x
|
| 77 |
-
exact char_two (mom p s z)
|
| 78 |
-
|
| 79 |
-
set_option maxHeartbeats 800000 in
|
| 80 |
-
theorem exact_vat (w : Pdual p n) (E : Finset (Label p.b)) (g : F)
|
| 81 |
-
(hE : (E.card:ℝ)<bp ((p.b:ℝ)-2*p.j))
|
| 82 |
-
(hj : Odd p.g) (hn : 2*p.r≤n) (hr : 1≤p.r)
|
| 83 |
-
(h : ∀ l s,s∉E → pr (spins p n)
|
| 84 |
-
(fun x => w (useAtom p l s Flavor.full x)≠g *dialed p l Flavor.full x)<1/4) :
|
| 85 |
-
g=0∧ silent w := by
|
| 86 |
-
classical
|
| 87 |
-
let Q l := w ∘ₗ fixStar p n l - g • eta p n
|
| 88 |
-
have hi (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :
|
| 89 |
-
Q l (mom p s z)= w (atom p l s z)-g*eta p n (mom p s z) := rfl
|
| 90 |
-
have hh (l s z) (hz : allows l z) : Q l (mom p s z)=0 := by
|
| 91 |
-
have he (s) (hs : s∉E) :
|
| 92 |
-
pr (spins p n) (fun x=> Q l (mom p s (lit Flavor.full l x))≠0)<1/4 := by
|
| 93 |
-
simp_rw [hi,←etaScan p l s Flavor.full]
|
| 94 |
-
simpa only [sub_ne_zero,useAtom,dialed] using h l s hs
|
| 95 |
-
exact vat_excluded z E (Q l) (fun i h=>vat_erase l i (Q l) (he i h) z hz) hE s
|
| 96 |
-
simp_rw [hi] at hh
|
| 97 |
-
have he l s z (h : allows l z) : w (atom p l s z) =g*eta p n (mom p s z) :=
|
| 98 |
-
sub_eq_zero.mp (hh l s z h)
|
| 99 |
-
obtain ⟨z,s,hz,hb⟩ := shared_base p hn hr (by obtain ⟨_,hh⟩ := hj; omega)
|
| 100 |
-
have h0 : g=0 := by
|
| 101 |
-
have ht : w (∑ l:Tag p.g,atom p l s z)=0 := by rw [atom_union,map_zero]
|
| 102 |
-
rw [map_sum] at ht
|
| 103 |
-
simp_rw [he _ s z (hz _),hb,mul_one] at ht
|
| 104 |
-
simpa only [Finset.sum_const, Finset.card_univ,Tag,Fintype.card_fin,
|
| 105 |
-
odd_smul_bit hj] using ht
|
| 106 |
-
refine ⟨h0,atom_silent (fun i s z h=> (he i s z h).trans ?_)⟩
|
| 107 |
-
rw [h0,zero_mul]
|
| 108 |
-
end HadwigerCounterexample
|
| 109 |
-
|
| 110 |
-
end
|
| 111 |
-
|
| 112 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PointAtomVanishing
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.UnaryPositivityBounds
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Common Predictions -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix Module LinearMap Function Finset Submodule
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {p : Shape} {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
abbrev Augur (p : Shape) (N : ℕ) := ∀ t : Tag p.g,F→AtomKey (p:=p) t N→F
|
| 15 |
+
def mismatch (p : Shape) {n N : ℕ} (g : Augur p N) (F : Pdual p n) (l : Tag p.g)
|
| 16 |
+
(s : Label p.b) (f : Flavor p.g) (x : Orient p n N) (y : Knobs p.g n) :=
|
| 17 |
+
F (useAtom p l s f y)≠ g l (dialed p l f y) (keyOne p l s (lit f l y) x)
|
| 18 |
+
def postulates (p : Shape) (o : Orient p n N)
|
| 19 |
+
(g : Augur p N) (w : Pdual p n) (E : Finset (Label p.b)) (δ : ℝ) :=
|
| 20 |
+
∀ s,s∉E→∀ l f, pr (spins p n) (fun i => mismatch p g w l s f o i)≤δ
|
| 21 |
+
|
| 22 |
+
def yoke (p : Shape) (m : Mixer p n) (x : UnitType p n N) (i : Bool)
|
| 23 |
+
(u : Profile p n) (α : F) : Pdual p n :=
|
| 24 |
+
innerP p x i + (Tsym m u + α • role p n)
|
| 25 |
+
|
| 26 |
+
def claimed (p : Shape) (x : UnitType p n N)
|
| 27 |
+
(g : Bool→Augur p N) (m : Mixer p n)
|
| 28 |
+
(w : Bool→Profile p n) (α : Bool→F) (L : Bool → Finset (Label p.b)) (δ : ℝ) :=
|
| 29 |
+
∀ i,postulates p (onSide x i) (g i) (yoke p m x i (w i) (α i)) (L i) δ
|
| 30 |
+
|
| 31 |
+
def silent (w : Pdual p n) := ∀ x, x∈Xspace p n → w x=0
|
| 32 |
+
|
| 33 |
+
def fixStar (p : Shape) (n : ℕ) (l : Tag p.g) :
|
| 34 |
+
Moment p n →ₗ[F] Profile p n :=
|
| 35 |
+
cut p n ∘ₗ LinearMap.single F (fun _ : Tag p.g => Moment p n) l
|
| 36 |
+
theorem fix_one (p : Shape) (n : ℕ) (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :
|
| 37 |
+
atom p l s z=fixStar p n l (mom p s z) := rfl
|
| 38 |
+
|
| 39 |
+
theorem atom_silent {w : Pdual p n}
|
| 40 |
+
(h : ∀ l s z,allows l z → w (atom p l s z)=0) : silent w := by
|
| 41 |
+
classical
|
| 42 |
+
intro x hx
|
| 43 |
+
obtain ⟨u,hu,rfl⟩ := mem_X.mp hx
|
| 44 |
+
have he l : Wtag p n l≤LinearMap.ker (w∘ₗfixStar p n l) := by
|
| 45 |
+
refine Submodule.span_le.mpr ?_
|
| 46 |
+
rintro x ⟨s,z,hz,rfl⟩
|
| 47 |
+
exact h l s z hz
|
| 48 |
+
have ht : (cut p n u)=∑ i : Tag p.g,fixStar p n i (u i) := by
|
| 49 |
+
have hh := Finset.univ_sum_single u
|
| 50 |
+
unfold fixStar
|
| 51 |
+
simp_rw [LinearMap.comp_apply, ← map_sum (cut p n)]
|
| 52 |
+
exact congrArg (cut p n) (Eq.symm hh)
|
| 53 |
+
rw [ht,map_sum]; exact Finset.sum_eq_zero fun i _=>he _ (hu i)
|
| 54 |
+
|
| 55 |
+
theorem shared_base (p : Shape) (hn : 2*p.r≤n) (hr : 1 ≤ p.r) (hg : 0 < p.g) :
|
| 56 |
+
∃ (z : Base p.g n) (s : Label p.b), (∀ l, allows l z) ∧ eta p n (mom p s z)=1 := by
|
| 57 |
+
classical
|
| 58 |
+
let l : Tag p.g := ⟨0,hg⟩
|
| 59 |
+
let f : Flavor p.g:= Flavor.sharedOnly
|
| 60 |
+
let i := (Sum.inr () : ProbeIdx p.g)
|
| 61 |
+
let v : Digest p.g := Pi.single i 1
|
| 62 |
+
have hx : v.feasible l f := by
|
| 63 |
+
rintro (x|⟨⟩) _
|
| 64 |
+
· exact Pi.single_eq_of_ne (by simp [i]) _
|
| 65 |
+
exact (‹¬_› trivial).elim
|
| 66 |
+
have he := exists_of_pr_pos (spins_law p n).nz
|
| 67 |
+
((scanPrice_pos p).trans_le (scan_fraction (n:=n) l f v hr hn hx))
|
| 68 |
+
obtain ⟨x,h,_⟩ := he
|
| 69 |
+
refine ⟨lit f l x,0,fun i d t h k => ite_eq_right (by simp [f,Flavor.keeps]),?_⟩
|
| 70 |
+
rw [←etaScan,h]; simp [v,Digest.sumBit,Digest.diagO,i]
|
| 71 |
+
|
| 72 |
+
theorem atom_union (p : Shape) (n : ℕ) (z : Base p.g n) (s : Label p.b) :
|
| 73 |
+
∑ i:Tag p.g,atom p i s z=0 := by
|
| 74 |
+
simp_rw [atom,←map_sum (cut p n)]
|
| 75 |
+
rw [Finset.univ_sum_single (fun i : Tag p.g => mom p s z)]
|
| 76 |
+
funext x
|
| 77 |
+
exact char_two (mom p s z)
|
| 78 |
+
|
| 79 |
+
set_option maxHeartbeats 800000 in
|
| 80 |
+
theorem exact_vat (w : Pdual p n) (E : Finset (Label p.b)) (g : F)
|
| 81 |
+
(hE : (E.card:ℝ)<bp ((p.b:ℝ)-2*p.j))
|
| 82 |
+
(hj : Odd p.g) (hn : 2*p.r≤n) (hr : 1≤p.r)
|
| 83 |
+
(h : ∀ l s,s∉E → pr (spins p n)
|
| 84 |
+
(fun x => w (useAtom p l s Flavor.full x)≠g *dialed p l Flavor.full x)<1/4) :
|
| 85 |
+
g=0∧ silent w := by
|
| 86 |
+
classical
|
| 87 |
+
let Q l := w ∘ₗ fixStar p n l - g • eta p n
|
| 88 |
+
have hi (l : Tag p.g) (s : Label p.b) (z : Base p.g n) :
|
| 89 |
+
Q l (mom p s z)= w (atom p l s z)-g*eta p n (mom p s z) := rfl
|
| 90 |
+
have hh (l s z) (hz : allows l z) : Q l (mom p s z)=0 := by
|
| 91 |
+
have he (s) (hs : s∉E) :
|
| 92 |
+
pr (spins p n) (fun x=> Q l (mom p s (lit Flavor.full l x))≠0)<1/4 := by
|
| 93 |
+
simp_rw [hi,←etaScan p l s Flavor.full]
|
| 94 |
+
simpa only [sub_ne_zero,useAtom,dialed] using h l s hs
|
| 95 |
+
exact vat_excluded z E (Q l) (fun i h=>vat_erase l i (Q l) (he i h) z hz) hE s
|
| 96 |
+
simp_rw [hi] at hh
|
| 97 |
+
have he l s z (h : allows l z) : w (atom p l s z) =g*eta p n (mom p s z) :=
|
| 98 |
+
sub_eq_zero.mp (hh l s z h)
|
| 99 |
+
obtain ⟨z,s,hz,hb⟩ := shared_base p hn hr (by obtain ⟨_,hh⟩ := hj; omega)
|
| 100 |
+
have h0 : g=0 := by
|
| 101 |
+
have ht : w (∑ l:Tag p.g,atom p l s z)=0 := by rw [atom_union,map_zero]
|
| 102 |
+
rw [map_sum] at ht
|
| 103 |
+
simp_rw [he _ s z (hz _),hb,mul_one] at ht
|
| 104 |
+
simpa only [Finset.sum_const, Finset.card_univ,Tag,Fintype.card_fin,
|
| 105 |
+
odd_smul_bit hj] using ht
|
| 106 |
+
refine ⟨h0,atom_silent (fun i s z h=> (he i s z h).trans ?_)⟩
|
| 107 |
+
rw [h0,zero_mul]
|
| 108 |
+
end HadwigerCounterexample
|
| 109 |
+
|
| 110 |
+
end
|
| 111 |
+
|
| 112 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleOptionRealization.lean
CHANGED
|
@@ -1,130 +1,130 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PairedEventBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Compatible Option Realization -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Function Module LinearMap
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p:Shape} {n N M K s0:ℕ}
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
|
| 14 |
-
variable {q:Format} {d e: Rates} {b:Bool}
|
| 15 |
-
abbrev Stalls (p:Shape) := Bool→Finset (Label p.b)
|
| 16 |
-
|
| 17 |
-
def booths (p:Shape) (K:ℕ) (s: Plan p n) (H:Stalls p) :=
|
| 18 |
-
(∀ i,(H i).card≤frameBills p.g K) ∧
|
| 19 |
-
∀ i j, protectedBy p (sPin s j i) (qorth K) (H i)
|
| 20 |
-
theorem buildBooths (K:ℕ) (s:Plan p n) (h:planRank s≤K)
|
| 21 |
-
(hj:(K+1)*qorth K≤p.j+1) :
|
| 22 |
-
∃ H,booths p K s H := by
|
| 23 |
-
classical
|
| 24 |
-
choose H hH hG using fun i : Bool=> pin_protection s i K (qorth K) h hj
|
| 25 |
-
exact ⟨H,hH,hG⟩
|
| 26 |
-
|
| 27 |
-
theorem shelter (K :ℕ) (S:Pin p n N) (t : Quill p q d b) (z : Tagging p (Messenger q)) (H:Stalls p)
|
| 28 |
-
(h:booths p K S.sp H) (hp : Injective t.sel)
|
| 29 |
-
(ht:∀ i:Messenger q,t.sel i∉H (parcel b i))
|
| 30 |
-
(hg : ∀ i,1≤q i ∧ q i≤7) : t.penSpace z S K := by
|
| 31 |
-
intro x i
|
| 32 |
-
let v:=(t.pen z).draw x
|
| 33 |
-
refine ⟨H i,h.2 i,fun j hj=>?_,?_,hp.injOn⟩
|
| 34 |
-
· have he : parcel b j=i := Finset.mem_filter.mp hj|>.2
|
| 35 |
-
rw [←he]; exact ht j
|
| 36 |
-
exact (Volley.here_card v (shots_ok b v rfl hg) i).trans (by unfold qorth; omega)
|
| 37 |
-
|
| 38 |
-
theorem sizedCharts (K:ℕ) (w:LeafMixture p n N) (t:Station p n N K w) (ht:t.bank)
|
| 39 |
-
(i:w.T) (h:planRank (w.pin i.val).sp≤K) :
|
| 40 |
-
∃ d:Stakes K,charted (t.cAxes i (toRates d)) (w.pin i.val).sp := by
|
| 41 |
-
let s:=(w.pin i.val).sp
|
| 42 |
-
let d (i:Nodes):= dim (effective s i)
|
| 43 |
-
have hd i : d i < K^2+1 := Nat.lt_of_le_of_lt
|
| 44 |
-
((effective_dim s i).trans (by gcongr)) (Nat.lt_succ_self _)
|
| 45 |
-
exact ⟨fun i=>⟨d i,hd i⟩,ht.1 i⟩
|
| 46 |
-
|
| 47 |
-
structure Fabric (p:Shape) (q:Format) (d:Rates) (b:Bool) where
|
| 48 |
-
sel : Messenger q → Label p.b
|
| 49 |
-
flav : Messenger q → Flavor p.g
|
| 50 |
-
amp : Amounts p q d b
|
| 51 |
-
|
| 52 |
-
namespace Fabric
|
| 53 |
-
variable (w:Fabric p q d b) (t:Tagging p (Messenger q))
|
| 54 |
-
def hang (s:Script p (Messenger q)) : Quill p q d b :=
|
| 55 |
-
⟨w.sel,w.flav,w.amp,s⟩
|
| 56 |
-
def up (w:Fabric p q d b) (t:Tagging p (Messenger q)) (z: Messenger q→F) :=
|
| 57 |
-
(w.hang 0).moral t z
|
| 58 |
-
|
| 59 |
-
end Fabric
|
| 60 |
-
|
| 61 |
-
variable {i j:Bool} {L:ℕ}
|
| 62 |
-
set_option maxHeartbeats 1200000 in
|
| 63 |
-
theorem optionVia (q:Format) (d e : Rates) (s t:Pin p n N) (T:Cross p n) (K:ℕ)
|
| 64 |
-
(ha: tableInj s.sp t.sp T) (hb : tableInj t.sp s.sp (reciprocal p T))
|
| 65 |
-
(p':Tagging p (Messenger q)) (x:Charts p n d) (y:Charts p n e)
|
| 66 |
-
(hx:charted x s.sp) (hy:charted y t.sp)
|
| 67 |
-
(f:Fabric p q d true) (g:Fabric p q e false)
|
| 68 |
-
(hs h:Stalls p) (hm:booths p K s.sp hs) (hu : booths p K t.sp h)
|
| 69 |
-
(hf:∀ i,f.sel i∉ hs (parcel true i)) (hg:∀ i,g.sel i∉ h (parcel false i))
|
| 70 |
-
(z:Messenger q→F) (hF:f.up p' z)(hG:g.up p' z)
|
| 71 |
-
(hj : 1≤p.J) (h2: 2≤p.g) (h₀:∀ i,1≤q i∧q i≤7)
|
| 72 |
-
(he:speak _ _ (sendSum z f.amp g.amp)=(hailing p x y T,0)) :
|
| 73 |
-
∃ (a b:Script p (Messenger q)),Typus.chances ⟨p',z,f.hang a,g.hang b⟩ x y s t T K := by
|
| 74 |
-
obtain ⟨hQ,hR,hL,hS⟩:= (spoken x y T z f.amp g.amp).mp he
|
| 75 |
-
obtain ⟨a,ha'⟩:= proclaim_script true f.amp g.amp p' y (reciprocal p T) hR (fun i=>(h₀ i).1)
|
| 76 |
-
hS h2 hj
|
| 77 |
-
have hh : rhyme g.amp f.amp := fun i=> (add_comm ..).trans (hR i)
|
| 78 |
-
obtain ⟨b,hb'⟩:= proclaim_script false g.amp f.amp p' x T hh (fun i=>(h₀ i).1)
|
| 79 |
-
hL h2 hj
|
| 80 |
-
exact ⟨a,b, ⟨h₀,hF,hG,hQ,hR,ha',hb'⟩,⟨hx,shelter K s (f.hang a) p' hs hm hF.1 hf h₀,hL,ha⟩,
|
| 81 |
-
⟨hy,shelter K t (g.hang b) p' h hu hG.1 hg h₀,hS,hb⟩⟩
|
| 82 |
-
|
| 83 |
-
def berthTicket (a b:Pin p n N) (T: Cross p n)
|
| 84 |
-
(x:UnitType p n N × UnitType p n N) :=
|
| 85 |
-
tableInj a.sp b.sp T ∧ tableInj b.sp a.sp (reciprocal p T)
|
| 86 |
-
∧ fitsTable a.sp b.sp T (actual p x.1 x.2)
|
| 87 |
-
|
| 88 |
-
theorem issueTicket (x y:UnitType p n N) (w : LeafMixture p n N) (t:Station p n N K w)
|
| 89 |
-
(i j:w.T) (ha:apart w.T)
|
| 90 |
-
(hx:x∈i.val) (hy:y∈j.val) (ht:t.bank)
|
| 91 |
-
(he : secureAt p w.rooting (x,y)) :
|
| 92 |
-
∃ k, berthTicket (w.pin i.val) (w.pin j.val) (t.mails i j k) (x,y) := by
|
| 93 |
-
obtain ⟨k,hk⟩:=ht.2 i j (actual p x y)
|
| 94 |
-
obtain ⟨h1,h2⟩:=he
|
| 95 |
-
let a:= w.pin i.val; let b:= w.pin j.val
|
| 96 |
-
have hh : w.rooting x=a.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha i.property hx)
|
| 97 |
-
have hg : w.rooting y=b.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha j.property hy)
|
| 98 |
-
change tableInj (w.rooting x) (w.rooting y) (actual p x y) at h1
|
| 99 |
-
change tableInj (w.rooting y) (w.rooting x) (actual p y x) at h2
|
| 100 |
-
rw [hh,hg] at h1 h2
|
| 101 |
-
rw [← reciprocal_actual] at h2
|
| 102 |
-
exact ⟨k, fits_inj hk h1,fits_inj (fits_recip hk) h2,hk⟩
|
| 103 |
-
|
| 104 |
-
theorem berth_flags (a b:Pin p n N) (T:Cross p n) {x:UnitType p n N × UnitType p n N}
|
| 105 |
-
(h:berthTicket a b T x) (ha:a.agree x.1) (hb:b.agree x.2) :
|
| 106 |
-
tableFlag a b T x.1 ∧ tableFlag b a (reciprocal p T) x.2 := by
|
| 107 |
-
have hg:=fits_recip h.2.2; rw [reciprocal_actual] at hg
|
| 108 |
-
exact ⟨fits_flag T _ a b x.1 h.2.2 (flag_actual _ _ hb),
|
| 109 |
-
fits_flag _ _ b a x.2 hg (flag_actual _ _ ha)⟩
|
| 110 |
-
|
| 111 |
-
def cardTone (m:BMark p n N) (x:UnitType p n N) (T:Cross p n) (j:Bool) : F :=
|
| 112 |
-
∑ i:Bool,contract p T i j (m x i)
|
| 113 |
-
|
| 114 |
-
theorem actualTone (m:BMark p n N) (a b : UnitType p n N) (j:Bool) :
|
| 115 |
-
cardTone m a (actual p a b) j = tone p b (unary j) (delta m a) := by
|
| 116 |
-
rw [lone]
|
| 117 |
-
unfold cardTone delta
|
| 118 |
-
rw [map_add,Fintype.sum_bool]
|
| 119 |
-
simp_rw [contract_actual]; rfl
|
| 120 |
-
theorem fitsTone {w v: Plan p n} {T U:Cross p n}
|
| 121 |
-
(m:BMark p n N) (x:UnitType p n N)
|
| 122 |
-
(h:fitsTable w v T U) (hx:∀ i,m x i∈effective w i) (j) :
|
| 123 |
-
cardTone m x T j=cardTone m x U j :=
|
| 124 |
-
Finset.sum_congr rfl (fun i _=>fits_contract h i j _ (hx i))
|
| 125 |
-
end StatusAnalysis
|
| 126 |
-
end HadwigerCounterexample
|
| 127 |
-
|
| 128 |
-
end
|
| 129 |
-
|
| 130 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PairedEventBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Compatible Option Realization -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Function Module LinearMap
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p:Shape} {n N M K s0:ℕ}
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
|
| 14 |
+
variable {q:Format} {d e: Rates} {b:Bool}
|
| 15 |
+
abbrev Stalls (p:Shape) := Bool→Finset (Label p.b)
|
| 16 |
+
|
| 17 |
+
def booths (p:Shape) (K:ℕ) (s: Plan p n) (H:Stalls p) :=
|
| 18 |
+
(∀ i,(H i).card≤frameBills p.g K) ∧
|
| 19 |
+
∀ i j, protectedBy p (sPin s j i) (qorth K) (H i)
|
| 20 |
+
theorem buildBooths (K:ℕ) (s:Plan p n) (h:planRank s≤K)
|
| 21 |
+
(hj:(K+1)*qorth K≤p.j+1) :
|
| 22 |
+
∃ H,booths p K s H := by
|
| 23 |
+
classical
|
| 24 |
+
choose H hH hG using fun i : Bool=> pin_protection s i K (qorth K) h hj
|
| 25 |
+
exact ⟨H,hH,hG⟩
|
| 26 |
+
|
| 27 |
+
theorem shelter (K :ℕ) (S:Pin p n N) (t : Quill p q d b) (z : Tagging p (Messenger q)) (H:Stalls p)
|
| 28 |
+
(h:booths p K S.sp H) (hp : Injective t.sel)
|
| 29 |
+
(ht:∀ i:Messenger q,t.sel i∉H (parcel b i))
|
| 30 |
+
(hg : ∀ i,1≤q i ∧ q i≤7) : t.penSpace z S K := by
|
| 31 |
+
intro x i
|
| 32 |
+
let v:=(t.pen z).draw x
|
| 33 |
+
refine ⟨H i,h.2 i,fun j hj=>?_,?_,hp.injOn⟩
|
| 34 |
+
· have he : parcel b j=i := Finset.mem_filter.mp hj|>.2
|
| 35 |
+
rw [←he]; exact ht j
|
| 36 |
+
exact (Volley.here_card v (shots_ok b v rfl hg) i).trans (by unfold qorth; omega)
|
| 37 |
+
|
| 38 |
+
theorem sizedCharts (K:ℕ) (w:LeafMixture p n N) (t:Station p n N K w) (ht:t.bank)
|
| 39 |
+
(i:w.T) (h:planRank (w.pin i.val).sp≤K) :
|
| 40 |
+
∃ d:Stakes K,charted (t.cAxes i (toRates d)) (w.pin i.val).sp := by
|
| 41 |
+
let s:=(w.pin i.val).sp
|
| 42 |
+
let d (i:Nodes):= dim (effective s i)
|
| 43 |
+
have hd i : d i < K^2+1 := Nat.lt_of_le_of_lt
|
| 44 |
+
((effective_dim s i).trans (by gcongr)) (Nat.lt_succ_self _)
|
| 45 |
+
exact ⟨fun i=>⟨d i,hd i⟩,ht.1 i⟩
|
| 46 |
+
|
| 47 |
+
structure Fabric (p:Shape) (q:Format) (d:Rates) (b:Bool) where
|
| 48 |
+
sel : Messenger q → Label p.b
|
| 49 |
+
flav : Messenger q → Flavor p.g
|
| 50 |
+
amp : Amounts p q d b
|
| 51 |
+
|
| 52 |
+
namespace Fabric
|
| 53 |
+
variable (w:Fabric p q d b) (t:Tagging p (Messenger q))
|
| 54 |
+
def hang (s:Script p (Messenger q)) : Quill p q d b :=
|
| 55 |
+
⟨w.sel,w.flav,w.amp,s⟩
|
| 56 |
+
def up (w:Fabric p q d b) (t:Tagging p (Messenger q)) (z: Messenger q→F) :=
|
| 57 |
+
(w.hang 0).moral t z
|
| 58 |
+
|
| 59 |
+
end Fabric
|
| 60 |
+
|
| 61 |
+
variable {i j:Bool} {L:ℕ}
|
| 62 |
+
set_option maxHeartbeats 1200000 in
|
| 63 |
+
theorem optionVia (q:Format) (d e : Rates) (s t:Pin p n N) (T:Cross p n) (K:ℕ)
|
| 64 |
+
(ha: tableInj s.sp t.sp T) (hb : tableInj t.sp s.sp (reciprocal p T))
|
| 65 |
+
(p':Tagging p (Messenger q)) (x:Charts p n d) (y:Charts p n e)
|
| 66 |
+
(hx:charted x s.sp) (hy:charted y t.sp)
|
| 67 |
+
(f:Fabric p q d true) (g:Fabric p q e false)
|
| 68 |
+
(hs h:Stalls p) (hm:booths p K s.sp hs) (hu : booths p K t.sp h)
|
| 69 |
+
(hf:∀ i,f.sel i∉ hs (parcel true i)) (hg:∀ i,g.sel i∉ h (parcel false i))
|
| 70 |
+
(z:Messenger q→F) (hF:f.up p' z)(hG:g.up p' z)
|
| 71 |
+
(hj : 1≤p.J) (h2: 2≤p.g) (h₀:∀ i,1≤q i∧q i≤7)
|
| 72 |
+
(he:speak _ _ (sendSum z f.amp g.amp)=(hailing p x y T,0)) :
|
| 73 |
+
∃ (a b:Script p (Messenger q)),Typus.chances ⟨p',z,f.hang a,g.hang b⟩ x y s t T K := by
|
| 74 |
+
obtain ⟨hQ,hR,hL,hS⟩:= (spoken x y T z f.amp g.amp).mp he
|
| 75 |
+
obtain ⟨a,ha'⟩:= proclaim_script true f.amp g.amp p' y (reciprocal p T) hR (fun i=>(h₀ i).1)
|
| 76 |
+
hS h2 hj
|
| 77 |
+
have hh : rhyme g.amp f.amp := fun i=> (add_comm ..).trans (hR i)
|
| 78 |
+
obtain ⟨b,hb'⟩:= proclaim_script false g.amp f.amp p' x T hh (fun i=>(h₀ i).1)
|
| 79 |
+
hL h2 hj
|
| 80 |
+
exact ⟨a,b, ⟨h₀,hF,hG,hQ,hR,ha',hb'⟩,⟨hx,shelter K s (f.hang a) p' hs hm hF.1 hf h₀,hL,ha⟩,
|
| 81 |
+
⟨hy,shelter K t (g.hang b) p' h hu hG.1 hg h₀,hS,hb⟩⟩
|
| 82 |
+
|
| 83 |
+
def berthTicket (a b:Pin p n N) (T: Cross p n)
|
| 84 |
+
(x:UnitType p n N × UnitType p n N) :=
|
| 85 |
+
tableInj a.sp b.sp T ∧ tableInj b.sp a.sp (reciprocal p T)
|
| 86 |
+
∧ fitsTable a.sp b.sp T (actual p x.1 x.2)
|
| 87 |
+
|
| 88 |
+
theorem issueTicket (x y:UnitType p n N) (w : LeafMixture p n N) (t:Station p n N K w)
|
| 89 |
+
(i j:w.T) (ha:apart w.T)
|
| 90 |
+
(hx:x∈i.val) (hy:y∈j.val) (ht:t.bank)
|
| 91 |
+
(he : secureAt p w.rooting (x,y)) :
|
| 92 |
+
∃ k, berthTicket (w.pin i.val) (w.pin j.val) (t.mails i j k) (x,y) := by
|
| 93 |
+
obtain ⟨k,hk⟩:=ht.2 i j (actual p x y)
|
| 94 |
+
obtain ⟨h1,h2⟩:=he
|
| 95 |
+
let a:= w.pin i.val; let b:= w.pin j.val
|
| 96 |
+
have hh : w.rooting x=a.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha i.property hx)
|
| 97 |
+
have hg : w.rooting y=b.sp:= congrArg Pin.sp (LeafMixture.poller_eq w ha j.property hy)
|
| 98 |
+
change tableInj (w.rooting x) (w.rooting y) (actual p x y) at h1
|
| 99 |
+
change tableInj (w.rooting y) (w.rooting x) (actual p y x) at h2
|
| 100 |
+
rw [hh,hg] at h1 h2
|
| 101 |
+
rw [← reciprocal_actual] at h2
|
| 102 |
+
exact ⟨k, fits_inj hk h1,fits_inj (fits_recip hk) h2,hk⟩
|
| 103 |
+
|
| 104 |
+
theorem berth_flags (a b:Pin p n N) (T:Cross p n) {x:UnitType p n N × UnitType p n N}
|
| 105 |
+
(h:berthTicket a b T x) (ha:a.agree x.1) (hb:b.agree x.2) :
|
| 106 |
+
tableFlag a b T x.1 ∧ tableFlag b a (reciprocal p T) x.2 := by
|
| 107 |
+
have hg:=fits_recip h.2.2; rw [reciprocal_actual] at hg
|
| 108 |
+
exact ⟨fits_flag T _ a b x.1 h.2.2 (flag_actual _ _ hb),
|
| 109 |
+
fits_flag _ _ b a x.2 hg (flag_actual _ _ ha)⟩
|
| 110 |
+
|
| 111 |
+
def cardTone (m:BMark p n N) (x:UnitType p n N) (T:Cross p n) (j:Bool) : F :=
|
| 112 |
+
∑ i:Bool,contract p T i j (m x i)
|
| 113 |
+
|
| 114 |
+
theorem actualTone (m:BMark p n N) (a b : UnitType p n N) (j:Bool) :
|
| 115 |
+
cardTone m a (actual p a b) j = tone p b (unary j) (delta m a) := by
|
| 116 |
+
rw [lone]
|
| 117 |
+
unfold cardTone delta
|
| 118 |
+
rw [map_add,Fintype.sum_bool]
|
| 119 |
+
simp_rw [contract_actual]; rfl
|
| 120 |
+
theorem fitsTone {w v: Plan p n} {T U:Cross p n}
|
| 121 |
+
(m:BMark p n N) (x:UnitType p n N)
|
| 122 |
+
(h:fitsTable w v T U) (hx:∀ i,m x i∈effective w i) (j) :
|
| 123 |
+
cardTone m x T j=cardTone m x U j :=
|
| 124 |
+
Finset.sum_congr rfl (fun i _=>fits_contract h i j _ (hx i))
|
| 125 |
+
end StatusAnalysis
|
| 126 |
+
end HadwigerCounterexample
|
| 127 |
+
|
| 128 |
+
end
|
| 129 |
+
|
| 130 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CompatiblePairTests.lean
CHANGED
|
@@ -1,105 +1,105 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PredictionClassBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Compatible Pair Tests -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Function Module LinearMap Matrix
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
open PreparationParameters Station PredictionClass Club Guild DualAnalysis
|
| 14 |
-
variable {p:Shape} {n N M r s0:ℕ}
|
| 15 |
-
{w:rhythms p M} {b:PreparationParameters}
|
| 16 |
-
|
| 17 |
-
set_option maxHeartbeats 1800000 in
|
| 18 |
-
theorem foretold (w:rhythms p M) (m:cycleM p) (x:Sketch p M)
|
| 19 |
-
(v:Station p n (M*n) b.pins (w n)) (hv:v.bank)
|
| 20 |
-
(U:Wgt (UnitType p n (M*n))) (h:Lead U (w n) (m n) b)
|
| 21 |
-
(hE:AnalyticParameters p M b s0)
|
| 22 |
-
(hm:(w n).within (engrave x b m w n))
|
| 23 |
-
(hn:2*p.r≤n) (Y:Silhouette p (M*n) r) (f:Bool→Pulsar p r)
|
| 24 |
-
{τ ε δ η a d0:ℝ} (hh: hue x.c Y f (fun i=>x.g i n) x.α τ)
|
| 25 |
-
(hε:0<ε) (hp:Jubilee p b.pins ε η)
|
| 26 |
-
(hB:supportBudget p b.pins η a)
|
| 27 |
-
(hz:x.ε n ≤scanPrice p*ε) (ht:10*ε≤τ) (hT:2*τ<1)
|
| 28 |
-
(hF:Beams b (m n) Y (w n) U v a ε δ d0) (i : ViewPair p n (M*n) (w n))
|
| 29 |
-
(hx:cirque (w n) U i ≠0)
|
| 30 |
-
(hg1:gauze p δ δ Y (m n) b.pins i.1.2) (hg2:gauze p δ δ Y (m n) b.pins i.2.2)
|
| 31 |
-
(hC:matchProg x n (i.1.2,i.2.2))
|
| 32 |
-
(hS:secureAt p (w n).rooting (i.1.2,i.2.2)) :
|
| 33 |
-
eligiblePair v (m n) i.1 i.2 Y a := by
|
| 34 |
-
classical
|
| 35 |
-
let s:=w n; let μ:= U; let K:=b.pins
|
| 36 |
-
let X:=i.1.2; let Z:=i.2.2
|
| 37 |
-
let j:=i.1.1; let k:=i.2.1
|
| 38 |
-
let L:=troupe s μ
|
| 39 |
-
have hs : L i.1≠0:=left_ne_zero_of_mul hx
|
| 40 |
-
have hl : L i.2 ≠0:=right_ne_zero_of_mul hx
|
| 41 |
-
have hX := troupe_home h i.1 hs
|
| 42 |
-
have hZ:= troupe_home h i.2 hl
|
| 43 |
-
have hL i:= (h.strength.leaf _ (Subtype.prop (show s.T from i))).bound
|
| 44 |
-
obtain ⟨g,hg⟩:= ready_loupe s v hv hE hL
|
| 45 |
-
let d:= g.r j; let e:=g.r k
|
| 46 |
-
let t:=v.cAxes j (toRates d); let u:=v.cAxes k (toRates e)
|
| 47 |
-
let A:=g.H j; let B:=g.H k
|
| 48 |
-
let m':=x.m n
|
| 49 |
-
let F:=x.L n X; let H:=x.L n Z
|
| 50 |
-
let P:= A⊔F; let Q:=B⊔ H
|
| 51 |
-
obtain ⟨⟨h1,h2⟩,h3,h4⟩:=hm _ j.property X hX.1
|
| 52 |
-
obtain ⟨⟨h1',h2'⟩,h3',h4'⟩:=hm _ k.property Z hZ.1
|
| 53 |
-
let M0:=s.pin j.val; let M1:=s.pin k.val
|
| 54 |
-
have he (i):m' X i∈ effective M0.sp i:= (hX.2.1 ▸ (h1 i).2)
|
| 55 |
-
have he' i:m' Z i∈effective M1.sp i:= (hZ.2.1 ▸ (h1' i).2)
|
| 56 |
-
choose T hP using fun i=> show m' X i∈LinearMap.range (t i) from
|
| 57 |
-
(hg.charts j i).1.symm ▸ he i
|
| 58 |
-
choose S hQ using fun i=> show m' Z i∈ LinearMap.range (u i) from
|
| 59 |
-
(hg.charts k i).1.symm ▸ he' i
|
| 60 |
-
let Γ:PredictionData p (toRates d) (toRates e) r := ⟨x.α,f,T,S⟩
|
| 61 |
-
have ht0:= hE.enter.first
|
| 62 |
-
let M' := m n
|
| 63 |
-
let D:=wisp p Y; let X0:=wake p Y M' X t; let X1:=wake p Y M' Z u
|
| 64 |
-
let β:=trimBeta p K
|
| 65 |
-
let C:=stellar D X0 X1 η P Q
|
| 66 |
-
have hk0 i t:=Nat.lt_succ_iff.mp (g.r i t).isLt
|
| 67 |
-
have hA: reports p r D X0 β δ:=routeLive s g v hg M' hE hn i.1 Y δ hF.haze.1 (hL _) hg1
|
| 68 |
-
have hB1: reports p r D X1 β δ:=routeLive s g v hg M' hE hn i.2 Y δ hF.haze.1 (hL _) hg2
|
| 69 |
-
have hR := boothseek b _ (g.H j) F (hg.baseline j) hE (fun i=>(h1 i).1)
|
| 70 |
-
have hR' := boothseek b _ (g.H k) H (hg.baseline k) hE (fun i=>(h1' i).1)
|
| 71 |
-
have hG: rich C:= plenitude hF.soft hA hB1 ht0.hG P Q hR hR' (trimBeta_pos ..) hp.pos
|
| 72 |
-
hp.sturdyR (hk0 _) (hk0 _)
|
| 73 |
-
obtain ⟨E,hE0,hr⟩:=stable C hG
|
| 74 |
-
obtain ⟨y,hy⟩:= issueTicket X Z s v j k h.strength.part hX.1 hZ.1 hv hS
|
| 75 |
-
let U0:=v.mails j k y
|
| 76 |
-
have hQ': x.c.compatible x.α (glint p (m' X)) (cardTone m' X U0,cardTone m' Z
|
| 77 |
-
(reciprocal p U0)) := by
|
| 78 |
-
change glint p _=_ at h3
|
| 79 |
-
have he1 l: cardTone m' X U0 l=(quench p (delta m') (X,Z)).1 l:=
|
| 80 |
-
(fitsTone m' X hy.2.2 he l).trans (actualTone m' X Z l)
|
| 81 |
-
have he2 l:cardTone m' Z (reciprocal p U0) l=(quench p (delta m') (X,Z)).2 l:= by
|
| 82 |
-
have hg := fits_recip hy.2.2; rw [reciprocal_actual] at hg
|
| 83 |
-
exact (fitsTone m' Z hg he' l).trans (actualTone m' Z X l)
|
| 84 |
-
rw [funext he1,funext he2,h3]; exact hC
|
| 85 |
-
have hc: countStory p K η δ ε β D:=⟨hF.soft,(trimBeta_pos ..).le,hε.le,hp.pos.le,
|
| 86 |
-
hp.book,hp.low⟩
|
| 87 |
-
have hv : Γ.colored D X0 X1 P Q (2*ε):= by
|
| 88 |
-
constructor
|
| 89 |
-
· exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) t T m' X F P le_sup_right
|
| 90 |
-
hP hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2 i j hj k f).trans hz) h4 hg1
|
| 91 |
-
exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) u S m' Z H Q le_sup_right
|
| 92 |
-
hQ hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2' i j hj k f).trans hz) h4' hg2
|
| 93 |
-
have hZ0 := laysScore p K Y (m n) D X Z m' (toRates d) (toRates e) t u x.c Γ P Q
|
| 94 |
-
E η ε β δ τ hP hQ (paintChorus _ _ f _ x.α τ hh T S) (by linarith only [hε,ht]) hT hc
|
| 95 |
-
hA hB1 hv (hk0 _) (hk0 _) ht0.hG ht hR hR' hE0 U0 (h3.trans h3'.symm) hQ' hG
|
| 96 |
-
exact inform (w n) v _ Y i.1 i.2 hX.2.2.1 hZ.2.2.1 hX.2.2.2 hZ.2.2.2 d e (hg.charts _)
|
| 97 |
-
(hg.charts _) hB A B (hg.baseline _) (hg.baseline _) P Q le_sup_left le_sup_left ht0.hG
|
| 98 |
-
hE.jump hp.pos y hy E hr hZ0
|
| 99 |
-
|
| 100 |
-
end StatusAnalysis
|
| 101 |
-
end HadwigerCounterexample
|
| 102 |
-
|
| 103 |
-
end
|
| 104 |
-
|
| 105 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PredictionClassBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Compatible Pair Tests -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Function Module LinearMap Matrix
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
open PreparationParameters Station PredictionClass Club Guild DualAnalysis
|
| 14 |
+
variable {p:Shape} {n N M r s0:ℕ}
|
| 15 |
+
{w:rhythms p M} {b:PreparationParameters}
|
| 16 |
+
|
| 17 |
+
set_option maxHeartbeats 1800000 in
|
| 18 |
+
theorem foretold (w:rhythms p M) (m:cycleM p) (x:Sketch p M)
|
| 19 |
+
(v:Station p n (M*n) b.pins (w n)) (hv:v.bank)
|
| 20 |
+
(U:Wgt (UnitType p n (M*n))) (h:Lead U (w n) (m n) b)
|
| 21 |
+
(hE:AnalyticParameters p M b s0)
|
| 22 |
+
(hm:(w n).within (engrave x b m w n))
|
| 23 |
+
(hn:2*p.r≤n) (Y:Silhouette p (M*n) r) (f:Bool→Pulsar p r)
|
| 24 |
+
{τ ε δ η a d0:ℝ} (hh: hue x.c Y f (fun i=>x.g i n) x.α τ)
|
| 25 |
+
(hε:0<ε) (hp:Jubilee p b.pins ε η)
|
| 26 |
+
(hB:supportBudget p b.pins η a)
|
| 27 |
+
(hz:x.ε n ≤scanPrice p*ε) (ht:10*ε≤τ) (hT:2*τ<1)
|
| 28 |
+
(hF:Beams b (m n) Y (w n) U v a ε δ d0) (i : ViewPair p n (M*n) (w n))
|
| 29 |
+
(hx:cirque (w n) U i ≠0)
|
| 30 |
+
(hg1:gauze p δ δ Y (m n) b.pins i.1.2) (hg2:gauze p δ δ Y (m n) b.pins i.2.2)
|
| 31 |
+
(hC:matchProg x n (i.1.2,i.2.2))
|
| 32 |
+
(hS:secureAt p (w n).rooting (i.1.2,i.2.2)) :
|
| 33 |
+
eligiblePair v (m n) i.1 i.2 Y a := by
|
| 34 |
+
classical
|
| 35 |
+
let s:=w n; let μ:= U; let K:=b.pins
|
| 36 |
+
let X:=i.1.2; let Z:=i.2.2
|
| 37 |
+
let j:=i.1.1; let k:=i.2.1
|
| 38 |
+
let L:=troupe s μ
|
| 39 |
+
have hs : L i.1≠0:=left_ne_zero_of_mul hx
|
| 40 |
+
have hl : L i.2 ≠0:=right_ne_zero_of_mul hx
|
| 41 |
+
have hX := troupe_home h i.1 hs
|
| 42 |
+
have hZ:= troupe_home h i.2 hl
|
| 43 |
+
have hL i:= (h.strength.leaf _ (Subtype.prop (show s.T from i))).bound
|
| 44 |
+
obtain ⟨g,hg⟩:= ready_loupe s v hv hE hL
|
| 45 |
+
let d:= g.r j; let e:=g.r k
|
| 46 |
+
let t:=v.cAxes j (toRates d); let u:=v.cAxes k (toRates e)
|
| 47 |
+
let A:=g.H j; let B:=g.H k
|
| 48 |
+
let m':=x.m n
|
| 49 |
+
let F:=x.L n X; let H:=x.L n Z
|
| 50 |
+
let P:= A⊔F; let Q:=B⊔ H
|
| 51 |
+
obtain ⟨⟨h1,h2⟩,h3,h4⟩:=hm _ j.property X hX.1
|
| 52 |
+
obtain ⟨⟨h1',h2'⟩,h3',h4'⟩:=hm _ k.property Z hZ.1
|
| 53 |
+
let M0:=s.pin j.val; let M1:=s.pin k.val
|
| 54 |
+
have he (i):m' X i∈ effective M0.sp i:= (hX.2.1 ▸ (h1 i).2)
|
| 55 |
+
have he' i:m' Z i∈effective M1.sp i:= (hZ.2.1 ▸ (h1' i).2)
|
| 56 |
+
choose T hP using fun i=> show m' X i∈LinearMap.range (t i) from
|
| 57 |
+
(hg.charts j i).1.symm ▸ he i
|
| 58 |
+
choose S hQ using fun i=> show m' Z i∈ LinearMap.range (u i) from
|
| 59 |
+
(hg.charts k i).1.symm ▸ he' i
|
| 60 |
+
let Γ:PredictionData p (toRates d) (toRates e) r := ⟨x.α,f,T,S⟩
|
| 61 |
+
have ht0:= hE.enter.first
|
| 62 |
+
let M' := m n
|
| 63 |
+
let D:=wisp p Y; let X0:=wake p Y M' X t; let X1:=wake p Y M' Z u
|
| 64 |
+
let β:=trimBeta p K
|
| 65 |
+
let C:=stellar D X0 X1 η P Q
|
| 66 |
+
have hk0 i t:=Nat.lt_succ_iff.mp (g.r i t).isLt
|
| 67 |
+
have hA: reports p r D X0 β δ:=routeLive s g v hg M' hE hn i.1 Y δ hF.haze.1 (hL _) hg1
|
| 68 |
+
have hB1: reports p r D X1 β δ:=routeLive s g v hg M' hE hn i.2 Y δ hF.haze.1 (hL _) hg2
|
| 69 |
+
have hR := boothseek b _ (g.H j) F (hg.baseline j) hE (fun i=>(h1 i).1)
|
| 70 |
+
have hR' := boothseek b _ (g.H k) H (hg.baseline k) hE (fun i=>(h1' i).1)
|
| 71 |
+
have hG: rich C:= plenitude hF.soft hA hB1 ht0.hG P Q hR hR' (trimBeta_pos ..) hp.pos
|
| 72 |
+
hp.sturdyR (hk0 _) (hk0 _)
|
| 73 |
+
obtain ⟨E,hE0,hr⟩:=stable C hG
|
| 74 |
+
obtain ⟨y,hy⟩:= issueTicket X Z s v j k h.strength.part hX.1 hZ.1 hv hS
|
| 75 |
+
let U0:=v.mails j k y
|
| 76 |
+
have hQ': x.c.compatible x.α (glint p (m' X)) (cardTone m' X U0,cardTone m' Z
|
| 77 |
+
(reciprocal p U0)) := by
|
| 78 |
+
change glint p _=_ at h3
|
| 79 |
+
have he1 l: cardTone m' X U0 l=(quench p (delta m') (X,Z)).1 l:=
|
| 80 |
+
(fitsTone m' X hy.2.2 he l).trans (actualTone m' X Z l)
|
| 81 |
+
have he2 l:cardTone m' Z (reciprocal p U0) l=(quench p (delta m') (X,Z)).2 l:= by
|
| 82 |
+
have hg := fits_recip hy.2.2; rw [reciprocal_actual] at hg
|
| 83 |
+
exact (fitsTone m' Z hg he' l).trans (actualTone m' Z X l)
|
| 84 |
+
rw [funext he1,funext he2,h3]; exact hC
|
| 85 |
+
have hc: countStory p K η δ ε β D:=⟨hF.soft,(trimBeta_pos ..).le,hε.le,hp.pos.le,
|
| 86 |
+
hp.book,hp.low⟩
|
| 87 |
+
have hv : Γ.colored D X0 X1 P Q (2*ε):= by
|
| 88 |
+
constructor
|
| 89 |
+
· exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) t T m' X F P le_sup_right
|
| 90 |
+
hP hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2 i j hj k f).trans hz) h4 hg1
|
| 91 |
+
exact crew_praise p x.c Y f (fun i=>x.g i n) x.α τ hh (m n) u S m' Z H Q le_sup_right
|
| 92 |
+
hQ hε.le hF.haze.2 hE hn (fun i j hj k f=>(h2' i j hj k f).trans hz) h4' hg2
|
| 93 |
+
have hZ0 := laysScore p K Y (m n) D X Z m' (toRates d) (toRates e) t u x.c Γ P Q
|
| 94 |
+
E η ε β δ τ hP hQ (paintChorus _ _ f _ x.α τ hh T S) (by linarith only [hε,ht]) hT hc
|
| 95 |
+
hA hB1 hv (hk0 _) (hk0 _) ht0.hG ht hR hR' hE0 U0 (h3.trans h3'.symm) hQ' hG
|
| 96 |
+
exact inform (w n) v _ Y i.1 i.2 hX.2.2.1 hZ.2.2.1 hX.2.2.2 hZ.2.2.2 d e (hg.charts _)
|
| 97 |
+
(hg.charts _) hB A B (hg.baseline _) (hg.baseline _) P Q le_sup_left le_sup_left ht0.hG
|
| 98 |
+
hE.jump hp.pos y hy E hr hZ0
|
| 99 |
+
|
| 100 |
+
end StatusAnalysis
|
| 101 |
+
end HadwigerCounterexample
|
| 102 |
+
|
| 103 |
+
end
|
| 104 |
+
|
| 105 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CompatibleTableEvents.lean
CHANGED
|
@@ -1,149 +1,149 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RareTestEvents
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Compatible Table Events -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix LinearMap Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
open PreparationParameters PredictionClass
|
| 14 |
-
|
| 15 |
-
variable {p:Shape} {n M K s0 N :ℕ} {w:LeafMixture p n N} {q:PreparationParameters}
|
| 16 |
-
|
| 17 |
-
structure Settled (t: LeafMixture p n N) (m:Mixer p n) (q:PreparationParameters)
|
| 18 |
-
(U : Wgt (UnitType p n N)) (z:BMark p n N) (k:F) : Prop where
|
| 19 |
-
readyC :
|
| 20 |
-
IsLaw U ∧ t.strength U (usual p m N) q.leafNew (2*q.ζ) q.pins ∧
|
| 21 |
-
t.within (fun o=>frameSide p m o ∧ exactInk p m z o ∧
|
| 22 |
-
(∀ i,z o i∈effective (t.rooting o) i) ∧ glint p (z o)=k)
|
| 23 |
-
hard : q.hardened p N t z
|
| 24 |
-
|
| 25 |
-
def shimmer (z:BMark p n N) (r:F) (x:UnitType p n N× UnitType p n N) :=
|
| 26 |
-
quench p (delta z) x=repeatQ r
|
| 27 |
-
|
| 28 |
-
variable (v: Station p n N q.pins w) (i j:w.T)
|
| 29 |
-
(U:Wgt (UnitType p n N)) (m:Mixer p n) (z:BMark p n N)
|
| 30 |
-
|
| 31 |
-
private theorem chartKnown {r : F} (q:PreparationParameters) (x:w.T) (d: Stakes q.pins)
|
| 32 |
-
(hw:Settled w m q U z r)
|
| 33 |
-
{v : Charts p n (toRates d)} (hc:charted v (w.pin x.val).sp)
|
| 34 |
-
(o : UnitType p n N) (hx:o∈x.val) :
|
| 35 |
-
(∀ i,totalRank (z o i)≤ q.pins) ∧ ∃ y,∀ i∈x.val,coordSpec z i v y := by
|
| 36 |
-
obtain ⟨h1,h2,h3⟩:=hw.readyC
|
| 37 |
-
let A:=(w.pin x.val).sp
|
| 38 |
-
have hi j : z o j∈effective A j := by
|
| 39 |
-
have hh : w.rooting o=A:=congrArg Pin.sp (LeafMixture.poller_eq w h2.part x.property hx)
|
| 40 |
-
rw [←hh]; exact (h3 x.val x.property o hx).2.2.1 j
|
| 41 |
-
obtain ⟨T,hK,hB,hG⟩:=hw.hard
|
| 42 |
-
obtain ⟨b,hb,hf⟩:=hG x.val x.property
|
| 43 |
-
choose y hy using fun j=> show z o j∈LinearMap.range (v j) from (hc j).1.symm ▸ hi j
|
| 44 |
-
refine ⟨fun i=>(effective_rank (hi i)).trans (h2.leaf x.val x.property).bound,y,
|
| 45 |
-
fun i hh j=>?_⟩
|
| 46 |
-
exact (hy j).trans (congr_fun (hb.2.2 _ hx _ hh).1 j)
|
| 47 |
-
|
| 48 |
-
set_option maxHeartbeats 1800000 in
|
| 49 |
-
theorem invoke (k:Fin (2^deckMax p q.pins))
|
| 50 |
-
(r:F) (a:ℝ) (hα:0<a) (h:AnalyticParameters p M q s0)
|
| 51 |
-
(hw:Settled w m q U z r) (ht:v.bank)
|
| 52 |
-
(hk:2*a ≤ pr (pairW (partW U i.val) (partW U j.val))
|
| 53 |
-
(fun x=> shimmer z r x∧ berthTicket (w.pin i.val) (w.pin j.val) (v.mails i j k) x)) :
|
| 54 |
-
∃ x:Scrip p q.pins, v.charter x.2.2 m x.2.1 U a (i,j) := by
|
| 55 |
-
classical
|
| 56 |
-
let K:=q.pins
|
| 57 |
-
let T:=v.mails i j k
|
| 58 |
-
have hq:=h.enter.first
|
| 59 |
-
let a0:= w.pin i.val; let b0:= w.pin j.val
|
| 60 |
-
let μ i:=partW U (Subtype.val (show w.T from i))
|
| 61 |
-
let S:=pairW (μ i) (μ j)
|
| 62 |
-
obtain ⟨hm,hv,hC⟩:=hw.readyC
|
| 63 |
-
have hu x:=show IsLaw (μ x) from on_law hm.nz (hv.leaf x.val x.property).pos
|
| 64 |
-
have hμ: IsLaw S:= pairW_law (hu _) (hu _)
|
| 65 |
-
have hK x : planRank (w.pin (Subtype.val (show w.T from x))).sp ≤ K :=
|
| 66 |
-
(hv.leaf _ (Subtype.prop x)).bound
|
| 67 |
-
obtain ⟨f,hF⟩:=sizedCharts q.pins w v ht i (hK i)
|
| 68 |
-
obtain ⟨g,hG⟩:=sizedCharts q.pins w v ht j (hK j)
|
| 69 |
-
let A:= toRates f; let B:=toRates g; let X:=v.cAxes i A; let Y:=v.cAxes j B
|
| 70 |
-
let P x:= shimmer z r x∧ berthTicket a0 b0 T x
|
| 71 |
-
obtain ⟨o,⟨hop,hOK⟩,ho⟩:= exists_of_pr_pos hμ.nz (lt_of_lt_of_le
|
| 72 |
-
(show 0<2*a by positivity) hk)
|
| 73 |
-
let x:=o.1; let y:=o.2
|
| 74 |
-
have hcol i x (hx:μ i x≠0) : x∈ i.val := (onW_ne hx).1
|
| 75 |
-
have hx : x∈ i.val:= hcol i x (left_ne_zero_of_mul ho.ne')
|
| 76 |
-
have hy : y∈ j.val:= hcol j y (right_ne_zero_of_mul ho.ne')
|
| 77 |
-
obtain ⟨hχ,l,hl⟩:= chartKnown (v:=X) U m z q i f hw hF x hx
|
| 78 |
-
obtain ⟨hξ,t,ht'⟩:= chartKnown (v:=Y) U m z q j g hw hG y hy
|
| 79 |
-
have he (i : w.T) x (hx:x∈ i.val) : ∀ j,z x j∈effective (w.pin i.val).sp j := by
|
| 80 |
-
have hi : w.rooting x=(w.pin i.val).sp:=congrArg Pin.sp (LeafMixture.poller_eq w hv.part i.property hx)
|
| 81 |
-
rw [← hi]; exact (hC _ i.property _ hx).2.2.1
|
| 82 |
-
let kappa : Tag p.g:= ⟨0,by linarith only [hq.hG]⟩
|
| 83 |
-
let tt : Tagging p (Messenger singles):=fun _=>kappa
|
| 84 |
-
let ref := show Messenger singles→F from fun _=>1
|
| 85 |
-
obtain ⟨E,h1,h2,h3⟩:= generic_summary p hq.hG kappa 1 0
|
| 86 |
-
obtain ⟨H,h4,h5,h6⟩:= generic_summary p hq.hG kappa 1 1
|
| 87 |
-
obtain ⟨L,hLa⟩:= buildBooths K a0.sp (hK i) h.penRoom
|
| 88 |
-
obtain ⟨O,hLb⟩:= buildBooths K b0.sp (hK j) h.penRoom
|
| 89 |
-
have hh : 2*frameBills p.g K+4 ≤ Fintype.card (Label p.b) := by
|
| 90 |
-
have hl : frameBills p.g K + 1000 ≤ q.B:=h.forbid
|
| 91 |
-
have he:= h.spare; omega
|
| 92 |
-
obtain ⟨J,hJ,hJ'⟩:= fourPens _ K L hLa hh
|
| 93 |
-
obtain ⟨I,hI,hI'⟩:= fourPens _ K O hLb hh
|
| 94 |
-
let F0:Fabric p singles A true:=⟨J,fun _ => Flavor.full,beacon p X l true T E⟩
|
| 95 |
-
let T':= reciprocal p T
|
| 96 |
-
let G0:Fabric p singles B false:=⟨I,fun _=> Flavor.full,beacon p Y t false T' H⟩
|
| 97 |
-
have hs : speak A B (sendSum ref F0.amp G0.amp)=(hailing p X Y T,0) := by
|
| 98 |
-
apply (spoken X Y T ref F0.amp G0.amp).mpr
|
| 99 |
-
have hFq a : fullq ref a=1 := by
|
| 100 |
-
unfold fullq
|
| 101 |
-
change (∑ _:Fin 1,(1:F))=1; rw [Fintype.sum_unique]
|
| 102 |
-
have hR : rhyme F0.amp G0.amp := by
|
| 103 |
-
intro i; have hf : (funds F0.amp i).1.1=E.diagO := congrArg (fun x=> x.1.1) (funds_one F0 i)
|
| 104 |
-
have hg : (funds G0.amp i).1.1=H.diagO := congrArg (fun x=> x.1.1) (funds_one G0 i)
|
| 105 |
-
change (funds (b:=true) F0.amp i).1.1+(funds (b:=false) G0.amp i).1.1=_; rw [hf,hg,h3,h6,zero_add]
|
| 106 |
-
refine ⟨hFq,hR, stillBeacon z x X l true T E (hl _ hx) (fun k=>?_),stillBeacon z y Y t false
|
| 107 |
-
T' H (ht' _ hy) (fun k=>?_)⟩
|
| 108 |
-
· rw [fitsTone z x hOK.2.2 (he _ _ hx), actualTone,(hC _ i.property _ hx).2.2.2]
|
| 109 |
-
exact congr_fun (congrArg Prod.fst hop) k
|
| 110 |
-
have hg:=fits_recip hOK.2.2; rw [reciprocal_actual] at hg
|
| 111 |
-
rw [fitsTone z y hg (he _ _ hy), actualTone,(hC _ j.property _ hy).2.2.2]
|
| 112 |
-
exact congr_fun (congrArg Prod.snd hop) k
|
| 113 |
-
obtain ⟨P0,Q0,hf⟩:= optionVia singles A B a0 b0 T K hOK.1 hOK.2.1 tt X Y hF hG F0 G0 L O hLa hLb
|
| 114 |
-
(fun i=>hJ' i _) (fun i=> hI' i _) ref ⟨hJ,fun i=>h2,fun i=>h1⟩
|
| 115 |
-
⟨hI,fun i=>h5,fun i=>h4⟩ h.jump (by linarith only [hq.hG]) singles_short hs
|
| 116 |
-
let τ:Typus p singles A B:= ⟨tt,ref,F0.hang P0,G0.hang Q0⟩
|
| 117 |
-
let Front:=v.frontPage τ m i j k; let Back:=v.backPage τ m i j k
|
| 118 |
-
have hi a (ha:a∈ i.val): a0.agree a := (hv.leaf _ i.property).fixpin _ ha
|
| 119 |
-
have hi' a (ha:a∈ j.val): b0.agree a := (hv.leaf _ j.property).fixpin _ ha
|
| 120 |
-
have hm : 2*a≤ (pr (μ i) Front)*(pr (μ j) Back) := by
|
| 121 |
-
rw [←pairW_pr]
|
| 122 |
-
apply hk.trans
|
| 123 |
-
refine pr_on_mono hμ.nz (fun x hx he=>?_)
|
| 124 |
-
have h1 := hcol i x.1 (left_ne_zero_of_mul hx)
|
| 125 |
-
have h2 := hcol j x.2 (right_ne_zero_of_mul hx)
|
| 126 |
-
obtain ⟨ha,hb⟩:= berth_flags a0 b0 T he.2 (hi _ h1) (hi' _ h2)
|
| 127 |
-
exact ⟨⟨hf,hi _ h1,(hC _ i.property x.1 h1).1, ha⟩,
|
| 128 |
-
⟨hf,hi' _ h2,(hC _ j.property _ h2).1,hb⟩⟩
|
| 129 |
-
refine ⟨⟨(volume1,f,g),k,show OnFile p _ from τ⟩,hf.1,⟨?_,fun o ho hx=>?_⟩,
|
| 130 |
-
⟨?_,fun o ho hx=>?_⟩⟩
|
| 131 |
-
· exact hm.trans ((mul_le_mul_of_nonneg_left ((pr_le_tot (hu _).nz).trans (hu j).total.le)
|
| 132 |
-
(pr_nonneg (hu _).nz)).trans_eq (mul_one _))
|
| 133 |
-
· have hv := hcol i o hx
|
| 134 |
-
exact steadyBeacon z o X l true T τ.qA tt m E K
|
| 135 |
-
(fun x=> Nat.lt_succ_iff.mp (f x).isLt) rfl (hK i) hF (hl _ hv) ho.2.2.1
|
| 136 |
-
(hC _ i.property _ hv).2.1
|
| 137 |
-
· exact hm.trans ((mul_le_mul_of_nonneg_right ((pr_le_tot (hu _).nz).trans (hu i).total.le)
|
| 138 |
-
(pr_nonneg (hu _).nz)).trans_eq (one_mul _))
|
| 139 |
-
have hv:=hcol j o hx
|
| 140 |
-
exact steadyBeacon z o Y t false T' τ.qB tt m H K
|
| 141 |
-
(fun x=> Nat.lt_succ_iff.mp (g x).isLt) rfl (hK j) hG (ht' _ hv) ho.2.2.1
|
| 142 |
-
(hC _ j.property _ hv).2.1
|
| 143 |
-
|
| 144 |
-
end StatusAnalysis
|
| 145 |
-
end HadwigerCounterexample
|
| 146 |
-
|
| 147 |
-
end
|
| 148 |
-
|
| 149 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RareTestEvents
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Compatible Table Events -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix LinearMap Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
open PreparationParameters PredictionClass
|
| 14 |
+
|
| 15 |
+
variable {p:Shape} {n M K s0 N :ℕ} {w:LeafMixture p n N} {q:PreparationParameters}
|
| 16 |
+
|
| 17 |
+
structure Settled (t: LeafMixture p n N) (m:Mixer p n) (q:PreparationParameters)
|
| 18 |
+
(U : Wgt (UnitType p n N)) (z:BMark p n N) (k:F) : Prop where
|
| 19 |
+
readyC :
|
| 20 |
+
IsLaw U ∧ t.strength U (usual p m N) q.leafNew (2*q.ζ) q.pins ∧
|
| 21 |
+
t.within (fun o=>frameSide p m o ∧ exactInk p m z o ∧
|
| 22 |
+
(∀ i,z o i∈effective (t.rooting o) i) ∧ glint p (z o)=k)
|
| 23 |
+
hard : q.hardened p N t z
|
| 24 |
+
|
| 25 |
+
def shimmer (z:BMark p n N) (r:F) (x:UnitType p n N× UnitType p n N) :=
|
| 26 |
+
quench p (delta z) x=repeatQ r
|
| 27 |
+
|
| 28 |
+
variable (v: Station p n N q.pins w) (i j:w.T)
|
| 29 |
+
(U:Wgt (UnitType p n N)) (m:Mixer p n) (z:BMark p n N)
|
| 30 |
+
|
| 31 |
+
private theorem chartKnown {r : F} (q:PreparationParameters) (x:w.T) (d: Stakes q.pins)
|
| 32 |
+
(hw:Settled w m q U z r)
|
| 33 |
+
{v : Charts p n (toRates d)} (hc:charted v (w.pin x.val).sp)
|
| 34 |
+
(o : UnitType p n N) (hx:o∈x.val) :
|
| 35 |
+
(∀ i,totalRank (z o i)≤ q.pins) ∧ ∃ y,∀ i∈x.val,coordSpec z i v y := by
|
| 36 |
+
obtain ⟨h1,h2,h3⟩:=hw.readyC
|
| 37 |
+
let A:=(w.pin x.val).sp
|
| 38 |
+
have hi j : z o j∈effective A j := by
|
| 39 |
+
have hh : w.rooting o=A:=congrArg Pin.sp (LeafMixture.poller_eq w h2.part x.property hx)
|
| 40 |
+
rw [←hh]; exact (h3 x.val x.property o hx).2.2.1 j
|
| 41 |
+
obtain ⟨T,hK,hB,hG⟩:=hw.hard
|
| 42 |
+
obtain ⟨b,hb,hf⟩:=hG x.val x.property
|
| 43 |
+
choose y hy using fun j=> show z o j∈LinearMap.range (v j) from (hc j).1.symm ▸ hi j
|
| 44 |
+
refine ⟨fun i=>(effective_rank (hi i)).trans (h2.leaf x.val x.property).bound,y,
|
| 45 |
+
fun i hh j=>?_⟩
|
| 46 |
+
exact (hy j).trans (congr_fun (hb.2.2 _ hx _ hh).1 j)
|
| 47 |
+
|
| 48 |
+
set_option maxHeartbeats 1800000 in
|
| 49 |
+
theorem invoke (k:Fin (2^deckMax p q.pins))
|
| 50 |
+
(r:F) (a:ℝ) (hα:0<a) (h:AnalyticParameters p M q s0)
|
| 51 |
+
(hw:Settled w m q U z r) (ht:v.bank)
|
| 52 |
+
(hk:2*a ≤ pr (pairW (partW U i.val) (partW U j.val))
|
| 53 |
+
(fun x=> shimmer z r x∧ berthTicket (w.pin i.val) (w.pin j.val) (v.mails i j k) x)) :
|
| 54 |
+
∃ x:Scrip p q.pins, v.charter x.2.2 m x.2.1 U a (i,j) := by
|
| 55 |
+
classical
|
| 56 |
+
let K:=q.pins
|
| 57 |
+
let T:=v.mails i j k
|
| 58 |
+
have hq:=h.enter.first
|
| 59 |
+
let a0:= w.pin i.val; let b0:= w.pin j.val
|
| 60 |
+
let μ i:=partW U (Subtype.val (show w.T from i))
|
| 61 |
+
let S:=pairW (μ i) (μ j)
|
| 62 |
+
obtain ⟨hm,hv,hC⟩:=hw.readyC
|
| 63 |
+
have hu x:=show IsLaw (μ x) from on_law hm.nz (hv.leaf x.val x.property).pos
|
| 64 |
+
have hμ: IsLaw S:= pairW_law (hu _) (hu _)
|
| 65 |
+
have hK x : planRank (w.pin (Subtype.val (show w.T from x))).sp ≤ K :=
|
| 66 |
+
(hv.leaf _ (Subtype.prop x)).bound
|
| 67 |
+
obtain ⟨f,hF⟩:=sizedCharts q.pins w v ht i (hK i)
|
| 68 |
+
obtain ⟨g,hG⟩:=sizedCharts q.pins w v ht j (hK j)
|
| 69 |
+
let A:= toRates f; let B:=toRates g; let X:=v.cAxes i A; let Y:=v.cAxes j B
|
| 70 |
+
let P x:= shimmer z r x∧ berthTicket a0 b0 T x
|
| 71 |
+
obtain ⟨o,⟨hop,hOK⟩,ho⟩:= exists_of_pr_pos hμ.nz (lt_of_lt_of_le
|
| 72 |
+
(show 0<2*a by positivity) hk)
|
| 73 |
+
let x:=o.1; let y:=o.2
|
| 74 |
+
have hcol i x (hx:μ i x≠0) : x∈ i.val := (onW_ne hx).1
|
| 75 |
+
have hx : x∈ i.val:= hcol i x (left_ne_zero_of_mul ho.ne')
|
| 76 |
+
have hy : y∈ j.val:= hcol j y (right_ne_zero_of_mul ho.ne')
|
| 77 |
+
obtain ⟨hχ,l,hl⟩:= chartKnown (v:=X) U m z q i f hw hF x hx
|
| 78 |
+
obtain ⟨hξ,t,ht'⟩:= chartKnown (v:=Y) U m z q j g hw hG y hy
|
| 79 |
+
have he (i : w.T) x (hx:x∈ i.val) : ∀ j,z x j∈effective (w.pin i.val).sp j := by
|
| 80 |
+
have hi : w.rooting x=(w.pin i.val).sp:=congrArg Pin.sp (LeafMixture.poller_eq w hv.part i.property hx)
|
| 81 |
+
rw [← hi]; exact (hC _ i.property _ hx).2.2.1
|
| 82 |
+
let kappa : Tag p.g:= ⟨0,by linarith only [hq.hG]⟩
|
| 83 |
+
let tt : Tagging p (Messenger singles):=fun _=>kappa
|
| 84 |
+
let ref := show Messenger singles→F from fun _=>1
|
| 85 |
+
obtain ⟨E,h1,h2,h3⟩:= generic_summary p hq.hG kappa 1 0
|
| 86 |
+
obtain ⟨H,h4,h5,h6⟩:= generic_summary p hq.hG kappa 1 1
|
| 87 |
+
obtain ⟨L,hLa⟩:= buildBooths K a0.sp (hK i) h.penRoom
|
| 88 |
+
obtain ⟨O,hLb⟩:= buildBooths K b0.sp (hK j) h.penRoom
|
| 89 |
+
have hh : 2*frameBills p.g K+4 ≤ Fintype.card (Label p.b) := by
|
| 90 |
+
have hl : frameBills p.g K + 1000 ≤ q.B:=h.forbid
|
| 91 |
+
have he:= h.spare; omega
|
| 92 |
+
obtain ⟨J,hJ,hJ'⟩:= fourPens _ K L hLa hh
|
| 93 |
+
obtain ⟨I,hI,hI'⟩:= fourPens _ K O hLb hh
|
| 94 |
+
let F0:Fabric p singles A true:=⟨J,fun _ => Flavor.full,beacon p X l true T E⟩
|
| 95 |
+
let T':= reciprocal p T
|
| 96 |
+
let G0:Fabric p singles B false:=⟨I,fun _=> Flavor.full,beacon p Y t false T' H⟩
|
| 97 |
+
have hs : speak A B (sendSum ref F0.amp G0.amp)=(hailing p X Y T,0) := by
|
| 98 |
+
apply (spoken X Y T ref F0.amp G0.amp).mpr
|
| 99 |
+
have hFq a : fullq ref a=1 := by
|
| 100 |
+
unfold fullq
|
| 101 |
+
change (∑ _:Fin 1,(1:F))=1; rw [Fintype.sum_unique]
|
| 102 |
+
have hR : rhyme F0.amp G0.amp := by
|
| 103 |
+
intro i; have hf : (funds F0.amp i).1.1=E.diagO := congrArg (fun x=> x.1.1) (funds_one F0 i)
|
| 104 |
+
have hg : (funds G0.amp i).1.1=H.diagO := congrArg (fun x=> x.1.1) (funds_one G0 i)
|
| 105 |
+
change (funds (b:=true) F0.amp i).1.1+(funds (b:=false) G0.amp i).1.1=_; rw [hf,hg,h3,h6,zero_add]
|
| 106 |
+
refine ⟨hFq,hR, stillBeacon z x X l true T E (hl _ hx) (fun k=>?_),stillBeacon z y Y t false
|
| 107 |
+
T' H (ht' _ hy) (fun k=>?_)⟩
|
| 108 |
+
· rw [fitsTone z x hOK.2.2 (he _ _ hx), actualTone,(hC _ i.property _ hx).2.2.2]
|
| 109 |
+
exact congr_fun (congrArg Prod.fst hop) k
|
| 110 |
+
have hg:=fits_recip hOK.2.2; rw [reciprocal_actual] at hg
|
| 111 |
+
rw [fitsTone z y hg (he _ _ hy), actualTone,(hC _ j.property _ hy).2.2.2]
|
| 112 |
+
exact congr_fun (congrArg Prod.snd hop) k
|
| 113 |
+
obtain ⟨P0,Q0,hf⟩:= optionVia singles A B a0 b0 T K hOK.1 hOK.2.1 tt X Y hF hG F0 G0 L O hLa hLb
|
| 114 |
+
(fun i=>hJ' i _) (fun i=> hI' i _) ref ⟨hJ,fun i=>h2,fun i=>h1⟩
|
| 115 |
+
⟨hI,fun i=>h5,fun i=>h4⟩ h.jump (by linarith only [hq.hG]) singles_short hs
|
| 116 |
+
let τ:Typus p singles A B:= ⟨tt,ref,F0.hang P0,G0.hang Q0⟩
|
| 117 |
+
let Front:=v.frontPage τ m i j k; let Back:=v.backPage τ m i j k
|
| 118 |
+
have hi a (ha:a∈ i.val): a0.agree a := (hv.leaf _ i.property).fixpin _ ha
|
| 119 |
+
have hi' a (ha:a∈ j.val): b0.agree a := (hv.leaf _ j.property).fixpin _ ha
|
| 120 |
+
have hm : 2*a≤ (pr (μ i) Front)*(pr (μ j) Back) := by
|
| 121 |
+
rw [←pairW_pr]
|
| 122 |
+
apply hk.trans
|
| 123 |
+
refine pr_on_mono hμ.nz (fun x hx he=>?_)
|
| 124 |
+
have h1 := hcol i x.1 (left_ne_zero_of_mul hx)
|
| 125 |
+
have h2 := hcol j x.2 (right_ne_zero_of_mul hx)
|
| 126 |
+
obtain ⟨ha,hb⟩:= berth_flags a0 b0 T he.2 (hi _ h1) (hi' _ h2)
|
| 127 |
+
exact ⟨⟨hf,hi _ h1,(hC _ i.property x.1 h1).1, ha⟩,
|
| 128 |
+
⟨hf,hi' _ h2,(hC _ j.property _ h2).1,hb⟩⟩
|
| 129 |
+
refine ⟨⟨(volume1,f,g),k,show OnFile p _ from τ⟩,hf.1,⟨?_,fun o ho hx=>?_⟩,
|
| 130 |
+
⟨?_,fun o ho hx=>?_⟩⟩
|
| 131 |
+
· exact hm.trans ((mul_le_mul_of_nonneg_left ((pr_le_tot (hu _).nz).trans (hu j).total.le)
|
| 132 |
+
(pr_nonneg (hu _).nz)).trans_eq (mul_one _))
|
| 133 |
+
· have hv := hcol i o hx
|
| 134 |
+
exact steadyBeacon z o X l true T τ.qA tt m E K
|
| 135 |
+
(fun x=> Nat.lt_succ_iff.mp (f x).isLt) rfl (hK i) hF (hl _ hv) ho.2.2.1
|
| 136 |
+
(hC _ i.property _ hv).2.1
|
| 137 |
+
· exact hm.trans ((mul_le_mul_of_nonneg_right ((pr_le_tot (hu _).nz).trans (hu i).total.le)
|
| 138 |
+
(pr_nonneg (hu _).nz)).trans_eq (one_mul _))
|
| 139 |
+
have hv:=hcol j o hx
|
| 140 |
+
exact steadyBeacon z o Y t false T' τ.qB tt m H K
|
| 141 |
+
(fun x=> Nat.lt_succ_iff.mp (g x).isLt) rfl (hK j) hG (ht' _ hv) ho.2.2.1
|
| 142 |
+
(hC _ j.property _ hv).2.1
|
| 143 |
+
|
| 144 |
+
end StatusAnalysis
|
| 145 |
+
end HadwigerCounterexample
|
| 146 |
+
|
| 147 |
+
end
|
| 148 |
+
|
| 149 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ComponentIndices.lean
CHANGED
|
@@ -1,115 +1,115 @@
|
|
| 1 |
-
import Mathlib.Algebra.Group.Fin.Basic
|
| 2 |
-
import Mathlib.Data.Fintype.Card
|
| 3 |
-
import Mathlib.Data.Fintype.Prod
|
| 4 |
-
|
| 5 |
-
namespace OAI
|
| 6 |
-
|
| 7 |
-
/-! # Component Indices -/
|
| 8 |
-
|
| 9 |
-
noncomputable section
|
| 10 |
-
namespace HadwigerCounterexample
|
| 11 |
-
|
| 12 |
-
abbrev Tag := Fin
|
| 13 |
-
abbrev Comp (g : ℕ) := { p : Tag g × Tag g // p.1 < p.2 }
|
| 14 |
-
|
| 15 |
-
variable {g : ℕ}
|
| 16 |
-
|
| 17 |
-
def edge (l d : Tag g) (h : l ≠ d) : Comp g :=
|
| 18 |
-
if hl : l < d then ⟨(l,d),hl⟩ else ⟨(d,l),lt_of_le_of_ne (le_of_not_gt hl) h.symm⟩
|
| 19 |
-
|
| 20 |
-
theorem edge_eq {l d : Tag g} (h : l < d) : edge l d (ne_of_lt h) = ⟨(l,d),h⟩ := by
|
| 21 |
-
simp [edge,h]
|
| 22 |
-
|
| 23 |
-
theorem edge_symm {l d : Tag g} (h : l ≠ d) : edge l d h = edge d l h.symm := by
|
| 24 |
-
rcases lt_or_gt_of_ne h with e|e
|
| 25 |
-
· simp [edge,e,not_lt.mpr e.le]
|
| 26 |
-
· simp [edge,e,not_lt.mpr e.le]
|
| 27 |
-
|
| 28 |
-
def inc (e : Comp g) (l : Tag g) : Prop := e.val.1 = l ∨ e.val.2 = l
|
| 29 |
-
instance (e : Comp g) (l : Tag g) : Decidable (inc e l) := inferInstanceAs (Decidable (_ ∨ _))
|
| 30 |
-
|
| 31 |
-
theorem inc_edge_fst {l d : Tag g} (h : l ≠ d) : inc (edge l d h) l := by
|
| 32 |
-
by_cases e : l < d <;> simp [inc,edge,e]
|
| 33 |
-
|
| 34 |
-
theorem inc_edge_iff {l d x : Tag g} (h : l ≠ d) : inc (edge l d h) x ↔ (l=x ∨ d=x) := by
|
| 35 |
-
by_cases e : l < d <;> simp [inc,edge,e,or_comm]
|
| 36 |
-
|
| 37 |
-
abbrev TagStar (l : Tag g) := {e : Comp g // inc e l}
|
| 38 |
-
|
| 39 |
-
def starEquiv (l : Tag g) : {d : Tag g // l ≠ d} ≃ TagStar l := by
|
| 40 |
-
let f (d : {d : Tag g // l ≠ d}) : TagStar l := ⟨edge l d d.property,inc_edge_fst _⟩
|
| 41 |
-
apply Equiv.ofBijective f
|
| 42 |
-
constructor
|
| 43 |
-
· intro i j h
|
| 44 |
-
have hi : inc (edge l i i.property) i := (inc_edge_iff _).mpr (Or.inr rfl)
|
| 45 |
-
change inc (f i).val i at hi
|
| 46 |
-
rw [h] at hi
|
| 47 |
-
exact Subtype.ext (((inc_edge_iff j.property).mp hi).resolve_left i.property).symm
|
| 48 |
-
· rintro ⟨⟨⟨i,j⟩,hij⟩,he⟩
|
| 49 |
-
rcases he with g|g
|
| 50 |
-
· change i = l at g
|
| 51 |
-
subst l
|
| 52 |
-
refine ⟨⟨j,hij.ne⟩,Subtype.ext ?_⟩
|
| 53 |
-
exact edge_eq hij
|
| 54 |
-
· change j = l at g
|
| 55 |
-
subst l
|
| 56 |
-
refine ⟨⟨i,hij.ne.symm⟩,Subtype.ext ?_⟩
|
| 57 |
-
dsimp only [f]
|
| 58 |
-
rw [edge_symm,edge_eq hij]
|
| 59 |
-
|
| 60 |
-
theorem card_star (l : Tag g) : Fintype.card (TagStar l) = g - 1 := by
|
| 61 |
-
rw [← Fintype.card_congr (starEquiv l)]
|
| 62 |
-
exact (Fintype.card_subtype_compl (fun d => l=d)).trans (by simp)
|
| 63 |
-
|
| 64 |
-
/-- l in I_d. -/
|
| 65 |
-
def allowed (d l : Tag g) :=
|
| 66 |
-
0 < (l-d).val ∧ (l-d).val ≤ (g-1)/2
|
| 67 |
-
|
| 68 |
-
instance (d l : Tag g) : Decidable (allowed d l) :=
|
| 69 |
-
inferInstanceAs (Decidable (_ ∧ _))
|
| 70 |
-
|
| 71 |
-
theorem not_allowed (d : Tag g) : ¬allowed d d := by
|
| 72 |
-
have : NeZero g := ⟨by have := d.isLt; omega⟩
|
| 73 |
-
simp [allowed]
|
| 74 |
-
|
| 75 |
-
theorem card_allowed (d : Tag g) : Fintype.card {l : Tag g // allowed d l} = (g-1)/2 := by
|
| 76 |
-
have : NeZero g := ⟨by have := d.isLt; omega⟩
|
| 77 |
-
let T := {l : Tag g // allowed d l}
|
| 78 |
-
let f (i : Fin ((g-1)/2)) : Tag g := ⟨i.val+1,by have := i.isLt; omega⟩
|
| 79 |
-
have hf (i) : allowed d (f i + d) := by
|
| 80 |
-
have := i.isLt
|
| 81 |
-
simp only [allowed,add_sub_cancel_right,f]
|
| 82 |
-
omega
|
| 83 |
-
let h : Fin ((g-1)/2) → T := fun i => ⟨f i + d,hf i⟩
|
| 84 |
-
have hh : Function.Bijective h := by
|
| 85 |
-
constructor
|
| 86 |
-
· intro i j hij
|
| 87 |
-
have he : f i = f j := add_right_cancel (congrArg Subtype.val hij)
|
| 88 |
-
have he' := congrArg Fin.val he
|
| 89 |
-
exact Fin.ext (Nat.add_right_cancel he')
|
| 90 |
-
· intro l
|
| 91 |
-
have hl := l.property
|
| 92 |
-
unfold allowed at hl
|
| 93 |
-
let i : Fin ((g-1)/2) := ⟨(l.val-d).val-1,by omega⟩
|
| 94 |
-
have hi : f i = l.val-d := Fin.ext (by dsimp only [i,f]; omega)
|
| 95 |
-
refine ⟨i,Subtype.ext ?_⟩
|
| 96 |
-
change f i + d = _
|
| 97 |
-
rw [hi,sub_add_cancel]
|
| 98 |
-
simpa using (Fintype.card_congr (Equiv.ofBijective h hh)).symm
|
| 99 |
-
|
| 100 |
-
theorem card_allowed' (l : Tag g) :
|
| 101 |
-
Fintype.card {d : Tag g // allowed d l} = (g-1)/2 := by
|
| 102 |
-
have : NeZero g := ⟨by have := l.isLt; omega⟩
|
| 103 |
-
let h : {d : Tag g // allowed d l} ≃ {x : Tag g // allowed 0 x} := {
|
| 104 |
-
toFun := fun d => ⟨l-d.val, by simpa only [allowed,sub_zero] using d.property⟩
|
| 105 |
-
invFun := fun x => ⟨l-x.val, by simpa only [allowed,sub_sub_cancel,sub_zero] using
|
| 106 |
-
x.property⟩
|
| 107 |
-
left_inv := fun d => Subtype.ext (sub_sub_cancel _ _)
|
| 108 |
-
right_inv := fun x => Subtype.ext (sub_sub_cancel _ _) }
|
| 109 |
-
exact (Fintype.card_congr h).trans (card_allowed _)
|
| 110 |
-
|
| 111 |
-
end HadwigerCounterexample
|
| 112 |
-
|
| 113 |
-
end
|
| 114 |
-
|
| 115 |
-
end OAI
|
|
|
|
| 1 |
+
import Mathlib.Algebra.Group.Fin.Basic
|
| 2 |
+
import Mathlib.Data.Fintype.Card
|
| 3 |
+
import Mathlib.Data.Fintype.Prod
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! # Component Indices -/
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace HadwigerCounterexample
|
| 11 |
+
|
| 12 |
+
abbrev Tag := Fin
|
| 13 |
+
abbrev Comp (g : ℕ) := { p : Tag g × Tag g // p.1 < p.2 }
|
| 14 |
+
|
| 15 |
+
variable {g : ℕ}
|
| 16 |
+
|
| 17 |
+
def edge (l d : Tag g) (h : l ≠ d) : Comp g :=
|
| 18 |
+
if hl : l < d then ⟨(l,d),hl⟩ else ⟨(d,l),lt_of_le_of_ne (le_of_not_gt hl) h.symm⟩
|
| 19 |
+
|
| 20 |
+
theorem edge_eq {l d : Tag g} (h : l < d) : edge l d (ne_of_lt h) = ⟨(l,d),h⟩ := by
|
| 21 |
+
simp [edge,h]
|
| 22 |
+
|
| 23 |
+
theorem edge_symm {l d : Tag g} (h : l ≠ d) : edge l d h = edge d l h.symm := by
|
| 24 |
+
rcases lt_or_gt_of_ne h with e|e
|
| 25 |
+
· simp [edge,e,not_lt.mpr e.le]
|
| 26 |
+
· simp [edge,e,not_lt.mpr e.le]
|
| 27 |
+
|
| 28 |
+
def inc (e : Comp g) (l : Tag g) : Prop := e.val.1 = l ∨ e.val.2 = l
|
| 29 |
+
instance (e : Comp g) (l : Tag g) : Decidable (inc e l) := inferInstanceAs (Decidable (_ ∨ _))
|
| 30 |
+
|
| 31 |
+
theorem inc_edge_fst {l d : Tag g} (h : l ≠ d) : inc (edge l d h) l := by
|
| 32 |
+
by_cases e : l < d <;> simp [inc,edge,e]
|
| 33 |
+
|
| 34 |
+
theorem inc_edge_iff {l d x : Tag g} (h : l ≠ d) : inc (edge l d h) x ↔ (l=x ∨ d=x) := by
|
| 35 |
+
by_cases e : l < d <;> simp [inc,edge,e,or_comm]
|
| 36 |
+
|
| 37 |
+
abbrev TagStar (l : Tag g) := {e : Comp g // inc e l}
|
| 38 |
+
|
| 39 |
+
def starEquiv (l : Tag g) : {d : Tag g // l ≠ d} ≃ TagStar l := by
|
| 40 |
+
let f (d : {d : Tag g // l ≠ d}) : TagStar l := ⟨edge l d d.property,inc_edge_fst _⟩
|
| 41 |
+
apply Equiv.ofBijective f
|
| 42 |
+
constructor
|
| 43 |
+
· intro i j h
|
| 44 |
+
have hi : inc (edge l i i.property) i := (inc_edge_iff _).mpr (Or.inr rfl)
|
| 45 |
+
change inc (f i).val i at hi
|
| 46 |
+
rw [h] at hi
|
| 47 |
+
exact Subtype.ext (((inc_edge_iff j.property).mp hi).resolve_left i.property).symm
|
| 48 |
+
· rintro ⟨⟨⟨i,j⟩,hij⟩,he⟩
|
| 49 |
+
rcases he with g|g
|
| 50 |
+
· change i = l at g
|
| 51 |
+
subst l
|
| 52 |
+
refine ⟨⟨j,hij.ne⟩,Subtype.ext ?_⟩
|
| 53 |
+
exact edge_eq hij
|
| 54 |
+
· change j = l at g
|
| 55 |
+
subst l
|
| 56 |
+
refine ⟨⟨i,hij.ne.symm⟩,Subtype.ext ?_⟩
|
| 57 |
+
dsimp only [f]
|
| 58 |
+
rw [edge_symm,edge_eq hij]
|
| 59 |
+
|
| 60 |
+
theorem card_star (l : Tag g) : Fintype.card (TagStar l) = g - 1 := by
|
| 61 |
+
rw [← Fintype.card_congr (starEquiv l)]
|
| 62 |
+
exact (Fintype.card_subtype_compl (fun d => l=d)).trans (by simp)
|
| 63 |
+
|
| 64 |
+
/-- l in I_d. -/
|
| 65 |
+
def allowed (d l : Tag g) :=
|
| 66 |
+
0 < (l-d).val ∧ (l-d).val ≤ (g-1)/2
|
| 67 |
+
|
| 68 |
+
instance (d l : Tag g) : Decidable (allowed d l) :=
|
| 69 |
+
inferInstanceAs (Decidable (_ ∧ _))
|
| 70 |
+
|
| 71 |
+
theorem not_allowed (d : Tag g) : ¬allowed d d := by
|
| 72 |
+
have : NeZero g := ⟨by have := d.isLt; omega⟩
|
| 73 |
+
simp [allowed]
|
| 74 |
+
|
| 75 |
+
theorem card_allowed (d : Tag g) : Fintype.card {l : Tag g // allowed d l} = (g-1)/2 := by
|
| 76 |
+
have : NeZero g := ⟨by have := d.isLt; omega⟩
|
| 77 |
+
let T := {l : Tag g // allowed d l}
|
| 78 |
+
let f (i : Fin ((g-1)/2)) : Tag g := ⟨i.val+1,by have := i.isLt; omega⟩
|
| 79 |
+
have hf (i) : allowed d (f i + d) := by
|
| 80 |
+
have := i.isLt
|
| 81 |
+
simp only [allowed,add_sub_cancel_right,f]
|
| 82 |
+
omega
|
| 83 |
+
let h : Fin ((g-1)/2) → T := fun i => ⟨f i + d,hf i⟩
|
| 84 |
+
have hh : Function.Bijective h := by
|
| 85 |
+
constructor
|
| 86 |
+
· intro i j hij
|
| 87 |
+
have he : f i = f j := add_right_cancel (congrArg Subtype.val hij)
|
| 88 |
+
have he' := congrArg Fin.val he
|
| 89 |
+
exact Fin.ext (Nat.add_right_cancel he')
|
| 90 |
+
· intro l
|
| 91 |
+
have hl := l.property
|
| 92 |
+
unfold allowed at hl
|
| 93 |
+
let i : Fin ((g-1)/2) := ⟨(l.val-d).val-1,by omega⟩
|
| 94 |
+
have hi : f i = l.val-d := Fin.ext (by dsimp only [i,f]; omega)
|
| 95 |
+
refine ⟨i,Subtype.ext ?_⟩
|
| 96 |
+
change f i + d = _
|
| 97 |
+
rw [hi,sub_add_cancel]
|
| 98 |
+
simpa using (Fintype.card_congr (Equiv.ofBijective h hh)).symm
|
| 99 |
+
|
| 100 |
+
theorem card_allowed' (l : Tag g) :
|
| 101 |
+
Fintype.card {d : Tag g // allowed d l} = (g-1)/2 := by
|
| 102 |
+
have : NeZero g := ⟨by have := l.isLt; omega⟩
|
| 103 |
+
let h : {d : Tag g // allowed d l} ≃ {x : Tag g // allowed 0 x} := {
|
| 104 |
+
toFun := fun d => ⟨l-d.val, by simpa only [allowed,sub_zero] using d.property⟩
|
| 105 |
+
invFun := fun x => ⟨l-x.val, by simpa only [allowed,sub_sub_cancel,sub_zero] using
|
| 106 |
+
x.property⟩
|
| 107 |
+
left_inv := fun d => Subtype.ext (sub_sub_cancel _ _)
|
| 108 |
+
right_inv := fun x => Subtype.ext (sub_sub_cancel _ _) }
|
| 109 |
+
exact (Fintype.card_congr h).trans (card_allowed _)
|
| 110 |
+
|
| 111 |
+
end HadwigerCounterexample
|
| 112 |
+
|
| 113 |
+
end
|
| 114 |
+
|
| 115 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConcentrationScales.lean
CHANGED
|
@@ -1,169 +1,169 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.DependentPairConcentration
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Concentration Scales -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
|
| 10 |
-
open Matrix LinearMap Module Finset Filter Real Function
|
| 11 |
-
open scoped BigOperators Topology
|
| 12 |
-
variable {X : Type*}
|
| 13 |
-
|
| 14 |
-
/-- pay slack for any fixed multiple of exponentially smaller term. -/
|
| 15 |
-
theorem pay_nat {a b : ℝ} (c : ℝ) (hab : b < a) :
|
| 16 |
-
∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ bp (-b*n) := by
|
| 17 |
-
have h := (bp_tendsto (sub_pos.mpr hab)).comp (tendsto_natCast_atTop_atTop (R:=ℝ))
|
| 18 |
-
filter_upwards [h.eventually (eventually_ge_atTop c)] with n hn
|
| 19 |
-
change c ≤ bp ((a-b)*n) at hn
|
| 20 |
-
refine (mul_le_mul_of_nonneg_right hn (bp_pos _).le).trans_eq ?_
|
| 21 |
-
rw [← bp_add, show (a-b)*n + -a*n= -b*n by ring]
|
| 22 |
-
|
| 23 |
-
theorem pay_div_nat {a b : ℝ} (c u : ℝ) (hu : 0 < u) (hab : b < a) :
|
| 24 |
-
∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ u*bp (-b*n) := by
|
| 25 |
-
filter_upwards [pay_nat (c/u) hab] with n hn
|
| 26 |
-
calc _ = u*(c/u*bp (-a*n)) := by field_simp
|
| 27 |
-
_ ≤ _ := mul_le_mul_of_nonneg_left hn hu.le
|
| 28 |
-
|
| 29 |
-
theorem cast_tops (M : ℕ) (hM : 1≤M) :
|
| 30 |
-
Tendsto (fun n : ℕ => (↑(M*n):ℝ)) atTop atTop := by
|
| 31 |
-
simp_rw [Nat.cast_mul]; exact
|
| 32 |
-
(tendsto_const_mul_atTop_of_pos (show 0<(M:ℝ) from by
|
| 33 |
-
exact_mod_cast (show 0 < M from hM))).mpr tendsto_natCast_atTop_atTop
|
| 34 |
-
|
| 35 |
-
variable {p : Shape} {M n N : ℕ}
|
| 36 |
-
variable {I J K G A B : Type} [Fintype I] [Fintype J] [Fintype K] [Fintype G]
|
| 37 |
-
variable [DecidableEq I] [DecidableEq J] [DecidableEq K] [DecidableEq G]
|
| 38 |
-
variable [Fintype A] [Fintype B]
|
| 39 |
-
variable {g : Route J G}
|
| 40 |
-
|
| 41 |
-
omit [Fintype G] [DecidableEq J] in
|
| 42 |
-
theorem port_limit (g : Route J G) (i : G) :
|
| 43 |
-
num (Port g i) ≤ num J := by
|
| 44 |
-
exact_mod_cast Fintype.card_subtype_le _
|
| 45 |
-
|
| 46 |
-
namespace Program
|
| 47 |
-
variable {s : Program p n g A}
|
| 48 |
-
|
| 49 |
-
/-- empirical input-and-image law -/
|
| 50 |
-
def makeData (s : Program p n g A) (w : Wgt A) (o : Forum p n N G) :
|
| 51 |
-
Wgt (A×Rack J N) :=
|
| 52 |
-
mapW w (fun x => (x,s.showKey x o))
|
| 53 |
-
omit [Fintype G] [DecidableEq G] in
|
| 54 |
-
theorem data_law (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)
|
| 55 |
-
(hw : IsLaw w) : IsLaw (s.makeData w o) := mapW_law hw _
|
| 56 |
-
omit [Fintype G] [DecidableEq G] in
|
| 57 |
-
theorem view_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)
|
| 58 |
-
(f : Wgt (A×Rack J N)) :
|
| 59 |
-
avg (s.makeData w o) f=s.oexpect w (fun a b => f (a,b)) o := mapW_avg ..
|
| 60 |
-
omit [Fintype G] [DecidableEq G] in
|
| 61 |
-
theorem freq_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)
|
| 62 |
-
(P : A×Rack J N→Prop) :
|
| 63 |
-
pr (s.makeData w o) P = oFreq w (fun a b => P (a,b)) o s := mapW_pr ..
|
| 64 |
-
|
| 65 |
-
set_option maxHeartbeats 600000 in
|
| 66 |
-
theorem variance_calendar (p : Shape) (M : ℕ) (g : Route J G)
|
| 67 |
-
(r u : ℝ) (hu : 0 < u) (hM : 1≤M) :
|
| 68 |
-
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)
|
| 69 |
-
(A : Type) [Fintype A] (s : Program p n g A)
|
| 70 |
-
(T : A→ Wgt (Rack J N)) (w : Wgt A), IsLaw w →
|
| 71 |
-
(∀ x y, |T x y|≤1) →2*num (Full p n)<N →
|
| 72 |
-
pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →
|
| 73 |
-
(let v := forumLaw m N
|
| 74 |
-
let f := s.oexpect w T
|
| 75 |
-
avg v (fun x => (f x-avg v f)^2)) ≤ u*bp (-(1/4:ℝ)*n) := by
|
| 76 |
-
let t := tied g Bool
|
| 77 |
-
let k := num (Bool×J)
|
| 78 |
-
let b := 2*netFact t
|
| 79 |
-
let c := num G* (2*bp k)+1
|
| 80 |
-
filter_upwards [pay_div_nat (a:=1) (2*bp r) (u/2) (by positivity) (b:=1/4) (by norm_num),
|
| 81 |
-
pay_div_nat (a:=1/2) (b*c) (u/2) (by positivity) (b:=1/4) (by norm_num),
|
| 82 |
-
(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]
|
| 83 |
-
with n hn hh hk N m A _ s T w hw hT hN h
|
| 84 |
-
change (2*k+1) ≤ (↑(M*n) : ℝ) at hk
|
| 85 |
-
have he := oVar m hN T w hw hT k (fun i => port_limit _ i) (by linarith only [hk])
|
| 86 |
-
(bp (r-n)) h
|
| 87 |
-
apply he.trans
|
| 88 |
-
subst N
|
| 89 |
-
have hv : (n:ℝ) ≤ (M*n:ℕ) := by exact_mod_cast (show n ≤ M*n from by nlinarith)
|
| 90 |
-
let P := bp (-(1/2:ℝ)*n)
|
| 91 |
-
have ht : twinkle t k (M*n) ≤ c*P := by
|
| 92 |
-
have hq : bp (k-(M*n:ℕ)) ≤ bp k*P := by
|
| 93 |
-
unfold P; rw [← bp_add]; apply bp_le; linarith only [hv,Nat.cast_nonneg (α:=ℝ) n]
|
| 94 |
-
have hr : bp (-(↑(M*n):ℝ)/2)≤P := bp_le (by linarith only [hv])
|
| 95 |
-
calc _ ≤ num G*(2*(bp k * P))+P := add_le_add
|
| 96 |
-
(mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hq (by norm_num))
|
| 97 |
-
(Nat.cast_nonneg _)) hr
|
| 98 |
-
_ = _ := by unfold c; ring
|
| 99 |
-
have h1 : 2*bp (r-n) ≤ u/2*bp (-(1/4:ℝ)*n) := by
|
| 100 |
-
simpa only [mul_assoc,← bp_add,neg_mul,one_mul,←sub_eq_add_neg] using hn
|
| 101 |
-
have h2 : 2*netFact t* twinkle t k (M*n)≤ u/2*bp (-(1/4:ℝ)*n) :=
|
| 102 |
-
(mul_le_mul_of_nonneg_left ht (by apply mul_nonneg (by norm_num) netFact_pos.le)).trans
|
| 103 |
-
(le_trans (le_of_eq (Eq.symm (mul_assoc b c P))) hh)
|
| 104 |
-
exact (add_le_add h1 h2).trans_eq (by ring)
|
| 105 |
-
|
| 106 |
-
theorem approx_calendar (p : Shape) (M : ℕ) (g : Route J G)
|
| 107 |
-
(r η : ℝ) (hη : 0<η) (hM : 1 ≤ M) :
|
| 108 |
-
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)
|
| 109 |
-
(A : Type) [Fintype A] (s : Program p n g A)
|
| 110 |
-
(w : Wgt A), IsLaw w →
|
| 111 |
-
2*num (Full p n)<N →
|
| 112 |
-
pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →
|
| 113 |
-
approxData (forumLaw m N) (s.makeData w) η (bp (-(1/4:ℝ)*n)) := by
|
| 114 |
-
filter_upwards [variance_calendar p M g r (η^2) (by positivity) hM]
|
| 115 |
-
with n hn N m A _ s w hw hN he F hF
|
| 116 |
-
subst N
|
| 117 |
-
let T (x : A) (y : Rack J (M*n)) := F (x,y)
|
| 118 |
-
rw [mixW_avg]; simp_rw [view_data]
|
| 119 |
-
refine (outlier (forum_law m hN).nz _ η hη
|
| 120 |
-
(hn m _ s T w hw (fun x y => hF _) hN he)).trans_eq ?_
|
| 121 |
-
field_simp
|
| 122 |
-
|
| 123 |
-
theorem thin_calendar (p : Shape) (M : ℕ) (g : Route J G)
|
| 124 |
-
(b η c : ℝ) (hc : 0 < c) (hη : 0<η) (hM : 1≤M) :
|
| 125 |
-
∃ l : ℕ, ∀ r : ℝ, ∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)
|
| 126 |
-
(A : Type) [Fintype A] (s : Program p n g A)
|
| 127 |
-
(w : Wgt A), IsLaw w →
|
| 128 |
-
2*num (Full p n)<N →
|
| 129 |
-
pr (draws (Fin l) w) (fun x => ¬ s.free x) ≤ bp (r-n) →
|
| 130 |
-
thinData (forumLaw m N) (s.makeData w) (bp (-c*n)) η (bp (-b*n)) := by
|
| 131 |
-
obtain ⟨l,hl⟩ := exists_nat_gt (b/c)
|
| 132 |
-
let d := η^l/2
|
| 133 |
-
have hd : 0<d := by positivity
|
| 134 |
-
let t := tied g (Fin l)
|
| 135 |
-
let k := num (Fin l × J)
|
| 136 |
-
refine ⟨l,fun r => ?_⟩
|
| 137 |
-
filter_upwards [pay_div_nat (a:=1) (bp r) d hd (b:=0) (by norm_num),
|
| 138 |
-
pay_div_nat (a:=c*l) (netFact t) d hd (b:=b)
|
| 139 |
-
(by rwa [div_lt_iff₀ hc,mul_comm] at hl),
|
| 140 |
-
(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]
|
| 141 |
-
with n hn hh hk N m A _ s w hw hN hr P hP
|
| 142 |
-
subst N; let N := M*n
|
| 143 |
-
change 2*k+1 ≤ (N:ℝ) at hk
|
| 144 |
-
let T (x : A) (y : Rack J N) := P (x,y)
|
| 145 |
-
let v := forumLaw (G:=G) m N
|
| 146 |
-
let f := fun o => oFreq w T o s
|
| 147 |
-
rw [show pr (mixW v (s.makeData w)) P=avg v (fun x => pr (s.makeData w x) P) from mixW_avg ..] at hP
|
| 148 |
-
simp_rw [freq_data] at *
|
| 149 |
-
have hi : bp (r-n) ≤ d := by
|
| 150 |
-
simpa only [neg_zero,zero_mul,bp_zero,mul_one,← bp_add,neg_mul,one_mul, ← sub_eq_add_neg]
|
| 151 |
-
using hn
|
| 152 |
-
have hj : η^l=d+d := by unfold d; ring
|
| 153 |
-
have he := oTail m hN T w hw (k:=k) (fun i => port_limit _ i) (by linarith only [hk])
|
| 154 |
-
(bp (r-n)) hr hη.le
|
| 155 |
-
have hv := forum_law (G:=G) m hN
|
| 156 |
-
apply le_of_mul_le_mul_left _ hd
|
| 157 |
-
calc d*pr v (fun x => η ≤ f x)
|
| 158 |
-
_ ≤ _ := mul_le_mul_of_nonneg_right (show d≤η^l-bp (r-n) from by
|
| 159 |
-
rw [hj]; linarith only [hi]) (pr_nonneg hv.nz)
|
| 160 |
-
_ ≤ _ := he
|
| 161 |
-
_ ≤ netFact t * bp (-c*n)^l := mul_le_mul_of_nonneg_left
|
| 162 |
-
(pow_le_pow_left₀ (avg_nonneg hv.nz fun x => pr_nonneg hw.nz) hP l) netFact_pos.le
|
| 163 |
-
_ ≤ _ := by rw [← bp_mul_nat,show -c*n*l= -(c*l)*n by ring]; exact hh
|
| 164 |
-
end Program
|
| 165 |
-
end HadwigerCounterexample
|
| 166 |
-
|
| 167 |
-
end
|
| 168 |
-
|
| 169 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.DependentPairConcentration
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Concentration Scales -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
|
| 10 |
+
open Matrix LinearMap Module Finset Filter Real Function
|
| 11 |
+
open scoped BigOperators Topology
|
| 12 |
+
variable {X : Type*}
|
| 13 |
+
|
| 14 |
+
/-- pay slack for any fixed multiple of exponentially smaller term. -/
|
| 15 |
+
theorem pay_nat {a b : ℝ} (c : ℝ) (hab : b < a) :
|
| 16 |
+
∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ bp (-b*n) := by
|
| 17 |
+
have h := (bp_tendsto (sub_pos.mpr hab)).comp (tendsto_natCast_atTop_atTop (R:=ℝ))
|
| 18 |
+
filter_upwards [h.eventually (eventually_ge_atTop c)] with n hn
|
| 19 |
+
change c ≤ bp ((a-b)*n) at hn
|
| 20 |
+
refine (mul_le_mul_of_nonneg_right hn (bp_pos _).le).trans_eq ?_
|
| 21 |
+
rw [← bp_add, show (a-b)*n + -a*n= -b*n by ring]
|
| 22 |
+
|
| 23 |
+
theorem pay_div_nat {a b : ℝ} (c u : ℝ) (hu : 0 < u) (hab : b < a) :
|
| 24 |
+
∀ᶠ n : ℕ in atTop,c * bp (-a*n) ≤ u*bp (-b*n) := by
|
| 25 |
+
filter_upwards [pay_nat (c/u) hab] with n hn
|
| 26 |
+
calc _ = u*(c/u*bp (-a*n)) := by field_simp
|
| 27 |
+
_ ≤ _ := mul_le_mul_of_nonneg_left hn hu.le
|
| 28 |
+
|
| 29 |
+
theorem cast_tops (M : ℕ) (hM : 1≤M) :
|
| 30 |
+
Tendsto (fun n : ℕ => (↑(M*n):ℝ)) atTop atTop := by
|
| 31 |
+
simp_rw [Nat.cast_mul]; exact
|
| 32 |
+
(tendsto_const_mul_atTop_of_pos (show 0<(M:ℝ) from by
|
| 33 |
+
exact_mod_cast (show 0 < M from hM))).mpr tendsto_natCast_atTop_atTop
|
| 34 |
+
|
| 35 |
+
variable {p : Shape} {M n N : ℕ}
|
| 36 |
+
variable {I J K G A B : Type} [Fintype I] [Fintype J] [Fintype K] [Fintype G]
|
| 37 |
+
variable [DecidableEq I] [DecidableEq J] [DecidableEq K] [DecidableEq G]
|
| 38 |
+
variable [Fintype A] [Fintype B]
|
| 39 |
+
variable {g : Route J G}
|
| 40 |
+
|
| 41 |
+
omit [Fintype G] [DecidableEq J] in
|
| 42 |
+
theorem port_limit (g : Route J G) (i : G) :
|
| 43 |
+
num (Port g i) ≤ num J := by
|
| 44 |
+
exact_mod_cast Fintype.card_subtype_le _
|
| 45 |
+
|
| 46 |
+
namespace Program
|
| 47 |
+
variable {s : Program p n g A}
|
| 48 |
+
|
| 49 |
+
/-- empirical input-and-image law -/
|
| 50 |
+
def makeData (s : Program p n g A) (w : Wgt A) (o : Forum p n N G) :
|
| 51 |
+
Wgt (A×Rack J N) :=
|
| 52 |
+
mapW w (fun x => (x,s.showKey x o))
|
| 53 |
+
omit [Fintype G] [DecidableEq G] in
|
| 54 |
+
theorem data_law (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)
|
| 55 |
+
(hw : IsLaw w) : IsLaw (s.makeData w o) := mapW_law hw _
|
| 56 |
+
omit [Fintype G] [DecidableEq G] in
|
| 57 |
+
theorem view_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)
|
| 58 |
+
(f : Wgt (A×Rack J N)) :
|
| 59 |
+
avg (s.makeData w o) f=s.oexpect w (fun a b => f (a,b)) o := mapW_avg ..
|
| 60 |
+
omit [Fintype G] [DecidableEq G] in
|
| 61 |
+
theorem freq_data (s : Program p n g A) (w : Wgt A) (o : Forum p n N G)
|
| 62 |
+
(P : A×Rack J N→Prop) :
|
| 63 |
+
pr (s.makeData w o) P = oFreq w (fun a b => P (a,b)) o s := mapW_pr ..
|
| 64 |
+
|
| 65 |
+
set_option maxHeartbeats 600000 in
|
| 66 |
+
theorem variance_calendar (p : Shape) (M : ℕ) (g : Route J G)
|
| 67 |
+
(r u : ℝ) (hu : 0 < u) (hM : 1≤M) :
|
| 68 |
+
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)
|
| 69 |
+
(A : Type) [Fintype A] (s : Program p n g A)
|
| 70 |
+
(T : A→ Wgt (Rack J N)) (w : Wgt A), IsLaw w →
|
| 71 |
+
(∀ x y, |T x y|≤1) →2*num (Full p n)<N →
|
| 72 |
+
pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →
|
| 73 |
+
(let v := forumLaw m N
|
| 74 |
+
let f := s.oexpect w T
|
| 75 |
+
avg v (fun x => (f x-avg v f)^2)) ≤ u*bp (-(1/4:ℝ)*n) := by
|
| 76 |
+
let t := tied g Bool
|
| 77 |
+
let k := num (Bool×J)
|
| 78 |
+
let b := 2*netFact t
|
| 79 |
+
let c := num G* (2*bp k)+1
|
| 80 |
+
filter_upwards [pay_div_nat (a:=1) (2*bp r) (u/2) (by positivity) (b:=1/4) (by norm_num),
|
| 81 |
+
pay_div_nat (a:=1/2) (b*c) (u/2) (by positivity) (b:=1/4) (by norm_num),
|
| 82 |
+
(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]
|
| 83 |
+
with n hn hh hk N m A _ s T w hw hT hN h
|
| 84 |
+
change (2*k+1) ≤ (↑(M*n) : ℝ) at hk
|
| 85 |
+
have he := oVar m hN T w hw hT k (fun i => port_limit _ i) (by linarith only [hk])
|
| 86 |
+
(bp (r-n)) h
|
| 87 |
+
apply he.trans
|
| 88 |
+
subst N
|
| 89 |
+
have hv : (n:ℝ) ≤ (M*n:ℕ) := by exact_mod_cast (show n ≤ M*n from by nlinarith)
|
| 90 |
+
let P := bp (-(1/2:ℝ)*n)
|
| 91 |
+
have ht : twinkle t k (M*n) ≤ c*P := by
|
| 92 |
+
have hq : bp (k-(M*n:ℕ)) ≤ bp k*P := by
|
| 93 |
+
unfold P; rw [← bp_add]; apply bp_le; linarith only [hv,Nat.cast_nonneg (α:=ℝ) n]
|
| 94 |
+
have hr : bp (-(↑(M*n):ℝ)/2)≤P := bp_le (by linarith only [hv])
|
| 95 |
+
calc _ ≤ num G*(2*(bp k * P))+P := add_le_add
|
| 96 |
+
(mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_left hq (by norm_num))
|
| 97 |
+
(Nat.cast_nonneg _)) hr
|
| 98 |
+
_ = _ := by unfold c; ring
|
| 99 |
+
have h1 : 2*bp (r-n) ≤ u/2*bp (-(1/4:ℝ)*n) := by
|
| 100 |
+
simpa only [mul_assoc,← bp_add,neg_mul,one_mul,←sub_eq_add_neg] using hn
|
| 101 |
+
have h2 : 2*netFact t* twinkle t k (M*n)≤ u/2*bp (-(1/4:ℝ)*n) :=
|
| 102 |
+
(mul_le_mul_of_nonneg_left ht (by apply mul_nonneg (by norm_num) netFact_pos.le)).trans
|
| 103 |
+
(le_trans (le_of_eq (Eq.symm (mul_assoc b c P))) hh)
|
| 104 |
+
exact (add_le_add h1 h2).trans_eq (by ring)
|
| 105 |
+
|
| 106 |
+
theorem approx_calendar (p : Shape) (M : ℕ) (g : Route J G)
|
| 107 |
+
(r η : ℝ) (hη : 0<η) (hM : 1 ≤ M) :
|
| 108 |
+
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)
|
| 109 |
+
(A : Type) [Fintype A] (s : Program p n g A)
|
| 110 |
+
(w : Wgt A), IsLaw w →
|
| 111 |
+
2*num (Full p n)<N →
|
| 112 |
+
pr (draws Bool w) (fun x => ¬ s.free x) ≤ bp (r-n) →
|
| 113 |
+
approxData (forumLaw m N) (s.makeData w) η (bp (-(1/4:ℝ)*n)) := by
|
| 114 |
+
filter_upwards [variance_calendar p M g r (η^2) (by positivity) hM]
|
| 115 |
+
with n hn N m A _ s w hw hN he F hF
|
| 116 |
+
subst N
|
| 117 |
+
let T (x : A) (y : Rack J (M*n)) := F (x,y)
|
| 118 |
+
rw [mixW_avg]; simp_rw [view_data]
|
| 119 |
+
refine (outlier (forum_law m hN).nz _ η hη
|
| 120 |
+
(hn m _ s T w hw (fun x y => hF _) hN he)).trans_eq ?_
|
| 121 |
+
field_simp
|
| 122 |
+
|
| 123 |
+
theorem thin_calendar (p : Shape) (M : ℕ) (g : Route J G)
|
| 124 |
+
(b η c : ℝ) (hc : 0 < c) (hη : 0<η) (hM : 1≤M) :
|
| 125 |
+
∃ l : ℕ, ∀ r : ℝ, ∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n)
|
| 126 |
+
(A : Type) [Fintype A] (s : Program p n g A)
|
| 127 |
+
(w : Wgt A), IsLaw w →
|
| 128 |
+
2*num (Full p n)<N →
|
| 129 |
+
pr (draws (Fin l) w) (fun x => ¬ s.free x) ≤ bp (r-n) →
|
| 130 |
+
thinData (forumLaw m N) (s.makeData w) (bp (-c*n)) η (bp (-b*n)) := by
|
| 131 |
+
obtain ⟨l,hl⟩ := exists_nat_gt (b/c)
|
| 132 |
+
let d := η^l/2
|
| 133 |
+
have hd : 0<d := by positivity
|
| 134 |
+
let t := tied g (Fin l)
|
| 135 |
+
let k := num (Fin l × J)
|
| 136 |
+
refine ⟨l,fun r => ?_⟩
|
| 137 |
+
filter_upwards [pay_div_nat (a:=1) (bp r) d hd (b:=0) (by norm_num),
|
| 138 |
+
pay_div_nat (a:=c*l) (netFact t) d hd (b:=b)
|
| 139 |
+
(by rwa [div_lt_iff₀ hc,mul_comm] at hl),
|
| 140 |
+
(cast_tops M hM).eventually (eventually_ge_atTop (2*k+1))]
|
| 141 |
+
with n hn hh hk N m A _ s w hw hN hr P hP
|
| 142 |
+
subst N; let N := M*n
|
| 143 |
+
change 2*k+1 ≤ (N:ℝ) at hk
|
| 144 |
+
let T (x : A) (y : Rack J N) := P (x,y)
|
| 145 |
+
let v := forumLaw (G:=G) m N
|
| 146 |
+
let f := fun o => oFreq w T o s
|
| 147 |
+
rw [show pr (mixW v (s.makeData w)) P=avg v (fun x => pr (s.makeData w x) P) from mixW_avg ..] at hP
|
| 148 |
+
simp_rw [freq_data] at *
|
| 149 |
+
have hi : bp (r-n) ≤ d := by
|
| 150 |
+
simpa only [neg_zero,zero_mul,bp_zero,mul_one,← bp_add,neg_mul,one_mul, ← sub_eq_add_neg]
|
| 151 |
+
using hn
|
| 152 |
+
have hj : η^l=d+d := by unfold d; ring
|
| 153 |
+
have he := oTail m hN T w hw (k:=k) (fun i => port_limit _ i) (by linarith only [hk])
|
| 154 |
+
(bp (r-n)) hr hη.le
|
| 155 |
+
have hv := forum_law (G:=G) m hN
|
| 156 |
+
apply le_of_mul_le_mul_left _ hd
|
| 157 |
+
calc d*pr v (fun x => η ≤ f x)
|
| 158 |
+
_ ≤ _ := mul_le_mul_of_nonneg_right (show d≤η^l-bp (r-n) from by
|
| 159 |
+
rw [hj]; linarith only [hi]) (pr_nonneg hv.nz)
|
| 160 |
+
_ ≤ _ := he
|
| 161 |
+
_ ≤ netFact t * bp (-c*n)^l := mul_le_mul_of_nonneg_left
|
| 162 |
+
(pow_le_pow_left₀ (avg_nonneg hv.nz fun x => pr_nonneg hw.nz) hP l) netFact_pos.le
|
| 163 |
+
_ ≤ _ := by rw [← bp_mul_nat,show -c*n*l= -(c*l)*n by ring]; exact hh
|
| 164 |
+
end Program
|
| 165 |
+
end HadwigerCounterexample
|
| 166 |
+
|
| 167 |
+
end
|
| 168 |
+
|
| 169 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalCellEntropy.lean
CHANGED
|
@@ -1,156 +1,156 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.GradientRealization
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.WalshBounds
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Conditional Cell Entropy -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix LinearMap Submodule Module Finset
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {p : Shape} {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
theorem plan_add_disjoint (a b : Plan p n) (h : ∀ z, Disjoint (a z) (b z)) :
|
| 15 |
-
planRank (a⊔b)=planRank a+planRank b := by
|
| 16 |
-
unfold planRank
|
| 17 |
-
rw [← Finset.sum_add_distrib]
|
| 18 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 19 |
-
have he := Submodule.finrank_sup_add_finrank_inf_eq (a i) (b i)
|
| 20 |
-
rw [(h i).eq_bot,finrank_bot,add_zero] at he
|
| 21 |
-
exact he
|
| 22 |
-
|
| 23 |
-
theorem plan_new_disjoint (a b : Plan p n) (h : ∀ z,Disjoint (a z) (b z)) :
|
| 24 |
-
planNew a b=planRank b := by rw [planNew,plan_add_disjoint a b h,Nat.add_sub_cancel_left]
|
| 25 |
-
|
| 26 |
-
variable {I : Type} [Fintype I]
|
| 27 |
-
|
| 28 |
-
def kslots (p : Shape) (I : Type) [Fintype I] :=
|
| 29 |
-
Fintype.card I*(p.g-1)*2
|
| 30 |
-
def kmax (p : Shape) := 56*(p.g-1)
|
| 31 |
-
theorem slots_budget {w : I→Bool} (v : Volley p n I)
|
| 32 |
-
(hb : v.bounded w) : kslots p I ≤ kmax p := by
|
| 33 |
-
classical
|
| 34 |
-
have h := v.call_count hb
|
| 35 |
-
unfold kslots kmax; nlinarith
|
| 36 |
-
|
| 37 |
-
instance instFKeys (t : Tagging p I) (N : ℕ) : Fintype (Keys (p:=p) t N) :=
|
| 38 |
-
by classical exact inferInstance
|
| 39 |
-
|
| 40 |
-
theorem dim_keys (t : Tagging p I) :
|
| 41 |
-
dim (Keys (p:=p) t N) = kslots p I * N := by
|
| 42 |
-
have h (l : Tag p.g) :
|
| 43 |
-
dim (AtomKey (p:=p) l N)=(p.g-1)*(2*N) := by
|
| 44 |
-
unfold AtomKey dim
|
| 45 |
-
|
| 46 |
-
rw [finrank_pi_fintype]
|
| 47 |
-
have he : finrank F (Bool → Vec (Fin N))=2*N := by
|
| 48 |
-
rw [finrank_pi_fintype]
|
| 49 |
-
simp_rw [show finrank F (Vec (Fin N))=_ from dim_vec _]
|
| 50 |
-
simp
|
| 51 |
-
simp_rw [he]
|
| 52 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_star]; rfl
|
| 53 |
-
unfold dim Keys kslots
|
| 54 |
-
rw [finrank_pi_fintype]
|
| 55 |
-
have hx i : finrank F (AtomKey (p:=p) (t i) N)=(p.g-1)*(2*N) := h (t i)
|
| 56 |
-
simp_rw [hx]
|
| 57 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.cast_id]
|
| 58 |
-
ring
|
| 59 |
-
|
| 60 |
-
namespace Volley
|
| 61 |
-
variable {v : Volley p n I}
|
| 62 |
-
|
| 63 |
-
theorem key_slots (t : Tagging p I) {q} {a : Plan p n}
|
| 64 |
-
(h : v.avoids a q) :
|
| 65 |
-
planNew a (v.keyPlan t) = kslots p I := by
|
| 66 |
-
classical
|
| 67 |
-
let Y := visits p t
|
| 68 |
-
have hh i := key_independent v t h i
|
| 69 |
-
have he (z : Place p) : dim (keyPlan v t z)=Fintype.card (Y z.1) :=
|
| 70 |
-
mrk_inj.mp (hh z).1
|
| 71 |
-
rw [plan_new_disjoint a _ (fun i => Disjoint.mono_left (pin_le_table a i)
|
| 72 |
-
(hh i).2.symm), planRank,Fintype.sum_prod_type]
|
| 73 |
-
simp_rw [Fintype.sum_bool,he,←two_mul,←Finset.mul_sum]
|
| 74 |
-
have hE : ∑ i : Comp p.g,Fintype.card (Y i)=Fintype.card I*(p.g-1) := by
|
| 75 |
-
have hf {A : Type} [Fintype A] (p : A → Prop) [DecidablePred p] :
|
| 76 |
-
Fintype.card {i:A//p i}=∑ i:A, if p i then (1:ℕ) else 0 := by
|
| 77 |
-
rw [Fintype.card_subtype,←Finset.sum_filter]; simp
|
| 78 |
-
|
| 79 |
-
have hY (i) : Fintype.card (Y i)=∑ j:I,if inc i (t j) then (1:ℕ) else 0 := hf _
|
| 80 |
-
simp_rw [hY]
|
| 81 |
-
rw [Finset.sum_comm]
|
| 82 |
-
simp_rw [← hf (fun i => inc i _)]
|
| 83 |
-
have hz (j) : Fintype.card {i:Comp p.g//inc i (t j)}=p.g-1 := card_star (t j)
|
| 84 |
-
simp_rw [hz]
|
| 85 |
-
simp
|
| 86 |
-
rw [hE]; unfold kslots; ring
|
| 87 |
-
|
| 88 |
-
/-- chosen reference x fixes the pin made of a and all key directions
|
| 89 |
-
for every y in the same pin which agrees on query key. -/
|
| 90 |
-
theorem key_pin (t : Tagging p I) {a : Pin p n N} {x y : UnitType p n N}
|
| 91 |
-
(hx : a.agree x) (hy : a.agree y) (h : v.keys t x=v.keys t y) :
|
| 92 |
-
(Pin.make (v.frozen a.sp t) x).agree y := by
|
| 93 |
-
classical
|
| 94 |
-
intro i u hu
|
| 95 |
-
obtain ⟨l,hl,r,⟨z,rfl⟩,rfl⟩ := Submodule.mem_sup.mp
|
| 96 |
-
(show u∈a.sp i⊔v.keyPlan t i from hu)
|
| 97 |
-
have hZ : images y i * v.keyM t i.1 = images x i * v.keyM t i.1 := by
|
| 98 |
-
ext b j
|
| 99 |
-
obtain ⟨k,hk⟩ := j
|
| 100 |
-
have ht := congr_fun (congr_fun (congr_fun h k) (⟨i.1,hk⟩ : TagStar _)) i.2
|
| 101 |
-
rw [v.keys_loc,v.keys_loc] at ht
|
| 102 |
-
exact congr_fun ht.symm b
|
| 103 |
-
change images y i *ᵥ _ = images x i *ᵥ _
|
| 104 |
-
rw [Matrix.mulVec_add,Matrix.mulVec_add,hx _ _ hl,hy _ _ hl]
|
| 105 |
-
rw [mulVecLin_apply,mulVec_mulVec,mulVec_mulVec,hZ]
|
| 106 |
-
end Volley
|
| 107 |
-
|
| 108 |
-
def tau (N k : ℕ) := bp (-((k:ℝ)+0.01)*N)
|
| 109 |
-
def hit (N : ℕ) := bp (-0.02*N)
|
| 110 |
-
|
| 111 |
-
theorem in_clear {a f : Pin p n N} {k : ℕ} {ζ : ℝ} {w : Wgt (UnitType p n N)}
|
| 112 |
-
(hz : ζ ≤ 0.004) (hkz : ζ*k ≤ 0.004)
|
| 113 |
-
(hw : SubLaw w) (h : a.clear ζ w) (hF : a.sp≤f.sp) (hk : planRank f.sp=planRank a.sp+k)
|
| 114 |
-
(S : UnitType p n N → Prop)
|
| 115 |
-
(hS : ∀ x,S x → f.agree x) (ht : tau N k ≤ pr w S) :
|
| 116 |
-
IsLaw (onW w S) ∧ f.clear 0.05 (onW w S) := by
|
| 117 |
-
classical
|
| 118 |
-
have hpos : 0 < pr w S := lt_of_lt_of_le (bp_pos _) ht
|
| 119 |
-
have hh : IsLaw (onW w S) := normW_law (subW_nonneg hw.nz _) hpos
|
| 120 |
-
refine ⟨hh,fun b => ?_⟩
|
| 121 |
-
let t := planNew f.sp b.sp
|
| 122 |
-
by_cases he : t=0
|
| 123 |
-
· change pr _ _ ≤ fee N _ t
|
| 124 |
-
rw [he,fee]
|
| 125 |
-
simp only [Nat.cast_zero,mul_zero,zero_mul,bp_zero]
|
| 126 |
-
exact (pr_le_tot hh.nz).trans hh.total.le
|
| 127 |
-
let R := fun x => S x ∧ b.agree x
|
| 128 |
-
by_cases hf : 0 < pr w R
|
| 129 |
-
· obtain ⟨x,⟨hx,hB⟩,_⟩ := exists_of_pr_pos hw.nz hf
|
| 130 |
-
let c := Pin.make (f.sp⊔b.sp) x
|
| 131 |
-
have hc : pr w R≤ fee N ζ (planNew a.sp c.sp) := (pr_mono hw.nz (q:=c.agree)
|
| 132 |
-
(fun y hy => ((Pin.combine (hS x hx) hB).mpr ⟨hS _ hy.1,hy.2⟩))).trans (h c)
|
| 133 |
-
have hN : planNew a.sp c.sp=k+t := by
|
| 134 |
-
have hh : planNew a.sp f.sp+t=planNew a.sp c.sp := planNew_mono_add hF
|
| 135 |
-
rw [← hh]
|
| 136 |
-
rw [planNew, sup_eq_right.mpr hF,hk, Nat.add_sub_cancel_left]
|
| 137 |
-
rw [hN] at hc
|
| 138 |
-
rw [pr_on]
|
| 139 |
-
refine ((div_le_div₀ (bp_pos _).le hc (bp_pos _) ht)).trans ?_
|
| 140 |
-
unfold fee
|
| 141 |
-
rw [←bp_sub]
|
| 142 |
-
refine bp_le ?_
|
| 143 |
-
have h1 : 1 ≤ (t:ℝ) := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr he
|
| 144 |
-
have hg := mul_le_mul_of_nonneg_right hz (show 0≤(t:ℝ) from Nat.cast_nonneg _)
|
| 145 |
-
rw [Nat.cast_add]
|
| 146 |
-
change _ ≤ -(1-0.05)*(t : ℝ)*N
|
| 147 |
-
rw [← sub_mul]
|
| 148 |
-
exact mul_le_mul_of_nonneg_right (by linarith only [hkz,h1,hg]) (Nat.cast_nonneg _)
|
| 149 |
-
· rw [pr_on]
|
| 150 |
-
exact (div_nonpos_of_nonpos_of_nonneg (not_lt.mp hf) hpos.le).trans (bp_pos _).le
|
| 151 |
-
|
| 152 |
-
end HadwigerCounterexample
|
| 153 |
-
|
| 154 |
-
end
|
| 155 |
-
|
| 156 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.GradientRealization
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.WalshBounds
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Conditional Cell Entropy -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix LinearMap Submodule Module Finset
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {p : Shape} {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
theorem plan_add_disjoint (a b : Plan p n) (h : ∀ z, Disjoint (a z) (b z)) :
|
| 15 |
+
planRank (a⊔b)=planRank a+planRank b := by
|
| 16 |
+
unfold planRank
|
| 17 |
+
rw [← Finset.sum_add_distrib]
|
| 18 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 19 |
+
have he := Submodule.finrank_sup_add_finrank_inf_eq (a i) (b i)
|
| 20 |
+
rw [(h i).eq_bot,finrank_bot,add_zero] at he
|
| 21 |
+
exact he
|
| 22 |
+
|
| 23 |
+
theorem plan_new_disjoint (a b : Plan p n) (h : ∀ z,Disjoint (a z) (b z)) :
|
| 24 |
+
planNew a b=planRank b := by rw [planNew,plan_add_disjoint a b h,Nat.add_sub_cancel_left]
|
| 25 |
+
|
| 26 |
+
variable {I : Type} [Fintype I]
|
| 27 |
+
|
| 28 |
+
def kslots (p : Shape) (I : Type) [Fintype I] :=
|
| 29 |
+
Fintype.card I*(p.g-1)*2
|
| 30 |
+
def kmax (p : Shape) := 56*(p.g-1)
|
| 31 |
+
theorem slots_budget {w : I→Bool} (v : Volley p n I)
|
| 32 |
+
(hb : v.bounded w) : kslots p I ≤ kmax p := by
|
| 33 |
+
classical
|
| 34 |
+
have h := v.call_count hb
|
| 35 |
+
unfold kslots kmax; nlinarith
|
| 36 |
+
|
| 37 |
+
instance instFKeys (t : Tagging p I) (N : ℕ) : Fintype (Keys (p:=p) t N) :=
|
| 38 |
+
by classical exact inferInstance
|
| 39 |
+
|
| 40 |
+
theorem dim_keys (t : Tagging p I) :
|
| 41 |
+
dim (Keys (p:=p) t N) = kslots p I * N := by
|
| 42 |
+
have h (l : Tag p.g) :
|
| 43 |
+
dim (AtomKey (p:=p) l N)=(p.g-1)*(2*N) := by
|
| 44 |
+
unfold AtomKey dim
|
| 45 |
+
|
| 46 |
+
rw [finrank_pi_fintype]
|
| 47 |
+
have he : finrank F (Bool → Vec (Fin N))=2*N := by
|
| 48 |
+
rw [finrank_pi_fintype]
|
| 49 |
+
simp_rw [show finrank F (Vec (Fin N))=_ from dim_vec _]
|
| 50 |
+
simp
|
| 51 |
+
simp_rw [he]
|
| 52 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,card_star]; rfl
|
| 53 |
+
unfold dim Keys kslots
|
| 54 |
+
rw [finrank_pi_fintype]
|
| 55 |
+
have hx i : finrank F (AtomKey (p:=p) (t i) N)=(p.g-1)*(2*N) := h (t i)
|
| 56 |
+
simp_rw [hx]
|
| 57 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.cast_id]
|
| 58 |
+
ring
|
| 59 |
+
|
| 60 |
+
namespace Volley
|
| 61 |
+
variable {v : Volley p n I}
|
| 62 |
+
|
| 63 |
+
theorem key_slots (t : Tagging p I) {q} {a : Plan p n}
|
| 64 |
+
(h : v.avoids a q) :
|
| 65 |
+
planNew a (v.keyPlan t) = kslots p I := by
|
| 66 |
+
classical
|
| 67 |
+
let Y := visits p t
|
| 68 |
+
have hh i := key_independent v t h i
|
| 69 |
+
have he (z : Place p) : dim (keyPlan v t z)=Fintype.card (Y z.1) :=
|
| 70 |
+
mrk_inj.mp (hh z).1
|
| 71 |
+
rw [plan_new_disjoint a _ (fun i => Disjoint.mono_left (pin_le_table a i)
|
| 72 |
+
(hh i).2.symm), planRank,Fintype.sum_prod_type]
|
| 73 |
+
simp_rw [Fintype.sum_bool,he,←two_mul,←Finset.mul_sum]
|
| 74 |
+
have hE : ∑ i : Comp p.g,Fintype.card (Y i)=Fintype.card I*(p.g-1) := by
|
| 75 |
+
have hf {A : Type} [Fintype A] (p : A → Prop) [DecidablePred p] :
|
| 76 |
+
Fintype.card {i:A//p i}=∑ i:A, if p i then (1:ℕ) else 0 := by
|
| 77 |
+
rw [Fintype.card_subtype,←Finset.sum_filter]; simp
|
| 78 |
+
|
| 79 |
+
have hY (i) : Fintype.card (Y i)=∑ j:I,if inc i (t j) then (1:ℕ) else 0 := hf _
|
| 80 |
+
simp_rw [hY]
|
| 81 |
+
rw [Finset.sum_comm]
|
| 82 |
+
simp_rw [← hf (fun i => inc i _)]
|
| 83 |
+
have hz (j) : Fintype.card {i:Comp p.g//inc i (t j)}=p.g-1 := card_star (t j)
|
| 84 |
+
simp_rw [hz]
|
| 85 |
+
simp
|
| 86 |
+
rw [hE]; unfold kslots; ring
|
| 87 |
+
|
| 88 |
+
/-- chosen reference x fixes the pin made of a and all key directions
|
| 89 |
+
for every y in the same pin which agrees on query key. -/
|
| 90 |
+
theorem key_pin (t : Tagging p I) {a : Pin p n N} {x y : UnitType p n N}
|
| 91 |
+
(hx : a.agree x) (hy : a.agree y) (h : v.keys t x=v.keys t y) :
|
| 92 |
+
(Pin.make (v.frozen a.sp t) x).agree y := by
|
| 93 |
+
classical
|
| 94 |
+
intro i u hu
|
| 95 |
+
obtain ⟨l,hl,r,⟨z,rfl⟩,rfl⟩ := Submodule.mem_sup.mp
|
| 96 |
+
(show u∈a.sp i⊔v.keyPlan t i from hu)
|
| 97 |
+
have hZ : images y i * v.keyM t i.1 = images x i * v.keyM t i.1 := by
|
| 98 |
+
ext b j
|
| 99 |
+
obtain ⟨k,hk⟩ := j
|
| 100 |
+
have ht := congr_fun (congr_fun (congr_fun h k) (⟨i.1,hk⟩ : TagStar _)) i.2
|
| 101 |
+
rw [v.keys_loc,v.keys_loc] at ht
|
| 102 |
+
exact congr_fun ht.symm b
|
| 103 |
+
change images y i *ᵥ _ = images x i *ᵥ _
|
| 104 |
+
rw [Matrix.mulVec_add,Matrix.mulVec_add,hx _ _ hl,hy _ _ hl]
|
| 105 |
+
rw [mulVecLin_apply,mulVec_mulVec,mulVec_mulVec,hZ]
|
| 106 |
+
end Volley
|
| 107 |
+
|
| 108 |
+
def tau (N k : ℕ) := bp (-((k:ℝ)+0.01)*N)
|
| 109 |
+
def hit (N : ℕ) := bp (-0.02*N)
|
| 110 |
+
|
| 111 |
+
theorem in_clear {a f : Pin p n N} {k : ℕ} {ζ : ℝ} {w : Wgt (UnitType p n N)}
|
| 112 |
+
(hz : ζ ≤ 0.004) (hkz : ζ*k ≤ 0.004)
|
| 113 |
+
(hw : SubLaw w) (h : a.clear ζ w) (hF : a.sp≤f.sp) (hk : planRank f.sp=planRank a.sp+k)
|
| 114 |
+
(S : UnitType p n N → Prop)
|
| 115 |
+
(hS : ∀ x,S x → f.agree x) (ht : tau N k ≤ pr w S) :
|
| 116 |
+
IsLaw (onW w S) ∧ f.clear 0.05 (onW w S) := by
|
| 117 |
+
classical
|
| 118 |
+
have hpos : 0 < pr w S := lt_of_lt_of_le (bp_pos _) ht
|
| 119 |
+
have hh : IsLaw (onW w S) := normW_law (subW_nonneg hw.nz _) hpos
|
| 120 |
+
refine ⟨hh,fun b => ?_⟩
|
| 121 |
+
let t := planNew f.sp b.sp
|
| 122 |
+
by_cases he : t=0
|
| 123 |
+
· change pr _ _ ≤ fee N _ t
|
| 124 |
+
rw [he,fee]
|
| 125 |
+
simp only [Nat.cast_zero,mul_zero,zero_mul,bp_zero]
|
| 126 |
+
exact (pr_le_tot hh.nz).trans hh.total.le
|
| 127 |
+
let R := fun x => S x ∧ b.agree x
|
| 128 |
+
by_cases hf : 0 < pr w R
|
| 129 |
+
· obtain ⟨x,⟨hx,hB⟩,_⟩ := exists_of_pr_pos hw.nz hf
|
| 130 |
+
let c := Pin.make (f.sp⊔b.sp) x
|
| 131 |
+
have hc : pr w R≤ fee N ζ (planNew a.sp c.sp) := (pr_mono hw.nz (q:=c.agree)
|
| 132 |
+
(fun y hy => ((Pin.combine (hS x hx) hB).mpr ⟨hS _ hy.1,hy.2⟩))).trans (h c)
|
| 133 |
+
have hN : planNew a.sp c.sp=k+t := by
|
| 134 |
+
have hh : planNew a.sp f.sp+t=planNew a.sp c.sp := planNew_mono_add hF
|
| 135 |
+
rw [← hh]
|
| 136 |
+
rw [planNew, sup_eq_right.mpr hF,hk, Nat.add_sub_cancel_left]
|
| 137 |
+
rw [hN] at hc
|
| 138 |
+
rw [pr_on]
|
| 139 |
+
refine ((div_le_div₀ (bp_pos _).le hc (bp_pos _) ht)).trans ?_
|
| 140 |
+
unfold fee
|
| 141 |
+
rw [←bp_sub]
|
| 142 |
+
refine bp_le ?_
|
| 143 |
+
have h1 : 1 ≤ (t:ℝ) := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr he
|
| 144 |
+
have hg := mul_le_mul_of_nonneg_right hz (show 0≤(t:ℝ) from Nat.cast_nonneg _)
|
| 145 |
+
rw [Nat.cast_add]
|
| 146 |
+
change _ ≤ -(1-0.05)*(t : ℝ)*N
|
| 147 |
+
rw [← sub_mul]
|
| 148 |
+
exact mul_le_mul_of_nonneg_right (by linarith only [hkz,h1,hg]) (Nat.cast_nonneg _)
|
| 149 |
+
· rw [pr_on]
|
| 150 |
+
exact (div_nonpos_of_nonpos_of_nonneg (not_lt.mp hf) hpos.le).trans (bp_pos _).le
|
| 151 |
+
|
| 152 |
+
end HadwigerCounterexample
|
| 153 |
+
|
| 154 |
+
end
|
| 155 |
+
|
| 156 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFlags.lean
CHANGED
|
@@ -1,107 +1,107 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteProjectionCenters
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditional Flags -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C X Y : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype X] [Fintype Y]
|
| 12 |
-
variable {w : Wgt X}
|
| 13 |
-
|
| 14 |
-
def stained (w : Wgt X) (f : X→Y) (i : Y) : Wgt X := by
|
| 15 |
-
classical exact if mapW w f i≠0 then onW w (fun x => f x=i) else w
|
| 16 |
-
theorem stained_law (f : X→Y) (hw : IsLaw w) (i : Y) : IsLaw (stained w f i) := by
|
| 17 |
-
unfold stained; split
|
| 18 |
-
next h => exact on_law hw.nz (lt_of_le_of_ne ((mapW_law hw f).nz _) (Ne.symm h))
|
| 19 |
-
next => exact hw
|
| 20 |
-
|
| 21 |
-
theorem stain_rebuild (f : X→Y) (P : Y→Prop) (hw : IsLaw w) :
|
| 22 |
-
subW w (P∘f) = mixW (subW (mapW w f) P) (stained w f) := by
|
| 23 |
-
classical
|
| 24 |
-
have hh := disintegrate hw.nz f
|
| 25 |
-
funext i
|
| 26 |
-
have hi (y) :
|
| 27 |
-
mapW w f y * stained w f y i=
|
| 28 |
-
mapW w f y * onW w (fun x => f x=y) i := by
|
| 29 |
-
by_cases h : mapW w f y=0 <;> simp [stained,h]
|
| 30 |
-
have he := congr_fun hh i
|
| 31 |
-
unfold subW mixW Function.comp
|
| 32 |
-
unfold mixW at he
|
| 33 |
-
rw [he,avg,Finset.sum_mul]
|
| 34 |
-
unfold avg at *
|
| 35 |
-
apply sum_congr rfl
|
| 36 |
-
intro j _
|
| 37 |
-
rw [mul_right_comm _ (ind _), hi]
|
| 38 |
-
by_cases hx : f i=j
|
| 39 |
-
· rw [hx]
|
| 40 |
-
simp only [onW_val,ind_zero hx,mul_zero,zero_div,zero_mul]
|
| 41 |
-
|
| 42 |
-
theorem stain_inputs (f : X→Y) (hw : IsLaw w) :
|
| 43 |
-
w=mixW (mapW w f) (stained w f) := by
|
| 44 |
-
have ht := stain_rebuild f (fun _ => True) hw
|
| 45 |
-
unfold subW at ht
|
| 46 |
-
simpa only [Function.comp_apply,ind_true,mul_one] using ht
|
| 47 |
-
|
| 48 |
-
variable {μ : Wgt A}
|
| 49 |
-
|
| 50 |
-
def colored (μ : Wgt A) (w : Wgt X) (v : A→ X→ Y) :=
|
| 51 |
-
semi μ (fun i => mapW w (v i))
|
| 52 |
-
def coloredP (w : Wgt X) (v : A→ X→Y) (K : A→X→B) :=
|
| 53 |
-
fun i : A×Y => mapW (stained w (v i.1) i.2) (K i.1)
|
| 54 |
-
def flaggedW (μ : Wgt A) (w : Wgt X) (v : A→X→Y) (K : A→X→B) (P : A→Y→Prop) :=
|
| 55 |
-
mixW μ (fun i => mapW (subW w (P i ∘ v i)) (K i))
|
| 56 |
-
|
| 57 |
-
theorem semi_total (μ : Wgt A) (v : A → Wgt Y) :
|
| 58 |
-
tot (semi μ v)=avg μ (fun i=>tot (v i)) := by
|
| 59 |
-
simpa only [avg_const,mul_one] using semi_avg μ v (fun i=>1)
|
| 60 |
-
|
| 61 |
-
theorem colored_ultra (hμ : IsLaw μ) (hw : IsLaw w) (K : A→X→B) (v : A→X→Y) :
|
| 62 |
-
Ultra (colored μ w v) (coloredP w v K) := by
|
| 63 |
-
have ht (i) := mapW_law hw (v i)
|
| 64 |
-
refine ⟨⟨fun x => mul_nonneg (hμ.nz _) ((ht _).nz _),?_⟩,
|
| 65 |
-
fun i => mapW_law (stained_law _ hw _) (K i.1)⟩
|
| 66 |
-
unfold colored; rw [semi_total]
|
| 67 |
-
simp_rw [(ht _).total]
|
| 68 |
-
exact hμ.avg_const _
|
| 69 |
-
|
| 70 |
-
theorem flag_catalog (K : A→ X→B) (v : A→ X→ Y) (P : A→ Y→ Prop)
|
| 71 |
-
(hw : IsLaw w) (hμ : IsLaw μ) :
|
| 72 |
-
catalog (colored μ w v) (coloredP w v K)
|
| 73 |
-
(flaggedW μ w v K P) := by
|
| 74 |
-
classical
|
| 75 |
-
let W := colored μ w v
|
| 76 |
-
have hh := (colored_ultra hμ hw K v).law
|
| 77 |
-
refine ⟨subW W (fun i => P i.1 i.2),subW_nonneg hh.nz _,subW_le hh.nz _,?_⟩
|
| 78 |
-
unfold flaggedW
|
| 79 |
-
simp_rw [stain_rebuild (v _) (P _) hw,map_mix]
|
| 80 |
-
funext x
|
| 81 |
-
simp only [mixW,coloredP,colored,W,avg,subW,semi,Finset.mul_sum,Fintype.sum_prod_type]
|
| 82 |
-
exact sum_congr rfl fun i _ => sum_congr rfl fun j _ => by ring
|
| 83 |
-
|
| 84 |
-
theorem colored_budget [Nonempty Y] (K : A→ X→B) (v : A→ X→ Y) (f : B→C)
|
| 85 |
-
(hw : IsLaw w) (hμ : IsLaw μ) :
|
| 86 |
-
budget (colored μ w v) (coloredP w v K) f ≤
|
| 87 |
-
budget μ (fun i => mapW w (K i)) f + Real.log (num Y) := by
|
| 88 |
-
unfold budget colored coloredP
|
| 89 |
-
rw [semi_avg,← hμ.avg_const (Real.log _),← avg_add]
|
| 90 |
-
apply avg_mono hμ.nz
|
| 91 |
-
intro i
|
| 92 |
-
let u := mapW w (v i)
|
| 93 |
-
have he : IsLaw u := mapW_law hw (v i)
|
| 94 |
-
let q (j : Y) := mapW (mapW (stained w (v i) j) (K i)) f
|
| 95 |
-
have hq (j) : IsLaw (q j) := mapW_law (mapW_law (stained_law _ hw _) _) _
|
| 96 |
-
have ht : mapW (mapW w (K i)) f=mixW u q := by
|
| 97 |
-
calc mapW _ _ = mapW (mapW (mixW u (stained w (v i))) (K i)) f :=
|
| 98 |
-
congrArg (fun z => mapW (mapW z (K i)) f) (stain_inputs (v i) hw)
|
| 99 |
-
_ = _ := by rw [map_mix,map_mix]
|
| 100 |
-
change avg u (fun j => tension (q j) _)≤ tension _ _+_
|
| 101 |
-
rw [tension_mix,add_comm _ (log _),ht]
|
| 102 |
-
exact add_le_add_left (mix_charge he hq) _
|
| 103 |
-
end HadwigerCounterexample
|
| 104 |
-
|
| 105 |
-
end
|
| 106 |
-
|
| 107 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteProjectionCenters
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditional Flags -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C X Y : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype X] [Fintype Y]
|
| 12 |
+
variable {w : Wgt X}
|
| 13 |
+
|
| 14 |
+
def stained (w : Wgt X) (f : X→Y) (i : Y) : Wgt X := by
|
| 15 |
+
classical exact if mapW w f i≠0 then onW w (fun x => f x=i) else w
|
| 16 |
+
theorem stained_law (f : X→Y) (hw : IsLaw w) (i : Y) : IsLaw (stained w f i) := by
|
| 17 |
+
unfold stained; split
|
| 18 |
+
next h => exact on_law hw.nz (lt_of_le_of_ne ((mapW_law hw f).nz _) (Ne.symm h))
|
| 19 |
+
next => exact hw
|
| 20 |
+
|
| 21 |
+
theorem stain_rebuild (f : X→Y) (P : Y→Prop) (hw : IsLaw w) :
|
| 22 |
+
subW w (P∘f) = mixW (subW (mapW w f) P) (stained w f) := by
|
| 23 |
+
classical
|
| 24 |
+
have hh := disintegrate hw.nz f
|
| 25 |
+
funext i
|
| 26 |
+
have hi (y) :
|
| 27 |
+
mapW w f y * stained w f y i=
|
| 28 |
+
mapW w f y * onW w (fun x => f x=y) i := by
|
| 29 |
+
by_cases h : mapW w f y=0 <;> simp [stained,h]
|
| 30 |
+
have he := congr_fun hh i
|
| 31 |
+
unfold subW mixW Function.comp
|
| 32 |
+
unfold mixW at he
|
| 33 |
+
rw [he,avg,Finset.sum_mul]
|
| 34 |
+
unfold avg at *
|
| 35 |
+
apply sum_congr rfl
|
| 36 |
+
intro j _
|
| 37 |
+
rw [mul_right_comm _ (ind _), hi]
|
| 38 |
+
by_cases hx : f i=j
|
| 39 |
+
· rw [hx]
|
| 40 |
+
simp only [onW_val,ind_zero hx,mul_zero,zero_div,zero_mul]
|
| 41 |
+
|
| 42 |
+
theorem stain_inputs (f : X→Y) (hw : IsLaw w) :
|
| 43 |
+
w=mixW (mapW w f) (stained w f) := by
|
| 44 |
+
have ht := stain_rebuild f (fun _ => True) hw
|
| 45 |
+
unfold subW at ht
|
| 46 |
+
simpa only [Function.comp_apply,ind_true,mul_one] using ht
|
| 47 |
+
|
| 48 |
+
variable {μ : Wgt A}
|
| 49 |
+
|
| 50 |
+
def colored (μ : Wgt A) (w : Wgt X) (v : A→ X→ Y) :=
|
| 51 |
+
semi μ (fun i => mapW w (v i))
|
| 52 |
+
def coloredP (w : Wgt X) (v : A→ X→Y) (K : A→X→B) :=
|
| 53 |
+
fun i : A×Y => mapW (stained w (v i.1) i.2) (K i.1)
|
| 54 |
+
def flaggedW (μ : Wgt A) (w : Wgt X) (v : A→X→Y) (K : A→X→B) (P : A→Y→Prop) :=
|
| 55 |
+
mixW μ (fun i => mapW (subW w (P i ∘ v i)) (K i))
|
| 56 |
+
|
| 57 |
+
theorem semi_total (μ : Wgt A) (v : A → Wgt Y) :
|
| 58 |
+
tot (semi μ v)=avg μ (fun i=>tot (v i)) := by
|
| 59 |
+
simpa only [avg_const,mul_one] using semi_avg μ v (fun i=>1)
|
| 60 |
+
|
| 61 |
+
theorem colored_ultra (hμ : IsLaw μ) (hw : IsLaw w) (K : A→X→B) (v : A→X→Y) :
|
| 62 |
+
Ultra (colored μ w v) (coloredP w v K) := by
|
| 63 |
+
have ht (i) := mapW_law hw (v i)
|
| 64 |
+
refine ⟨⟨fun x => mul_nonneg (hμ.nz _) ((ht _).nz _),?_⟩,
|
| 65 |
+
fun i => mapW_law (stained_law _ hw _) (K i.1)⟩
|
| 66 |
+
unfold colored; rw [semi_total]
|
| 67 |
+
simp_rw [(ht _).total]
|
| 68 |
+
exact hμ.avg_const _
|
| 69 |
+
|
| 70 |
+
theorem flag_catalog (K : A→ X→B) (v : A→ X→ Y) (P : A→ Y→ Prop)
|
| 71 |
+
(hw : IsLaw w) (hμ : IsLaw μ) :
|
| 72 |
+
catalog (colored μ w v) (coloredP w v K)
|
| 73 |
+
(flaggedW μ w v K P) := by
|
| 74 |
+
classical
|
| 75 |
+
let W := colored μ w v
|
| 76 |
+
have hh := (colored_ultra hμ hw K v).law
|
| 77 |
+
refine ⟨subW W (fun i => P i.1 i.2),subW_nonneg hh.nz _,subW_le hh.nz _,?_⟩
|
| 78 |
+
unfold flaggedW
|
| 79 |
+
simp_rw [stain_rebuild (v _) (P _) hw,map_mix]
|
| 80 |
+
funext x
|
| 81 |
+
simp only [mixW,coloredP,colored,W,avg,subW,semi,Finset.mul_sum,Fintype.sum_prod_type]
|
| 82 |
+
exact sum_congr rfl fun i _ => sum_congr rfl fun j _ => by ring
|
| 83 |
+
|
| 84 |
+
theorem colored_budget [Nonempty Y] (K : A→ X→B) (v : A→ X→ Y) (f : B→C)
|
| 85 |
+
(hw : IsLaw w) (hμ : IsLaw μ) :
|
| 86 |
+
budget (colored μ w v) (coloredP w v K) f ≤
|
| 87 |
+
budget μ (fun i => mapW w (K i)) f + Real.log (num Y) := by
|
| 88 |
+
unfold budget colored coloredP
|
| 89 |
+
rw [semi_avg,← hμ.avg_const (Real.log _),← avg_add]
|
| 90 |
+
apply avg_mono hμ.nz
|
| 91 |
+
intro i
|
| 92 |
+
let u := mapW w (v i)
|
| 93 |
+
have he : IsLaw u := mapW_law hw (v i)
|
| 94 |
+
let q (j : Y) := mapW (mapW (stained w (v i) j) (K i)) f
|
| 95 |
+
have hq (j) : IsLaw (q j) := mapW_law (mapW_law (stained_law _ hw _) _) _
|
| 96 |
+
have ht : mapW (mapW w (K i)) f=mixW u q := by
|
| 97 |
+
calc mapW _ _ = mapW (mapW (mixW u (stained w (v i))) (K i)) f :=
|
| 98 |
+
congrArg (fun z => mapW (mapW z (K i)) f) (stain_inputs (v i) hw)
|
| 99 |
+
_ = _ := by rw [map_mix,map_mix]
|
| 100 |
+
change avg u (fun j => tension (q j) _)≤ tension _ _+_
|
| 101 |
+
rw [tension_mix,add_comm _ (log _),ht]
|
| 102 |
+
exact add_le_add_left (mix_charge he hq) _
|
| 103 |
+
end HadwigerCounterexample
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
|
| 107 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalFourCorners.lean
CHANGED
|
@@ -1,101 +1,101 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.UnseenCrossingFactorization
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.GramConditionedLaws
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Conditional Four Corners -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Finset Matrix Module LinearMap Function Filter
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {p : Shape} {n N : ℕ} {I J : Type} [Fintype I] [DecidableEq I]
|
| 13 |
-
set_option maxHeartbeats 600000 in
|
| 14 |
-
private theorem stip_mask (E : Rail I) (t : Vec E) (p : Wgt (Rack I N)) (δ : ℝ)
|
| 15 |
-
(hδ : 0≤δ) (hh : |avg unif p|≤δ) (h : ∀ f:Vec E,f≠0 →
|
| 16 |
-
|avg unif (fun i=>phasedBy (ledgerM E f) i*p i)|≤bp (-(N:ℝ)/2)) :
|
| 17 |
-
|partMean (fun x=>traced x E t) p|≤δ+bp (-(N:ℝ)/2) := by
|
| 18 |
-
classical
|
| 19 |
-
have he (f : Vec E) :
|
| 20 |
-
|vectorPhase f t*avg unif (fun i : Rack I N=>phasedBy (ledgerM E f) i*p i)|≤ δ+bp (-(N:ℝ)/2) := by
|
| 21 |
-
rw [abs_mul,vectorPhase,wsign_abs,one_mul]
|
| 22 |
-
by_cases hz : f=0
|
| 23 |
-
· subst f; simpa only [ledger_zero,layer_zero,one_mul] using hh.trans (le_add_of_nonneg_right (bp_pos (-(N:ℝ)/2)).le)
|
| 24 |
-
exact (h f hz).trans (le_add_of_nonneg_left hδ)
|
| 25 |
-
have hf : partMean (fun x=>traced x E t) p=avg unif (fun f:Vec E => vectorPhase f t*avg unif
|
| 26 |
-
(fun i:Rack I N=>phasedBy (ledgerM E f) i*p i)) := by
|
| 27 |
-
unfold partMean; simp_rw [rail_expand,←avg_mul]
|
| 28 |
-
rw [avg_avg]; simp_rw [←avg_mul']; exact avg_congr (fun i _=>avg_congr fun j _=>by ring)
|
| 29 |
-
rw [hf]
|
| 30 |
-
exact (abs_avg_le unif_law.nz).trans (unif_law.avg_le he)
|
| 31 |
-
namespace Template
|
| 32 |
-
variable (v : Template p I)
|
| 33 |
-
|
| 34 |
-
theorem pack_bound (v : Template p I) (j : I) (U : Wgt (Keys (p:=p) v.t N))
|
| 35 |
-
(hU : ∀ i, |U i|≤1) (i) : |packSecs v j U i| ≤1 := by
|
| 36 |
-
unfold packSecs; rw [Finset.abs_prod]
|
| 37 |
-
exact (Finset.prod_le_prod₀ (fun i _=>abs_nonneg _) (fun i _ => hU _)).trans_eq (by simp)
|
| 38 |
-
|
| 39 |
-
set_option maxHeartbeats 800000 in
|
| 40 |
-
theorem lopsided (v : Template p I) (j : I) (q : I→F)
|
| 41 |
-
(U : Wgt (Keys (p:=p) v.t N)) (δ : ℝ) (hδ : 0≤δ)
|
| 42 |
-
(hU : ∀ x,|U x|≤1) (h : chairCut v j U δ)
|
| 43 |
-
(hW : carried U (ownPart (p:=p) v.t q))
|
| 44 |
-
(Z : GeoM v.seam) :
|
| 45 |
-
|partMean (gramPart Z) (packSecs v j U)|≤δ+bp (-(N:ℝ)/2) := by
|
| 46 |
-
classical
|
| 47 |
-
let P := packSecs v j U
|
| 48 |
-
let Q := gramPart Z (N:=N)
|
| 49 |
-
have hb := bp_pos (-(N:ℝ)/2)
|
| 50 |
-
by_cases hp : ∃ x,Q x∧P x≠0
|
| 51 |
-
· obtain ⟨x,hx,hP⟩ := hp
|
| 52 |
-
let E := cantRail v j
|
| 53 |
-
let T (y : v.PackStack N) := traced y E (cantVec v j Z)
|
| 54 |
-
have hg i : ind (Q i)*P i=ind (T i)*P i := by
|
| 55 |
-
by_cases hh : P i=0
|
| 56 |
-
· rw [hh,mul_zero,mul_zero]
|
| 57 |
-
rw [show Q i=T i from propext
|
| 58 |
-
(cant_bridge v j q Z x i (pack_gate v j q U hW hP) (pack_gate v j q U hW hh) hx)]
|
| 59 |
-
change |avg unif (fun x => ind (Q x)*P x)|≤_
|
| 60 |
-
simp_rw [hg]
|
| 61 |
-
exact stip_mask E (cantVec v j Z) P δ hδ (global_quart v j U hU δ h) (cant_leak v j U hU)
|
| 62 |
-
have hh (x) : ind (Q x)*P x=0 := by
|
| 63 |
-
by_cases he : Q x <;> simp only [he,ind_true,ind_false,one_mul,zero_mul]
|
| 64 |
-
exact not_ne_iff.mp (fun hx => hp ⟨x,he,hx⟩)
|
| 65 |
-
change |avg unif (fun x=>ind (Q x)*P x)|≤_
|
| 66 |
-
simp_rw [hh,avg_zero,abs_zero]
|
| 67 |
-
exact add_nonneg hδ hb.le
|
| 68 |
-
|
| 69 |
-
set_option maxHeartbeats 800000 in
|
| 70 |
-
theorem pack_hot (v : Template p I) (j : I) (q : I→F) (U : Wgt (Keys (p:=p) v.t N))
|
| 71 |
-
(δ : ℝ) (hδ : 0≤δ) (hU : ∀ x, |U x|≤1) (h : chairCut v j U δ)
|
| 72 |
-
(hW : carried U (ownPart (p:=p) v.t q))
|
| 73 |
-
(Z : GeoM v.seam) (k : ℝ) (hk : ∀ i,num (Port v.seam i)≤ k)
|
| 74 |
-
(hN : 2*k-(N:ℝ) ≤ -1) :
|
| 75 |
-
let W := netFact v.seam
|
| 76 |
-
|avg (rackStation Z N) (packSecs v j U)|≤
|
| 77 |
-
2*W*(num (Ports p)*(2*bp (k-N)))+W*(δ+bp (-(N:ℝ)/2)) := by
|
| 78 |
-
classical
|
| 79 |
-
intro W
|
| 80 |
-
let B := pr unif (gramPart Z (N:=N))
|
| 81 |
-
have hb := wave_norm Z N (fun i => by linarith only [hN,hk i])
|
| 82 |
-
have h0 : 0<W := netFact_pos
|
| 83 |
-
have he : 0<B := (inv_pos_of_pos h0).trans_le hb
|
| 84 |
-
let V := packSecs v j U
|
| 85 |
-
let D := avg (rackWave Z N) V
|
| 86 |
-
have hl := lopsided v j q U δ hδ hU h hW Z
|
| 87 |
-
rw [part_reset _ _ he,abs_mul,abs_of_nonneg he.le] at hl
|
| 88 |
-
have hh :
|
| 89 |
-
|D| ≤ W*(δ+bp (-(N:ℝ)/2)) := by
|
| 90 |
-
apply le_of_mul_le_mul_left _ (inv_pos_of_pos h0)
|
| 91 |
-
exact (le_trans (mul_le_mul_of_nonneg_right hb (abs_nonneg _)) hl).trans_eq (by field_simp)
|
| 92 |
-
let A := avg (rackStation Z N) V
|
| 93 |
-
have hs := compare_station Z V (pack_bound v j U hU) k hk hN
|
| 94 |
-
change |A|≤_
|
| 95 |
-
exact le_trans (by simpa only [sub_zero] using (abs_sub_le A D 0)) (add_le_add hs hh)
|
| 96 |
-
end Template
|
| 97 |
-
end HadwigerCounterexample
|
| 98 |
-
|
| 99 |
-
end
|
| 100 |
-
|
| 101 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.UnseenCrossingFactorization
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.GramConditionedLaws
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Conditional Four Corners -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Finset Matrix Module LinearMap Function Filter
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {p : Shape} {n N : ℕ} {I J : Type} [Fintype I] [DecidableEq I]
|
| 13 |
+
set_option maxHeartbeats 600000 in
|
| 14 |
+
private theorem stip_mask (E : Rail I) (t : Vec E) (p : Wgt (Rack I N)) (δ : ℝ)
|
| 15 |
+
(hδ : 0≤δ) (hh : |avg unif p|≤δ) (h : ∀ f:Vec E,f≠0 →
|
| 16 |
+
|avg unif (fun i=>phasedBy (ledgerM E f) i*p i)|≤bp (-(N:ℝ)/2)) :
|
| 17 |
+
|partMean (fun x=>traced x E t) p|≤δ+bp (-(N:ℝ)/2) := by
|
| 18 |
+
classical
|
| 19 |
+
have he (f : Vec E) :
|
| 20 |
+
|vectorPhase f t*avg unif (fun i : Rack I N=>phasedBy (ledgerM E f) i*p i)|≤ δ+bp (-(N:ℝ)/2) := by
|
| 21 |
+
rw [abs_mul,vectorPhase,wsign_abs,one_mul]
|
| 22 |
+
by_cases hz : f=0
|
| 23 |
+
· subst f; simpa only [ledger_zero,layer_zero,one_mul] using hh.trans (le_add_of_nonneg_right (bp_pos (-(N:ℝ)/2)).le)
|
| 24 |
+
exact (h f hz).trans (le_add_of_nonneg_left hδ)
|
| 25 |
+
have hf : partMean (fun x=>traced x E t) p=avg unif (fun f:Vec E => vectorPhase f t*avg unif
|
| 26 |
+
(fun i:Rack I N=>phasedBy (ledgerM E f) i*p i)) := by
|
| 27 |
+
unfold partMean; simp_rw [rail_expand,←avg_mul]
|
| 28 |
+
rw [avg_avg]; simp_rw [←avg_mul']; exact avg_congr (fun i _=>avg_congr fun j _=>by ring)
|
| 29 |
+
rw [hf]
|
| 30 |
+
exact (abs_avg_le unif_law.nz).trans (unif_law.avg_le he)
|
| 31 |
+
namespace Template
|
| 32 |
+
variable (v : Template p I)
|
| 33 |
+
|
| 34 |
+
theorem pack_bound (v : Template p I) (j : I) (U : Wgt (Keys (p:=p) v.t N))
|
| 35 |
+
(hU : ∀ i, |U i|≤1) (i) : |packSecs v j U i| ≤1 := by
|
| 36 |
+
unfold packSecs; rw [Finset.abs_prod]
|
| 37 |
+
exact (Finset.prod_le_prod₀ (fun i _=>abs_nonneg _) (fun i _ => hU _)).trans_eq (by simp)
|
| 38 |
+
|
| 39 |
+
set_option maxHeartbeats 800000 in
|
| 40 |
+
theorem lopsided (v : Template p I) (j : I) (q : I→F)
|
| 41 |
+
(U : Wgt (Keys (p:=p) v.t N)) (δ : ℝ) (hδ : 0≤δ)
|
| 42 |
+
(hU : ∀ x,|U x|≤1) (h : chairCut v j U δ)
|
| 43 |
+
(hW : carried U (ownPart (p:=p) v.t q))
|
| 44 |
+
(Z : GeoM v.seam) :
|
| 45 |
+
|partMean (gramPart Z) (packSecs v j U)|≤δ+bp (-(N:ℝ)/2) := by
|
| 46 |
+
classical
|
| 47 |
+
let P := packSecs v j U
|
| 48 |
+
let Q := gramPart Z (N:=N)
|
| 49 |
+
have hb := bp_pos (-(N:ℝ)/2)
|
| 50 |
+
by_cases hp : ∃ x,Q x∧P x≠0
|
| 51 |
+
· obtain ⟨x,hx,hP⟩ := hp
|
| 52 |
+
let E := cantRail v j
|
| 53 |
+
let T (y : v.PackStack N) := traced y E (cantVec v j Z)
|
| 54 |
+
have hg i : ind (Q i)*P i=ind (T i)*P i := by
|
| 55 |
+
by_cases hh : P i=0
|
| 56 |
+
· rw [hh,mul_zero,mul_zero]
|
| 57 |
+
rw [show Q i=T i from propext
|
| 58 |
+
(cant_bridge v j q Z x i (pack_gate v j q U hW hP) (pack_gate v j q U hW hh) hx)]
|
| 59 |
+
change |avg unif (fun x => ind (Q x)*P x)|≤_
|
| 60 |
+
simp_rw [hg]
|
| 61 |
+
exact stip_mask E (cantVec v j Z) P δ hδ (global_quart v j U hU δ h) (cant_leak v j U hU)
|
| 62 |
+
have hh (x) : ind (Q x)*P x=0 := by
|
| 63 |
+
by_cases he : Q x <;> simp only [he,ind_true,ind_false,one_mul,zero_mul]
|
| 64 |
+
exact not_ne_iff.mp (fun hx => hp ⟨x,he,hx⟩)
|
| 65 |
+
change |avg unif (fun x=>ind (Q x)*P x)|≤_
|
| 66 |
+
simp_rw [hh,avg_zero,abs_zero]
|
| 67 |
+
exact add_nonneg hδ hb.le
|
| 68 |
+
|
| 69 |
+
set_option maxHeartbeats 800000 in
|
| 70 |
+
theorem pack_hot (v : Template p I) (j : I) (q : I→F) (U : Wgt (Keys (p:=p) v.t N))
|
| 71 |
+
(δ : ℝ) (hδ : 0≤δ) (hU : ∀ x, |U x|≤1) (h : chairCut v j U δ)
|
| 72 |
+
(hW : carried U (ownPart (p:=p) v.t q))
|
| 73 |
+
(Z : GeoM v.seam) (k : ℝ) (hk : ∀ i,num (Port v.seam i)≤ k)
|
| 74 |
+
(hN : 2*k-(N:ℝ) ≤ -1) :
|
| 75 |
+
let W := netFact v.seam
|
| 76 |
+
|avg (rackStation Z N) (packSecs v j U)|≤
|
| 77 |
+
2*W*(num (Ports p)*(2*bp (k-N)))+W*(δ+bp (-(N:ℝ)/2)) := by
|
| 78 |
+
classical
|
| 79 |
+
intro W
|
| 80 |
+
let B := pr unif (gramPart Z (N:=N))
|
| 81 |
+
have hb := wave_norm Z N (fun i => by linarith only [hN,hk i])
|
| 82 |
+
have h0 : 0<W := netFact_pos
|
| 83 |
+
have he : 0<B := (inv_pos_of_pos h0).trans_le hb
|
| 84 |
+
let V := packSecs v j U
|
| 85 |
+
let D := avg (rackWave Z N) V
|
| 86 |
+
have hl := lopsided v j q U δ hδ hU h hW Z
|
| 87 |
+
rw [part_reset _ _ he,abs_mul,abs_of_nonneg he.le] at hl
|
| 88 |
+
have hh :
|
| 89 |
+
|D| ≤ W*(δ+bp (-(N:ℝ)/2)) := by
|
| 90 |
+
apply le_of_mul_le_mul_left _ (inv_pos_of_pos h0)
|
| 91 |
+
exact (le_trans (mul_le_mul_of_nonneg_right hb (abs_nonneg _)) hl).trans_eq (by field_simp)
|
| 92 |
+
let A := avg (rackStation Z N) V
|
| 93 |
+
have hs := compare_station Z V (pack_bound v j U hU) k hk hN
|
| 94 |
+
change |A|≤_
|
| 95 |
+
exact le_trans (by simpa only [sub_zero] using (abs_sub_le A D 0)) (add_le_add hs hh)
|
| 96 |
+
end Template
|
| 97 |
+
end HadwigerCounterexample
|
| 98 |
+
|
| 99 |
+
end
|
| 100 |
+
|
| 101 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalLargeSetHits.lean
CHANGED
|
@@ -1,106 +1,106 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.SimultaneousProjection
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditional Large Set Hits -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix LinearMap Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
variable {p:Shape} {M n N K r s0:ℕ}
|
| 13 |
-
namespace StatusAnalysis
|
| 14 |
-
namespace Quill
|
| 15 |
-
variable {q:Format} {d:Rates} {b:Bool} (w:Quill p q d b) (t : Tagging p (Messenger q))
|
| 16 |
-
(z:Messenger q→F) (m:Mixer p n)
|
| 17 |
-
|
| 18 |
-
def prelim (K:ℕ) (s:Charts p n d) (i:Messenger q) :=
|
| 19 |
-
d (parcel b i)≤ K^2 ∧ Injective (s (parcel b i)) ∧
|
| 20 |
-
∀ x,totalRank (s (parcel b i) x)≤ K
|
| 21 |
-
|
| 22 |
-
def sameInk (i:Messenger q) (v: Magazine p (d (parcel b i))) :=
|
| 23 |
-
Appearance.nearly p (w.amp i).1 (w.amp i).2.1 v
|
| 24 |
-
|
| 25 |
-
structure steady (K:ℕ) (s:Charts p n d) (o: UnitType p n N) : Prop where
|
| 26 |
-
frame : PreparationParameters.frameSide p m o
|
| 27 |
-
steadyAxes (i:Messenger q) : prelim (b:=b) K s i
|
| 28 |
-
enough i : (w.amp i).1.diagO=(w.amp i).2.1.1
|
| 29 |
-
sufficesP i :
|
| 30 |
-
let j:= parcel b i; let x:=w.allure t z i
|
| 31 |
-
carried (w.policies t z n i) (fun y=> w.sameInk i (x.profile j o m (s j) y) →
|
| 32 |
-
x.profile j o m (s j) y=w.amp i)
|
| 33 |
-
|
| 34 |
-
set_option maxHeartbeats 800000 in
|
| 35 |
-
theorem thinGlaze (Y : Silhouette p N r) (o : UnitType p n N) (i : Messenger q)
|
| 36 |
-
(s : Charts p n d) (k:AtomKey (p:=p) (t i) N)
|
| 37 |
-
{δ : ℝ} (hd:0<δ)
|
| 38 |
-
(hw:w.moral t z) (hp : w.steady t z m K s o)
|
| 39 |
-
(he : gauze p δ δ Y m K o) (ht : 1≤p.r) (hn : 2*p.r≤n) :
|
| 40 |
-
let x:=w.allure t z i
|
| 41 |
-
δ ≤ x.reference Y (Y (t i) (z i) k) →
|
| 42 |
-
basebeta p K/2 ≤ w.seraph t z o m s Y i k := by
|
| 43 |
-
classical
|
| 44 |
-
intro x h
|
| 45 |
-
let j:=parcel b i
|
| 46 |
-
let z':= w.amp i; let a:=Y (t i) (z i) k
|
| 47 |
-
let μ:=x.reflected Y j o m (s j) a
|
| 48 |
-
have hx : x.apt := w.allure_apt t z hw i
|
| 49 |
-
have hm : IsLaw μ:= x.reflectedLaw Y (Appearance.witLaw hx ht hn) _ _ _ _ _
|
| 50 |
-
obtain ⟨h1,h2,h3⟩:=hp.steadyAxes i
|
| 51 |
-
have hh := x.demonstrates Y o (m:=m) (s j) K j a δ hd z'.1 z'.2.1.2 (hw.2.2 i)
|
| 52 |
-
(hw.2.1 i) ht hn h (he _) h1 h2 h3
|
| 53 |
-
have hq (y) (h:μ y≠0) (hz:w.sameInk i y): y=w.amp i := by
|
| 54 |
-
let P := fun x=>w.sameInk i x → x=w.amp i
|
| 55 |
-
have hb : carried μ P:= x.reflection_exact Y j o m (s j) a P (hp.sufficesP i)
|
| 56 |
-
exact (show P y from not_not.mp fun hi=>h (hb y hi)) hz
|
| 57 |
-
have h4 : (z'.1.diagO,z'.2.1.2)=z'.2.1 := Prod.ext (hp.enough i) rfl
|
| 58 |
-
rw [h4] at hh
|
| 59 |
-
exact hh.trans ((pr_on_mono hm.nz hq).trans_eq (pr_point' ..))
|
| 60 |
-
|
| 61 |
-
theorem tinyCell_loss (Y:Silhouette p N r) {δ:ℝ} (hd:0≤δ) (i : Messenger q)
|
| 62 |
-
(hN: 2*num (Messenger q×Toast p)-(N:ℝ)≤ -1)
|
| 63 |
-
(hh:2*num (Toast p)-(N:ℝ)≤ -1) :
|
| 64 |
-
let x:= w.allure t z i
|
| 65 |
-
let μ:=lawNu p N t z
|
| 66 |
-
pr μ (fun y=> x.reference Y (Y (t i) (z i) (y i)) < δ) ≤
|
| 67 |
-
r*δ+2*netFact (trayPort p t)*bp (-(N:ℝ)/2) := by
|
| 68 |
-
classical
|
| 69 |
-
intro a μ
|
| 70 |
-
let I:=Messenger q
|
| 71 |
-
let Ω:=fun i=> lawOmega p N (t i) (z i)
|
| 72 |
-
let S:=fun y=>a.reference Y (Y (t i) (z i) y)<δ
|
| 73 |
-
let f : ∀ i:Messenger q,Wgt (AtomKey (p:=p) (t i) N) := fun j=>
|
| 74 |
-
if h:j=i then h ▸ (fun x : AtomKey (p:=p) (t i) N=> ind (S x)) else fun _=>1
|
| 75 |
-
have hi : f i=fun x=>ind (S x) := by unfold f; simp
|
| 76 |
-
have hf j (h:j≠i) : f j=fun _ => 1 := by unfold f; simp [h]
|
| 77 |
-
have hg j x : |f j x| ≤ 1 := by
|
| 78 |
-
by_cases h:j=i
|
| 79 |
-
· subst j; rw [hi]; exact (abs_of_nonneg (ind_nonneg _)).le.trans (ind_le_one _)
|
| 80 |
-
rw [hf j h]; simp
|
| 81 |
-
have he x : prodW f x= ind (S (x i)) := by
|
| 82 |
-
unfold prodW; rw [Finset.prod_eq_single i _ (by simp),hi]
|
| 83 |
-
intro b _ hb; rw [hf _ hb]
|
| 84 |
-
have hR :
|
| 85 |
-
∏ i,avg (Ω i) (f i) = pr (Ω i) S := by
|
| 86 |
-
rw [Finset.prod_eq_single i _ (by simp),hi]; rfl
|
| 87 |
-
intro b _ hb; rw [hf _ hb,(omegaLaw _ _ _ hh).avg_const]
|
| 88 |
-
let L:=2*netFact (trayPort p t)*bp (-(N:ℝ)/2)
|
| 89 |
-
have hM : pr μ (fun x=> S (x i)) ≤ pr (Ω i) S+L := by
|
| 90 |
-
have hm := reference_product t z f hg hN
|
| 91 |
-
change |avg μ (prodW f)-∏ i,avg (Ω i) (f i)|≤L at hm
|
| 92 |
-
rw [show prodW f=(fun x=>ind (S (x i))) from funext he,hR] at hm
|
| 93 |
-
exact sub_le_iff_le_add'.mp ((abs_le.mp hm).2)
|
| 94 |
-
have hZ : pr (Ω i) S ≤ r*δ := by
|
| 95 |
-
let Q:=fun x=> a.reference Y x < δ
|
| 96 |
-
rw [show pr (Ω i) S= pr (a.reference Y) Q from (mapW_pr (Ω i) (Y (t i) (z i)) Q).symm]
|
| 97 |
-
exact haze_small _ δ hd
|
| 98 |
-
exact hM.trans (add_le_add_left hZ _)
|
| 99 |
-
|
| 100 |
-
end Quill
|
| 101 |
-
end StatusAnalysis
|
| 102 |
-
end HadwigerCounterexample
|
| 103 |
-
|
| 104 |
-
end
|
| 105 |
-
|
| 106 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.SimultaneousProjection
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditional Large Set Hits -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix LinearMap Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
variable {p:Shape} {M n N K r s0:ℕ}
|
| 13 |
+
namespace StatusAnalysis
|
| 14 |
+
namespace Quill
|
| 15 |
+
variable {q:Format} {d:Rates} {b:Bool} (w:Quill p q d b) (t : Tagging p (Messenger q))
|
| 16 |
+
(z:Messenger q→F) (m:Mixer p n)
|
| 17 |
+
|
| 18 |
+
def prelim (K:ℕ) (s:Charts p n d) (i:Messenger q) :=
|
| 19 |
+
d (parcel b i)≤ K^2 ∧ Injective (s (parcel b i)) ∧
|
| 20 |
+
∀ x,totalRank (s (parcel b i) x)≤ K
|
| 21 |
+
|
| 22 |
+
def sameInk (i:Messenger q) (v: Magazine p (d (parcel b i))) :=
|
| 23 |
+
Appearance.nearly p (w.amp i).1 (w.amp i).2.1 v
|
| 24 |
+
|
| 25 |
+
structure steady (K:ℕ) (s:Charts p n d) (o: UnitType p n N) : Prop where
|
| 26 |
+
frame : PreparationParameters.frameSide p m o
|
| 27 |
+
steadyAxes (i:Messenger q) : prelim (b:=b) K s i
|
| 28 |
+
enough i : (w.amp i).1.diagO=(w.amp i).2.1.1
|
| 29 |
+
sufficesP i :
|
| 30 |
+
let j:= parcel b i; let x:=w.allure t z i
|
| 31 |
+
carried (w.policies t z n i) (fun y=> w.sameInk i (x.profile j o m (s j) y) →
|
| 32 |
+
x.profile j o m (s j) y=w.amp i)
|
| 33 |
+
|
| 34 |
+
set_option maxHeartbeats 800000 in
|
| 35 |
+
theorem thinGlaze (Y : Silhouette p N r) (o : UnitType p n N) (i : Messenger q)
|
| 36 |
+
(s : Charts p n d) (k:AtomKey (p:=p) (t i) N)
|
| 37 |
+
{δ : ℝ} (hd:0<δ)
|
| 38 |
+
(hw:w.moral t z) (hp : w.steady t z m K s o)
|
| 39 |
+
(he : gauze p δ δ Y m K o) (ht : 1≤p.r) (hn : 2*p.r≤n) :
|
| 40 |
+
let x:=w.allure t z i
|
| 41 |
+
δ ≤ x.reference Y (Y (t i) (z i) k) →
|
| 42 |
+
basebeta p K/2 ≤ w.seraph t z o m s Y i k := by
|
| 43 |
+
classical
|
| 44 |
+
intro x h
|
| 45 |
+
let j:=parcel b i
|
| 46 |
+
let z':= w.amp i; let a:=Y (t i) (z i) k
|
| 47 |
+
let μ:=x.reflected Y j o m (s j) a
|
| 48 |
+
have hx : x.apt := w.allure_apt t z hw i
|
| 49 |
+
have hm : IsLaw μ:= x.reflectedLaw Y (Appearance.witLaw hx ht hn) _ _ _ _ _
|
| 50 |
+
obtain ⟨h1,h2,h3⟩:=hp.steadyAxes i
|
| 51 |
+
have hh := x.demonstrates Y o (m:=m) (s j) K j a δ hd z'.1 z'.2.1.2 (hw.2.2 i)
|
| 52 |
+
(hw.2.1 i) ht hn h (he _) h1 h2 h3
|
| 53 |
+
have hq (y) (h:μ y≠0) (hz:w.sameInk i y): y=w.amp i := by
|
| 54 |
+
let P := fun x=>w.sameInk i x → x=w.amp i
|
| 55 |
+
have hb : carried μ P:= x.reflection_exact Y j o m (s j) a P (hp.sufficesP i)
|
| 56 |
+
exact (show P y from not_not.mp fun hi=>h (hb y hi)) hz
|
| 57 |
+
have h4 : (z'.1.diagO,z'.2.1.2)=z'.2.1 := Prod.ext (hp.enough i) rfl
|
| 58 |
+
rw [h4] at hh
|
| 59 |
+
exact hh.trans ((pr_on_mono hm.nz hq).trans_eq (pr_point' ..))
|
| 60 |
+
|
| 61 |
+
theorem tinyCell_loss (Y:Silhouette p N r) {δ:ℝ} (hd:0≤δ) (i : Messenger q)
|
| 62 |
+
(hN: 2*num (Messenger q×Toast p)-(N:ℝ)≤ -1)
|
| 63 |
+
(hh:2*num (Toast p)-(N:ℝ)≤ -1) :
|
| 64 |
+
let x:= w.allure t z i
|
| 65 |
+
let μ:=lawNu p N t z
|
| 66 |
+
pr μ (fun y=> x.reference Y (Y (t i) (z i) (y i)) < δ) ≤
|
| 67 |
+
r*δ+2*netFact (trayPort p t)*bp (-(N:ℝ)/2) := by
|
| 68 |
+
classical
|
| 69 |
+
intro a μ
|
| 70 |
+
let I:=Messenger q
|
| 71 |
+
let Ω:=fun i=> lawOmega p N (t i) (z i)
|
| 72 |
+
let S:=fun y=>a.reference Y (Y (t i) (z i) y)<δ
|
| 73 |
+
let f : ∀ i:Messenger q,Wgt (AtomKey (p:=p) (t i) N) := fun j=>
|
| 74 |
+
if h:j=i then h ▸ (fun x : AtomKey (p:=p) (t i) N=> ind (S x)) else fun _=>1
|
| 75 |
+
have hi : f i=fun x=>ind (S x) := by unfold f; simp
|
| 76 |
+
have hf j (h:j≠i) : f j=fun _ => 1 := by unfold f; simp [h]
|
| 77 |
+
have hg j x : |f j x| ≤ 1 := by
|
| 78 |
+
by_cases h:j=i
|
| 79 |
+
· subst j; rw [hi]; exact (abs_of_nonneg (ind_nonneg _)).le.trans (ind_le_one _)
|
| 80 |
+
rw [hf j h]; simp
|
| 81 |
+
have he x : prodW f x= ind (S (x i)) := by
|
| 82 |
+
unfold prodW; rw [Finset.prod_eq_single i _ (by simp),hi]
|
| 83 |
+
intro b _ hb; rw [hf _ hb]
|
| 84 |
+
have hR :
|
| 85 |
+
∏ i,avg (Ω i) (f i) = pr (Ω i) S := by
|
| 86 |
+
rw [Finset.prod_eq_single i _ (by simp),hi]; rfl
|
| 87 |
+
intro b _ hb; rw [hf _ hb,(omegaLaw _ _ _ hh).avg_const]
|
| 88 |
+
let L:=2*netFact (trayPort p t)*bp (-(N:ℝ)/2)
|
| 89 |
+
have hM : pr μ (fun x=> S (x i)) ≤ pr (Ω i) S+L := by
|
| 90 |
+
have hm := reference_product t z f hg hN
|
| 91 |
+
change |avg μ (prodW f)-∏ i,avg (Ω i) (f i)|≤L at hm
|
| 92 |
+
rw [show prodW f=(fun x=>ind (S (x i))) from funext he,hR] at hm
|
| 93 |
+
exact sub_le_iff_le_add'.mp ((abs_le.mp hm).2)
|
| 94 |
+
have hZ : pr (Ω i) S ≤ r*δ := by
|
| 95 |
+
let Q:=fun x=> a.reference Y x < δ
|
| 96 |
+
rw [show pr (Ω i) S= pr (a.reference Y) Q from (mapW_pr (Ω i) (Y (t i) (z i)) Q).symm]
|
| 97 |
+
exact haze_small _ δ hd
|
| 98 |
+
exact hM.trans (add_le_add_left hZ _)
|
| 99 |
+
|
| 100 |
+
end Quill
|
| 101 |
+
end StatusAnalysis
|
| 102 |
+
end HadwigerCounterexample
|
| 103 |
+
|
| 104 |
+
end
|
| 105 |
+
|
| 106 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProductLaws.lean
CHANGED
|
@@ -1,125 +1,125 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioning
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditional Product Laws -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
|
| 11 |
-
variable {A B I : Type} [Fintype A] [Fintype B]
|
| 12 |
-
|
| 13 |
-
theorem subLaw_pair {w : Wgt A} {v : Wgt B} (hw : SubLaw w) (hv : SubLaw v) :
|
| 14 |
-
SubLaw (pairW w v) := by
|
| 15 |
-
refine ⟨fun x => mul_nonneg (hw.nz _) (hv.nz _),?_⟩
|
| 16 |
-
rw [pairW_tot]
|
| 17 |
-
exact (mul_le_mul hw.total hv.total (tot_nonneg hv.nz) (by norm_num)).trans_eq (one_mul _)
|
| 18 |
-
|
| 19 |
-
theorem pair_unif :
|
| 20 |
-
unif (α:=A×B) = pairW unif unif := by
|
| 21 |
-
funext x; simp [pairW,unif_apply,mul_comm]
|
| 22 |
-
|
| 23 |
-
theorem unifOn_slice (p : A × B → Prop) (x : A) (y : B) :
|
| 24 |
-
unifOn p (x,y) =
|
| 25 |
-
mapW (unifOn p) Prod.fst x * unifOn (fun y => p (x,y)) y := by
|
| 26 |
-
classical
|
| 27 |
-
have hm : mapW (unifOn p) Prod.fst x =
|
| 28 |
-
nbr (fun y => p (x,y)) / nbr p := by
|
| 29 |
-
simp only [mapW,pr,avg,Fintype.sum_prod_type,unifOn_val, nbr,tot]
|
| 30 |
-
rw [Finset.sum_eq_single x]
|
| 31 |
-
· simp [ind_true,div_eq_mul_inv,Finset.sum_mul]
|
| 32 |
-
· intro b _ hb
|
| 33 |
-
simp [ind,hb]
|
| 34 |
-
· simp
|
| 35 |
-
rw [hm,unifOn_val,unifOn_val]
|
| 36 |
-
by_cases h : p (x,y)
|
| 37 |
-
· have hh {A : Type} [Fintype A] (p : A → Prop) (x : A) (hx : p x) : 0 < nbr p := by
|
| 38 |
-
have hp := weight_le_tot (fun y => ind_nonneg (p y)) x
|
| 39 |
-
exact lt_of_lt_of_le (ind_one hx ▸ zero_lt_one) hp
|
| 40 |
-
rw [ind_one h]
|
| 41 |
-
have hv := hh _ _ h
|
| 42 |
-
have hw := hh (fun y => p (x,y)) _ h
|
| 43 |
-
field_simp
|
| 44 |
-
· rw [ind_zero h]
|
| 45 |
-
ring
|
| 46 |
-
|
| 47 |
-
theorem unifOn_and (p q : A → Prop) :
|
| 48 |
-
onW (unifOn p) q = unifOn (fun x => p x ∧ q x) := by
|
| 49 |
-
classical
|
| 50 |
-
have hp : pr (unifOn p) q = nbr (fun x => p x ∧ q x) / nbr p := by
|
| 51 |
-
simp only [pr,avg,unifOn_val,div_eq_mul_inv,ind_and,nbr,tot,Finset.sum_mul]
|
| 52 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 53 |
-
ring
|
| 54 |
-
funext x
|
| 55 |
-
rw [onW_val,hp,unifOn_val,unifOn_val,ind_and]
|
| 56 |
-
by_cases h : p x
|
| 57 |
-
· by_cases g : q x
|
| 58 |
-
· have hl (p : A → Prop) (h : p x) : 0 < nbr p :=
|
| 59 |
-
lt_of_lt_of_le (ind_one h ▸ zero_lt_one) (weight_le_tot (fun y => ind_nonneg (p y)) x)
|
| 60 |
-
have hh := hl p h
|
| 61 |
-
have hg := hl (fun x => p x ∧ q x) ⟨h,g⟩
|
| 62 |
-
field_simp
|
| 63 |
-
· rw [ind_zero g]
|
| 64 |
-
ring
|
| 65 |
-
· rw [ind_zero h]
|
| 66 |
-
ring
|
| 67 |
-
|
| 68 |
-
theorem unifOn_and_prod (p : A → Prop) (q : B → Prop) :
|
| 69 |
-
unifOn (fun x : A × B => p x.1 ∧ q x.2) = pairW (unifOn p) (unifOn q) := by
|
| 70 |
-
have h :
|
| 71 |
-
nbr (fun x : A × B => p x.1 ∧ q x.2) = nbr p * nbr q := by
|
| 72 |
-
change tot _ = _ * _
|
| 73 |
-
simp_rw [ind_and]
|
| 74 |
-
exact pairW_tot (fun x => ind (p x)) (fun y => ind (q y))
|
| 75 |
-
funext x
|
| 76 |
-
simp only [pairW,unifOn_val,h,ind_and]
|
| 77 |
-
ring_nf
|
| 78 |
-
|
| 79 |
-
theorem pr_cap {w v : Wgt A} {c : ℝ} (h : ∀ x, w x ≤ c*v x) (p : A → Prop) :
|
| 80 |
-
pr w p ≤ c*pr v p := calc
|
| 81 |
-
_ ≤ pr (fun x => c*v x) p := pr_mono_left (w:=w) (v:=fun x => c*v x) h _
|
| 82 |
-
_ = _ := by simp only [pr,avg,Finset.mul_sum,mul_assoc]
|
| 83 |
-
|
| 84 |
-
def semi (w : Wgt A) (k : A → Wgt B) : Wgt (A × B) := fun x => w x.1 * k x.1 x.2
|
| 85 |
-
|
| 86 |
-
theorem semi_avg (w : Wgt A) (k : A → Wgt B) (f : A × B → ℝ) :
|
| 87 |
-
avg (semi w k) f = avg w (fun x => avg (k x) (fun y => f (x,y))) := by
|
| 88 |
-
simp only [avg,semi,Fintype.sum_prod_type,Finset.mul_sum,mul_assoc]
|
| 89 |
-
|
| 90 |
-
theorem pair_semi_avg (w w' : Wgt A) (k k' : A → Wgt B) (f : (A × B) × (A × B) → ℝ) :
|
| 91 |
-
avg (pairW (semi w k) (semi w' k')) f =
|
| 92 |
-
avg (pairW w w') (fun x =>
|
| 93 |
-
avg (pairW (k x.1) (k' x.2)) (fun y => f ((x.1,y.1), (x.2,y.2)))) := by
|
| 94 |
-
simp only [pairW_avg, semi_avg]
|
| 95 |
-
refine avg_congr fun x _ => ?_
|
| 96 |
-
exact avg_avg _ _ _
|
| 97 |
-
|
| 98 |
-
theorem pair_semi_pr (w w' : Wgt A) (k k' : A → Wgt B) (p : A × A → Prop) (q : B × B → Prop) :
|
| 99 |
-
pr (pairW (semi w k) (semi w' k')) (fun x => p (x.1.1,x.2.1) ∧ q (x.1.2,x.2.2)) =
|
| 100 |
-
avg (pairW w w') (fun x => ind (p x) * pr (pairW (k x.1) (k' x.2)) q) := by
|
| 101 |
-
unfold pr
|
| 102 |
-
rw [pair_semi_avg]
|
| 103 |
-
simp_rw [ind_and]
|
| 104 |
-
refine avg_congr fun x _ => ?_
|
| 105 |
-
exact avg_mul' _ _ _
|
| 106 |
-
|
| 107 |
-
variable [Fintype I] [DecidableEq I]
|
| 108 |
-
|
| 109 |
-
/-- Reassociate two arrays of independent columns into componentwise independent pairs. -/
|
| 110 |
-
theorem prodW_pair_pr (w v : I → Wgt A) (p : I → A × A → Prop) :
|
| 111 |
-
pr (pairW (prodW w) (prodW v)) (fun x => ∀ i, p i (x.1 i,x.2 i)) =
|
| 112 |
-
∏ i, pr (pairW (w i) (v i)) (p i) := by
|
| 113 |
-
simp_rw [pr,ind_all,pairW_avg]
|
| 114 |
-
have hx (x : I → A) :
|
| 115 |
-
avg (prodW v) (fun y => ∏ i, ind (p i (x i,y i))) =
|
| 116 |
-
∏ i, avg (v i) (fun y => ind (p i (x i,y))) :=
|
| 117 |
-
prodW_avg _ (fun i y => ind (p i (x i,y)))
|
| 118 |
-
simp_rw [hx]
|
| 119 |
-
exact prodW_avg w (fun i x => avg (v i) (fun y => ind (p i (x,y))))
|
| 120 |
-
|
| 121 |
-
end HadwigerCounterexample
|
| 122 |
-
|
| 123 |
-
end
|
| 124 |
-
|
| 125 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteConditioning
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditional Product Laws -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
|
| 11 |
+
variable {A B I : Type} [Fintype A] [Fintype B]
|
| 12 |
+
|
| 13 |
+
theorem subLaw_pair {w : Wgt A} {v : Wgt B} (hw : SubLaw w) (hv : SubLaw v) :
|
| 14 |
+
SubLaw (pairW w v) := by
|
| 15 |
+
refine ⟨fun x => mul_nonneg (hw.nz _) (hv.nz _),?_⟩
|
| 16 |
+
rw [pairW_tot]
|
| 17 |
+
exact (mul_le_mul hw.total hv.total (tot_nonneg hv.nz) (by norm_num)).trans_eq (one_mul _)
|
| 18 |
+
|
| 19 |
+
theorem pair_unif :
|
| 20 |
+
unif (α:=A×B) = pairW unif unif := by
|
| 21 |
+
funext x; simp [pairW,unif_apply,mul_comm]
|
| 22 |
+
|
| 23 |
+
theorem unifOn_slice (p : A × B → Prop) (x : A) (y : B) :
|
| 24 |
+
unifOn p (x,y) =
|
| 25 |
+
mapW (unifOn p) Prod.fst x * unifOn (fun y => p (x,y)) y := by
|
| 26 |
+
classical
|
| 27 |
+
have hm : mapW (unifOn p) Prod.fst x =
|
| 28 |
+
nbr (fun y => p (x,y)) / nbr p := by
|
| 29 |
+
simp only [mapW,pr,avg,Fintype.sum_prod_type,unifOn_val, nbr,tot]
|
| 30 |
+
rw [Finset.sum_eq_single x]
|
| 31 |
+
· simp [ind_true,div_eq_mul_inv,Finset.sum_mul]
|
| 32 |
+
· intro b _ hb
|
| 33 |
+
simp [ind,hb]
|
| 34 |
+
· simp
|
| 35 |
+
rw [hm,unifOn_val,unifOn_val]
|
| 36 |
+
by_cases h : p (x,y)
|
| 37 |
+
· have hh {A : Type} [Fintype A] (p : A → Prop) (x : A) (hx : p x) : 0 < nbr p := by
|
| 38 |
+
have hp := weight_le_tot (fun y => ind_nonneg (p y)) x
|
| 39 |
+
exact lt_of_lt_of_le (ind_one hx ▸ zero_lt_one) hp
|
| 40 |
+
rw [ind_one h]
|
| 41 |
+
have hv := hh _ _ h
|
| 42 |
+
have hw := hh (fun y => p (x,y)) _ h
|
| 43 |
+
field_simp
|
| 44 |
+
· rw [ind_zero h]
|
| 45 |
+
ring
|
| 46 |
+
|
| 47 |
+
theorem unifOn_and (p q : A → Prop) :
|
| 48 |
+
onW (unifOn p) q = unifOn (fun x => p x ∧ q x) := by
|
| 49 |
+
classical
|
| 50 |
+
have hp : pr (unifOn p) q = nbr (fun x => p x ∧ q x) / nbr p := by
|
| 51 |
+
simp only [pr,avg,unifOn_val,div_eq_mul_inv,ind_and,nbr,tot,Finset.sum_mul]
|
| 52 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 53 |
+
ring
|
| 54 |
+
funext x
|
| 55 |
+
rw [onW_val,hp,unifOn_val,unifOn_val,ind_and]
|
| 56 |
+
by_cases h : p x
|
| 57 |
+
· by_cases g : q x
|
| 58 |
+
· have hl (p : A → Prop) (h : p x) : 0 < nbr p :=
|
| 59 |
+
lt_of_lt_of_le (ind_one h ▸ zero_lt_one) (weight_le_tot (fun y => ind_nonneg (p y)) x)
|
| 60 |
+
have hh := hl p h
|
| 61 |
+
have hg := hl (fun x => p x ∧ q x) ⟨h,g⟩
|
| 62 |
+
field_simp
|
| 63 |
+
· rw [ind_zero g]
|
| 64 |
+
ring
|
| 65 |
+
· rw [ind_zero h]
|
| 66 |
+
ring
|
| 67 |
+
|
| 68 |
+
theorem unifOn_and_prod (p : A → Prop) (q : B → Prop) :
|
| 69 |
+
unifOn (fun x : A × B => p x.1 ∧ q x.2) = pairW (unifOn p) (unifOn q) := by
|
| 70 |
+
have h :
|
| 71 |
+
nbr (fun x : A × B => p x.1 ∧ q x.2) = nbr p * nbr q := by
|
| 72 |
+
change tot _ = _ * _
|
| 73 |
+
simp_rw [ind_and]
|
| 74 |
+
exact pairW_tot (fun x => ind (p x)) (fun y => ind (q y))
|
| 75 |
+
funext x
|
| 76 |
+
simp only [pairW,unifOn_val,h,ind_and]
|
| 77 |
+
ring_nf
|
| 78 |
+
|
| 79 |
+
theorem pr_cap {w v : Wgt A} {c : ℝ} (h : ∀ x, w x ≤ c*v x) (p : A → Prop) :
|
| 80 |
+
pr w p ≤ c*pr v p := calc
|
| 81 |
+
_ ≤ pr (fun x => c*v x) p := pr_mono_left (w:=w) (v:=fun x => c*v x) h _
|
| 82 |
+
_ = _ := by simp only [pr,avg,Finset.mul_sum,mul_assoc]
|
| 83 |
+
|
| 84 |
+
def semi (w : Wgt A) (k : A → Wgt B) : Wgt (A × B) := fun x => w x.1 * k x.1 x.2
|
| 85 |
+
|
| 86 |
+
theorem semi_avg (w : Wgt A) (k : A → Wgt B) (f : A × B → ℝ) :
|
| 87 |
+
avg (semi w k) f = avg w (fun x => avg (k x) (fun y => f (x,y))) := by
|
| 88 |
+
simp only [avg,semi,Fintype.sum_prod_type,Finset.mul_sum,mul_assoc]
|
| 89 |
+
|
| 90 |
+
theorem pair_semi_avg (w w' : Wgt A) (k k' : A → Wgt B) (f : (A × B) × (A × B) → ℝ) :
|
| 91 |
+
avg (pairW (semi w k) (semi w' k')) f =
|
| 92 |
+
avg (pairW w w') (fun x =>
|
| 93 |
+
avg (pairW (k x.1) (k' x.2)) (fun y => f ((x.1,y.1), (x.2,y.2)))) := by
|
| 94 |
+
simp only [pairW_avg, semi_avg]
|
| 95 |
+
refine avg_congr fun x _ => ?_
|
| 96 |
+
exact avg_avg _ _ _
|
| 97 |
+
|
| 98 |
+
theorem pair_semi_pr (w w' : Wgt A) (k k' : A → Wgt B) (p : A × A → Prop) (q : B × B → Prop) :
|
| 99 |
+
pr (pairW (semi w k) (semi w' k')) (fun x => p (x.1.1,x.2.1) ∧ q (x.1.2,x.2.2)) =
|
| 100 |
+
avg (pairW w w') (fun x => ind (p x) * pr (pairW (k x.1) (k' x.2)) q) := by
|
| 101 |
+
unfold pr
|
| 102 |
+
rw [pair_semi_avg]
|
| 103 |
+
simp_rw [ind_and]
|
| 104 |
+
refine avg_congr fun x _ => ?_
|
| 105 |
+
exact avg_mul' _ _ _
|
| 106 |
+
|
| 107 |
+
variable [Fintype I] [DecidableEq I]
|
| 108 |
+
|
| 109 |
+
/-- Reassociate two arrays of independent columns into componentwise independent pairs. -/
|
| 110 |
+
theorem prodW_pair_pr (w v : I → Wgt A) (p : I → A × A → Prop) :
|
| 111 |
+
pr (pairW (prodW w) (prodW v)) (fun x => ∀ i, p i (x.1 i,x.2 i)) =
|
| 112 |
+
∏ i, pr (pairW (w i) (v i)) (p i) := by
|
| 113 |
+
simp_rw [pr,ind_all,pairW_avg]
|
| 114 |
+
have hx (x : I → A) :
|
| 115 |
+
avg (prodW v) (fun y => ∏ i, ind (p i (x i,y i))) =
|
| 116 |
+
∏ i, avg (v i) (fun y => ind (p i (x i,y))) :=
|
| 117 |
+
prodW_avg _ (fun i y => ind (p i (x i,y)))
|
| 118 |
+
simp_rw [hx]
|
| 119 |
+
exact prodW_avg w (fun i x => avg (v i) (fun y => ind (p i (x,y))))
|
| 120 |
+
|
| 121 |
+
end HadwigerCounterexample
|
| 122 |
+
|
| 123 |
+
end
|
| 124 |
+
|
| 125 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalProjection.lean
CHANGED
|
@@ -1,96 +1,96 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.HistogramBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditional Projection -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C K : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 12 |
-
|
| 13 |
-
def dip (μ f g : Wgt A) := avg μ (fun i => f i*g i)
|
| 14 |
-
def ode (μ f : Wgt A) := dip μ f f
|
| 15 |
-
def cashbook (μ : Wgt A) (f : A→B) (g : Wgt A) :=
|
| 16 |
-
fun i => mapW (fun x => μ x*g x) f i / mapW μ f i
|
| 17 |
-
def banner (μ : Wgt A) (f : A→B) (g : Wgt A) := cashbook μ f g ∘ f
|
| 18 |
-
|
| 19 |
-
theorem ode_nonneg {μ : Wgt A} (hμ : ∀ i,0 ≤ μ i) (f : Wgt A) : 0≤ ode μ f :=
|
| 20 |
-
avg_nonneg hμ (fun _ => mul_self_nonneg _)
|
| 21 |
-
theorem ode_upper {μ : Wgt A} (hμ : SubLaw μ) (f : Wgt A) (B : ℝ)
|
| 22 |
-
(hf : ∀ i,|f i|≤B) : ode μ f ≤ B^2 := by
|
| 23 |
-
apply hμ.avg_le (sq_nonneg _)
|
| 24 |
-
intro i
|
| 25 |
-
exact (le_of_eq (Eq.symm (pow_two _))).trans
|
| 26 |
-
((le_of_eq (sq_abs (f i)).symm).trans (pow_le_pow_left₀ (abs_nonneg _) (hf i) 2))
|
| 27 |
-
|
| 28 |
-
theorem dip_sym (μ f g : Wgt A) : dip μ f g=dip μ g f := by unfold dip; simp only [mul_comm]
|
| 29 |
-
theorem dip_sub (μ f g h : Wgt A) :
|
| 30 |
-
dip μ (fun i=> f i-g i) h=dip μ f h-dip μ g h := by
|
| 31 |
-
unfold dip; simp only [sub_mul,avg_sub]
|
| 32 |
-
|
| 33 |
-
omit [Fintype B] in
|
| 34 |
-
theorem cashbook_bound (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A)
|
| 35 |
-
(b : ℝ) (hb : 0≤b) (h : ∀ i,|g i|≤b) (i) : |cashbook μ f g i| ≤ b := by
|
| 36 |
-
have he : cashbook μ f g i=avg (onW μ (fun x=>f x=i)) g := by
|
| 37 |
-
unfold cashbook onW
|
| 38 |
-
rw [avg_norm,subW_tot]
|
| 39 |
-
unfold mapW pr avg subW; congr 1
|
| 40 |
-
exact Finset.sum_congr rfl fun j _ => by ring
|
| 41 |
-
have hw : SubLaw (onW μ (fun x=>f x=i)) := normW_subLaw (subW_nonneg hμ _)
|
| 42 |
-
rw [he]
|
| 43 |
-
exact (abs_avg_le hw.nz).trans (hw.avg_le hb h)
|
| 44 |
-
|
| 45 |
-
theorem cash_orth (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A) (h : Wgt B) :
|
| 46 |
-
dip μ (banner μ f g) (h ∘ f)=dip μ g (h ∘ f) := by
|
| 47 |
-
classical
|
| 48 |
-
let w := fun x=> μ x*g x
|
| 49 |
-
have he : pour μ f (mapW w f) = fun i => μ i*banner μ f g i := rfl
|
| 50 |
-
have hz : lsupp w μ := fun _ hi => left_ne_zero_of_mul hi
|
| 51 |
-
have ht := map_pour μ f _ (hz.map hμ f)
|
| 52 |
-
rw [he] at ht
|
| 53 |
-
have hi := congrArg (fun w' => avg w' h) ht
|
| 54 |
-
simp_rw [mapW_avg] at hi
|
| 55 |
-
simpa only [w,dip,avg,mul_assoc,Function.comp_apply] using hi
|
| 56 |
-
|
| 57 |
-
theorem ode_step (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : Wgt A)
|
| 58 |
-
(p : A→B) (q : B→C) :
|
| 59 |
-
ode μ (banner μ p f)=ode μ (banner μ (q∘p) f)+
|
| 60 |
-
ode μ (fun i => banner μ p f i - banner μ (q∘p) f i) := by
|
| 61 |
-
classical
|
| 62 |
-
let g := banner μ p f; let h := banner μ (q ∘ p) f
|
| 63 |
-
have hh : ode μ h=dip μ g h :=
|
| 64 |
-
(cash_orth μ hμ (q∘p) f (cashbook μ (q∘p) f)).trans
|
| 65 |
-
(cash_orth μ hμ p f (cashbook μ (q∘p) f ∘ q)).symm
|
| 66 |
-
have hi i : (g i - h i)*(g i-h i)=g i*g i - 2*(g i*h i)+h i*h i := by ring
|
| 67 |
-
change ode μ g=ode μ h+dip μ (fun i => g i-h i) (fun i=>g i-h i)
|
| 68 |
-
unfold dip
|
| 69 |
-
simp_rw [hi,avg_add,avg_sub,avg_mul']
|
| 70 |
-
change ode μ g=ode μ h+(ode μ g-2*dip μ g h + ode μ h)
|
| 71 |
-
linarith only [hh]
|
| 72 |
-
|
| 73 |
-
theorem archive_gain {μ : Wgt A} (hw : SubLaw μ) (f : Wgt A)
|
| 74 |
-
(p : A→B) (q : B→ C)
|
| 75 |
-
(h : Wgt B) (hh : ∀ i:A,|h (p i)| ≤1) :
|
| 76 |
-
(dip μ (fun i => f i - banner μ (q∘p) f i) (h ∘ p))^2 ≤
|
| 77 |
-
ode μ (banner μ p f)-ode μ (banner μ (q∘p) f) := by
|
| 78 |
-
let u := banner μ p f; let v := banner μ (q∘p) f
|
| 79 |
-
let w i := u i-v i
|
| 80 |
-
rw [ode_step μ hw.nz f p q]
|
| 81 |
-
have he : dip μ (fun i=> f i - banner μ (q∘p) f i) (h∘p)=dip μ w (h∘p) := by
|
| 82 |
-
unfold w
|
| 83 |
-
rw [dip_sub,dip_sub,cash_orth μ hw.nz p f h]
|
| 84 |
-
have ht : ode μ (h∘p) ≤ 1 := (ode_upper hw (h∘p) 1 hh).trans_eq (by ring)
|
| 85 |
-
have hq : dip μ w (h∘p)^2≤ode μ w*ode μ (h∘p) := by
|
| 86 |
-
simpa only [ode,dip,pow_two] using avg_CS hw.nz w (h∘p)
|
| 87 |
-
rw [he]
|
| 88 |
-
apply le_trans hq
|
| 89 |
-
refine (mul_le_mul_of_nonneg_left ht (ode_nonneg hw.nz w)).trans_eq ?_
|
| 90 |
-
unfold w u v
|
| 91 |
-
ring
|
| 92 |
-
end HadwigerCounterexample
|
| 93 |
-
|
| 94 |
-
end
|
| 95 |
-
|
| 96 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.HistogramBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditional Projection -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C K : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 12 |
+
|
| 13 |
+
def dip (μ f g : Wgt A) := avg μ (fun i => f i*g i)
|
| 14 |
+
def ode (μ f : Wgt A) := dip μ f f
|
| 15 |
+
def cashbook (μ : Wgt A) (f : A→B) (g : Wgt A) :=
|
| 16 |
+
fun i => mapW (fun x => μ x*g x) f i / mapW μ f i
|
| 17 |
+
def banner (μ : Wgt A) (f : A→B) (g : Wgt A) := cashbook μ f g ∘ f
|
| 18 |
+
|
| 19 |
+
theorem ode_nonneg {μ : Wgt A} (hμ : ∀ i,0 ≤ μ i) (f : Wgt A) : 0≤ ode μ f :=
|
| 20 |
+
avg_nonneg hμ (fun _ => mul_self_nonneg _)
|
| 21 |
+
theorem ode_upper {μ : Wgt A} (hμ : SubLaw μ) (f : Wgt A) (B : ℝ)
|
| 22 |
+
(hf : ∀ i,|f i|≤B) : ode μ f ≤ B^2 := by
|
| 23 |
+
apply hμ.avg_le (sq_nonneg _)
|
| 24 |
+
intro i
|
| 25 |
+
exact (le_of_eq (Eq.symm (pow_two _))).trans
|
| 26 |
+
((le_of_eq (sq_abs (f i)).symm).trans (pow_le_pow_left₀ (abs_nonneg _) (hf i) 2))
|
| 27 |
+
|
| 28 |
+
theorem dip_sym (μ f g : Wgt A) : dip μ f g=dip μ g f := by unfold dip; simp only [mul_comm]
|
| 29 |
+
theorem dip_sub (μ f g h : Wgt A) :
|
| 30 |
+
dip μ (fun i=> f i-g i) h=dip μ f h-dip μ g h := by
|
| 31 |
+
unfold dip; simp only [sub_mul,avg_sub]
|
| 32 |
+
|
| 33 |
+
omit [Fintype B] in
|
| 34 |
+
theorem cashbook_bound (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A)
|
| 35 |
+
(b : ℝ) (hb : 0≤b) (h : ∀ i,|g i|≤b) (i) : |cashbook μ f g i| ≤ b := by
|
| 36 |
+
have he : cashbook μ f g i=avg (onW μ (fun x=>f x=i)) g := by
|
| 37 |
+
unfold cashbook onW
|
| 38 |
+
rw [avg_norm,subW_tot]
|
| 39 |
+
unfold mapW pr avg subW; congr 1
|
| 40 |
+
exact Finset.sum_congr rfl fun j _ => by ring
|
| 41 |
+
have hw : SubLaw (onW μ (fun x=>f x=i)) := normW_subLaw (subW_nonneg hμ _)
|
| 42 |
+
rw [he]
|
| 43 |
+
exact (abs_avg_le hw.nz).trans (hw.avg_le hb h)
|
| 44 |
+
|
| 45 |
+
theorem cash_orth (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : A→B) (g : Wgt A) (h : Wgt B) :
|
| 46 |
+
dip μ (banner μ f g) (h ∘ f)=dip μ g (h ∘ f) := by
|
| 47 |
+
classical
|
| 48 |
+
let w := fun x=> μ x*g x
|
| 49 |
+
have he : pour μ f (mapW w f) = fun i => μ i*banner μ f g i := rfl
|
| 50 |
+
have hz : lsupp w μ := fun _ hi => left_ne_zero_of_mul hi
|
| 51 |
+
have ht := map_pour μ f _ (hz.map hμ f)
|
| 52 |
+
rw [he] at ht
|
| 53 |
+
have hi := congrArg (fun w' => avg w' h) ht
|
| 54 |
+
simp_rw [mapW_avg] at hi
|
| 55 |
+
simpa only [w,dip,avg,mul_assoc,Function.comp_apply] using hi
|
| 56 |
+
|
| 57 |
+
theorem ode_step (μ : Wgt A) (hμ : ∀ i,0≤ μ i) (f : Wgt A)
|
| 58 |
+
(p : A→B) (q : B→C) :
|
| 59 |
+
ode μ (banner μ p f)=ode μ (banner μ (q∘p) f)+
|
| 60 |
+
ode μ (fun i => banner μ p f i - banner μ (q∘p) f i) := by
|
| 61 |
+
classical
|
| 62 |
+
let g := banner μ p f; let h := banner μ (q ∘ p) f
|
| 63 |
+
have hh : ode μ h=dip μ g h :=
|
| 64 |
+
(cash_orth μ hμ (q∘p) f (cashbook μ (q∘p) f)).trans
|
| 65 |
+
(cash_orth μ hμ p f (cashbook μ (q∘p) f ∘ q)).symm
|
| 66 |
+
have hi i : (g i - h i)*(g i-h i)=g i*g i - 2*(g i*h i)+h i*h i := by ring
|
| 67 |
+
change ode μ g=ode μ h+dip μ (fun i => g i-h i) (fun i=>g i-h i)
|
| 68 |
+
unfold dip
|
| 69 |
+
simp_rw [hi,avg_add,avg_sub,avg_mul']
|
| 70 |
+
change ode μ g=ode μ h+(ode μ g-2*dip μ g h + ode μ h)
|
| 71 |
+
linarith only [hh]
|
| 72 |
+
|
| 73 |
+
theorem archive_gain {μ : Wgt A} (hw : SubLaw μ) (f : Wgt A)
|
| 74 |
+
(p : A→B) (q : B→ C)
|
| 75 |
+
(h : Wgt B) (hh : ∀ i:A,|h (p i)| ≤1) :
|
| 76 |
+
(dip μ (fun i => f i - banner μ (q∘p) f i) (h ∘ p))^2 ≤
|
| 77 |
+
ode μ (banner μ p f)-ode μ (banner μ (q∘p) f) := by
|
| 78 |
+
let u := banner μ p f; let v := banner μ (q∘p) f
|
| 79 |
+
let w i := u i-v i
|
| 80 |
+
rw [ode_step μ hw.nz f p q]
|
| 81 |
+
have he : dip μ (fun i=> f i - banner μ (q∘p) f i) (h∘p)=dip μ w (h∘p) := by
|
| 82 |
+
unfold w
|
| 83 |
+
rw [dip_sub,dip_sub,cash_orth μ hw.nz p f h]
|
| 84 |
+
have ht : ode μ (h∘p) ≤ 1 := (ode_upper hw (h∘p) 1 hh).trans_eq (by ring)
|
| 85 |
+
have hq : dip μ w (h∘p)^2≤ode μ w*ode μ (h∘p) := by
|
| 86 |
+
simpa only [ode,dip,pow_two] using avg_CS hw.nz w (h∘p)
|
| 87 |
+
rw [he]
|
| 88 |
+
apply le_trans hq
|
| 89 |
+
refine (mul_le_mul_of_nonneg_left ht (ode_nonneg hw.nz w)).trans_eq ?_
|
| 90 |
+
unfold w u v
|
| 91 |
+
ring
|
| 92 |
+
end HadwigerCounterexample
|
| 93 |
+
|
| 94 |
+
end
|
| 95 |
+
|
| 96 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionalSignaturePositivity.lean
CHANGED
|
@@ -1,110 +1,110 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.CellPositivityScales
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditional Signature Positivity -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
variable {p:Shape} {n N K r d : ℕ}
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
open Template
|
| 14 |
-
|
| 15 |
-
namespace Appearance
|
| 16 |
-
variable (x : Appearance p) (Y : Silhouette p N r)
|
| 17 |
-
|
| 18 |
-
theorem smudges (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d) (i:Nodes) (j : Knobs p.g n) :
|
| 19 |
-
(x.profile i o m v j).2.1=((scan p x.l x.f j).diagO,stains x.trot m v j) := by
|
| 20 |
-
apply Prod.ext
|
| 21 |
-
· exact role_scan p _ _ _ _
|
| 22 |
-
funext i; exact T_swap m _ _
|
| 23 |
-
|
| 24 |
-
def nearly (p: Shape) (z: Digest p.g) (u: Par d) (x: Magazine p d) :=
|
| 25 |
-
x.1=z∧ x.2.1=u
|
| 26 |
-
|
| 27 |
-
set_option maxHeartbeats 800000 in
|
| 28 |
-
theorem demonstrates (o : UnitType p n N) {m : Mixer p n}
|
| 29 |
-
(v : Ax p n d) (K:ℕ) (i:Nodes) (j:Fin r) (δ : ℝ) (hd:0<δ)
|
| 30 |
-
(z : Digest p.g) (u:Cell d)
|
| 31 |
-
(he : z.feasible x.l x.f) (hf : z.sumBit=x.q) (ht : 1≤p.r) (hn : 2*p.r≤n)
|
| 32 |
-
(hh : δ≤ x.reference Y j)
|
| 33 |
-
(hs : smoothSilk p δ δ Y m K (onSide o i)) (hK : d≤K^2)
|
| 34 |
-
(hV : Injective v) (hv : ∀ x,totalRank (v x) ≤ K) :
|
| 35 |
-
basebeta p K/2 ≤ pr (x.reflected Y i o m v j) (nearly p z (z.diagO,u)) := by
|
| 36 |
-
classical
|
| 37 |
-
have ha : x.apt := ⟨z,he,hf⟩
|
| 38 |
-
let μ:= x.reference Y j
|
| 39 |
-
let f := onSide o i
|
| 40 |
-
obtain ⟨hM,hB⟩:= hs x
|
| 41 |
-
specialize hM ha
|
| 42 |
-
specialize hB z j he hf hh
|
| 43 |
-
let U (y:AtomKey (p:=p) (x.trot.t ()) N) := Y x.l x.q y=j
|
| 44 |
-
have hm : basebeta p K*μ ≤
|
| 45 |
-
pr (x.wit n) (fun y=> (scan p x.l x.f y=z∧Y x.l x.q (x.face f y)=j) ∧
|
| 46 |
-
stains x.trot m v y=u) := by
|
| 47 |
-
let h := patrol_beta x.trot U m K z he ht hn f
|
| 48 |
-
dsimp only at h
|
| 49 |
-
rw [hf] at h
|
| 50 |
-
exact h hB d hK v hV hv u
|
| 51 |
-
let w := nearly p z (z.diagO,u)
|
| 52 |
-
have hq (y : Knobs p.g n) :
|
| 53 |
-
(scan p x.l x.f y=z ∧ Y x.l x.q (x.face f y)=j) ∧ stains x.trot m v y=u →
|
| 54 |
-
x.showTag Y (onSide o i) y=j∧ w (x.profile i o m v y) := by
|
| 55 |
-
rintro ⟨⟨h,h1⟩,h2⟩
|
| 56 |
-
refine ⟨h1,h,?_⟩; rw [smudges,h,h2]
|
| 57 |
-
have hW := witLaw ha ht hn
|
| 58 |
-
have heq := (hm.trans (pr_mono hW.nz hq)).trans_eq (x.show_pr Y i o m v hW j w)
|
| 59 |
-
let ν:= x.empirical Y f j
|
| 60 |
-
have h2 : ν ≤ 2*μ := by
|
| 61 |
-
have hz : |μ-ν|≤δ := le_trans
|
| 62 |
-
(Finset.single_le_sum (fun k _ => abs_nonneg (x.reference Y k-x.empirical Y f k))
|
| 63 |
-
(Finset.mem_univ j)) hM
|
| 64 |
-
change δ≤ μ at hh
|
| 65 |
-
linarith [(abs_le.mp hz).1]
|
| 66 |
-
let Q := pr (x.reflected Y i o m v j) w
|
| 67 |
-
have h3 : basebeta p K*μ≤ ν*Q := heq
|
| 68 |
-
have ht := mul_le_mul_of_nonneg_right h2
|
| 69 |
-
(show 0≤ Q from pr_nonneg (x.reflectedLaw Y hW i o m v j).nz)
|
| 70 |
-
apply le_of_mul_le_mul_right _ (hd.trans_le hh)
|
| 71 |
-
change _*μ ≤ Q*μ
|
| 72 |
-
linarith only [h3,ht]
|
| 73 |
-
|
| 74 |
-
def fitsink (x : Appearance p) (w : Magazine p d) :=
|
| 75 |
-
w.1.feasible x.l x.f ∧ w.1.sumBit=x.q ∧ w.1.diagO=w.2.1.1
|
| 76 |
-
theorem rawink (x : Appearance p) (m : Mixer p n) (i : Nodes) (o : UnitType p n N)
|
| 77 |
-
(v : Ax p n d) :
|
| 78 |
-
carried (x.wit n) (x.fitsink ∘ x.profile i o m v) := by
|
| 79 |
-
let w:=x.wit n
|
| 80 |
-
have hC : carried w (fun y=>dialed p x.l x.f y=x.q) :=
|
| 81 |
-
normW_carried (subW_carried (spins p n) _)
|
| 82 |
-
intro y hi
|
| 83 |
-
refine hC y (fun h=>?_); apply hi
|
| 84 |
-
refine ⟨?_,h, (role_scan p _ _ _ _).symm⟩
|
| 85 |
-
intro j hj
|
| 86 |
-
unfold profile; change scan p x.l x.f y j=0
|
| 87 |
-
unfold scan
|
| 88 |
-
simp [hj]
|
| 89 |
-
theorem refInk (i : Nodes) (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d)
|
| 90 |
-
(j:Fin r) : carried (x.reflected Y i o m v j) x.fitsink :=
|
| 91 |
-
reflection_exact x Y i o m v j _ (rawink x m i o v)
|
| 92 |
-
|
| 93 |
-
end Appearance
|
| 94 |
-
|
| 95 |
-
theorem haze_small (w : Wgt (Fin r)) (δ : ℝ) (hδ : 0≤δ) :
|
| 96 |
-
pr w (fun x=> w x < δ) ≤ r*δ := by
|
| 97 |
-
classical
|
| 98 |
-
unfold pr avg
|
| 99 |
-
refine (Finset.sum_le_sum (s:=Finset.univ) (g:=fun _=>δ) (fun i _=>?_)).trans_eq (by simp)
|
| 100 |
-
dsimp only
|
| 101 |
-
by_cases h:w i<δ
|
| 102 |
-
· rw [ind_one h,mul_one]; exact h.le
|
| 103 |
-
rw [ind_zero h,mul_zero]; exact hδ
|
| 104 |
-
|
| 105 |
-
end StatusAnalysis
|
| 106 |
-
end HadwigerCounterexample
|
| 107 |
-
|
| 108 |
-
end
|
| 109 |
-
|
| 110 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.CellPositivityScales
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditional Signature Positivity -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
variable {p:Shape} {n N K r d : ℕ}
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
open Template
|
| 14 |
+
|
| 15 |
+
namespace Appearance
|
| 16 |
+
variable (x : Appearance p) (Y : Silhouette p N r)
|
| 17 |
+
|
| 18 |
+
theorem smudges (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d) (i:Nodes) (j : Knobs p.g n) :
|
| 19 |
+
(x.profile i o m v j).2.1=((scan p x.l x.f j).diagO,stains x.trot m v j) := by
|
| 20 |
+
apply Prod.ext
|
| 21 |
+
· exact role_scan p _ _ _ _
|
| 22 |
+
funext i; exact T_swap m _ _
|
| 23 |
+
|
| 24 |
+
def nearly (p: Shape) (z: Digest p.g) (u: Par d) (x: Magazine p d) :=
|
| 25 |
+
x.1=z∧ x.2.1=u
|
| 26 |
+
|
| 27 |
+
set_option maxHeartbeats 800000 in
|
| 28 |
+
theorem demonstrates (o : UnitType p n N) {m : Mixer p n}
|
| 29 |
+
(v : Ax p n d) (K:ℕ) (i:Nodes) (j:Fin r) (δ : ℝ) (hd:0<δ)
|
| 30 |
+
(z : Digest p.g) (u:Cell d)
|
| 31 |
+
(he : z.feasible x.l x.f) (hf : z.sumBit=x.q) (ht : 1≤p.r) (hn : 2*p.r≤n)
|
| 32 |
+
(hh : δ≤ x.reference Y j)
|
| 33 |
+
(hs : smoothSilk p δ δ Y m K (onSide o i)) (hK : d≤K^2)
|
| 34 |
+
(hV : Injective v) (hv : ∀ x,totalRank (v x) ≤ K) :
|
| 35 |
+
basebeta p K/2 ≤ pr (x.reflected Y i o m v j) (nearly p z (z.diagO,u)) := by
|
| 36 |
+
classical
|
| 37 |
+
have ha : x.apt := ⟨z,he,hf⟩
|
| 38 |
+
let μ:= x.reference Y j
|
| 39 |
+
let f := onSide o i
|
| 40 |
+
obtain ⟨hM,hB⟩:= hs x
|
| 41 |
+
specialize hM ha
|
| 42 |
+
specialize hB z j he hf hh
|
| 43 |
+
let U (y:AtomKey (p:=p) (x.trot.t ()) N) := Y x.l x.q y=j
|
| 44 |
+
have hm : basebeta p K*μ ≤
|
| 45 |
+
pr (x.wit n) (fun y=> (scan p x.l x.f y=z∧Y x.l x.q (x.face f y)=j) ∧
|
| 46 |
+
stains x.trot m v y=u) := by
|
| 47 |
+
let h := patrol_beta x.trot U m K z he ht hn f
|
| 48 |
+
dsimp only at h
|
| 49 |
+
rw [hf] at h
|
| 50 |
+
exact h hB d hK v hV hv u
|
| 51 |
+
let w := nearly p z (z.diagO,u)
|
| 52 |
+
have hq (y : Knobs p.g n) :
|
| 53 |
+
(scan p x.l x.f y=z ∧ Y x.l x.q (x.face f y)=j) ∧ stains x.trot m v y=u →
|
| 54 |
+
x.showTag Y (onSide o i) y=j∧ w (x.profile i o m v y) := by
|
| 55 |
+
rintro ⟨⟨h,h1⟩,h2⟩
|
| 56 |
+
refine ⟨h1,h,?_⟩; rw [smudges,h,h2]
|
| 57 |
+
have hW := witLaw ha ht hn
|
| 58 |
+
have heq := (hm.trans (pr_mono hW.nz hq)).trans_eq (x.show_pr Y i o m v hW j w)
|
| 59 |
+
let ν:= x.empirical Y f j
|
| 60 |
+
have h2 : ν ≤ 2*μ := by
|
| 61 |
+
have hz : |μ-ν|≤δ := le_trans
|
| 62 |
+
(Finset.single_le_sum (fun k _ => abs_nonneg (x.reference Y k-x.empirical Y f k))
|
| 63 |
+
(Finset.mem_univ j)) hM
|
| 64 |
+
change δ≤ μ at hh
|
| 65 |
+
linarith [(abs_le.mp hz).1]
|
| 66 |
+
let Q := pr (x.reflected Y i o m v j) w
|
| 67 |
+
have h3 : basebeta p K*μ≤ ν*Q := heq
|
| 68 |
+
have ht := mul_le_mul_of_nonneg_right h2
|
| 69 |
+
(show 0≤ Q from pr_nonneg (x.reflectedLaw Y hW i o m v j).nz)
|
| 70 |
+
apply le_of_mul_le_mul_right _ (hd.trans_le hh)
|
| 71 |
+
change _*μ ≤ Q*μ
|
| 72 |
+
linarith only [h3,ht]
|
| 73 |
+
|
| 74 |
+
def fitsink (x : Appearance p) (w : Magazine p d) :=
|
| 75 |
+
w.1.feasible x.l x.f ∧ w.1.sumBit=x.q ∧ w.1.diagO=w.2.1.1
|
| 76 |
+
theorem rawink (x : Appearance p) (m : Mixer p n) (i : Nodes) (o : UnitType p n N)
|
| 77 |
+
(v : Ax p n d) :
|
| 78 |
+
carried (x.wit n) (x.fitsink ∘ x.profile i o m v) := by
|
| 79 |
+
let w:=x.wit n
|
| 80 |
+
have hC : carried w (fun y=>dialed p x.l x.f y=x.q) :=
|
| 81 |
+
normW_carried (subW_carried (spins p n) _)
|
| 82 |
+
intro y hi
|
| 83 |
+
refine hC y (fun h=>?_); apply hi
|
| 84 |
+
refine ⟨?_,h, (role_scan p _ _ _ _).symm⟩
|
| 85 |
+
intro j hj
|
| 86 |
+
unfold profile; change scan p x.l x.f y j=0
|
| 87 |
+
unfold scan
|
| 88 |
+
simp [hj]
|
| 89 |
+
theorem refInk (i : Nodes) (o : UnitType p n N) (m:Mixer p n) (v : Ax p n d)
|
| 90 |
+
(j:Fin r) : carried (x.reflected Y i o m v j) x.fitsink :=
|
| 91 |
+
reflection_exact x Y i o m v j _ (rawink x m i o v)
|
| 92 |
+
|
| 93 |
+
end Appearance
|
| 94 |
+
|
| 95 |
+
theorem haze_small (w : Wgt (Fin r)) (δ : ℝ) (hδ : 0≤δ) :
|
| 96 |
+
pr w (fun x=> w x < δ) ≤ r*δ := by
|
| 97 |
+
classical
|
| 98 |
+
unfold pr avg
|
| 99 |
+
refine (Finset.sum_le_sum (s:=Finset.univ) (g:=fun _=>δ) (fun i _=>?_)).trans_eq (by simp)
|
| 100 |
+
dsimp only
|
| 101 |
+
by_cases h:w i<δ
|
| 102 |
+
· rw [ind_one h,mul_one]; exact h.le
|
| 103 |
+
rw [ind_zero h,mul_zero]; exact hδ
|
| 104 |
+
|
| 105 |
+
end StatusAnalysis
|
| 106 |
+
end HadwigerCounterexample
|
| 107 |
+
|
| 108 |
+
end
|
| 109 |
+
|
| 110 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedBatchLaws.lean
CHANGED
|
@@ -1,198 +1,198 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.IndependentWeightCorrelation
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditioned Batch Laws -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix Module LinearMap Submodule Function Finset
|
| 11 |
-
variable {I J G H : Type} [Fintype I] [Fintype J] [Fintype G] [Fintype H]
|
| 12 |
-
variable [DecidableEq I] [DecidableEq J] [DecidableEq G]
|
| 13 |
-
variable {N : ℕ}
|
| 14 |
-
|
| 15 |
-
def street (g : Route (I×J) G) (i : I) : Route J G := fun j => g (i,j)
|
| 16 |
-
def condLane (g : Route (I×J) G) (i : I) (z : G) (k : Port (street g i) z) :
|
| 17 |
-
Port g z := ⟨(i,k.val),k.property⟩
|
| 18 |
-
def laneM {g : Route (I×J) G} (Z : GeoM g) (i : I) :
|
| 19 |
-
GeoM (street g i) :=
|
| 20 |
-
fun z => (Z z).submatrix (condLane g i z) (condLane g i z)
|
| 21 |
-
|
| 22 |
-
private theorem cut_inj {I J : Type} [Fintype I] [Fintype J] [DecidableEq I]
|
| 23 |
-
(A : PlusRack I N) (h : Injective A.mulVec) {g : J→I} (hg : Injective g) :
|
| 24 |
-
Injective (A.submatrix _root_.id g).mulVec := by
|
| 25 |
-
rw [← mul_embedMat]
|
| 26 |
-
exact inj_comp_mat _ _ h (embedMat_inj hg)
|
| 27 |
-
|
| 28 |
-
variable {g : Route (I×J) G}
|
| 29 |
-
|
| 30 |
-
omit [Fintype G] in
|
| 31 |
-
set_option maxHeartbeats 600000 in
|
| 32 |
-
theorem laneGram (Z : GeoM g) (x : Rack (I × J) N) (h : bothPart Z x) (i : I) :
|
| 33 |
-
bothPart (laneM Z i) (led i x) := by
|
| 34 |
-
classical
|
| 35 |
-
obtain ⟨hh,hj⟩ := (both_test ..).mp h
|
| 36 |
-
apply (both_test ..).mpr
|
| 37 |
-
constructor
|
| 38 |
-
· refine (part_scores ..).mpr fun q a b => ?_
|
| 39 |
-
exact (part_scores ..).mp hh q (condLane g i q a) (condLane g i q b)
|
| 40 |
-
intro j
|
| 41 |
-
let f := condLane g i j
|
| 42 |
-
have he : Injective f := by intro a b h; exact Subtype.ext (congrArg
|
| 43 |
-
(fun x : Port g j => x.val.2) h)
|
| 44 |
-
exact ⟨cut_inj (rackEquiv g N x j).1 (hj j).1 he,
|
| 45 |
-
cut_inj (rackEquiv g N x j).2 (hj j).2 he⟩
|
| 46 |
-
|
| 47 |
-
def crossroads (g : Route (I×J) G) :=
|
| 48 |
-
(crowded g)\(cInside g)
|
| 49 |
-
def outsideZ (Z : GeoM g) : Vec (crossroads g) :=
|
| 50 |
-
fun x => directions g Z ⟨x.val,Finset.sdiff_subset x.property⟩
|
| 51 |
-
|
| 52 |
-
omit [Fintype G] in
|
| 53 |
-
private theorem road_iff (Z : GeoM g) (x : Rack (I×J) N) :
|
| 54 |
-
bothPart Z x ↔ (traced x (crossroads g) (outsideZ Z) ∧
|
| 55 |
-
(∀ i,bothPart (laneM Z i) (led i x))) ∧injPart g x := by
|
| 56 |
-
classical
|
| 57 |
-
constructor
|
| 58 |
-
· intro h
|
| 59 |
-
have ht := (both_test ..).mp h
|
| 60 |
-
refine ⟨⟨?_,laneGram Z x h⟩,ht.2⟩
|
| 61 |
-
funext i
|
| 62 |
-
exact congr_fun ((match_crowd x g Z).mpr ht.1) (⟨i.val,Finset.sdiff_subset i.property⟩ :
|
| 63 |
-
↑(crowded g))
|
| 64 |
-
rintro ⟨⟨ht,hH⟩,hf⟩
|
| 65 |
-
refine (both_test ..).mpr ⟨(part_scores ..).mpr ?_,hf⟩
|
| 66 |
-
intro i a b
|
| 67 |
-
rcases a with ⟨⟨l,x'⟩,hl⟩
|
| 68 |
-
rcases b with ⟨⟨t,y⟩,hr⟩
|
| 69 |
-
subst i
|
| 70 |
-
let j := g (l,x')
|
| 71 |
-
by_cases hh : l=t
|
| 72 |
-
· subst t
|
| 73 |
-
let a : Port (street g l) j := ⟨x',rfl⟩
|
| 74 |
-
let b : Port (street g l) j := ⟨y,hr⟩
|
| 75 |
-
exact (part_scores ..).mp ((both_test ..).mp (hH l)).1 j a b
|
| 76 |
-
let z : I×J := (l,x')
|
| 77 |
-
let v : I×J := (t,y)
|
| 78 |
-
have hv : (z,v)∈crossroads g := Finset.mem_sdiff.mpr
|
| 79 |
-
⟨Finset.mem_filter.mpr ⟨mem_univ _,hr.symm⟩,fun h => hh (mem_filter.mp h).2⟩
|
| 80 |
-
exact congr_fun ht (⟨(z,v),hv⟩ : ↑(crossroads g))
|
| 81 |
-
|
| 82 |
-
private def condMean (p : H→Prop) (f : Wgt H) :=
|
| 83 |
-
avg unif (fun x => ind (p x)*f x)
|
| 84 |
-
private theorem cond_reset [Nonempty H] (p : H→Prop) (f : Wgt H) (h : 0<pr unif p) :
|
| 85 |
-
condMean p f=pr unif p * avg (unifOn p) f := by
|
| 86 |
-
rw [←on_unif]; unfold onW
|
| 87 |
-
rw [avg_norm,subW_tot]
|
| 88 |
-
have he : condMean p f = avg (subW unif p) f := by simp only [avg,subW,mul_assoc]; rfl
|
| 89 |
-
rw [he]
|
| 90 |
-
field_simp
|
| 91 |
-
|
| 92 |
-
def twinkle (_ : Route (I×J) G) (k : ℝ) (N : ℕ) :=
|
| 93 |
-
num G * (2*bp (k-N))+bp (-(N:ℝ)/2)
|
| 94 |
-
|
| 95 |
-
set_option maxHeartbeats 800000 in
|
| 96 |
-
private theorem lane_means (Z : GeoM g) (f : I → Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)
|
| 97 |
-
(k : ℝ) (hk : ∀ i,num (Port g i)≤k) :
|
| 98 |
-
|condMean (bothPart Z) (brightProd f) - bp (-( (crossroads g).card:ℝ)) *
|
| 99 |
-
∏ i,condMean (bothPart (laneM Z i)) (f i)|≤twinkle g k N := by
|
| 100 |
-
classical
|
| 101 |
-
let E := crossroads g
|
| 102 |
-
let F i (x : Rack J N) := ind (bothPart (laneM Z i) x)*f i x
|
| 103 |
-
have hF i x : |F i x|≤1 := by
|
| 104 |
-
unfold F; by_cases h : bothPart (laneM Z i) x <;> simp only [h,ind_true,ind_false,one_mul,
|
| 105 |
-
zero_mul]; exact hf i x; norm_num
|
| 106 |
-
have hE i (h : i∈E) : i.1.1≠i.2.1 := fun he =>
|
| 107 |
-
(mem_sdiff.mp h).2 (mem_filter.mpr ⟨(mem_sdiff.mp h).1,he⟩)
|
| 108 |
-
have ht := speed_expand F hF E (outsideZ Z) hE
|
| 109 |
-
have hP : avg unif (brightProd F)=∏ i, condMean (bothPart (laneM Z i)) (f i) :=
|
| 110 |
-
(led_uniform (prodW F)).trans (prodW_avg _ _)
|
| 111 |
-
let A x := ind (traced x E (outsideZ Z))*brightProd F x
|
| 112 |
-
have hA x : |A x|≤1 := by
|
| 113 |
-
by_cases h : traced x E (outsideZ Z)
|
| 114 |
-
· unfold A; rw [ind_one h,one_mul]; exact lane_abs F hF _ x
|
| 115 |
-
unfold A; rw [ind_zero h,zero_mul]; norm_num
|
| 116 |
-
have hi x :
|
| 117 |
-
ind (bothPart Z x) * brightProd f x= ind (injPart g x) * A x := by
|
| 118 |
-
rw [road_iff]; unfold A F
|
| 119 |
-
simp only [ind_and, ind_all,brightProd,Finset.prod_mul_distrib]
|
| 120 |
-
ring
|
| 121 |
-
have hg :
|
| 122 |
-
|condMean (bothPart Z) (brightProd f) - avg unif A|≤ num G*(2*bp (k-N)) := by
|
| 123 |
-
unfold condMean
|
| 124 |
-
simp_rw [hi]
|
| 125 |
-
rw [← avg_sub]
|
| 126 |
-
refine (abs_avg_le unif_law.nz).trans ((avg_mono unif_law.nz (g:=fun x =>
|
| 127 |
-
ind (¬injPart g x)) fun i => ?_).trans (injPart_failure g N k hk))
|
| 128 |
-
by_cases h : injPart g i <;>
|
| 129 |
-
simp only [h,ind_true,not_true,ind_false,one_mul,sub_self,abs_zero,zero_mul,zero_sub,
|
| 130 |
-
abs_neg,not_false_eq_true]; exact le_rfl; exact hA _
|
| 131 |
-
rw [hP] at ht
|
| 132 |
-
unfold twinkle
|
| 133 |
-
apply le_trans _ (add_le_add hg ht)
|
| 134 |
-
exact abs_sub_le ..
|
| 135 |
-
|
| 136 |
-
omit [DecidableEq I] in
|
| 137 |
-
theorem lane_norm (Z : GeoM g) (hN : ∀ i, 2*num (Port g i)-(N:ℝ)≤ -1)
|
| 138 |
-
(i : I) : 0<pr unif (bothPart (laneM Z i) (N:=N)) := by
|
| 139 |
-
have he j : Injective (condLane g i j) := by intro a b h; exact Subtype.ext (congrArg
|
| 140 |
-
(fun x : Port g j => x.val.2) h)
|
| 141 |
-
have hx j : num (Port (street g i) j)≤num (Port g j) := by
|
| 142 |
-
exact_mod_cast Fintype.card_le_of_injective _ (he j)
|
| 143 |
-
refine lt_of_lt_of_le (inv_pos_of_pos netFact_pos) (net_norm (laneM Z i) N (fun j => ?_)).1
|
| 144 |
-
linarith only [hx j,hN j]
|
| 145 |
-
|
| 146 |
-
set_option maxHeartbeats 800000 in
|
| 147 |
-
theorem compare_lanes (Z : GeoM g) (f : I→ Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)
|
| 148 |
-
(k : ℝ) (hk : ∀ i,num (Port g i)≤k) (hN : ∀ i,2*num (Port g i)-(N:ℝ)≤ -1) :
|
| 149 |
-
|avg (rackStation Z N) (brightProd f)- ∏ i,avg (rackStation (laneM Z i) N) (f i)|≤
|
| 150 |
-
2*netFact g*twinkle g k N := by
|
| 151 |
-
classical
|
| 152 |
-
let A := pr unif (bothPart (N:=N) Z)
|
| 153 |
-
let B i := pr unif (bothPart (N:=N) (laneM Z i))
|
| 154 |
-
let u := avg (rackStation Z N) (brightProd f)
|
| 155 |
-
let v i := avg (rackStation (laneM Z i) N) (f i)
|
| 156 |
-
let P := bp (- ((crossroads g).card:ℝ))*(∏ i, B i)
|
| 157 |
-
let V := ∏ i,v i
|
| 158 |
-
have hV : |V|≤1 := by
|
| 159 |
-
unfold V
|
| 160 |
-
rw [Finset.abs_prod]
|
| 161 |
-
have he (i) :
|
| 162 |
-
SubLaw (rackStation (laneM Z i) N) := unifOn_sub _
|
| 163 |
-
refine (Finset.prod_le_prod₀ (fun i _ => abs_nonneg _)
|
| 164 |
-
(fun i _ => (abs_avg_le (he i).nz).trans ((he i).avg_le zero_le_one (hf i)))).trans_eq ?_
|
| 165 |
-
simp
|
| 166 |
-
have hh := net_norm Z N hN
|
| 167 |
-
have h0 : 0<A := (inv_pos_of_pos netFact_pos).trans_le hh.1
|
| 168 |
-
have h1 : |A*u-P*V|≤twinkle g k N := by
|
| 169 |
-
have hb := lane_norm (N:=N) Z hN
|
| 170 |
-
have ht := lane_means Z f hf k hk
|
| 171 |
-
rw [cond_reset (bothPart (N:=N) Z) _ h0] at ht
|
| 172 |
-
simp_rw [cond_reset _ _ (hb _)] at ht; rw [Finset.prod_mul_distrib] at ht
|
| 173 |
-
simpa only [A,B,u,v,P,V,rackStation,mul_assoc] using ht
|
| 174 |
-
have h2 : |A-P|≤ twinkle g k N := by
|
| 175 |
-
let F (i:I) := fun _ : Rack J N => (1:ℝ)
|
| 176 |
-
have ht := lane_means Z F (by intro i x; simp [F]) k hk
|
| 177 |
-
have he (i : I) :
|
| 178 |
-
condMean (bothPart (laneM Z i)) (F i)=B i := by simp only [F,condMean,mul_one]; rfl
|
| 179 |
-
have hx :
|
| 180 |
-
condMean (bothPart (N:=N) Z) (brightProd F)=A := by
|
| 181 |
-
simp only [F,brightProd,condMean,Finset.prod_const_one,mul_one,A,pr]
|
| 182 |
-
simp_rw [he,hx] at ht; exact ht
|
| 183 |
-
have hg : A * |u-V|≤2*twinkle g k N := by
|
| 184 |
-
have hh : |(A-P)*V|≤twinkle g k N := by
|
| 185 |
-
rw [abs_mul]; exact ((mul_le_mul_of_nonneg_left hV (abs_nonneg _)).trans_eq (mul_one _)).trans h2
|
| 186 |
-
calc A*|u-V|= |(A*u-P*V)-(A-P)*V| := by
|
| 187 |
-
rw [show A*u-P*V-(A-P)*V=(A*(u-V)) by ring,abs_mul,abs_of_nonneg h0.le]
|
| 188 |
-
_ ≤ _ := ((abs_sub ..).trans (add_le_add h1 hh)).trans_eq (two_mul _).symm
|
| 189 |
-
apply le_of_mul_le_mul_left _ (inv_pos_of_pos (netFact_pos (f:=g)))
|
| 190 |
-
exact ((mul_le_mul_of_nonneg_right hh.1 (abs_nonneg _)).trans hg).trans_eq (by
|
| 191 |
-
have h := netFact_pos (f:=g)
|
| 192 |
-
field_simp)
|
| 193 |
-
|
| 194 |
-
end HadwigerCounterexample
|
| 195 |
-
|
| 196 |
-
end
|
| 197 |
-
|
| 198 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.IndependentWeightCorrelation
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditioned Batch Laws -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix Module LinearMap Submodule Function Finset
|
| 11 |
+
variable {I J G H : Type} [Fintype I] [Fintype J] [Fintype G] [Fintype H]
|
| 12 |
+
variable [DecidableEq I] [DecidableEq J] [DecidableEq G]
|
| 13 |
+
variable {N : ℕ}
|
| 14 |
+
|
| 15 |
+
def street (g : Route (I×J) G) (i : I) : Route J G := fun j => g (i,j)
|
| 16 |
+
def condLane (g : Route (I×J) G) (i : I) (z : G) (k : Port (street g i) z) :
|
| 17 |
+
Port g z := ⟨(i,k.val),k.property⟩
|
| 18 |
+
def laneM {g : Route (I×J) G} (Z : GeoM g) (i : I) :
|
| 19 |
+
GeoM (street g i) :=
|
| 20 |
+
fun z => (Z z).submatrix (condLane g i z) (condLane g i z)
|
| 21 |
+
|
| 22 |
+
private theorem cut_inj {I J : Type} [Fintype I] [Fintype J] [DecidableEq I]
|
| 23 |
+
(A : PlusRack I N) (h : Injective A.mulVec) {g : J→I} (hg : Injective g) :
|
| 24 |
+
Injective (A.submatrix _root_.id g).mulVec := by
|
| 25 |
+
rw [← mul_embedMat]
|
| 26 |
+
exact inj_comp_mat _ _ h (embedMat_inj hg)
|
| 27 |
+
|
| 28 |
+
variable {g : Route (I×J) G}
|
| 29 |
+
|
| 30 |
+
omit [Fintype G] in
|
| 31 |
+
set_option maxHeartbeats 600000 in
|
| 32 |
+
theorem laneGram (Z : GeoM g) (x : Rack (I × J) N) (h : bothPart Z x) (i : I) :
|
| 33 |
+
bothPart (laneM Z i) (led i x) := by
|
| 34 |
+
classical
|
| 35 |
+
obtain ⟨hh,hj⟩ := (both_test ..).mp h
|
| 36 |
+
apply (both_test ..).mpr
|
| 37 |
+
constructor
|
| 38 |
+
· refine (part_scores ..).mpr fun q a b => ?_
|
| 39 |
+
exact (part_scores ..).mp hh q (condLane g i q a) (condLane g i q b)
|
| 40 |
+
intro j
|
| 41 |
+
let f := condLane g i j
|
| 42 |
+
have he : Injective f := by intro a b h; exact Subtype.ext (congrArg
|
| 43 |
+
(fun x : Port g j => x.val.2) h)
|
| 44 |
+
exact ⟨cut_inj (rackEquiv g N x j).1 (hj j).1 he,
|
| 45 |
+
cut_inj (rackEquiv g N x j).2 (hj j).2 he⟩
|
| 46 |
+
|
| 47 |
+
def crossroads (g : Route (I×J) G) :=
|
| 48 |
+
(crowded g)\(cInside g)
|
| 49 |
+
def outsideZ (Z : GeoM g) : Vec (crossroads g) :=
|
| 50 |
+
fun x => directions g Z ⟨x.val,Finset.sdiff_subset x.property⟩
|
| 51 |
+
|
| 52 |
+
omit [Fintype G] in
|
| 53 |
+
private theorem road_iff (Z : GeoM g) (x : Rack (I×J) N) :
|
| 54 |
+
bothPart Z x ↔ (traced x (crossroads g) (outsideZ Z) ∧
|
| 55 |
+
(∀ i,bothPart (laneM Z i) (led i x))) ∧injPart g x := by
|
| 56 |
+
classical
|
| 57 |
+
constructor
|
| 58 |
+
· intro h
|
| 59 |
+
have ht := (both_test ..).mp h
|
| 60 |
+
refine ⟨⟨?_,laneGram Z x h⟩,ht.2⟩
|
| 61 |
+
funext i
|
| 62 |
+
exact congr_fun ((match_crowd x g Z).mpr ht.1) (⟨i.val,Finset.sdiff_subset i.property⟩ :
|
| 63 |
+
↑(crowded g))
|
| 64 |
+
rintro ⟨⟨ht,hH⟩,hf⟩
|
| 65 |
+
refine (both_test ..).mpr ⟨(part_scores ..).mpr ?_,hf⟩
|
| 66 |
+
intro i a b
|
| 67 |
+
rcases a with ⟨⟨l,x'⟩,hl⟩
|
| 68 |
+
rcases b with ⟨⟨t,y⟩,hr⟩
|
| 69 |
+
subst i
|
| 70 |
+
let j := g (l,x')
|
| 71 |
+
by_cases hh : l=t
|
| 72 |
+
· subst t
|
| 73 |
+
let a : Port (street g l) j := ⟨x',rfl⟩
|
| 74 |
+
let b : Port (street g l) j := ⟨y,hr⟩
|
| 75 |
+
exact (part_scores ..).mp ((both_test ..).mp (hH l)).1 j a b
|
| 76 |
+
let z : I×J := (l,x')
|
| 77 |
+
let v : I×J := (t,y)
|
| 78 |
+
have hv : (z,v)∈crossroads g := Finset.mem_sdiff.mpr
|
| 79 |
+
⟨Finset.mem_filter.mpr ⟨mem_univ _,hr.symm⟩,fun h => hh (mem_filter.mp h).2⟩
|
| 80 |
+
exact congr_fun ht (⟨(z,v),hv⟩ : ↑(crossroads g))
|
| 81 |
+
|
| 82 |
+
private def condMean (p : H→Prop) (f : Wgt H) :=
|
| 83 |
+
avg unif (fun x => ind (p x)*f x)
|
| 84 |
+
private theorem cond_reset [Nonempty H] (p : H→Prop) (f : Wgt H) (h : 0<pr unif p) :
|
| 85 |
+
condMean p f=pr unif p * avg (unifOn p) f := by
|
| 86 |
+
rw [←on_unif]; unfold onW
|
| 87 |
+
rw [avg_norm,subW_tot]
|
| 88 |
+
have he : condMean p f = avg (subW unif p) f := by simp only [avg,subW,mul_assoc]; rfl
|
| 89 |
+
rw [he]
|
| 90 |
+
field_simp
|
| 91 |
+
|
| 92 |
+
def twinkle (_ : Route (I×J) G) (k : ℝ) (N : ℕ) :=
|
| 93 |
+
num G * (2*bp (k-N))+bp (-(N:ℝ)/2)
|
| 94 |
+
|
| 95 |
+
set_option maxHeartbeats 800000 in
|
| 96 |
+
private theorem lane_means (Z : GeoM g) (f : I → Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)
|
| 97 |
+
(k : ℝ) (hk : ∀ i,num (Port g i)≤k) :
|
| 98 |
+
|condMean (bothPart Z) (brightProd f) - bp (-( (crossroads g).card:ℝ)) *
|
| 99 |
+
∏ i,condMean (bothPart (laneM Z i)) (f i)|≤twinkle g k N := by
|
| 100 |
+
classical
|
| 101 |
+
let E := crossroads g
|
| 102 |
+
let F i (x : Rack J N) := ind (bothPart (laneM Z i) x)*f i x
|
| 103 |
+
have hF i x : |F i x|≤1 := by
|
| 104 |
+
unfold F; by_cases h : bothPart (laneM Z i) x <;> simp only [h,ind_true,ind_false,one_mul,
|
| 105 |
+
zero_mul]; exact hf i x; norm_num
|
| 106 |
+
have hE i (h : i∈E) : i.1.1≠i.2.1 := fun he =>
|
| 107 |
+
(mem_sdiff.mp h).2 (mem_filter.mpr ⟨(mem_sdiff.mp h).1,he⟩)
|
| 108 |
+
have ht := speed_expand F hF E (outsideZ Z) hE
|
| 109 |
+
have hP : avg unif (brightProd F)=∏ i, condMean (bothPart (laneM Z i)) (f i) :=
|
| 110 |
+
(led_uniform (prodW F)).trans (prodW_avg _ _)
|
| 111 |
+
let A x := ind (traced x E (outsideZ Z))*brightProd F x
|
| 112 |
+
have hA x : |A x|≤1 := by
|
| 113 |
+
by_cases h : traced x E (outsideZ Z)
|
| 114 |
+
· unfold A; rw [ind_one h,one_mul]; exact lane_abs F hF _ x
|
| 115 |
+
unfold A; rw [ind_zero h,zero_mul]; norm_num
|
| 116 |
+
have hi x :
|
| 117 |
+
ind (bothPart Z x) * brightProd f x= ind (injPart g x) * A x := by
|
| 118 |
+
rw [road_iff]; unfold A F
|
| 119 |
+
simp only [ind_and, ind_all,brightProd,Finset.prod_mul_distrib]
|
| 120 |
+
ring
|
| 121 |
+
have hg :
|
| 122 |
+
|condMean (bothPart Z) (brightProd f) - avg unif A|≤ num G*(2*bp (k-N)) := by
|
| 123 |
+
unfold condMean
|
| 124 |
+
simp_rw [hi]
|
| 125 |
+
rw [← avg_sub]
|
| 126 |
+
refine (abs_avg_le unif_law.nz).trans ((avg_mono unif_law.nz (g:=fun x =>
|
| 127 |
+
ind (¬injPart g x)) fun i => ?_).trans (injPart_failure g N k hk))
|
| 128 |
+
by_cases h : injPart g i <;>
|
| 129 |
+
simp only [h,ind_true,not_true,ind_false,one_mul,sub_self,abs_zero,zero_mul,zero_sub,
|
| 130 |
+
abs_neg,not_false_eq_true]; exact le_rfl; exact hA _
|
| 131 |
+
rw [hP] at ht
|
| 132 |
+
unfold twinkle
|
| 133 |
+
apply le_trans _ (add_le_add hg ht)
|
| 134 |
+
exact abs_sub_le ..
|
| 135 |
+
|
| 136 |
+
omit [DecidableEq I] in
|
| 137 |
+
theorem lane_norm (Z : GeoM g) (hN : ∀ i, 2*num (Port g i)-(N:ℝ)≤ -1)
|
| 138 |
+
(i : I) : 0<pr unif (bothPart (laneM Z i) (N:=N)) := by
|
| 139 |
+
have he j : Injective (condLane g i j) := by intro a b h; exact Subtype.ext (congrArg
|
| 140 |
+
(fun x : Port g j => x.val.2) h)
|
| 141 |
+
have hx j : num (Port (street g i) j)≤num (Port g j) := by
|
| 142 |
+
exact_mod_cast Fintype.card_le_of_injective _ (he j)
|
| 143 |
+
refine lt_of_lt_of_le (inv_pos_of_pos netFact_pos) (net_norm (laneM Z i) N (fun j => ?_)).1
|
| 144 |
+
linarith only [hx j,hN j]
|
| 145 |
+
|
| 146 |
+
set_option maxHeartbeats 800000 in
|
| 147 |
+
theorem compare_lanes (Z : GeoM g) (f : I→ Wgt (Rack J N)) (hf : ∀ i x,|f i x|≤1)
|
| 148 |
+
(k : ℝ) (hk : ∀ i,num (Port g i)≤k) (hN : ∀ i,2*num (Port g i)-(N:ℝ)≤ -1) :
|
| 149 |
+
|avg (rackStation Z N) (brightProd f)- ∏ i,avg (rackStation (laneM Z i) N) (f i)|≤
|
| 150 |
+
2*netFact g*twinkle g k N := by
|
| 151 |
+
classical
|
| 152 |
+
let A := pr unif (bothPart (N:=N) Z)
|
| 153 |
+
let B i := pr unif (bothPart (N:=N) (laneM Z i))
|
| 154 |
+
let u := avg (rackStation Z N) (brightProd f)
|
| 155 |
+
let v i := avg (rackStation (laneM Z i) N) (f i)
|
| 156 |
+
let P := bp (- ((crossroads g).card:ℝ))*(∏ i, B i)
|
| 157 |
+
let V := ∏ i,v i
|
| 158 |
+
have hV : |V|≤1 := by
|
| 159 |
+
unfold V
|
| 160 |
+
rw [Finset.abs_prod]
|
| 161 |
+
have he (i) :
|
| 162 |
+
SubLaw (rackStation (laneM Z i) N) := unifOn_sub _
|
| 163 |
+
refine (Finset.prod_le_prod₀ (fun i _ => abs_nonneg _)
|
| 164 |
+
(fun i _ => (abs_avg_le (he i).nz).trans ((he i).avg_le zero_le_one (hf i)))).trans_eq ?_
|
| 165 |
+
simp
|
| 166 |
+
have hh := net_norm Z N hN
|
| 167 |
+
have h0 : 0<A := (inv_pos_of_pos netFact_pos).trans_le hh.1
|
| 168 |
+
have h1 : |A*u-P*V|≤twinkle g k N := by
|
| 169 |
+
have hb := lane_norm (N:=N) Z hN
|
| 170 |
+
have ht := lane_means Z f hf k hk
|
| 171 |
+
rw [cond_reset (bothPart (N:=N) Z) _ h0] at ht
|
| 172 |
+
simp_rw [cond_reset _ _ (hb _)] at ht; rw [Finset.prod_mul_distrib] at ht
|
| 173 |
+
simpa only [A,B,u,v,P,V,rackStation,mul_assoc] using ht
|
| 174 |
+
have h2 : |A-P|≤ twinkle g k N := by
|
| 175 |
+
let F (i:I) := fun _ : Rack J N => (1:ℝ)
|
| 176 |
+
have ht := lane_means Z F (by intro i x; simp [F]) k hk
|
| 177 |
+
have he (i : I) :
|
| 178 |
+
condMean (bothPart (laneM Z i)) (F i)=B i := by simp only [F,condMean,mul_one]; rfl
|
| 179 |
+
have hx :
|
| 180 |
+
condMean (bothPart (N:=N) Z) (brightProd F)=A := by
|
| 181 |
+
simp only [F,brightProd,condMean,Finset.prod_const_one,mul_one,A,pr]
|
| 182 |
+
simp_rw [he,hx] at ht; exact ht
|
| 183 |
+
have hg : A * |u-V|≤2*twinkle g k N := by
|
| 184 |
+
have hh : |(A-P)*V|≤twinkle g k N := by
|
| 185 |
+
rw [abs_mul]; exact ((mul_le_mul_of_nonneg_left hV (abs_nonneg _)).trans_eq (mul_one _)).trans h2
|
| 186 |
+
calc A*|u-V|= |(A*u-P*V)-(A-P)*V| := by
|
| 187 |
+
rw [show A*u-P*V-(A-P)*V=(A*(u-V)) by ring,abs_mul,abs_of_nonneg h0.le]
|
| 188 |
+
_ ≤ _ := ((abs_sub ..).trans (add_le_add h1 hh)).trans_eq (two_mul _).symm
|
| 189 |
+
apply le_of_mul_le_mul_left _ (inv_pos_of_pos (netFact_pos (f:=g)))
|
| 190 |
+
exact ((mul_le_mul_of_nonneg_right hh.1 (abs_nonneg _)).trans hg).trans_eq (by
|
| 191 |
+
have h := netFact_pos (f:=g)
|
| 192 |
+
field_simp)
|
| 193 |
+
|
| 194 |
+
end HadwigerCounterexample
|
| 195 |
+
|
| 196 |
+
end
|
| 197 |
+
|
| 198 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConditionedCorrelations.lean
CHANGED
|
@@ -1,97 +1,97 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BilinearBlockCorrelation
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Conditioned Correlations -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real Filter Matrix LinearMap Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {I A : Type} [Fintype I] [Fintype A]
|
| 12 |
-
variable {n : ℕ}
|
| 13 |
-
|
| 14 |
-
set_option maxHeartbeats 600000 in
|
| 15 |
-
theorem spark_condition (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)
|
| 16 |
-
(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)
|
| 17 |
-
(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i|≤1) (hu : ∀ i,|u i|≤1)
|
| 18 |
-
(μ δ : Wgt (Knobs p.g n)) (hμ : IsLaw μ) (hδ : IsLaw δ)
|
| 19 |
-
(C : ℝ) (hC : 0<C)
|
| 20 |
-
(hc : ∀ i,μ i ≤ C*unif i) (hc' : ∀ i,δ i ≤ C*unif i)
|
| 21 |
-
(hM : n ≤ 5*blockRank B s t M) :
|
| 22 |
-
let Q i z := evmat M (spring p l s f i) (spring p j t g z)
|
| 23 |
-
|avg (pairW μ δ) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤
|
| 24 |
-
C^2*bp (-(n:ℝ)/10) := by
|
| 25 |
-
classical
|
| 26 |
-
intro Q
|
| 27 |
-
let V := Knobs p.g n
|
| 28 |
-
let fit (f p : Wgt V) := fun i => p i*f i/(C*unif i)
|
| 29 |
-
have h0 (i : V) : 0<C*unif i := by rw [unif_apply]; positivity
|
| 30 |
-
have hh (t p : Wgt V) (ht : ∀ i, |t i|≤1) (hp : IsLaw p) (h : ∀ i,p i≤C*unif i) i :
|
| 31 |
-
|fit t p i|≤1 := by
|
| 32 |
-
unfold fit; rw [abs_div,abs_of_pos (h0 i),abs_mul,abs_of_nonneg (hp.nz _)]
|
| 33 |
-
refine (div_le_one (h0 i)).mpr ?_
|
| 34 |
-
exact ((mul_le_mul_of_nonneg_left (ht _) (hp.nz _)).trans_eq (mul_one _)).trans (h _)
|
| 35 |
-
let F (x : V×V) := wsign (Q x.1 x.2)*(w x.1*u x.2)
|
| 36 |
-
let Z (x : V×V) := wsign (Q x.1 x.2)*(fit w μ x.1*fit u δ x.2)
|
| 37 |
-
have he :
|
| 38 |
-
avg (pairW μ δ) F=C^2 * avg (pairW unif unif) Z := by
|
| 39 |
-
unfold avg; rw [Finset.mul_sum]
|
| 40 |
-
refine sum_congr rfl fun i _ => ?_
|
| 41 |
-
unfold Z F fit pairW
|
| 42 |
-
have h1 := h0 i.1; have h2 := h0 i.2
|
| 43 |
-
have h3 : unif i.1 ≠ 0 := by rw [unif_apply]; positivity
|
| 44 |
-
have h4 : unif i.2 ≠ 0 := by rw [unif_apply]; positivity
|
| 45 |
-
field_simp
|
| 46 |
-
change |avg (pairW μ δ) F|≤_
|
| 47 |
-
rw [he,abs_mul,abs_of_nonneg (sq_nonneg _)]
|
| 48 |
-
have hi : (n:ℝ)≤5*blockRank B s t M := by exact_mod_cast hM
|
| 49 |
-
exact mul_le_mul_of_nonneg_left ((spark_uncap p M s t l j f g B hB hB'
|
| 50 |
-
_ _ (hh w μ hw hμ hc) (hh u δ hu hδ hc')).trans (bp_le (by linarith only [hi]))) (sq_nonneg _)
|
| 51 |
-
|
| 52 |
-
def litFire (p : Shape) {n N : ℕ} (x : UnitType p n N) :=
|
| 53 |
-
∀ (s t : Label p.b) (c : Vec (Notches p)), c≠0 →
|
| 54 |
-
n≤5*blockRank Block.Z s t (issue p c x)
|
| 55 |
-
|
| 56 |
-
theorem litFire_calendar (p : Shape) (C : ℝ) (M : ℕ) (hM : 4≤M) :
|
| 57 |
-
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n), 2*num (Full p n)<N →
|
| 58 |
-
∀ w : Wgt (UnitType p n N),
|
| 59 |
-
(∀ i,w i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →
|
| 60 |
-
pr w (fun i => ¬litFire p i) ≤ bp (-(n:ℝ)*n/8) := by
|
| 61 |
-
classical
|
| 62 |
-
let I := Label p.b × Label p.b × Vec (Notches p)
|
| 63 |
-
have ht := bp_poly_dom_nat (a:=1) zero_lt_one (num I) 0
|
| 64 |
-
filter_upwards [issue_live p,ht,(tendsto_natCast_atTop_atTop (R:=ℝ)).eventually
|
| 65 |
-
(eventually_ge_atTop (8*(C*M+1)))]
|
| 66 |
-
with n hn hp hab N m hN w h
|
| 67 |
-
change 8*(C*M+1)≤ (n:ℝ) at hab
|
| 68 |
-
refine (pr_cap h _).trans ?_
|
| 69 |
-
let Q (i : I) (x : UnitType p n N) :=
|
| 70 |
-
i.2.2≠0 ∧ 5*blockRank Block.Z i.1 i.2.1 (issue p i.2.2 x)<n
|
| 71 |
-
let v := pairW (raw m N) (raw m N)
|
| 72 |
-
have hv : IsLaw v := pairW_law (raw_law m hN) (raw_law m hN)
|
| 73 |
-
have he (i : I) : pr v (Q i)≤bp (-(n:ℝ)*n/4) := by
|
| 74 |
-
by_cases h : i.2.2=0
|
| 75 |
-
· simp only [Q,h,ne_eq,not_true,false_and,pr_false]; exact (bp_pos _).le
|
| 76 |
-
exact (pr_mono hv.nz fun x h => h.2).trans
|
| 77 |
-
(hn N (by unfold N; nlinarith only [Nat.mul_le_mul_right n hM]) hN m _ _ i.2.2 h)
|
| 78 |
-
have hh (x : UnitType p n N) (h : ¬litFire p x) : ∃ i,Q i x := by
|
| 79 |
-
unfold litFire at h
|
| 80 |
-
push Not at h
|
| 81 |
-
obtain ⟨s,t,c,hc,h⟩ := h; exact ⟨(s,t,c),hc,h⟩
|
| 82 |
-
have hi : pr v (fun x=> ¬litFire p x) ≤ num I*bp (-(n:ℝ)*n/4) :=
|
| 83 |
-
(le_trans (pr_mono hv.nz hh) (pr_exists_le hv.nz Q)).trans ((sum_le_sum
|
| 84 |
-
fun i _ => he i).trans_eq (by simp [num]))
|
| 85 |
-
refine (mul_le_mul_of_nonneg_left hi (bp_pos _).le).trans ?_
|
| 86 |
-
simp only [pow_zero,mul_one,one_mul] at hp
|
| 87 |
-
apply (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hp.le
|
| 88 |
-
(bp_pos (-(n:ℝ)*n/4)).le) (bp_pos (C*N)).le).trans
|
| 89 |
-
rw [← bp_add,← bp_add]
|
| 90 |
-
apply bp_le
|
| 91 |
-
unfold N; push_cast
|
| 92 |
-
nlinarith only [mul_le_mul_of_nonneg_right hab (Nat.cast_nonneg n : 0≤(n:ℝ))]
|
| 93 |
-
end HadwigerCounterexample
|
| 94 |
-
|
| 95 |
-
end
|
| 96 |
-
|
| 97 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BilinearBlockCorrelation
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Conditioned Correlations -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real Filter Matrix LinearMap Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {I A : Type} [Fintype I] [Fintype A]
|
| 12 |
+
variable {n : ℕ}
|
| 13 |
+
|
| 14 |
+
set_option maxHeartbeats 600000 in
|
| 15 |
+
theorem spark_condition (p : Shape) (M : Moment p n) (s t : Label p.b) (l j : Tag p.g)
|
| 16 |
+
(f g : Flavor p.g) (B) (hB : f.keeps l B) (hB' : g.keeps j B)
|
| 17 |
+
(w u : Wgt (Knobs p.g n)) (hw : ∀ i,|w i|≤1) (hu : ∀ i,|u i|≤1)
|
| 18 |
+
(μ δ : Wgt (Knobs p.g n)) (hμ : IsLaw μ) (hδ : IsLaw δ)
|
| 19 |
+
(C : ℝ) (hC : 0<C)
|
| 20 |
+
(hc : ∀ i,μ i ≤ C*unif i) (hc' : ∀ i,δ i ≤ C*unif i)
|
| 21 |
+
(hM : n ≤ 5*blockRank B s t M) :
|
| 22 |
+
let Q i z := evmat M (spring p l s f i) (spring p j t g z)
|
| 23 |
+
|avg (pairW μ δ) (fun x => wsign (Q x.1 x.2)*(w x.1*u x.2))|≤
|
| 24 |
+
C^2*bp (-(n:ℝ)/10) := by
|
| 25 |
+
classical
|
| 26 |
+
intro Q
|
| 27 |
+
let V := Knobs p.g n
|
| 28 |
+
let fit (f p : Wgt V) := fun i => p i*f i/(C*unif i)
|
| 29 |
+
have h0 (i : V) : 0<C*unif i := by rw [unif_apply]; positivity
|
| 30 |
+
have hh (t p : Wgt V) (ht : ∀ i, |t i|≤1) (hp : IsLaw p) (h : ∀ i,p i≤C*unif i) i :
|
| 31 |
+
|fit t p i|≤1 := by
|
| 32 |
+
unfold fit; rw [abs_div,abs_of_pos (h0 i),abs_mul,abs_of_nonneg (hp.nz _)]
|
| 33 |
+
refine (div_le_one (h0 i)).mpr ?_
|
| 34 |
+
exact ((mul_le_mul_of_nonneg_left (ht _) (hp.nz _)).trans_eq (mul_one _)).trans (h _)
|
| 35 |
+
let F (x : V×V) := wsign (Q x.1 x.2)*(w x.1*u x.2)
|
| 36 |
+
let Z (x : V×V) := wsign (Q x.1 x.2)*(fit w μ x.1*fit u δ x.2)
|
| 37 |
+
have he :
|
| 38 |
+
avg (pairW μ δ) F=C^2 * avg (pairW unif unif) Z := by
|
| 39 |
+
unfold avg; rw [Finset.mul_sum]
|
| 40 |
+
refine sum_congr rfl fun i _ => ?_
|
| 41 |
+
unfold Z F fit pairW
|
| 42 |
+
have h1 := h0 i.1; have h2 := h0 i.2
|
| 43 |
+
have h3 : unif i.1 ≠ 0 := by rw [unif_apply]; positivity
|
| 44 |
+
have h4 : unif i.2 ≠ 0 := by rw [unif_apply]; positivity
|
| 45 |
+
field_simp
|
| 46 |
+
change |avg (pairW μ δ) F|≤_
|
| 47 |
+
rw [he,abs_mul,abs_of_nonneg (sq_nonneg _)]
|
| 48 |
+
have hi : (n:ℝ)≤5*blockRank B s t M := by exact_mod_cast hM
|
| 49 |
+
exact mul_le_mul_of_nonneg_left ((spark_uncap p M s t l j f g B hB hB'
|
| 50 |
+
_ _ (hh w μ hw hμ hc) (hh u δ hu hδ hc')).trans (bp_le (by linarith only [hi]))) (sq_nonneg _)
|
| 51 |
+
|
| 52 |
+
def litFire (p : Shape) {n N : ℕ} (x : UnitType p n N) :=
|
| 53 |
+
∀ (s t : Label p.b) (c : Vec (Notches p)), c≠0 →
|
| 54 |
+
n≤5*blockRank Block.Z s t (issue p c x)
|
| 55 |
+
|
| 56 |
+
theorem litFire_calendar (p : Shape) (C : ℝ) (M : ℕ) (hM : 4≤M) :
|
| 57 |
+
∀ᶠ n : ℕ in atTop, let N := M*n; ∀ (m : Mixer p n), 2*num (Full p n)<N →
|
| 58 |
+
∀ w : Wgt (UnitType p n N),
|
| 59 |
+
(∀ i,w i ≤ bp (C*N)*pairW (raw m N) (raw m N) i) →
|
| 60 |
+
pr w (fun i => ¬litFire p i) ≤ bp (-(n:ℝ)*n/8) := by
|
| 61 |
+
classical
|
| 62 |
+
let I := Label p.b × Label p.b × Vec (Notches p)
|
| 63 |
+
have ht := bp_poly_dom_nat (a:=1) zero_lt_one (num I) 0
|
| 64 |
+
filter_upwards [issue_live p,ht,(tendsto_natCast_atTop_atTop (R:=ℝ)).eventually
|
| 65 |
+
(eventually_ge_atTop (8*(C*M+1)))]
|
| 66 |
+
with n hn hp hab N m hN w h
|
| 67 |
+
change 8*(C*M+1)≤ (n:ℝ) at hab
|
| 68 |
+
refine (pr_cap h _).trans ?_
|
| 69 |
+
let Q (i : I) (x : UnitType p n N) :=
|
| 70 |
+
i.2.2≠0 ∧ 5*blockRank Block.Z i.1 i.2.1 (issue p i.2.2 x)<n
|
| 71 |
+
let v := pairW (raw m N) (raw m N)
|
| 72 |
+
have hv : IsLaw v := pairW_law (raw_law m hN) (raw_law m hN)
|
| 73 |
+
have he (i : I) : pr v (Q i)≤bp (-(n:ℝ)*n/4) := by
|
| 74 |
+
by_cases h : i.2.2=0
|
| 75 |
+
· simp only [Q,h,ne_eq,not_true,false_and,pr_false]; exact (bp_pos _).le
|
| 76 |
+
exact (pr_mono hv.nz fun x h => h.2).trans
|
| 77 |
+
(hn N (by unfold N; nlinarith only [Nat.mul_le_mul_right n hM]) hN m _ _ i.2.2 h)
|
| 78 |
+
have hh (x : UnitType p n N) (h : ¬litFire p x) : ∃ i,Q i x := by
|
| 79 |
+
unfold litFire at h
|
| 80 |
+
push Not at h
|
| 81 |
+
obtain ⟨s,t,c,hc,h⟩ := h; exact ⟨(s,t,c),hc,h⟩
|
| 82 |
+
have hi : pr v (fun x=> ¬litFire p x) ≤ num I*bp (-(n:ℝ)*n/4) :=
|
| 83 |
+
(le_trans (pr_mono hv.nz hh) (pr_exists_le hv.nz Q)).trans ((sum_le_sum
|
| 84 |
+
fun i _ => he i).trans_eq (by simp [num]))
|
| 85 |
+
refine (mul_le_mul_of_nonneg_left hi (bp_pos _).le).trans ?_
|
| 86 |
+
simp only [pow_zero,mul_one,one_mul] at hp
|
| 87 |
+
apply (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hp.le
|
| 88 |
+
(bp_pos (-(n:ℝ)*n/4)).le) (bp_pos (C*N)).le).trans
|
| 89 |
+
rw [← bp_add,← bp_add]
|
| 90 |
+
apply bp_le
|
| 91 |
+
unfold N; push_cast
|
| 92 |
+
nlinarith only [mul_le_mul_of_nonneg_right hab (Nat.cast_nonneg n : 0≤(n:ℝ))]
|
| 93 |
+
end HadwigerCounterexample
|
| 94 |
+
|
| 95 |
+
end
|
| 96 |
+
|
| 97 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ConstructionScales.lean
CHANGED
|
@@ -1,100 +1,100 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RawFrameLaws
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Construction Scales -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix Filter
|
| 11 |
-
|
| 12 |
-
theorem card_full (p : Shape) (n : ℕ) :
|
| 13 |
-
Fintype.card (Full p n) = psize p * (1+(p.g*p.g+3)*n) + p.h := by
|
| 14 |
-
calc
|
| 15 |
-
_ = Fintype.card (Row p n) + Fintype.card (Fin p.h) :=
|
| 16 |
-
Fintype.card_sum ..
|
| 17 |
-
_ = _ := by rw [card_row, Fintype.card_fin]
|
| 18 |
-
|
| 19 |
-
theorem full_linear (p : Shape) : ∃ B : ℝ, 0 ≤ B ∧ ∀ n : ℕ, 0 < n →
|
| 20 |
-
num (Full p n) ≤ B*n := by
|
| 21 |
-
let b := psize p*(1+(p.g*p.g+3)) + p.h
|
| 22 |
-
refine ⟨↑b,Nat.cast_nonneg b, fun n hn => ?_⟩
|
| 23 |
-
have h1 : 1 ≤ n := hn
|
| 24 |
-
have h2 : Fintype.card (Full p n) ≤ b*n := by
|
| 25 |
-
rw [card_full]
|
| 26 |
-
unfold b
|
| 27 |
-
calc _ ≤ psize p * (n+(p.g*p.g+3)*n) + p.h*n :=
|
| 28 |
-
add_le_add (Nat.mul_le_mul_left _ (by omega)) (by nlinarith)
|
| 29 |
-
_ = _ := by ring
|
| 30 |
-
exact_mod_cast h2
|
| 31 |
-
|
| 32 |
-
theorem unit_size (p : Shape) (n N : ℕ) :
|
| 33 |
-
num (UnitType p n N) = bp (num (Comp p.g) * 4 * N * num (Full p n)) := by
|
| 34 |
-
have hc :
|
| 35 |
-
(Fintype.card (UnitType p n N)) =
|
| 36 |
-
((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) *
|
| 37 |
-
((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) := by
|
| 38 |
-
simp [UnitType, Orient, Oframe, RawFrame, pow_two]
|
| 39 |
-
unfold num
|
| 40 |
-
rw [hc]
|
| 41 |
-
push_cast
|
| 42 |
-
rw [card_space,dim_mat,Fintype.card_fin]
|
| 43 |
-
push_cast
|
| 44 |
-
simp only [← bp_mul_nat,← bp_add]
|
| 45 |
-
push_cast; ring_nf
|
| 46 |
-
|
| 47 |
-
/-- Fixed linear and constant expenses become any fixed small fraction of N. -/
|
| 48 |
-
theorem have_budget {δ : ℝ} (hd : 0 < δ) (a b : ℝ) (hb : 0 ≤ b) :
|
| 49 |
-
∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n → a*n+b ≤ δ*(M*n : ℕ) := by
|
| 50 |
-
have h : Tendsto (fun M : ℕ => δ*M) atTop atTop :=
|
| 51 |
-
(tendsto_const_mul_atTop_of_pos hd).mpr tendsto_natCast_atTop_atTop
|
| 52 |
-
filter_upwards [h.eventually (eventually_ge_atTop (a+b))] with M hM n hn
|
| 53 |
-
change a+b ≤ δ*M at hM
|
| 54 |
-
push_cast
|
| 55 |
-
have hn' : 1 ≤ (n:ℝ) := by exact_mod_cast hn
|
| 56 |
-
nlinarith only [mul_le_mul_of_nonneg_right hM (Nat.cast_nonneg n : (0:ℝ)≤n),
|
| 57 |
-
mul_le_mul_of_nonneg_right hn' hb]
|
| 58 |
-
|
| 59 |
-
theorem columns_budget (p : Shape) {δ : ℝ} (hd : 0 < δ) (a b : ℝ)
|
| 60 |
-
(ha : 0 ≤ a) (hb : 0 ≤ b) :
|
| 61 |
-
∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n →
|
| 62 |
-
a*num (Full p n) + b ≤ δ*(M*n:ℕ) := by
|
| 63 |
-
obtain ⟨B,hB,h⟩ := full_linear p
|
| 64 |
-
filter_upwards [have_budget hd (a*B) b hb] with M hM n hn
|
| 65 |
-
refine le_trans ?_ (hM n hn)
|
| 66 |
-
rw [mul_assoc]
|
| 67 |
-
exact add_le_add_left (mul_le_mul_of_nonneg_left (h _ hn) ha) _
|
| 68 |
-
|
| 69 |
-
theorem raw_ready (p : Shape) {δ : ℝ} (hd : 0 < δ) :
|
| 70 |
-
∀ᶠ M : ℕ in atTop, ∀ᶠ n : ℕ in atTop, let N := M*n;
|
| 71 |
-
num (UnitType p n N) ≤ bp ((4*num (Comp p.g))*N^ (2 : ℕ)) ∧
|
| 72 |
-
∀ m : Mixer p n, IsLaw (raw m N) ∧ ∀ a : Pin p n N,
|
| 73 |
-
pr (pairW (raw m N) (raw m N)) a.agree ≤ bp (-(1-δ)*(planRank a.sp)*N) := by
|
| 74 |
-
have hd' : 0 < δ/2 := by positivity
|
| 75 |
-
filter_upwards [columns_budget p hd' 2 (4*num (Comp p.g)) (by norm_num)
|
| 76 |
-
(by unfold num; positivity),
|
| 77 |
-
columns_budget p (δ:=1) (by norm_num) 2 1 (by norm_num) (by norm_num)] with M ha hb
|
| 78 |
-
filter_upwards [eventually_ge_atTop 1] with n hn
|
| 79 |
-
specialize ha n hn
|
| 80 |
-
specialize hb n hn
|
| 81 |
-
let N := M*n
|
| 82 |
-
have hi : 0 ≤ num (Comp p.g) := Nat.cast_nonneg _
|
| 83 |
-
have hj : 0 ≤ num (Full p n) := Nat.cast_nonneg _
|
| 84 |
-
rw [one_mul] at hb
|
| 85 |
-
have hh : 2*num (Full p n)<N := by unfold N; linarith only [hb]
|
| 86 |
-
dsimp only
|
| 87 |
-
constructor
|
| 88 |
-
· rw [unit_size]
|
| 89 |
-
apply bp_le
|
| 90 |
-
have hf : num (Full p n) ≤ N := by linarith
|
| 91 |
-
|
| 92 |
-
exact le_trans (mul_le_mul_of_nonneg_left hf (by positivity))
|
| 93 |
-
(le_of_eq (by unfold N; push_cast; ring))
|
| 94 |
-
· intro m
|
| 95 |
-
refine ⟨raw_law m hh, fun a => reference_cap _ a hd ?_ ?_ ?_⟩ <;> linarith
|
| 96 |
-
end HadwigerCounterexample
|
| 97 |
-
|
| 98 |
-
end
|
| 99 |
-
|
| 100 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RawFrameLaws
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Construction Scales -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix Filter
|
| 11 |
+
|
| 12 |
+
theorem card_full (p : Shape) (n : ℕ) :
|
| 13 |
+
Fintype.card (Full p n) = psize p * (1+(p.g*p.g+3)*n) + p.h := by
|
| 14 |
+
calc
|
| 15 |
+
_ = Fintype.card (Row p n) + Fintype.card (Fin p.h) :=
|
| 16 |
+
Fintype.card_sum ..
|
| 17 |
+
_ = _ := by rw [card_row, Fintype.card_fin]
|
| 18 |
+
|
| 19 |
+
theorem full_linear (p : Shape) : ∃ B : ℝ, 0 ≤ B ∧ ∀ n : ℕ, 0 < n →
|
| 20 |
+
num (Full p n) ≤ B*n := by
|
| 21 |
+
let b := psize p*(1+(p.g*p.g+3)) + p.h
|
| 22 |
+
refine ⟨↑b,Nat.cast_nonneg b, fun n hn => ?_⟩
|
| 23 |
+
have h1 : 1 ≤ n := hn
|
| 24 |
+
have h2 : Fintype.card (Full p n) ≤ b*n := by
|
| 25 |
+
rw [card_full]
|
| 26 |
+
unfold b
|
| 27 |
+
calc _ ≤ psize p * (n+(p.g*p.g+3)*n) + p.h*n :=
|
| 28 |
+
add_le_add (Nat.mul_le_mul_left _ (by omega)) (by nlinarith)
|
| 29 |
+
_ = _ := by ring
|
| 30 |
+
exact_mod_cast h2
|
| 31 |
+
|
| 32 |
+
theorem unit_size (p : Shape) (n N : ℕ) :
|
| 33 |
+
num (UnitType p n N) = bp (num (Comp p.g) * 4 * N * num (Full p n)) := by
|
| 34 |
+
have hc :
|
| 35 |
+
(Fintype.card (UnitType p n N)) =
|
| 36 |
+
((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) *
|
| 37 |
+
((Fintype.card (Mat (Fin N) (Full p n)))^2)^(Fintype.card (Comp p.g)) := by
|
| 38 |
+
simp [UnitType, Orient, Oframe, RawFrame, pow_two]
|
| 39 |
+
unfold num
|
| 40 |
+
rw [hc]
|
| 41 |
+
push_cast
|
| 42 |
+
rw [card_space,dim_mat,Fintype.card_fin]
|
| 43 |
+
push_cast
|
| 44 |
+
simp only [← bp_mul_nat,← bp_add]
|
| 45 |
+
push_cast; ring_nf
|
| 46 |
+
|
| 47 |
+
/-- Fixed linear and constant expenses become any fixed small fraction of N. -/
|
| 48 |
+
theorem have_budget {δ : ℝ} (hd : 0 < δ) (a b : ℝ) (hb : 0 ≤ b) :
|
| 49 |
+
∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n → a*n+b ≤ δ*(M*n : ℕ) := by
|
| 50 |
+
have h : Tendsto (fun M : ℕ => δ*M) atTop atTop :=
|
| 51 |
+
(tendsto_const_mul_atTop_of_pos hd).mpr tendsto_natCast_atTop_atTop
|
| 52 |
+
filter_upwards [h.eventually (eventually_ge_atTop (a+b))] with M hM n hn
|
| 53 |
+
change a+b ≤ δ*M at hM
|
| 54 |
+
push_cast
|
| 55 |
+
have hn' : 1 ≤ (n:ℝ) := by exact_mod_cast hn
|
| 56 |
+
nlinarith only [mul_le_mul_of_nonneg_right hM (Nat.cast_nonneg n : (0:ℝ)≤n),
|
| 57 |
+
mul_le_mul_of_nonneg_right hn' hb]
|
| 58 |
+
|
| 59 |
+
theorem columns_budget (p : Shape) {δ : ℝ} (hd : 0 < δ) (a b : ℝ)
|
| 60 |
+
(ha : 0 ≤ a) (hb : 0 ≤ b) :
|
| 61 |
+
∀ᶠ M : ℕ in atTop, ∀ n : ℕ, 1 ≤ n →
|
| 62 |
+
a*num (Full p n) + b ≤ δ*(M*n:ℕ) := by
|
| 63 |
+
obtain ⟨B,hB,h⟩ := full_linear p
|
| 64 |
+
filter_upwards [have_budget hd (a*B) b hb] with M hM n hn
|
| 65 |
+
refine le_trans ?_ (hM n hn)
|
| 66 |
+
rw [mul_assoc]
|
| 67 |
+
exact add_le_add_left (mul_le_mul_of_nonneg_left (h _ hn) ha) _
|
| 68 |
+
|
| 69 |
+
theorem raw_ready (p : Shape) {δ : ℝ} (hd : 0 < δ) :
|
| 70 |
+
∀ᶠ M : ℕ in atTop, ∀ᶠ n : ℕ in atTop, let N := M*n;
|
| 71 |
+
num (UnitType p n N) ≤ bp ((4*num (Comp p.g))*N^ (2 : ℕ)) ∧
|
| 72 |
+
∀ m : Mixer p n, IsLaw (raw m N) ∧ ∀ a : Pin p n N,
|
| 73 |
+
pr (pairW (raw m N) (raw m N)) a.agree ≤ bp (-(1-δ)*(planRank a.sp)*N) := by
|
| 74 |
+
have hd' : 0 < δ/2 := by positivity
|
| 75 |
+
filter_upwards [columns_budget p hd' 2 (4*num (Comp p.g)) (by norm_num)
|
| 76 |
+
(by unfold num; positivity),
|
| 77 |
+
columns_budget p (δ:=1) (by norm_num) 2 1 (by norm_num) (by norm_num)] with M ha hb
|
| 78 |
+
filter_upwards [eventually_ge_atTop 1] with n hn
|
| 79 |
+
specialize ha n hn
|
| 80 |
+
specialize hb n hn
|
| 81 |
+
let N := M*n
|
| 82 |
+
have hi : 0 ≤ num (Comp p.g) := Nat.cast_nonneg _
|
| 83 |
+
have hj : 0 ≤ num (Full p n) := Nat.cast_nonneg _
|
| 84 |
+
rw [one_mul] at hb
|
| 85 |
+
have hh : 2*num (Full p n)<N := by unfold N; linarith only [hb]
|
| 86 |
+
dsimp only
|
| 87 |
+
constructor
|
| 88 |
+
· rw [unit_size]
|
| 89 |
+
apply bp_le
|
| 90 |
+
have hf : num (Full p n) ≤ N := by linarith
|
| 91 |
+
|
| 92 |
+
exact le_trans (mul_le_mul_of_nonneg_left hf (by positivity))
|
| 93 |
+
(le_of_eq (by unfold N; push_cast; ring))
|
| 94 |
+
· intro m
|
| 95 |
+
refine ⟨raw_law m hh, fun a => reference_cap _ a hd ?_ ?_ ?_⟩ <;> linarith
|
| 96 |
+
end HadwigerCounterexample
|
| 97 |
+
|
| 98 |
+
end
|
| 99 |
+
|
| 100 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateBlocks.lean
CHANGED
|
@@ -1,147 +1,147 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BooleanLabels
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.QuadraticTesters
|
| 3 |
-
import OAI.Combinatorics.HadwigerCounterexample.CoordinateEmbeddings
|
| 4 |
-
|
| 5 |
-
namespace OAI
|
| 6 |
-
|
| 7 |
-
/-! # Coordinate Blocks -/
|
| 8 |
-
|
| 9 |
-
noncomputable section
|
| 10 |
-
namespace HadwigerCounterexample
|
| 11 |
-
open Matrix
|
| 12 |
-
open scoped BigOperators
|
| 13 |
-
variable {p : Shape} {n : ℕ}
|
| 14 |
-
|
| 15 |
-
def blockA (p : Shape) (n : ℕ) (B : Block p.g) : Mat (AIdx p.g n) (Fin n) :=
|
| 16 |
-
embedMat (fun i => some (B,i))
|
| 17 |
-
|
| 18 |
-
def blockRay (p : Shape) (n : ℕ) (s : Label p.b) (B : Block p.g) : Mat (Row p n) (Fin n) :=
|
| 19 |
-
labMat p n s * blockA p n B
|
| 20 |
-
|
| 21 |
-
theorem lab_inj (s : Label p.b) : Function.Injective (labMat p n s).mulVec := by
|
| 22 |
-
intro x y he
|
| 23 |
-
funext i
|
| 24 |
-
rw [labMat_act,labMat_act] at he
|
| 25 |
-
have h := congr_fun he (emptySel,i)
|
| 26 |
-
simpa [putLab,selV,emptySel] using h
|
| 27 |
-
|
| 28 |
-
theorem joined_lab_inj {s t : Label p.b} (hj : 1≤p.j) (hs : s≠t) :
|
| 29 |
-
Function.Injective (fromCols (labMat p n s) (labMat p n t)).mulVec := by
|
| 30 |
-
apply inj_fromCols (lab_inj _) (lab_inj _)
|
| 31 |
-
classical
|
| 32 |
-
rw [disjoint_iff_inf_le]
|
| 33 |
-
rintro x ⟨⟨v,rfl⟩,w,h⟩
|
| 34 |
-
simp only [mulVecLin_apply,labMat_act] at h
|
| 35 |
-
let Z : Label p.b → Vec (AIdx p.g n) := fun i => if i=s then v else -w
|
| 36 |
-
have he : ∑ i ∈ ({s,t} : Finset _), putLab p n i (Z i)=0 := by
|
| 37 |
-
simp [Z,hs,hs.symm,map_neg,h]
|
| 38 |
-
have hi : ({s,t}:Finset _).card ≤ p.j+1 := by
|
| 39 |
-
have hh : ({s,t}:Finset _).card=2 := by simp [hs]
|
| 40 |
-
omega
|
| 41 |
-
have hg := ray_indep _ _ hi he s (by simp)
|
| 42 |
-
have hv : v=0 := by simpa [Z] using hg
|
| 43 |
-
rw [hv,map_zero]; exact Submodule.zero_mem _
|
| 44 |
-
|
| 45 |
-
theorem block_inj (B : Block p.g) : Function.Injective (blockA p n B).mulVec :=
|
| 46 |
-
embedMat_inj (show Function.Injective (fun i => some (B,i)) from
|
| 47 |
-
fun _ _ h => congrArg Prod.snd (Option.some.inj h))
|
| 48 |
-
|
| 49 |
-
theorem blockRay_inj (p : Shape) (n) (s) (B) :
|
| 50 |
-
Function.Injective (blockRay p n s B).mulVec :=
|
| 51 |
-
inj_comp_mat _ _ (lab_inj _) (block_inj B)
|
| 52 |
-
|
| 53 |
-
theorem joined_block_inj {s t : Label p.b} (hj : 1 ≤ p.j) (hs : s ≠ t) (B : Block p.g) :
|
| 54 |
-
Function.Injective (fromCols (blockRay p n s B) (blockRay p n t B)).mulVec := by
|
| 55 |
-
classical
|
| 56 |
-
apply inj_fromCols (blockRay_inj ..) (blockRay_inj ..)
|
| 57 |
-
rw [disjoint_iff_inf_le]
|
| 58 |
-
rintro x ⟨⟨v,rfl⟩,w,h⟩
|
| 59 |
-
simp only [Matrix.mulVecLin_apply,blockRay,← Matrix.mulVec_mulVec] at h
|
| 60 |
-
let a := Sum.elim (blockA p n B *ᵥ v) (0 : Vec (AIdx p.g n))
|
| 61 |
-
let b := Sum.elim (0 : Vec (AIdx p.g n)) (blockA p n B *ᵥ w)
|
| 62 |
-
have heq : a=b := joined_lab_inj hj hs (by
|
| 63 |
-
dsimp only [a,b]
|
| 64 |
-
rw [fromCols_mulVec_sumElim,fromCols_mulVec_sumElim,Matrix.mulVec_zero,
|
| 65 |
-
Matrix.mulVec_zero,zero_add,add_zero,h])
|
| 66 |
-
have hg : blockA p n B *ᵥ v = 0 := funext (fun x => congr_fun heq (.inl x))
|
| 67 |
-
change blockRay p n s B *ᵥ v ∈ _
|
| 68 |
-
rw [blockRay,← Matrix.mulVec_mulVec,hg,Matrix.mulVec_zero]
|
| 69 |
-
exact Submodule.zero_mem _
|
| 70 |
-
|
| 71 |
-
theorem blockRay_eval (p : Shape) (s : Label p.b) (B) (i) (j : Fin n) :
|
| 72 |
-
blockRay p n s B i j = if i.2=some (B,j) then monoBit s i.1.val else 0 := by
|
| 73 |
-
rw [blockRay,blockA,mul_embedMat]; rfl
|
| 74 |
-
|
| 75 |
-
theorem project_pick {d B : Block p.g} (hd : d ≠ B) (a) (s) (i) :
|
| 76 |
-
(blockRay p n s B)ᵀ *ᵥ pick p n a d i = 0 := by
|
| 77 |
-
classical
|
| 78 |
-
unfold pick
|
| 79 |
-
split
|
| 80 |
-
· rename_i hi
|
| 81 |
-
rw [Matrix.mulVec_single_one]
|
| 82 |
-
ext j
|
| 83 |
-
change blockRay p n s B (a,some (d,⟨i,hi⟩)) j=0
|
| 84 |
-
simp [blockRay_eval,hd]
|
| 85 |
-
rw [Matrix.mulVec_zero]
|
| 86 |
-
|
| 87 |
-
theorem project_same (B : Block p.g) (a s) (i : Fin n) :
|
| 88 |
-
(blockRay p n s B)ᵀ *ᵥ pick p n a B i.val = Pi.single i (monoBit s a.val) := by
|
| 89 |
-
classical
|
| 90 |
-
rw [pick,dite_eq_left i.isLt,Matrix.mulVec_single_one]
|
| 91 |
-
ext j
|
| 92 |
-
change blockRay p n s B _ j=_
|
| 93 |
-
rw [blockRay_eval]
|
| 94 |
-
simp [Pi.single_apply, eq_comm]
|
| 95 |
-
|
| 96 |
-
def pullM {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I) (Q : Mat U J) :
|
| 97 |
-
Mat V U →ₗ[F] Mat I J := liftM Pᵀ Qᵀ
|
| 98 |
-
theorem pullM_def {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I)
|
| 99 |
-
(Q : Mat U J) (M : Mat V U) : pullM P Q M=Pᵀ*M*Q := rfl
|
| 100 |
-
|
| 101 |
-
theorem pull_test {d B : Block p.g} (h : d≠B) (s s') :
|
| 102 |
-
pullM (blockRay p n s B) (blockRay p n s' B) (testM p n d) = 0 := by
|
| 103 |
-
unfold testM pullM
|
| 104 |
-
simp only [map_sum,liftM_outer,project_pick h]
|
| 105 |
-
simp
|
| 106 |
-
|
| 107 |
-
theorem pull_self_Z (M) (s s' : Label p.b) :
|
| 108 |
-
pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z) (selfM p n M)=0 := by
|
| 109 |
-
let L := pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z)
|
| 110 |
-
have hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)
|
| 111 |
-
(B:=Block.Z) (by simp [Block.O,Block.Z]) s s'
|
| 112 |
-
have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.Z) (by simp [Block.S,Block.Z]) s s'
|
| 113 |
-
have h (a : SelIdx p.b p.j) (s : Label p.b) (i) :=
|
| 114 |
-
project_pick (n:=n) (p:=p) (d:=Block.sharp) (B:=Block.Z) (by simp [Block.sharp,Block.Z]) a s i
|
| 115 |
-
rw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]
|
| 116 |
-
unfold sharpM sharpPick pullM
|
| 117 |
-
by_cases he : 1 ≤ p.j
|
| 118 |
-
· simp only [map_sum,map_smul,map_add, dite_eq_left he,liftM_outer,h]
|
| 119 |
-
simp
|
| 120 |
-
· simp only [dite_eq_right he]; simp
|
| 121 |
-
|
| 122 |
-
theorem pull_self_sharp (M) (s s' : Label p.b) (hj : 1≤p.j) :
|
| 123 |
-
pullM (blockRay p n s Block.sharp) (blockRay p n s' Block.sharp) (selfM p n M) =
|
| 124 |
-
∑ i, (s i+s' i) • M i := by
|
| 125 |
-
classical
|
| 126 |
-
have hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)
|
| 127 |
-
(B:=Block.sharp) (by simp [Block.O,Block.sharp]) s s'
|
| 128 |
-
have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.sharp) (by simp [Block.S,Block.sharp]) s s'
|
| 129 |
-
rw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]
|
| 130 |
-
unfold sharpM sharpPick pullM
|
| 131 |
-
simp only [map_sum,map_add,map_smul, dite_eq_left hj,liftM_outer,project_same]
|
| 132 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 133 |
-
ext a b
|
| 134 |
-
simp only [Matrix.sum_apply,Matrix.add_apply,Matrix.smul_apply,smul_eq_mul,
|
| 135 |
-
vecMulVec_apply,monoBit,emptySel,Finset.prod_empty,Finset.prod_singleton,Pi.single_apply]
|
| 136 |
-
rw [Finset.sum_eq_single a]
|
| 137 |
-
· rw [Finset.sum_eq_single b]
|
| 138 |
-
· simp; ring
|
| 139 |
-
· intro j _ h; simp [h.symm]
|
| 140 |
-
· simp
|
| 141 |
-
· intro j _ h; simp [h.symm]
|
| 142 |
-
simp
|
| 143 |
-
end HadwigerCounterexample
|
| 144 |
-
|
| 145 |
-
end
|
| 146 |
-
|
| 147 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BooleanLabels
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.QuadraticTesters
|
| 3 |
+
import OAI.Combinatorics.HadwigerCounterexample.CoordinateEmbeddings
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! # Coordinate Blocks -/
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
namespace HadwigerCounterexample
|
| 11 |
+
open Matrix
|
| 12 |
+
open scoped BigOperators
|
| 13 |
+
variable {p : Shape} {n : ℕ}
|
| 14 |
+
|
| 15 |
+
def blockA (p : Shape) (n : ℕ) (B : Block p.g) : Mat (AIdx p.g n) (Fin n) :=
|
| 16 |
+
embedMat (fun i => some (B,i))
|
| 17 |
+
|
| 18 |
+
def blockRay (p : Shape) (n : ℕ) (s : Label p.b) (B : Block p.g) : Mat (Row p n) (Fin n) :=
|
| 19 |
+
labMat p n s * blockA p n B
|
| 20 |
+
|
| 21 |
+
theorem lab_inj (s : Label p.b) : Function.Injective (labMat p n s).mulVec := by
|
| 22 |
+
intro x y he
|
| 23 |
+
funext i
|
| 24 |
+
rw [labMat_act,labMat_act] at he
|
| 25 |
+
have h := congr_fun he (emptySel,i)
|
| 26 |
+
simpa [putLab,selV,emptySel] using h
|
| 27 |
+
|
| 28 |
+
theorem joined_lab_inj {s t : Label p.b} (hj : 1≤p.j) (hs : s≠t) :
|
| 29 |
+
Function.Injective (fromCols (labMat p n s) (labMat p n t)).mulVec := by
|
| 30 |
+
apply inj_fromCols (lab_inj _) (lab_inj _)
|
| 31 |
+
classical
|
| 32 |
+
rw [disjoint_iff_inf_le]
|
| 33 |
+
rintro x ⟨⟨v,rfl⟩,w,h⟩
|
| 34 |
+
simp only [mulVecLin_apply,labMat_act] at h
|
| 35 |
+
let Z : Label p.b → Vec (AIdx p.g n) := fun i => if i=s then v else -w
|
| 36 |
+
have he : ∑ i ∈ ({s,t} : Finset _), putLab p n i (Z i)=0 := by
|
| 37 |
+
simp [Z,hs,hs.symm,map_neg,h]
|
| 38 |
+
have hi : ({s,t}:Finset _).card ≤ p.j+1 := by
|
| 39 |
+
have hh : ({s,t}:Finset _).card=2 := by simp [hs]
|
| 40 |
+
omega
|
| 41 |
+
have hg := ray_indep _ _ hi he s (by simp)
|
| 42 |
+
have hv : v=0 := by simpa [Z] using hg
|
| 43 |
+
rw [hv,map_zero]; exact Submodule.zero_mem _
|
| 44 |
+
|
| 45 |
+
theorem block_inj (B : Block p.g) : Function.Injective (blockA p n B).mulVec :=
|
| 46 |
+
embedMat_inj (show Function.Injective (fun i => some (B,i)) from
|
| 47 |
+
fun _ _ h => congrArg Prod.snd (Option.some.inj h))
|
| 48 |
+
|
| 49 |
+
theorem blockRay_inj (p : Shape) (n) (s) (B) :
|
| 50 |
+
Function.Injective (blockRay p n s B).mulVec :=
|
| 51 |
+
inj_comp_mat _ _ (lab_inj _) (block_inj B)
|
| 52 |
+
|
| 53 |
+
theorem joined_block_inj {s t : Label p.b} (hj : 1 ≤ p.j) (hs : s ≠ t) (B : Block p.g) :
|
| 54 |
+
Function.Injective (fromCols (blockRay p n s B) (blockRay p n t B)).mulVec := by
|
| 55 |
+
classical
|
| 56 |
+
apply inj_fromCols (blockRay_inj ..) (blockRay_inj ..)
|
| 57 |
+
rw [disjoint_iff_inf_le]
|
| 58 |
+
rintro x ⟨⟨v,rfl⟩,w,h⟩
|
| 59 |
+
simp only [Matrix.mulVecLin_apply,blockRay,← Matrix.mulVec_mulVec] at h
|
| 60 |
+
let a := Sum.elim (blockA p n B *ᵥ v) (0 : Vec (AIdx p.g n))
|
| 61 |
+
let b := Sum.elim (0 : Vec (AIdx p.g n)) (blockA p n B *ᵥ w)
|
| 62 |
+
have heq : a=b := joined_lab_inj hj hs (by
|
| 63 |
+
dsimp only [a,b]
|
| 64 |
+
rw [fromCols_mulVec_sumElim,fromCols_mulVec_sumElim,Matrix.mulVec_zero,
|
| 65 |
+
Matrix.mulVec_zero,zero_add,add_zero,h])
|
| 66 |
+
have hg : blockA p n B *ᵥ v = 0 := funext (fun x => congr_fun heq (.inl x))
|
| 67 |
+
change blockRay p n s B *ᵥ v ∈ _
|
| 68 |
+
rw [blockRay,← Matrix.mulVec_mulVec,hg,Matrix.mulVec_zero]
|
| 69 |
+
exact Submodule.zero_mem _
|
| 70 |
+
|
| 71 |
+
theorem blockRay_eval (p : Shape) (s : Label p.b) (B) (i) (j : Fin n) :
|
| 72 |
+
blockRay p n s B i j = if i.2=some (B,j) then monoBit s i.1.val else 0 := by
|
| 73 |
+
rw [blockRay,blockA,mul_embedMat]; rfl
|
| 74 |
+
|
| 75 |
+
theorem project_pick {d B : Block p.g} (hd : d ≠ B) (a) (s) (i) :
|
| 76 |
+
(blockRay p n s B)ᵀ *ᵥ pick p n a d i = 0 := by
|
| 77 |
+
classical
|
| 78 |
+
unfold pick
|
| 79 |
+
split
|
| 80 |
+
· rename_i hi
|
| 81 |
+
rw [Matrix.mulVec_single_one]
|
| 82 |
+
ext j
|
| 83 |
+
change blockRay p n s B (a,some (d,⟨i,hi⟩)) j=0
|
| 84 |
+
simp [blockRay_eval,hd]
|
| 85 |
+
rw [Matrix.mulVec_zero]
|
| 86 |
+
|
| 87 |
+
theorem project_same (B : Block p.g) (a s) (i : Fin n) :
|
| 88 |
+
(blockRay p n s B)ᵀ *ᵥ pick p n a B i.val = Pi.single i (monoBit s a.val) := by
|
| 89 |
+
classical
|
| 90 |
+
rw [pick,dite_eq_left i.isLt,Matrix.mulVec_single_one]
|
| 91 |
+
ext j
|
| 92 |
+
change blockRay p n s B _ j=_
|
| 93 |
+
rw [blockRay_eval]
|
| 94 |
+
simp [Pi.single_apply, eq_comm]
|
| 95 |
+
|
| 96 |
+
def pullM {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I) (Q : Mat U J) :
|
| 97 |
+
Mat V U →ₗ[F] Mat I J := liftM Pᵀ Qᵀ
|
| 98 |
+
theorem pullM_def {I J V U : Type} [Fintype V] [Fintype U] (P : Mat V I)
|
| 99 |
+
(Q : Mat U J) (M : Mat V U) : pullM P Q M=Pᵀ*M*Q := rfl
|
| 100 |
+
|
| 101 |
+
theorem pull_test {d B : Block p.g} (h : d≠B) (s s') :
|
| 102 |
+
pullM (blockRay p n s B) (blockRay p n s' B) (testM p n d) = 0 := by
|
| 103 |
+
unfold testM pullM
|
| 104 |
+
simp only [map_sum,liftM_outer,project_pick h]
|
| 105 |
+
simp
|
| 106 |
+
|
| 107 |
+
theorem pull_self_Z (M) (s s' : Label p.b) :
|
| 108 |
+
pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z) (selfM p n M)=0 := by
|
| 109 |
+
let L := pullM (blockRay p n s Block.Z) (blockRay p n s' Block.Z)
|
| 110 |
+
have hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)
|
| 111 |
+
(B:=Block.Z) (by simp [Block.O,Block.Z]) s s'
|
| 112 |
+
have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.Z) (by simp [Block.S,Block.Z]) s s'
|
| 113 |
+
have h (a : SelIdx p.b p.j) (s : Label p.b) (i) :=
|
| 114 |
+
project_pick (n:=n) (p:=p) (d:=Block.sharp) (B:=Block.Z) (by simp [Block.sharp,Block.Z]) a s i
|
| 115 |
+
rw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]
|
| 116 |
+
unfold sharpM sharpPick pullM
|
| 117 |
+
by_cases he : 1 ≤ p.j
|
| 118 |
+
· simp only [map_sum,map_smul,map_add, dite_eq_left he,liftM_outer,h]
|
| 119 |
+
simp
|
| 120 |
+
· simp only [dite_eq_right he]; simp
|
| 121 |
+
|
| 122 |
+
theorem pull_self_sharp (M) (s s' : Label p.b) (hj : 1≤p.j) :
|
| 123 |
+
pullM (blockRay p n s Block.sharp) (blockRay p n s' Block.sharp) (selfM p n M) =
|
| 124 |
+
∑ i, (s i+s' i) • M i := by
|
| 125 |
+
classical
|
| 126 |
+
have hx (i j : Tag p.g) := pull_test (n:=n) (d:=Block.O i j)
|
| 127 |
+
(B:=Block.sharp) (by simp [Block.O,Block.sharp]) s s'
|
| 128 |
+
have hs := pull_test (p:=p) (n:=n) (d:=Block.S) (B:=Block.sharp) (by simp [Block.S,Block.sharp]) s s'
|
| 129 |
+
rw [selfM]; simp only [map_add,map_sum,hx,hs,Finset.sum_const_zero,zero_add]
|
| 130 |
+
unfold sharpM sharpPick pullM
|
| 131 |
+
simp only [map_sum,map_add,map_smul, dite_eq_left hj,liftM_outer,project_same]
|
| 132 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 133 |
+
ext a b
|
| 134 |
+
simp only [Matrix.sum_apply,Matrix.add_apply,Matrix.smul_apply,smul_eq_mul,
|
| 135 |
+
vecMulVec_apply,monoBit,emptySel,Finset.prod_empty,Finset.prod_singleton,Pi.single_apply]
|
| 136 |
+
rw [Finset.sum_eq_single a]
|
| 137 |
+
· rw [Finset.sum_eq_single b]
|
| 138 |
+
· simp; ring
|
| 139 |
+
· intro j _ h; simp [h.symm]
|
| 140 |
+
· simp
|
| 141 |
+
· intro j _ h; simp [h.symm]
|
| 142 |
+
simp
|
| 143 |
+
end HadwigerCounterexample
|
| 144 |
+
|
| 145 |
+
end
|
| 146 |
+
|
| 147 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateDuality.lean
CHANGED
|
@@ -1,87 +1,87 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ScalarStatusAlgebra
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Coordinate Duality -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Module LinearMap Submodule Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
namespace StatusAnalysis
|
| 12 |
-
variable {A B : Rates} {d e : ℕ}
|
| 13 |
-
|
| 14 |
-
structure DualCoefficients (A B : Rates) where
|
| 15 |
-
left : Quota
|
| 16 |
-
right : Quota
|
| 17 |
-
gam : Grid→F
|
| 18 |
-
hed : Grid→F
|
| 19 |
-
north : (i:Grid)→ Cell (A i.1)
|
| 20 |
-
south : (i:Grid)→ Cell (B i.2)
|
| 21 |
-
def DualCoefficients.bet (p : DualCoefficients A B) (i : Grid) (x : LedgerS A B i) :=
|
| 22 |
-
p.gam i * x.1 + p.hed i * x.2.1 + (dotProduct (p.north i) x.2.2.1+
|
| 23 |
-
dotProduct (p.south i) x.2.2.2)
|
| 24 |
-
def DualCoefficients.law (p : DualCoefficients A B) (V : StatusSp A B) :=
|
| 25 |
-
∀ i:Grid,∀ v∈V i, p.bet i (want _ _ v) =
|
| 26 |
-
p.left i.2 * couple _ v.2.1 + p.right i.1 * couple _ v.2.2
|
| 27 |
-
|
| 28 |
-
private theorem coordinates (f : Question d e →ₗ[F] F) :
|
| 29 |
-
∃ a b : F,∃ (u : Cell d) (v : Cell e),∀ (x:Question d e),
|
| 30 |
-
f x=a*x.1+b*x.2.1 + (dotProduct u x.2.2.1+dotProduct v x.2.2.2) := by
|
| 31 |
-
let g := f ∘ₗ LinearMap.inr F F _ ∘ₗ LinearMap.inr F F _
|
| 32 |
-
obtain ⟨u,hu⟩:=dotL_surj (g ∘ₗ LinearMap.inl F _ _)
|
| 33 |
-
obtain ⟨v,hv⟩:=dotL_surj (g ∘ₗ LinearMap.inr F _ _)
|
| 34 |
-
let a : Question d e := (1,0); let b : Question d e := (0,1,0)
|
| 35 |
-
refine ⟨f a,f b,u,v,?_⟩
|
| 36 |
-
rintro ⟨x,y,z,w⟩
|
| 37 |
-
have he : ((x,y,z,w):Question d e)=x • a +y • b+((0,0,z,0)+(0,0,0,w)) := by
|
| 38 |
-
unfold a b; ext <;> simp
|
| 39 |
-
have h1 : f (0,0,z,0)=dotProduct u z := LinearMap.congr_fun hu z
|
| 40 |
-
have h2 : f (0,0,0,w)=dotProduct v w := LinearMap.congr_fun hv w
|
| 41 |
-
change f (x,y,z,w)=f a*x + f b*y + _
|
| 42 |
-
conv_lhs => rw [he]
|
| 43 |
-
rw [map_add,map_add,map_add,map_smul,map_smul,h1,h2]; simp [mul_comm]
|
| 44 |
-
|
| 45 |
-
theorem jargon_score (V : StatusSp A B) (T : Cabinet A B)
|
| 46 |
-
(h : ¬scorecard V T) (hh : ∀ i,coverBase (V i)) :
|
| 47 |
-
∃ p : DualCoefficients A B, (p.left≠0 ∨ p.right≠0) ∧ p.law V ∧ ∑ i,p.bet i (T i)≠0 := by
|
| 48 |
-
obtain ⟨p,hp,hf⟩:= counter_score V T h
|
| 49 |
-
choose a b u v he using fun i=>coordinates (p.alf i)
|
| 50 |
-
let g : DualCoefficients A B:=⟨p.altL,p.altR,a,b,u,v⟩
|
| 51 |
-
have hz i x : g.bet i x=p.alf i x := (he i x).symm
|
| 52 |
-
refine ⟨g,critic_nz V T hh p hp hf,fun i x hx=>?_,?_⟩
|
| 53 |
-
· rw [hz]; exact hp i x hx
|
| 54 |
-
simp_rw [hz]; exact hf
|
| 55 |
-
|
| 56 |
-
abbrev excessK (V : Space (Signal d e)) := V ⊓ LinearMap.ker (view d e)
|
| 57 |
-
theorem signal_dim :
|
| 58 |
-
dim (Signal d e) = dim (View d e)+2 := by
|
| 59 |
-
simp only [Signal,View,Whole,dim,finrank_prod,finrank_self]
|
| 60 |
-
omega
|
| 61 |
-
theorem ker_two (V : Space (Signal d e)) :
|
| 62 |
-
dim (excessK V) ≤ 2 := by
|
| 63 |
-
have he : Surjective (view d e) := by
|
| 64 |
-
rintro ⟨i,j,k⟩; exact ⟨(i,(j,0),(k,0)),rfl⟩
|
| 65 |
-
have ht := LinearMap.finrank_range_add_finrank_ker (view d e)
|
| 66 |
-
change rk (view _ _) + dim _=dim (Signal d e) at ht
|
| 67 |
-
rw [rk_surj.mp he,signal_dim] at ht
|
| 68 |
-
exact (Submodule.finrank_mono (show excessK V≤_ from inf_le_right)).trans
|
| 69 |
-
(by omega : dim (LinearMap.ker (view d e)) ≤ 2)
|
| 70 |
-
|
| 71 |
-
def overage (V : Space (Signal d e)) := dim V - dim (View d e)
|
| 72 |
-
theorem overage_two (V : Space (Signal d e)) : overage V≤2 := by
|
| 73 |
-
have hi : dim V ≤ dim (Signal d e) := finrank_le _
|
| 74 |
-
rw [signal_dim] at hi; unfold overage; omega
|
| 75 |
-
theorem overage_mono {V W : Space (Signal d e)} (h : V≤W) :
|
| 76 |
-
overage V≤overage W := Nat.sub_le_sub_right (finrank_mono h) _
|
| 77 |
-
theorem overage_lt {V W : Space (Signal d e)} (h : V<W) (he : coverBase V) :
|
| 78 |
-
overage V<overage W := by
|
| 79 |
-
have hh := finrank_lt_finrank_of_lt h; change dim V<dim W at hh
|
| 80 |
-
have hx : dim (View d e) ≤ dim V := LinearMap.finrank_le_finrank_of_surjective he
|
| 81 |
-
unfold overage; omega
|
| 82 |
-
end StatusAnalysis
|
| 83 |
-
end HadwigerCounterexample
|
| 84 |
-
|
| 85 |
-
end
|
| 86 |
-
|
| 87 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ScalarStatusAlgebra
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Coordinate Duality -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Module LinearMap Submodule Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
namespace StatusAnalysis
|
| 12 |
+
variable {A B : Rates} {d e : ℕ}
|
| 13 |
+
|
| 14 |
+
structure DualCoefficients (A B : Rates) where
|
| 15 |
+
left : Quota
|
| 16 |
+
right : Quota
|
| 17 |
+
gam : Grid→F
|
| 18 |
+
hed : Grid→F
|
| 19 |
+
north : (i:Grid)→ Cell (A i.1)
|
| 20 |
+
south : (i:Grid)→ Cell (B i.2)
|
| 21 |
+
def DualCoefficients.bet (p : DualCoefficients A B) (i : Grid) (x : LedgerS A B i) :=
|
| 22 |
+
p.gam i * x.1 + p.hed i * x.2.1 + (dotProduct (p.north i) x.2.2.1+
|
| 23 |
+
dotProduct (p.south i) x.2.2.2)
|
| 24 |
+
def DualCoefficients.law (p : DualCoefficients A B) (V : StatusSp A B) :=
|
| 25 |
+
∀ i:Grid,∀ v∈V i, p.bet i (want _ _ v) =
|
| 26 |
+
p.left i.2 * couple _ v.2.1 + p.right i.1 * couple _ v.2.2
|
| 27 |
+
|
| 28 |
+
private theorem coordinates (f : Question d e →ₗ[F] F) :
|
| 29 |
+
∃ a b : F,∃ (u : Cell d) (v : Cell e),∀ (x:Question d e),
|
| 30 |
+
f x=a*x.1+b*x.2.1 + (dotProduct u x.2.2.1+dotProduct v x.2.2.2) := by
|
| 31 |
+
let g := f ∘ₗ LinearMap.inr F F _ ∘ₗ LinearMap.inr F F _
|
| 32 |
+
obtain ⟨u,hu⟩:=dotL_surj (g ∘ₗ LinearMap.inl F _ _)
|
| 33 |
+
obtain ⟨v,hv⟩:=dotL_surj (g ∘ₗ LinearMap.inr F _ _)
|
| 34 |
+
let a : Question d e := (1,0); let b : Question d e := (0,1,0)
|
| 35 |
+
refine ⟨f a,f b,u,v,?_⟩
|
| 36 |
+
rintro ⟨x,y,z,w⟩
|
| 37 |
+
have he : ((x,y,z,w):Question d e)=x • a +y • b+((0,0,z,0)+(0,0,0,w)) := by
|
| 38 |
+
unfold a b; ext <;> simp
|
| 39 |
+
have h1 : f (0,0,z,0)=dotProduct u z := LinearMap.congr_fun hu z
|
| 40 |
+
have h2 : f (0,0,0,w)=dotProduct v w := LinearMap.congr_fun hv w
|
| 41 |
+
change f (x,y,z,w)=f a*x + f b*y + _
|
| 42 |
+
conv_lhs => rw [he]
|
| 43 |
+
rw [map_add,map_add,map_add,map_smul,map_smul,h1,h2]; simp [mul_comm]
|
| 44 |
+
|
| 45 |
+
theorem jargon_score (V : StatusSp A B) (T : Cabinet A B)
|
| 46 |
+
(h : ¬scorecard V T) (hh : ∀ i,coverBase (V i)) :
|
| 47 |
+
∃ p : DualCoefficients A B, (p.left≠0 ∨ p.right≠0) ∧ p.law V ∧ ∑ i,p.bet i (T i)≠0 := by
|
| 48 |
+
obtain ⟨p,hp,hf⟩:= counter_score V T h
|
| 49 |
+
choose a b u v he using fun i=>coordinates (p.alf i)
|
| 50 |
+
let g : DualCoefficients A B:=⟨p.altL,p.altR,a,b,u,v⟩
|
| 51 |
+
have hz i x : g.bet i x=p.alf i x := (he i x).symm
|
| 52 |
+
refine ⟨g,critic_nz V T hh p hp hf,fun i x hx=>?_,?_⟩
|
| 53 |
+
· rw [hz]; exact hp i x hx
|
| 54 |
+
simp_rw [hz]; exact hf
|
| 55 |
+
|
| 56 |
+
abbrev excessK (V : Space (Signal d e)) := V ⊓ LinearMap.ker (view d e)
|
| 57 |
+
theorem signal_dim :
|
| 58 |
+
dim (Signal d e) = dim (View d e)+2 := by
|
| 59 |
+
simp only [Signal,View,Whole,dim,finrank_prod,finrank_self]
|
| 60 |
+
omega
|
| 61 |
+
theorem ker_two (V : Space (Signal d e)) :
|
| 62 |
+
dim (excessK V) ≤ 2 := by
|
| 63 |
+
have he : Surjective (view d e) := by
|
| 64 |
+
rintro ⟨i,j,k⟩; exact ⟨(i,(j,0),(k,0)),rfl⟩
|
| 65 |
+
have ht := LinearMap.finrank_range_add_finrank_ker (view d e)
|
| 66 |
+
change rk (view _ _) + dim _=dim (Signal d e) at ht
|
| 67 |
+
rw [rk_surj.mp he,signal_dim] at ht
|
| 68 |
+
exact (Submodule.finrank_mono (show excessK V≤_ from inf_le_right)).trans
|
| 69 |
+
(by omega : dim (LinearMap.ker (view d e)) ≤ 2)
|
| 70 |
+
|
| 71 |
+
def overage (V : Space (Signal d e)) := dim V - dim (View d e)
|
| 72 |
+
theorem overage_two (V : Space (Signal d e)) : overage V≤2 := by
|
| 73 |
+
have hi : dim V ≤ dim (Signal d e) := finrank_le _
|
| 74 |
+
rw [signal_dim] at hi; unfold overage; omega
|
| 75 |
+
theorem overage_mono {V W : Space (Signal d e)} (h : V≤W) :
|
| 76 |
+
overage V≤overage W := Nat.sub_le_sub_right (finrank_mono h) _
|
| 77 |
+
theorem overage_lt {V W : Space (Signal d e)} (h : V<W) (he : coverBase V) :
|
| 78 |
+
overage V<overage W := by
|
| 79 |
+
have hh := finrank_lt_finrank_of_lt h; change dim V<dim W at hh
|
| 80 |
+
have hx : dim (View d e) ≤ dim V := LinearMap.finrank_le_finrank_of_surjective he
|
| 81 |
+
unfold overage; omega
|
| 82 |
+
end StatusAnalysis
|
| 83 |
+
end HadwigerCounterexample
|
| 84 |
+
|
| 85 |
+
end
|
| 86 |
+
|
| 87 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CoordinateEmbeddings.lean
CHANGED
|
@@ -1,163 +1,163 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.MatrixRanks
|
| 2 |
-
import Mathlib.Data.Matrix.ColumnRowPartitioned
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Coordinate Embeddings -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix Module Function
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {U V I J K T : Type} [Fintype U] [Fintype V] [Fintype I] [Fintype J]
|
| 13 |
-
[Fintype K] [Fintype T]
|
| 14 |
-
|
| 15 |
-
def embedMat [DecidableEq U] (f : I → U) : Mat U I := Matrix.of (fun i j => if i=f j then 1 else 0)
|
| 16 |
-
|
| 17 |
-
omit [Fintype I] in
|
| 18 |
-
theorem embedMatT [DecidableEq U] (f : I → U) (x : Vec U) :
|
| 19 |
-
(embedMat f)ᵀ *ᵥ x = fun i => x (f i) := by
|
| 20 |
-
classical funext i
|
| 21 |
-
simp [embedMat,Matrix.mulVec,dotProduct]
|
| 22 |
-
|
| 23 |
-
omit [Fintype V] [Fintype I] in
|
| 24 |
-
theorem mul_embedMat [DecidableEq U] (f : I → U) (M : Mat V U) :
|
| 25 |
-
M*embedMat f = M.submatrix _root_.id f := by
|
| 26 |
-
ext i j
|
| 27 |
-
simp [Matrix.mul_apply,embedMat]
|
| 28 |
-
|
| 29 |
-
omit [Fintype V] [Fintype I] in
|
| 30 |
-
theorem embedMat_mul [DecidableEq U] (f : I → U) (M : Mat U V) :
|
| 31 |
-
(embedMat f)ᵀ*M = M.submatrix f _root_.id := by
|
| 32 |
-
ext i j
|
| 33 |
-
simp [Matrix.mul_apply,embedMat]
|
| 34 |
-
|
| 35 |
-
omit [Fintype I] in
|
| 36 |
-
theorem embedMat_self [DecidableEq I] [DecidableEq U] {f : I → U} (h : Injective f) :
|
| 37 |
-
(embedMat f)ᵀ * embedMat f = 1 := by
|
| 38 |
-
ext i j
|
| 39 |
-
rw [embedMat_mul]
|
| 40 |
-
simp only [embedMat,Matrix.submatrix_apply,Matrix.of_apply,id_eq,
|
| 41 |
-
Matrix.one_apply,h.eq_iff]
|
| 42 |
-
|
| 43 |
-
theorem embedMat_inj [DecidableEq U] {f : I → U} (h : Injective f) :
|
| 44 |
-
Injective (embedMat f).mulVec := by
|
| 45 |
-
classical
|
| 46 |
-
intro x y g
|
| 47 |
-
change embedMat f *ᵥ x = embedMat f *ᵥ y at g
|
| 48 |
-
have he (x : Vec I) : (embedMat f)ᵀ *ᵥ (embedMat f *ᵥ x) = x := by
|
| 49 |
-
rw [Matrix.mulVec_mulVec,embedMat_self h,Matrix.one_mulVec]
|
| 50 |
-
rw [← he x,g,he]
|
| 51 |
-
|
| 52 |
-
omit [Fintype U] in
|
| 53 |
-
theorem inj_fromCols {A : Mat U I} {B : Mat U J} (hA : Injective A.mulVec)
|
| 54 |
-
(hB : Injective B.mulVec) (h : Disjoint (colSp A) (colSp B)) :
|
| 55 |
-
Injective (fromCols A B).mulVec := by
|
| 56 |
-
rw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]
|
| 57 |
-
intro x hx
|
| 58 |
-
let a := fun i => x (Sum.inl i)
|
| 59 |
-
let b := fun j => x (Sum.inr j)
|
| 60 |
-
rw [fromCols_mulVec] at hx
|
| 61 |
-
have he : A*ᵥa=B*ᵥb := add_right_cancel (hx.trans (char_two (B*ᵥb)).symm)
|
| 62 |
-
have hi : A*ᵥa ∈ colSp A ⊓ colSp B :=
|
| 63 |
-
⟨⟨a,rfl⟩, he.symm ▸ (show B*ᵥb∈colSp B from ⟨b,rfl⟩)⟩
|
| 64 |
-
rw [h.eq_bot] at hi
|
| 65 |
-
have hg : A*ᵥa=0 := by simpa using hi
|
| 66 |
-
have ha : a=0 := hA (hg.trans (Matrix.mulVec_zero A).symm)
|
| 67 |
-
rw [he] at hg
|
| 68 |
-
have hb : b=0 := hB (hg.trans (Matrix.mulVec_zero B).symm)
|
| 69 |
-
funext i
|
| 70 |
-
cases i
|
| 71 |
-
· exact congr_fun ha _
|
| 72 |
-
· exact congr_fun hb _
|
| 73 |
-
|
| 74 |
-
/-- Specify an arbitrary cross Gram bilinear form between independent columns. -/
|
| 75 |
-
theorem prescribe_between {A : Mat U I} {B : Mat V J}
|
| 76 |
-
(hA : Injective A.mulVec) (hB : Injective B.mulVec) (M : Mat I J) :
|
| 77 |
-
∃ L : Mat U V, Aᵀ*L*B=M := by
|
| 78 |
-
classical
|
| 79 |
-
obtain ⟨a,ha⟩ := mat_left_inv hA
|
| 80 |
-
obtain ⟨b,hb⟩ := mat_left_inv hB
|
| 81 |
-
refine ⟨aᵀ*(M*b),?_⟩
|
| 82 |
-
rw [← Matrix.mul_assoc Aᵀ,←transpose_mul,ha,transpose_one,Matrix.one_mul,
|
| 83 |
-
Matrix.mul_assoc,hb,Matrix.mul_one]
|
| 84 |
-
|
| 85 |
-
/-- Two opposite-direction restrictions are specifiable on disjoint bases. -/
|
| 86 |
-
theorem prescribe_opposite {A : Mat U I} {B : Mat V J} {C : Mat U K} {D : Mat V T}
|
| 87 |
-
(hc : Injective (fromCols A C).mulVec) (hd : Injective (fromCols B D).mulVec)
|
| 88 |
-
(M : Mat I J) (N : Mat T K) :
|
| 89 |
-
∃ L : Mat U V, Aᵀ*L*B=M ∧ Dᵀ*Lᵀ*C=N := by
|
| 90 |
-
obtain ⟨L,hL⟩ := prescribe_between hc hd (fromBlocks M 0 0 Nᵀ)
|
| 91 |
-
rw [transpose_fromCols, fromRows_mul, fromRows_mul_fromCols] at hL
|
| 92 |
-
have hi : Cᵀ*L*D=Nᵀ := congrArg Matrix.toBlocks₂₂ hL
|
| 93 |
-
refine ⟨L, congrArg Matrix.toBlocks₁₁ hL, ?_⟩
|
| 94 |
-
have hg := congrArg Matrix.transpose hi
|
| 95 |
-
rwa [transpose_mul,transpose_mul,transpose_transpose,transpose_transpose,← Matrix.mul_assoc] at hg
|
| 96 |
-
|
| 97 |
-
omit [Fintype I] in
|
| 98 |
-
theorem rank_ge_mul (A : Mat I J) (B : Mat J K) :
|
| 99 |
-
A.rank+B.rank ≤ (A*B).rank+Fintype.card J := by
|
| 100 |
-
let f := A.mulVecLin
|
| 101 |
-
let g := f ∘ₗ (colSp B).subtype
|
| 102 |
-
have he : LinearMap.range g = colSp (A*B) := by
|
| 103 |
-
change LinearMap.range g = LinearMap.range ((A*B).mulVecLin)
|
| 104 |
-
rw [mulVecLin_mul]
|
| 105 |
-
unfold g
|
| 106 |
-
rw [LinearMap.range_comp,LinearMap.range_comp]
|
| 107 |
-
simp [f,colSp]
|
| 108 |
-
have hi : dim (LinearMap.ker g) ≤ dim (LinearMap.ker f) := by
|
| 109 |
-
let q := ((colSp B).subtype ∘ₗ (LinearMap.ker g).subtype)
|
| 110 |
-
have hq (x : LinearMap.ker g) : q x ∈ LinearMap.ker f := x.property
|
| 111 |
-
let k := q.codRestrict (LinearMap.ker f) hq
|
| 112 |
-
have hk : Injective k := by
|
| 113 |
-
intro x y h
|
| 114 |
-
have heq := congrArg (fun b : LinearMap.ker f => b.val) h
|
| 115 |
-
exact Subtype.ext (Subtype.ext heq)
|
| 116 |
-
exact LinearMap.finrank_le_finrank_of_injective hk
|
| 117 |
-
have h1 := g.finrank_range_add_finrank_ker
|
| 118 |
-
rw [he] at h1
|
| 119 |
-
have h2 := f.finrank_range_add_finrank_ker
|
| 120 |
-
change (A*B).rank + dim (LinearMap.ker g)=B.rank at h1
|
| 121 |
-
change A.rank + dim (LinearMap.ker f)=dim (Vec J) at h2
|
| 122 |
-
rw [dim_vec] at h2; omega
|
| 123 |
-
|
| 124 |
-
theorem rank_ge_congr (A : Mat I I) (B : Mat J I) :
|
| 125 |
-
A.rank + 2*B.rank ≤ (liftM B B A).rank + 2*Fintype.card I := by
|
| 126 |
-
have h1 := rank_ge_mul B A
|
| 127 |
-
have h2 := rank_ge_mul (B*A) Bᵀ
|
| 128 |
-
rw [Matrix.rank_transpose] at h2
|
| 129 |
-
rw [liftM_def]; omega
|
| 130 |
-
|
| 131 |
-
/-- Choose a large space in the domain which becomes disjoint from S in the target. -/
|
| 132 |
-
theorem choose_free {A : Mat I J} (hA : Injective A.mulVec) (S : Space (Vec I)) :
|
| 133 |
-
∃ T : Space (Vec J), Fintype.card J ≤ dim T+dim S ∧
|
| 134 |
-
Disjoint S (colSp (A*pack T)) := by
|
| 135 |
-
let U := S.comap A.mulVecLin
|
| 136 |
-
obtain ⟨T,hT⟩ := U.exists_isCompl
|
| 137 |
-
refine ⟨T,?_,?_⟩
|
| 138 |
-
· have hi : dim U ≤ dim S := by
|
| 139 |
-
let q := A.mulVecLin ∘ₗ U.subtype
|
| 140 |
-
have he (x : U) : q x∈S := x.property
|
| 141 |
-
let B := q.codRestrict S he
|
| 142 |
-
have hb : Injective B := fun x y h => Subtype.ext (hA
|
| 143 |
-
(show q x=q y from congrArg Subtype.val h))
|
| 144 |
-
exact LinearMap.finrank_le_finrank_of_injective hb
|
| 145 |
-
have he := (U.prodEquivOfIsCompl T hT).finrank_eq
|
| 146 |
-
rw [finrank_prod,show finrank F (Vec J)=Fintype.card J from dim_vec _] at he
|
| 147 |
-
change dim U + dim T = Fintype.card J at he
|
| 148 |
-
rw [← he]
|
| 149 |
-
exact (Nat.add_le_add_right hi _).trans_eq (Nat.add_comm _ _)
|
| 150 |
-
rw [colSp,mulVecLin_mul,LinearMap.range_comp,show LinearMap.range (pack T).mulVecLin = T from
|
| 151 |
-
colSp_pack T]
|
| 152 |
-
rw [disjoint_iff_inf_le]
|
| 153 |
-
rintro x ⟨hx,y,hy,rfl⟩
|
| 154 |
-
have hh : y∈U⊓T := ⟨hx,hy⟩
|
| 155 |
-
rw [hT.inf_eq_bot] at hh
|
| 156 |
-
have he : y=0 := by simpa using hh
|
| 157 |
-
rw [he,map_zero]; exact Submodule.zero_mem _
|
| 158 |
-
|
| 159 |
-
end HadwigerCounterexample
|
| 160 |
-
|
| 161 |
-
end
|
| 162 |
-
|
| 163 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.MatrixRanks
|
| 2 |
+
import Mathlib.Data.Matrix.ColumnRowPartitioned
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Coordinate Embeddings -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix Module Function
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {U V I J K T : Type} [Fintype U] [Fintype V] [Fintype I] [Fintype J]
|
| 13 |
+
[Fintype K] [Fintype T]
|
| 14 |
+
|
| 15 |
+
def embedMat [DecidableEq U] (f : I → U) : Mat U I := Matrix.of (fun i j => if i=f j then 1 else 0)
|
| 16 |
+
|
| 17 |
+
omit [Fintype I] in
|
| 18 |
+
theorem embedMatT [DecidableEq U] (f : I → U) (x : Vec U) :
|
| 19 |
+
(embedMat f)ᵀ *ᵥ x = fun i => x (f i) := by
|
| 20 |
+
classical funext i
|
| 21 |
+
simp [embedMat,Matrix.mulVec,dotProduct]
|
| 22 |
+
|
| 23 |
+
omit [Fintype V] [Fintype I] in
|
| 24 |
+
theorem mul_embedMat [DecidableEq U] (f : I → U) (M : Mat V U) :
|
| 25 |
+
M*embedMat f = M.submatrix _root_.id f := by
|
| 26 |
+
ext i j
|
| 27 |
+
simp [Matrix.mul_apply,embedMat]
|
| 28 |
+
|
| 29 |
+
omit [Fintype V] [Fintype I] in
|
| 30 |
+
theorem embedMat_mul [DecidableEq U] (f : I → U) (M : Mat U V) :
|
| 31 |
+
(embedMat f)ᵀ*M = M.submatrix f _root_.id := by
|
| 32 |
+
ext i j
|
| 33 |
+
simp [Matrix.mul_apply,embedMat]
|
| 34 |
+
|
| 35 |
+
omit [Fintype I] in
|
| 36 |
+
theorem embedMat_self [DecidableEq I] [DecidableEq U] {f : I → U} (h : Injective f) :
|
| 37 |
+
(embedMat f)ᵀ * embedMat f = 1 := by
|
| 38 |
+
ext i j
|
| 39 |
+
rw [embedMat_mul]
|
| 40 |
+
simp only [embedMat,Matrix.submatrix_apply,Matrix.of_apply,id_eq,
|
| 41 |
+
Matrix.one_apply,h.eq_iff]
|
| 42 |
+
|
| 43 |
+
theorem embedMat_inj [DecidableEq U] {f : I → U} (h : Injective f) :
|
| 44 |
+
Injective (embedMat f).mulVec := by
|
| 45 |
+
classical
|
| 46 |
+
intro x y g
|
| 47 |
+
change embedMat f *ᵥ x = embedMat f *ᵥ y at g
|
| 48 |
+
have he (x : Vec I) : (embedMat f)ᵀ *ᵥ (embedMat f *ᵥ x) = x := by
|
| 49 |
+
rw [Matrix.mulVec_mulVec,embedMat_self h,Matrix.one_mulVec]
|
| 50 |
+
rw [← he x,g,he]
|
| 51 |
+
|
| 52 |
+
omit [Fintype U] in
|
| 53 |
+
theorem inj_fromCols {A : Mat U I} {B : Mat U J} (hA : Injective A.mulVec)
|
| 54 |
+
(hB : Injective B.mulVec) (h : Disjoint (colSp A) (colSp B)) :
|
| 55 |
+
Injective (fromCols A B).mulVec := by
|
| 56 |
+
rw [← Matrix.coe_mulVecLin,← LinearMap.ker_eq_bot, Matrix.ker_mulVecLin_eq_bot_iff]
|
| 57 |
+
intro x hx
|
| 58 |
+
let a := fun i => x (Sum.inl i)
|
| 59 |
+
let b := fun j => x (Sum.inr j)
|
| 60 |
+
rw [fromCols_mulVec] at hx
|
| 61 |
+
have he : A*ᵥa=B*ᵥb := add_right_cancel (hx.trans (char_two (B*ᵥb)).symm)
|
| 62 |
+
have hi : A*ᵥa ∈ colSp A ⊓ colSp B :=
|
| 63 |
+
⟨⟨a,rfl⟩, he.symm ▸ (show B*ᵥb∈colSp B from ⟨b,rfl⟩)⟩
|
| 64 |
+
rw [h.eq_bot] at hi
|
| 65 |
+
have hg : A*ᵥa=0 := by simpa using hi
|
| 66 |
+
have ha : a=0 := hA (hg.trans (Matrix.mulVec_zero A).symm)
|
| 67 |
+
rw [he] at hg
|
| 68 |
+
have hb : b=0 := hB (hg.trans (Matrix.mulVec_zero B).symm)
|
| 69 |
+
funext i
|
| 70 |
+
cases i
|
| 71 |
+
· exact congr_fun ha _
|
| 72 |
+
· exact congr_fun hb _
|
| 73 |
+
|
| 74 |
+
/-- Specify an arbitrary cross Gram bilinear form between independent columns. -/
|
| 75 |
+
theorem prescribe_between {A : Mat U I} {B : Mat V J}
|
| 76 |
+
(hA : Injective A.mulVec) (hB : Injective B.mulVec) (M : Mat I J) :
|
| 77 |
+
∃ L : Mat U V, Aᵀ*L*B=M := by
|
| 78 |
+
classical
|
| 79 |
+
obtain ⟨a,ha⟩ := mat_left_inv hA
|
| 80 |
+
obtain ⟨b,hb⟩ := mat_left_inv hB
|
| 81 |
+
refine ⟨aᵀ*(M*b),?_⟩
|
| 82 |
+
rw [← Matrix.mul_assoc Aᵀ,←transpose_mul,ha,transpose_one,Matrix.one_mul,
|
| 83 |
+
Matrix.mul_assoc,hb,Matrix.mul_one]
|
| 84 |
+
|
| 85 |
+
/-- Two opposite-direction restrictions are specifiable on disjoint bases. -/
|
| 86 |
+
theorem prescribe_opposite {A : Mat U I} {B : Mat V J} {C : Mat U K} {D : Mat V T}
|
| 87 |
+
(hc : Injective (fromCols A C).mulVec) (hd : Injective (fromCols B D).mulVec)
|
| 88 |
+
(M : Mat I J) (N : Mat T K) :
|
| 89 |
+
∃ L : Mat U V, Aᵀ*L*B=M ∧ Dᵀ*Lᵀ*C=N := by
|
| 90 |
+
obtain ⟨L,hL⟩ := prescribe_between hc hd (fromBlocks M 0 0 Nᵀ)
|
| 91 |
+
rw [transpose_fromCols, fromRows_mul, fromRows_mul_fromCols] at hL
|
| 92 |
+
have hi : Cᵀ*L*D=Nᵀ := congrArg Matrix.toBlocks₂₂ hL
|
| 93 |
+
refine ⟨L, congrArg Matrix.toBlocks₁₁ hL, ?_⟩
|
| 94 |
+
have hg := congrArg Matrix.transpose hi
|
| 95 |
+
rwa [transpose_mul,transpose_mul,transpose_transpose,transpose_transpose,← Matrix.mul_assoc] at hg
|
| 96 |
+
|
| 97 |
+
omit [Fintype I] in
|
| 98 |
+
theorem rank_ge_mul (A : Mat I J) (B : Mat J K) :
|
| 99 |
+
A.rank+B.rank ≤ (A*B).rank+Fintype.card J := by
|
| 100 |
+
let f := A.mulVecLin
|
| 101 |
+
let g := f ∘ₗ (colSp B).subtype
|
| 102 |
+
have he : LinearMap.range g = colSp (A*B) := by
|
| 103 |
+
change LinearMap.range g = LinearMap.range ((A*B).mulVecLin)
|
| 104 |
+
rw [mulVecLin_mul]
|
| 105 |
+
unfold g
|
| 106 |
+
rw [LinearMap.range_comp,LinearMap.range_comp]
|
| 107 |
+
simp [f,colSp]
|
| 108 |
+
have hi : dim (LinearMap.ker g) ≤ dim (LinearMap.ker f) := by
|
| 109 |
+
let q := ((colSp B).subtype ∘ₗ (LinearMap.ker g).subtype)
|
| 110 |
+
have hq (x : LinearMap.ker g) : q x ∈ LinearMap.ker f := x.property
|
| 111 |
+
let k := q.codRestrict (LinearMap.ker f) hq
|
| 112 |
+
have hk : Injective k := by
|
| 113 |
+
intro x y h
|
| 114 |
+
have heq := congrArg (fun b : LinearMap.ker f => b.val) h
|
| 115 |
+
exact Subtype.ext (Subtype.ext heq)
|
| 116 |
+
exact LinearMap.finrank_le_finrank_of_injective hk
|
| 117 |
+
have h1 := g.finrank_range_add_finrank_ker
|
| 118 |
+
rw [he] at h1
|
| 119 |
+
have h2 := f.finrank_range_add_finrank_ker
|
| 120 |
+
change (A*B).rank + dim (LinearMap.ker g)=B.rank at h1
|
| 121 |
+
change A.rank + dim (LinearMap.ker f)=dim (Vec J) at h2
|
| 122 |
+
rw [dim_vec] at h2; omega
|
| 123 |
+
|
| 124 |
+
theorem rank_ge_congr (A : Mat I I) (B : Mat J I) :
|
| 125 |
+
A.rank + 2*B.rank ≤ (liftM B B A).rank + 2*Fintype.card I := by
|
| 126 |
+
have h1 := rank_ge_mul B A
|
| 127 |
+
have h2 := rank_ge_mul (B*A) Bᵀ
|
| 128 |
+
rw [Matrix.rank_transpose] at h2
|
| 129 |
+
rw [liftM_def]; omega
|
| 130 |
+
|
| 131 |
+
/-- Choose a large space in the domain which becomes disjoint from S in the target. -/
|
| 132 |
+
theorem choose_free {A : Mat I J} (hA : Injective A.mulVec) (S : Space (Vec I)) :
|
| 133 |
+
∃ T : Space (Vec J), Fintype.card J ≤ dim T+dim S ∧
|
| 134 |
+
Disjoint S (colSp (A*pack T)) := by
|
| 135 |
+
let U := S.comap A.mulVecLin
|
| 136 |
+
obtain ⟨T,hT⟩ := U.exists_isCompl
|
| 137 |
+
refine ⟨T,?_,?_⟩
|
| 138 |
+
· have hi : dim U ≤ dim S := by
|
| 139 |
+
let q := A.mulVecLin ∘ₗ U.subtype
|
| 140 |
+
have he (x : U) : q x∈S := x.property
|
| 141 |
+
let B := q.codRestrict S he
|
| 142 |
+
have hb : Injective B := fun x y h => Subtype.ext (hA
|
| 143 |
+
(show q x=q y from congrArg Subtype.val h))
|
| 144 |
+
exact LinearMap.finrank_le_finrank_of_injective hb
|
| 145 |
+
have he := (U.prodEquivOfIsCompl T hT).finrank_eq
|
| 146 |
+
rw [finrank_prod,show finrank F (Vec J)=Fintype.card J from dim_vec _] at he
|
| 147 |
+
change dim U + dim T = Fintype.card J at he
|
| 148 |
+
rw [← he]
|
| 149 |
+
exact (Nat.add_le_add_right hi _).trans_eq (Nat.add_comm _ _)
|
| 150 |
+
rw [colSp,mulVecLin_mul,LinearMap.range_comp,show LinearMap.range (pack T).mulVecLin = T from
|
| 151 |
+
colSp_pack T]
|
| 152 |
+
rw [disjoint_iff_inf_le]
|
| 153 |
+
rintro x ⟨hx,y,hy,rfl⟩
|
| 154 |
+
have hh : y∈U⊓T := ⟨hx,hy⟩
|
| 155 |
+
rw [hT.inf_eq_bot] at hh
|
| 156 |
+
have he : y=0 := by simpa using hh
|
| 157 |
+
rw [he,map_zero]; exact Submodule.zero_mem _
|
| 158 |
+
|
| 159 |
+
end HadwigerCounterexample
|
| 160 |
+
|
| 161 |
+
end
|
| 162 |
+
|
| 163 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/CoverAlternatives.lean
CHANGED
|
@@ -1,86 +1,86 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PhaseClassCompatibility
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.LowRankKernelAlternative
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Cover Alternatives -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix Finset Filter
|
| 11 |
-
open scoped BigOperators Topology
|
| 12 |
-
open PredictionClass
|
| 13 |
-
variable {p : Shape} {n N M : ℕ}
|
| 14 |
-
theorem longStory (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)
|
| 15 |
-
(c : PredictionClass) (α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)
|
| 16 |
-
(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :
|
| 17 |
-
∃ P : UnitType p n N×UnitType p n N→Prop,named P (bp (3*d*(N:ℝ))) ∧
|
| 18 |
-
named (P ∘ Prod.swap) (bp (3*d*(N:ℝ))) ∧
|
| 19 |
-
∀ x,pairW w w x≠0→ (P x↔ matchUp Δ α r c x) := by
|
| 20 |
-
classical
|
| 21 |
-
let Q (x : Daypair p T×Daypair p T) : Prop :=
|
| 22 |
-
c.compatible α r (fun i=>x.2.2 i x.1.1, fun i => x.1.2 i x.2.1)
|
| 23 |
-
let f := daypair p T Δ w
|
| 24 |
-
refine ⟨fun x=>Q (f x.1,f x.2),day_named p T Δ w d hd Q,day_named p T Δ w d hd (Q∘Prod.swap),
|
| 25 |
-
fun x hx=>?_⟩
|
| 26 |
-
have hs (x y : UnitType p n N) (hz : w x≠0) (i) :
|
| 27 |
-
(f y).2 i (f x).1=tone p y (unary i) (Δ x) :=
|
| 28 |
-
shadow_valid p T Δ hh x y (unary i) hz
|
| 29 |
-
unfold Q matchUp quench
|
| 30 |
-
dsimp only
|
| 31 |
-
simp_rw [hs _ _ (left_ne_zero_of_mul hx), hs _ _ (right_ne_zero_of_mul hx)]
|
| 32 |
-
|
| 33 |
-
theorem matSeason (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)
|
| 34 |
-
(α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)
|
| 35 |
-
(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :
|
| 36 |
-
∃ F : Mat (UnitType p n N) (UnitType p n N), F.rank ≤ 2*d*N ∧
|
| 37 |
-
(∀ x, F x x=0) ∧ ∀ x,pairW w w x≠0→ (F x.1 x.2=0 ↔ matchUp Δ α r twinned x) := by
|
| 38 |
-
let F := circus p T Δ w
|
| 39 |
-
have he : F.rank ≤ N*d := (circus_rank ..).trans (Nat.mul_le_mul_left _ hd)
|
| 40 |
-
refine ⟨F+Fᵀ, (mrk_add_le F Fᵀ).trans ?_,fun x=>char_two _,fun x hx=>?_⟩
|
| 41 |
-
· rw [Matrix.rank_transpose]; nlinarith
|
| 42 |
-
· unfold matchUp compatible quench
|
| 43 |
-
dsimp only; rw [←tone_vec,←tone_vec]
|
| 44 |
-
have h x y (hx : w x ≠ 0) : F x y = tone p y allSide (Δ x) :=
|
| 45 |
-
shadow_valid p T Δ hh x y allSide hx
|
| 46 |
-
change (F x.1 x.2+F x.2 x.1=0) ↔ _
|
| 47 |
-
rw [h _ _ (left_ne_zero_of_mul hx),h _ _ (right_ne_zero_of_mul hx)]
|
| 48 |
-
|
| 49 |
-
set_option maxHeartbeats 1000000 in
|
| 50 |
-
theorem coFiber (l : Filter ℕ) (hz : l≤atTop) {M : ℕ} (hM : 1≤ M) (d : ℕ)
|
| 51 |
-
(p : Shape) (w : ∀ n,Wgt (UnitType p n (M*n)))
|
| 52 |
-
(α : Party) (r : F) (Δ : ∀ n, UnitType p n (M*n) → Ambient p (M*n))
|
| 53 |
-
(h : ∀ᶠ n in l, IsLaw (w n) ∧
|
| 54 |
-
∃ T : Cov p (M*n),cdim p T≤d∧∀ x,w n x≠0 → covered p T (Δ n x))
|
| 55 |
-
(he : slight l (fun n=>pr (pairW (w n) (w n)) (matchUp (Δ n) α r twinned))) :
|
| 56 |
-
∃ S : ∀ n, UnitType p n (M*n)→Prop,warm l (fun n=>((M*n:ℕ):ℝ)) (fun n=>pr (w n) (S n)) ∧
|
| 57 |
-
∀ᶠ n in l, ∀ x,S n x.1 → S n x.2 → matchUp (Δ n) α r twinned x := by
|
| 58 |
-
classical
|
| 59 |
-
let X n:= UnitType p n (M*n)
|
| 60 |
-
let q n:= matchUp (Δ n) α r twinned
|
| 61 |
-
let c (k : ℕ) := ((k:ℝ)+1)⁻¹
|
| 62 |
-
let P n (S : X n→Prop) (k : ℕ) :=
|
| 63 |
-
bp (-(c k)*((M*n:ℕ):ℝ)) ≤ pr (w n) S ∧ ∀ x,S x.1 → S x.2 → q n x
|
| 64 |
-
have hf (k : ℕ) : ∀ᶠ n in l,∃ S : X n→Prop,P n S k := by
|
| 65 |
-
obtain ⟨θ,hθ,hg⟩:= fiber_growth (2*d) (c k) (by unfold c; positivity) (by positivity)
|
| 66 |
-
filter_upwards [h,he θ hθ, (trend_sizes l hz hM).1.eventually hg] with n hn hh hF
|
| 67 |
-
obtain ⟨hv,T,hT,h⟩:=hn
|
| 68 |
-
obtain ⟨F,hf,hz,hc⟩:= matSeason T d hT α r (Δ n) (w n) h
|
| 69 |
-
have ht : pr (pairW (w n) (w n)) (fun x => F x.1 x.2=0) ≤ θ :=
|
| 70 |
-
(avg_congr (fun x hx => show ind _=ind _ from congrArg ind (propext (hc x hx)))).trans_le hh
|
| 71 |
-
have hr : (F.rank:ℝ)≤ 2*d*(M*n:ℕ) := by exact_mod_cast hf
|
| 72 |
-
obtain ⟨S,hS,ht⟩:= hF (X n) F (w n) hv hr hz ht
|
| 73 |
-
let Y (x:X n) := S x∧ w n x≠0
|
| 74 |
-
have he : pr (w n) Y=pr (w n) S := avg_congr (fun x hx=>by simp [Y, hx])
|
| 75 |
-
refine ⟨Y, hS.trans_eq he.symm, fun x hx hy =>
|
| 76 |
-
(hc x (mul_ne_zero hx.2 hy.2)).mp (ht x.1 hx.1 x.2 hy.1)⟩
|
| 77 |
-
obtain ⟨k,hk,hf⟩:= diagonal_gains l hz (fun n k => ∃ S : X n→Prop,P n S k) hf
|
| 78 |
-
obtain ⟨S,h⟩:= taking hf
|
| 79 |
-
refine ⟨S,fun ε he=>?_, h.mono fun i hi=>hi.2⟩
|
| 80 |
-
filter_upwards [h,slight_inv_stage hk ε he] with n hn hh
|
| 81 |
-
exact (bp_le (mul_le_mul_of_nonneg_right (neg_le_neg hh) (Nat.cast_nonneg _))).trans hn.1
|
| 82 |
-
end HadwigerCounterexample
|
| 83 |
-
|
| 84 |
-
end
|
| 85 |
-
|
| 86 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PhaseClassCompatibility
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.LowRankKernelAlternative
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Cover Alternatives -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix Finset Filter
|
| 11 |
+
open scoped BigOperators Topology
|
| 12 |
+
open PredictionClass
|
| 13 |
+
variable {p : Shape} {n N M : ℕ}
|
| 14 |
+
theorem longStory (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)
|
| 15 |
+
(c : PredictionClass) (α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)
|
| 16 |
+
(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :
|
| 17 |
+
∃ P : UnitType p n N×UnitType p n N→Prop,named P (bp (3*d*(N:ℝ))) ∧
|
| 18 |
+
named (P ∘ Prod.swap) (bp (3*d*(N:ℝ))) ∧
|
| 19 |
+
∀ x,pairW w w x≠0→ (P x↔ matchUp Δ α r c x) := by
|
| 20 |
+
classical
|
| 21 |
+
let Q (x : Daypair p T×Daypair p T) : Prop :=
|
| 22 |
+
c.compatible α r (fun i=>x.2.2 i x.1.1, fun i => x.1.2 i x.2.1)
|
| 23 |
+
let f := daypair p T Δ w
|
| 24 |
+
refine ⟨fun x=>Q (f x.1,f x.2),day_named p T Δ w d hd Q,day_named p T Δ w d hd (Q∘Prod.swap),
|
| 25 |
+
fun x hx=>?_⟩
|
| 26 |
+
have hs (x y : UnitType p n N) (hz : w x≠0) (i) :
|
| 27 |
+
(f y).2 i (f x).1=tone p y (unary i) (Δ x) :=
|
| 28 |
+
shadow_valid p T Δ hh x y (unary i) hz
|
| 29 |
+
unfold Q matchUp quench
|
| 30 |
+
dsimp only
|
| 31 |
+
simp_rw [hs _ _ (left_ne_zero_of_mul hx), hs _ _ (right_ne_zero_of_mul hx)]
|
| 32 |
+
|
| 33 |
+
theorem matSeason (T : Cov p N) (d : ℕ) (hd : cdim p T≤d)
|
| 34 |
+
(α : Party) (r : F) (Δ : UnitType p n N → Ambient p N)
|
| 35 |
+
(w : Wgt (UnitType p n N)) (hh : ∀ x,w x≠ 0 → covered p T (Δ x)) :
|
| 36 |
+
∃ F : Mat (UnitType p n N) (UnitType p n N), F.rank ≤ 2*d*N ∧
|
| 37 |
+
(∀ x, F x x=0) ∧ ∀ x,pairW w w x≠0→ (F x.1 x.2=0 ↔ matchUp Δ α r twinned x) := by
|
| 38 |
+
let F := circus p T Δ w
|
| 39 |
+
have he : F.rank ≤ N*d := (circus_rank ..).trans (Nat.mul_le_mul_left _ hd)
|
| 40 |
+
refine ⟨F+Fᵀ, (mrk_add_le F Fᵀ).trans ?_,fun x=>char_two _,fun x hx=>?_⟩
|
| 41 |
+
· rw [Matrix.rank_transpose]; nlinarith
|
| 42 |
+
· unfold matchUp compatible quench
|
| 43 |
+
dsimp only; rw [←tone_vec,←tone_vec]
|
| 44 |
+
have h x y (hx : w x ≠ 0) : F x y = tone p y allSide (Δ x) :=
|
| 45 |
+
shadow_valid p T Δ hh x y allSide hx
|
| 46 |
+
change (F x.1 x.2+F x.2 x.1=0) ↔ _
|
| 47 |
+
rw [h _ _ (left_ne_zero_of_mul hx),h _ _ (right_ne_zero_of_mul hx)]
|
| 48 |
+
|
| 49 |
+
set_option maxHeartbeats 1000000 in
|
| 50 |
+
theorem coFiber (l : Filter ℕ) (hz : l≤atTop) {M : ℕ} (hM : 1≤ M) (d : ℕ)
|
| 51 |
+
(p : Shape) (w : ∀ n,Wgt (UnitType p n (M*n)))
|
| 52 |
+
(α : Party) (r : F) (Δ : ∀ n, UnitType p n (M*n) → Ambient p (M*n))
|
| 53 |
+
(h : ∀ᶠ n in l, IsLaw (w n) ∧
|
| 54 |
+
∃ T : Cov p (M*n),cdim p T≤d∧∀ x,w n x≠0 → covered p T (Δ n x))
|
| 55 |
+
(he : slight l (fun n=>pr (pairW (w n) (w n)) (matchUp (Δ n) α r twinned))) :
|
| 56 |
+
∃ S : ∀ n, UnitType p n (M*n)→Prop,warm l (fun n=>((M*n:ℕ):ℝ)) (fun n=>pr (w n) (S n)) ∧
|
| 57 |
+
∀ᶠ n in l, ∀ x,S n x.1 → S n x.2 → matchUp (Δ n) α r twinned x := by
|
| 58 |
+
classical
|
| 59 |
+
let X n:= UnitType p n (M*n)
|
| 60 |
+
let q n:= matchUp (Δ n) α r twinned
|
| 61 |
+
let c (k : ℕ) := ((k:ℝ)+1)⁻¹
|
| 62 |
+
let P n (S : X n→Prop) (k : ℕ) :=
|
| 63 |
+
bp (-(c k)*((M*n:ℕ):ℝ)) ≤ pr (w n) S ∧ ∀ x,S x.1 → S x.2 → q n x
|
| 64 |
+
have hf (k : ℕ) : ∀ᶠ n in l,∃ S : X n→Prop,P n S k := by
|
| 65 |
+
obtain ⟨θ,hθ,hg⟩:= fiber_growth (2*d) (c k) (by unfold c; positivity) (by positivity)
|
| 66 |
+
filter_upwards [h,he θ hθ, (trend_sizes l hz hM).1.eventually hg] with n hn hh hF
|
| 67 |
+
obtain ⟨hv,T,hT,h⟩:=hn
|
| 68 |
+
obtain ⟨F,hf,hz,hc⟩:= matSeason T d hT α r (Δ n) (w n) h
|
| 69 |
+
have ht : pr (pairW (w n) (w n)) (fun x => F x.1 x.2=0) ≤ θ :=
|
| 70 |
+
(avg_congr (fun x hx => show ind _=ind _ from congrArg ind (propext (hc x hx)))).trans_le hh
|
| 71 |
+
have hr : (F.rank:ℝ)≤ 2*d*(M*n:ℕ) := by exact_mod_cast hf
|
| 72 |
+
obtain ⟨S,hS,ht⟩:= hF (X n) F (w n) hv hr hz ht
|
| 73 |
+
let Y (x:X n) := S x∧ w n x≠0
|
| 74 |
+
have he : pr (w n) Y=pr (w n) S := avg_congr (fun x hx=>by simp [Y, hx])
|
| 75 |
+
refine ⟨Y, hS.trans_eq he.symm, fun x hx hy =>
|
| 76 |
+
(hc x (mul_ne_zero hx.2 hy.2)).mp (ht x.1 hx.1 x.2 hy.1)⟩
|
| 77 |
+
obtain ⟨k,hk,hf⟩:= diagonal_gains l hz (fun n k => ∃ S : X n→Prop,P n S k) hf
|
| 78 |
+
obtain ⟨S,h⟩:= taking hf
|
| 79 |
+
refine ⟨S,fun ε he=>?_, h.mono fun i hi=>hi.2⟩
|
| 80 |
+
filter_upwards [h,slight_inv_stage hk ε he] with n hn hh
|
| 81 |
+
exact (bp_le (mul_le_mul_of_nonneg_right (neg_le_neg hh) (Nat.cast_nonneg _))).trans hn.1
|
| 82 |
+
end HadwigerCounterexample
|
| 83 |
+
|
| 84 |
+
end
|
| 85 |
+
|
| 86 |
+
end OAI
|