Sync from openai/math@faee2cf485a8 (part 10)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- lean/OAI/Combinatorics/HadwigerCounterexample/PrimalChannelDecomposition.lean +123 -123
- lean/OAI/Combinatorics/HadwigerCounterexample/PrimalChannelTests.lean +158 -158
- lean/OAI/Combinatorics/HadwigerCounterexample/PrimalSpaceCompression.lean +199 -199
- lean/OAI/Combinatorics/HadwigerCounterexample/ProbePointMasses.lean +208 -208
- lean/OAI/Combinatorics/HadwigerCounterexample/ProductCharacterTests.lean +135 -135
- lean/OAI/Combinatorics/HadwigerCounterexample/ProductComparisonScales.lean +130 -130
- lean/OAI/Combinatorics/HadwigerCounterexample/ProductCoordinateReplacement.lean +58 -58
- lean/OAI/Combinatorics/HadwigerCounterexample/ProductLaws.lean +119 -119
- lean/OAI/Combinatorics/HadwigerCounterexample/ProjectedSurrogates.lean +159 -159
- lean/OAI/Combinatorics/HadwigerCounterexample/ProjectionEnergy.lean +129 -129
- lean/OAI/Combinatorics/HadwigerCounterexample/ProjectionError.lean +100 -100
- lean/OAI/Combinatorics/HadwigerCounterexample/ProjectionNets.lean +106 -106
- lean/OAI/Combinatorics/HadwigerCounterexample/QuadraticFourier.lean +83 -83
- lean/OAI/Combinatorics/HadwigerCounterexample/QuadraticTesters.lean +163 -163
- lean/OAI/Combinatorics/HadwigerCounterexample/QueryConcentration.lean +172 -172
- lean/OAI/Combinatorics/HadwigerCounterexample/RandomBinaryMixing.lean +120 -120
- lean/OAI/Combinatorics/HadwigerCounterexample/RandomLinearTransforms.lean +141 -141
- lean/OAI/Combinatorics/HadwigerCounterexample/RankEfficientDecomposition.lean +130 -130
- lean/OAI/Combinatorics/HadwigerCounterexample/RankSubrectangles.lean +126 -126
- lean/OAI/Combinatorics/HadwigerCounterexample/RareLeafEvents.lean +101 -101
- lean/OAI/Combinatorics/HadwigerCounterexample/RareTestEvents.lean +132 -132
- lean/OAI/Combinatorics/HadwigerCounterexample/RawFrameLaws.lean +185 -185
- lean/OAI/Combinatorics/HadwigerCounterexample/RealizationConditions.lean +93 -93
- lean/OAI/Combinatorics/HadwigerCounterexample/RectangleComparisons.lean +146 -146
- lean/OAI/Combinatorics/HadwigerCounterexample/RectangleRegularity.lean +115 -115
- lean/OAI/Combinatorics/HadwigerCounterexample/RecursiveComparisonErrors.lean +93 -93
- lean/OAI/Combinatorics/HadwigerCounterexample/ReferenceProductTests.lean +85 -85
- lean/OAI/Combinatorics/HadwigerCounterexample/RefinedPinImages.lean +240 -240
- lean/OAI/Combinatorics/HadwigerCounterexample/RefinementEnergy.lean +105 -105
- lean/OAI/Combinatorics/HadwigerCounterexample/ReindexedFourierSupport.lean +73 -73
- lean/OAI/Combinatorics/HadwigerCounterexample/RelationMismatchBounds.lean +129 -129
- lean/OAI/Combinatorics/HadwigerCounterexample/RelativeEntropy.lean +108 -108
- lean/OAI/Combinatorics/HadwigerCounterexample/RelativeInjectionBounds.lean +110 -110
- lean/OAI/Combinatorics/HadwigerCounterexample/RepeatedBatchLaws.lean +131 -131
- lean/OAI/Combinatorics/HadwigerCounterexample/RepeatedQueryBounds.lean +161 -161
- lean/OAI/Combinatorics/HadwigerCounterexample/RepeatedQueryEnergy.lean +117 -117
- lean/OAI/Combinatorics/HadwigerCounterexample/ReservedLabels.lean +122 -122
- lean/OAI/Combinatorics/HadwigerCounterexample/ResidualCutPairs.lean +202 -202
- lean/OAI/Combinatorics/HadwigerCounterexample/ResidualRegularity.lean +107 -107
- lean/OAI/Combinatorics/HadwigerCounterexample/ResponseAnnihilators.lean +206 -206
- lean/OAI/Combinatorics/HadwigerCounterexample/ResponseSolvability.lean +188 -188
- lean/OAI/Combinatorics/HadwigerCounterexample/RestrictedComparisonLaws.lean +101 -101
- lean/OAI/Combinatorics/HadwigerCounterexample/RoundedRefinements.lean +156 -156
- lean/OAI/Combinatorics/HadwigerCounterexample/SampledGraphs.lean +102 -102
- lean/OAI/Combinatorics/HadwigerCounterexample/ScalarStatusAlgebra.lean +162 -162
- lean/OAI/Combinatorics/HadwigerCounterexample/ScriptGramCorrespondence.lean +104 -104
- lean/OAI/Combinatorics/HadwigerCounterexample/SimultaneousProjection.lean +142 -142
- lean/OAI/Combinatorics/HadwigerCounterexample/SinglePositionExpansion.lean +82 -82
- lean/OAI/Combinatorics/HadwigerCounterexample/SingletonPhaseTests.lean +135 -135
- lean/OAI/Combinatorics/HadwigerCounterexample/SmallCoverBounds.lean +116 -116
lean/OAI/Combinatorics/HadwigerCounterexample/PrimalChannelDecomposition.lean
CHANGED
|
@@ -1,123 +1,123 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RealizationConditions
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Primal Channel Decomposition -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix Submodule
|
| 11 |
-
variable {I : Type} [Fintype I]
|
| 12 |
-
|
| 13 |
-
/-- Onto projection in coordinates, killing a specified disjoint subspace. -/
|
| 14 |
-
structure ProjData (S T : Space (Vec I)) (A : Mat I I) : Prop where
|
| 15 |
-
onto (x) : A *ᵥ x ∈ S
|
| 16 |
-
fixes x : x ∈ S → A *ᵥ x=x
|
| 17 |
-
kills x : x∈T → A *ᵥ x=0
|
| 18 |
-
|
| 19 |
-
theorem proj_exists (S T : Space (Vec I)) (h : Disjoint S T) :
|
| 20 |
-
∃ A, ProjData S T A := by
|
| 21 |
-
classical
|
| 22 |
-
obtain ⟨A,hA⟩ := mat_left_inv (inj_fromCols (pack_inj S) (pack_inj T)
|
| 23 |
-
(by rw [colSp_pack, colSp_pack]; exact h))
|
| 24 |
-
let B := A.toRows₁
|
| 25 |
-
let C := A.toRows₂
|
| 26 |
-
have he : fromRows B C * fromCols (pack S) (pack T)=1 := by
|
| 27 |
-
rw [show fromRows B C=A from Matrix.fromRows_toRows A,hA]
|
| 28 |
-
rw [Matrix.fromRows_mul_fromCols, ← Matrix.fromBlocks_one] at he
|
| 29 |
-
have hb : B*pack S=1 := congrArg Matrix.toBlocks₁₁ he
|
| 30 |
-
have hg : B*pack T=0 := congrArg Matrix.toBlocks₁₂ he
|
| 31 |
-
refine ⟨pack S*B,fun x => ?_,fun x hx => ?_,fun x hx => ?_⟩
|
| 32 |
-
· rw [←mulVec_mulVec]
|
| 33 |
-
exact (pack_mem_iff ..).mpr ⟨_,rfl⟩
|
| 34 |
-
· obtain ⟨x,rfl⟩ := (pack_mem_iff ..).mp hx
|
| 35 |
-
rw [←mulVec_mulVec, mulVec_mulVec _ B, hb,one_mulVec]
|
| 36 |
-
· obtain ⟨x,rfl⟩ := (pack_mem_iff ..).mp hx
|
| 37 |
-
rw [←mulVec_mulVec,mulVec_mulVec _ B,hg,zero_mulVec,mulVec_zero]
|
| 38 |
-
|
| 39 |
-
theorem rank_maps {J : Type} [Fintype J] {A : Mat I J} (S : Space (Vec I))
|
| 40 |
-
(ha : ∀ x,A *ᵥ x∈ S) : A.rank ≤ dim S :=
|
| 41 |
-
Submodule.finrank_mono (show colSp A ≤ S by
|
| 42 |
-
rintro x ⟨x,rfl⟩; exact ha x)
|
| 43 |
-
|
| 44 |
-
theorem evmat_addM {J : Type} [Fintype J] (A B : Mat I J) (x y) :
|
| 45 |
-
evmat (A+B) x y = evmat A x y+evmat B x y := by rw [←mpair_outer,mpair_add,
|
| 46 |
-
mpair_outer,mpair_outer]
|
| 47 |
-
|
| 48 |
-
theorem evmat_subM {J : Type} [Fintype J] (A B : Mat I J) (x y) :
|
| 49 |
-
evmat (A-B) x y = evmat A x y-evmat B x y := by
|
| 50 |
-
rw [ZModModule.sub_eq_add, ZModModule.sub_eq_add, evmat_addM]
|
| 51 |
-
|
| 52 |
-
variable {p : Shape} {n : ℕ}
|
| 53 |
-
|
| 54 |
-
/-- aggregate primal (resp. channel) directions in a unit. -/
|
| 55 |
-
def primal (p : Shape) (n : ℕ) := colSp (IP p n true) ⊔ colSp (IP p n false)
|
| 56 |
-
def channels (p : Shape) (n : ℕ) := colSp (IH p n true) ⊔ colSp (IH p n false)
|
| 57 |
-
|
| 58 |
-
theorem ip_le_primal (b : Bool) : colSp (IP p n b)≤primal p n := by
|
| 59 |
-
cases b; exact le_sup_right; exact le_sup_left
|
| 60 |
-
|
| 61 |
-
theorem ih_le_channels (b : Bool) : colSp (IH p n b)≤channels p n := by
|
| 62 |
-
cases b; exact le_sup_right; exact le_sup_left
|
| 63 |
-
|
| 64 |
-
theorem channels_proj (b : Bool) : channels p n ≤ LinearMap.ker (IP p n b)ᵀ.mulVecLin := by
|
| 65 |
-
have hi (i : Bool) : colSp (IH p n i) ≤ LinearMap.ker (IP p n b)ᵀ.mulVecLin := by
|
| 66 |
-
rintro x ⟨y,rfl⟩
|
| 67 |
-
change (IP p n b)ᵀ *ᵥ (IH p n i *ᵥ y) = _
|
| 68 |
-
rw [mulVec_mulVec, IP_IH, Matrix.zero_mulVec]
|
| 69 |
-
exact sup_le (hi _) (hi _)
|
| 70 |
-
|
| 71 |
-
theorem primal_proj (b : Bool) : primal p n ≤ LinearMap.ker (IH p n b)ᵀ.mulVecLin := by
|
| 72 |
-
have hi (i : Bool) : colSp (IP p n i) ≤ LinearMap.ker (IH p n b)ᵀ.mulVecLin := by
|
| 73 |
-
rintro x ⟨y,rfl⟩
|
| 74 |
-
change (IH p n b)ᵀ *ᵥ (IP p n i *ᵥ y) = _
|
| 75 |
-
rw [mulVec_mulVec, IH_IP, Matrix.zero_mulVec]
|
| 76 |
-
exact sup_le (hi _) (hi _)
|
| 77 |
-
|
| 78 |
-
theorem channels_disjoint : Disjoint (primal p n) (channels p n) := by
|
| 79 |
-
rw [disjoint_iff_inf_le]
|
| 80 |
-
rintro x ⟨hx,hy⟩
|
| 81 |
-
have he (b : Bool) : (IP p n b)ᵀ *ᵥ x = 0 := channels_proj b hy
|
| 82 |
-
have hf (b : Bool) : (IH p n b)ᵀ *ᵥ x = 0 := primal_proj b hx
|
| 83 |
-
have hh := ip_decomp (show Dir p n from x)
|
| 84 |
-
simp_rw [he,hf,mulVec_zero,add_zero, Finset.sum_const_zero] at hh
|
| 85 |
-
rw [← hh]
|
| 86 |
-
exact Submodule.zero_mem _
|
| 87 |
-
|
| 88 |
-
/-- prSmall a z consists of the pure-primal coordinates kept by the small
|
| 89 |
-
table. -/
|
| 90 |
-
def prSmall (a : Plan p n) (z : Place p) :=
|
| 91 |
-
(sPin a z true).map (IP p n true).mulVecLin ⊔
|
| 92 |
-
(sPin a z false).map (IP p n false).mulVecLin
|
| 93 |
-
|
| 94 |
-
theorem prSmall_le (a : Plan p n) (z : Place p) : prSmall a z≤primal p n := by
|
| 95 |
-
apply sup_le_sup <;> rintro x ⟨x,h,rfl⟩ <;> exact ⟨x,rfl⟩
|
| 96 |
-
|
| 97 |
-
theorem prSmall_dim (a : Plan p n) (z : Place p) :
|
| 98 |
-
dim (prSmall a z)≤2 * planRank a := by
|
| 99 |
-
rw [two_mul]
|
| 100 |
-
have hh (i : Bool) :
|
| 101 |
-
dim ((sPin a z i).map (IP p n i).mulVecLin) ≤ planRank a :=
|
| 102 |
-
(Submodule.finrank_map_le ..).trans ((sPin_dim ..).trans (dim_le_plan a z))
|
| 103 |
-
exact (Submodule.finrank_add_le_finrank_add_finrank ..).trans (Nat.add_le_add (hh _) (hh _))
|
| 104 |
-
|
| 105 |
-
theorem prSmall_table (a : Plan p n) (z : Place p) :
|
| 106 |
-
tabSpace a z = prSmall a z ⊔ channels p n := by
|
| 107 |
-
unfold tabSpace halfTable prSmall channels
|
| 108 |
-
ac_rfl
|
| 109 |
-
|
| 110 |
-
theorem keyPlane (v : Volley p n I) (t : Tagging p I) (z : Place p) :
|
| 111 |
-
v.keyPlan t z≤ primal p n := by
|
| 112 |
-
unfold Volley.keyPlan colSp
|
| 113 |
-
rw [range_mulVecLin]
|
| 114 |
-
apply Submodule.span_le.mpr
|
| 115 |
-
rintro x ⟨j,rfl⟩
|
| 116 |
-
exact (show colSp (IP p n _) ≤ primal p n from ip_le_primal (v.obj j.val))
|
| 117 |
-
(show v.rayLoc j.val∈colSp (IP p n _) from ⟨_,rfl⟩)
|
| 118 |
-
|
| 119 |
-
end HadwigerCounterexample
|
| 120 |
-
|
| 121 |
-
end
|
| 122 |
-
|
| 123 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RealizationConditions
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Primal Channel Decomposition -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix Submodule
|
| 11 |
+
variable {I : Type} [Fintype I]
|
| 12 |
+
|
| 13 |
+
/-- Onto projection in coordinates, killing a specified disjoint subspace. -/
|
| 14 |
+
structure ProjData (S T : Space (Vec I)) (A : Mat I I) : Prop where
|
| 15 |
+
onto (x) : A *ᵥ x ∈ S
|
| 16 |
+
fixes x : x ∈ S → A *ᵥ x=x
|
| 17 |
+
kills x : x∈T → A *ᵥ x=0
|
| 18 |
+
|
| 19 |
+
theorem proj_exists (S T : Space (Vec I)) (h : Disjoint S T) :
|
| 20 |
+
∃ A, ProjData S T A := by
|
| 21 |
+
classical
|
| 22 |
+
obtain ⟨A,hA⟩ := mat_left_inv (inj_fromCols (pack_inj S) (pack_inj T)
|
| 23 |
+
(by rw [colSp_pack, colSp_pack]; exact h))
|
| 24 |
+
let B := A.toRows₁
|
| 25 |
+
let C := A.toRows₂
|
| 26 |
+
have he : fromRows B C * fromCols (pack S) (pack T)=1 := by
|
| 27 |
+
rw [show fromRows B C=A from Matrix.fromRows_toRows A,hA]
|
| 28 |
+
rw [Matrix.fromRows_mul_fromCols, ← Matrix.fromBlocks_one] at he
|
| 29 |
+
have hb : B*pack S=1 := congrArg Matrix.toBlocks₁₁ he
|
| 30 |
+
have hg : B*pack T=0 := congrArg Matrix.toBlocks₁₂ he
|
| 31 |
+
refine ⟨pack S*B,fun x => ?_,fun x hx => ?_,fun x hx => ?_⟩
|
| 32 |
+
· rw [←mulVec_mulVec]
|
| 33 |
+
exact (pack_mem_iff ..).mpr ⟨_,rfl⟩
|
| 34 |
+
· obtain ⟨x,rfl⟩ := (pack_mem_iff ..).mp hx
|
| 35 |
+
rw [←mulVec_mulVec, mulVec_mulVec _ B, hb,one_mulVec]
|
| 36 |
+
· obtain ⟨x,rfl⟩ := (pack_mem_iff ..).mp hx
|
| 37 |
+
rw [←mulVec_mulVec,mulVec_mulVec _ B,hg,zero_mulVec,mulVec_zero]
|
| 38 |
+
|
| 39 |
+
theorem rank_maps {J : Type} [Fintype J] {A : Mat I J} (S : Space (Vec I))
|
| 40 |
+
(ha : ∀ x,A *ᵥ x∈ S) : A.rank ≤ dim S :=
|
| 41 |
+
Submodule.finrank_mono (show colSp A ≤ S by
|
| 42 |
+
rintro x ⟨x,rfl⟩; exact ha x)
|
| 43 |
+
|
| 44 |
+
theorem evmat_addM {J : Type} [Fintype J] (A B : Mat I J) (x y) :
|
| 45 |
+
evmat (A+B) x y = evmat A x y+evmat B x y := by rw [←mpair_outer,mpair_add,
|
| 46 |
+
mpair_outer,mpair_outer]
|
| 47 |
+
|
| 48 |
+
theorem evmat_subM {J : Type} [Fintype J] (A B : Mat I J) (x y) :
|
| 49 |
+
evmat (A-B) x y = evmat A x y-evmat B x y := by
|
| 50 |
+
rw [ZModModule.sub_eq_add, ZModModule.sub_eq_add, evmat_addM]
|
| 51 |
+
|
| 52 |
+
variable {p : Shape} {n : ℕ}
|
| 53 |
+
|
| 54 |
+
/-- aggregate primal (resp. channel) directions in a unit. -/
|
| 55 |
+
def primal (p : Shape) (n : ℕ) := colSp (IP p n true) ⊔ colSp (IP p n false)
|
| 56 |
+
def channels (p : Shape) (n : ℕ) := colSp (IH p n true) ⊔ colSp (IH p n false)
|
| 57 |
+
|
| 58 |
+
theorem ip_le_primal (b : Bool) : colSp (IP p n b)≤primal p n := by
|
| 59 |
+
cases b; exact le_sup_right; exact le_sup_left
|
| 60 |
+
|
| 61 |
+
theorem ih_le_channels (b : Bool) : colSp (IH p n b)≤channels p n := by
|
| 62 |
+
cases b; exact le_sup_right; exact le_sup_left
|
| 63 |
+
|
| 64 |
+
theorem channels_proj (b : Bool) : channels p n ≤ LinearMap.ker (IP p n b)ᵀ.mulVecLin := by
|
| 65 |
+
have hi (i : Bool) : colSp (IH p n i) ≤ LinearMap.ker (IP p n b)ᵀ.mulVecLin := by
|
| 66 |
+
rintro x ⟨y,rfl⟩
|
| 67 |
+
change (IP p n b)ᵀ *ᵥ (IH p n i *ᵥ y) = _
|
| 68 |
+
rw [mulVec_mulVec, IP_IH, Matrix.zero_mulVec]
|
| 69 |
+
exact sup_le (hi _) (hi _)
|
| 70 |
+
|
| 71 |
+
theorem primal_proj (b : Bool) : primal p n ≤ LinearMap.ker (IH p n b)ᵀ.mulVecLin := by
|
| 72 |
+
have hi (i : Bool) : colSp (IP p n i) ≤ LinearMap.ker (IH p n b)ᵀ.mulVecLin := by
|
| 73 |
+
rintro x ⟨y,rfl⟩
|
| 74 |
+
change (IH p n b)ᵀ *ᵥ (IP p n i *ᵥ y) = _
|
| 75 |
+
rw [mulVec_mulVec, IH_IP, Matrix.zero_mulVec]
|
| 76 |
+
exact sup_le (hi _) (hi _)
|
| 77 |
+
|
| 78 |
+
theorem channels_disjoint : Disjoint (primal p n) (channels p n) := by
|
| 79 |
+
rw [disjoint_iff_inf_le]
|
| 80 |
+
rintro x ⟨hx,hy⟩
|
| 81 |
+
have he (b : Bool) : (IP p n b)ᵀ *ᵥ x = 0 := channels_proj b hy
|
| 82 |
+
have hf (b : Bool) : (IH p n b)ᵀ *ᵥ x = 0 := primal_proj b hx
|
| 83 |
+
have hh := ip_decomp (show Dir p n from x)
|
| 84 |
+
simp_rw [he,hf,mulVec_zero,add_zero, Finset.sum_const_zero] at hh
|
| 85 |
+
rw [← hh]
|
| 86 |
+
exact Submodule.zero_mem _
|
| 87 |
+
|
| 88 |
+
/-- prSmall a z consists of the pure-primal coordinates kept by the small
|
| 89 |
+
table. -/
|
| 90 |
+
def prSmall (a : Plan p n) (z : Place p) :=
|
| 91 |
+
(sPin a z true).map (IP p n true).mulVecLin ⊔
|
| 92 |
+
(sPin a z false).map (IP p n false).mulVecLin
|
| 93 |
+
|
| 94 |
+
theorem prSmall_le (a : Plan p n) (z : Place p) : prSmall a z≤primal p n := by
|
| 95 |
+
apply sup_le_sup <;> rintro x ⟨x,h,rfl⟩ <;> exact ⟨x,rfl⟩
|
| 96 |
+
|
| 97 |
+
theorem prSmall_dim (a : Plan p n) (z : Place p) :
|
| 98 |
+
dim (prSmall a z)≤2 * planRank a := by
|
| 99 |
+
rw [two_mul]
|
| 100 |
+
have hh (i : Bool) :
|
| 101 |
+
dim ((sPin a z i).map (IP p n i).mulVecLin) ≤ planRank a :=
|
| 102 |
+
(Submodule.finrank_map_le ..).trans ((sPin_dim ..).trans (dim_le_plan a z))
|
| 103 |
+
exact (Submodule.finrank_add_le_finrank_add_finrank ..).trans (Nat.add_le_add (hh _) (hh _))
|
| 104 |
+
|
| 105 |
+
theorem prSmall_table (a : Plan p n) (z : Place p) :
|
| 106 |
+
tabSpace a z = prSmall a z ⊔ channels p n := by
|
| 107 |
+
unfold tabSpace halfTable prSmall channels
|
| 108 |
+
ac_rfl
|
| 109 |
+
|
| 110 |
+
theorem keyPlane (v : Volley p n I) (t : Tagging p I) (z : Place p) :
|
| 111 |
+
v.keyPlan t z≤ primal p n := by
|
| 112 |
+
unfold Volley.keyPlan colSp
|
| 113 |
+
rw [range_mulVecLin]
|
| 114 |
+
apply Submodule.span_le.mpr
|
| 115 |
+
rintro x ⟨j,rfl⟩
|
| 116 |
+
exact (show colSp (IP p n _) ≤ primal p n from ip_le_primal (v.obj j.val))
|
| 117 |
+
(show v.rayLoc j.val∈colSp (IP p n _) from ⟨_,rfl⟩)
|
| 118 |
+
|
| 119 |
+
end HadwigerCounterexample
|
| 120 |
+
|
| 121 |
+
end
|
| 122 |
+
|
| 123 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/PrimalChannelTests.lean
CHANGED
|
@@ -1,158 +1,158 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.GramCharacterQuotients
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Primal Channel Tests -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Module Submodule Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ}
|
| 12 |
-
|
| 13 |
-
private theorem cp_rep (f : Module.Dual F (Cross p n)) :
|
| 14 |
-
∃ M : Cross p n,cpDual p M=f := by
|
| 15 |
-
classical
|
| 16 |
-
let B : Cross p n →ₗ[F] Module.Dual F (Cross p n) := {
|
| 17 |
-
toFun := cpDual p
|
| 18 |
-
map_add' := by
|
| 19 |
-
intro x y
|
| 20 |
-
refine LinearMap.ext fun w => ?_
|
| 21 |
-
rw [LinearMap.add_apply]
|
| 22 |
-
simp only [cpDual_val,Pi.add_apply,mpair_add, Finset.sum_add_distrib]
|
| 23 |
-
map_smul' := by
|
| 24 |
-
intro a x
|
| 25 |
-
refine LinearMap.ext fun w => ?_
|
| 26 |
-
rw [LinearMap.smul_apply]
|
| 27 |
-
simp only [cpDual_val,Pi.smul_apply,mpair_smul,RingHom.id_apply,smul_eq_mul,Finset.mul_sum] }
|
| 28 |
-
have hb : Function.Injective B := by
|
| 29 |
-
rw [← LinearMap.ker_eq_bot]
|
| 30 |
-
refine le_bot_iff.mp (fun x hx => ?_)
|
| 31 |
-
have h1 : x = 0 := by
|
| 32 |
-
funext i
|
| 33 |
-
apply mpair_nondeg
|
| 34 |
-
refine LinearMap.ext fun y => ?_
|
| 35 |
-
change cpDual p x=0 at hx
|
| 36 |
-
have h := LinearMap.congr_fun hx (Pi.single i y)
|
| 37 |
-
rw [cpDual_val,Finset.sum_eq_single i] at h
|
| 38 |
-
· rwa [Pi.single_eq_same] at h
|
| 39 |
-
· intro j _ hj; simp [hj]
|
| 40 |
-
simp
|
| 41 |
-
rw [h1]; exact Submodule.zero_mem _
|
| 42 |
-
exact rk_surj.mpr ((rk_inj.mp hb).trans Subspace.dual_finrank_eq.symm) f
|
| 43 |
-
|
| 44 |
-
abbrev CheckOne (p : Shape) (n : ℕ) :=
|
| 45 |
-
Place p → Bool → Bool → Mat (Chan p) (Row p n)
|
| 46 |
-
abbrev CheckGram (p : Shape) (n : ℕ) :=
|
| 47 |
-
CheckOne p n × CheckOne p n
|
| 48 |
-
instance cgOneFin (p : Shape) (n : ℕ) : Fintype (CheckOne p n) := by
|
| 49 |
-
classical
|
| 50 |
-
letI : Fintype (Mat (Chan p) (Row p n)) := inferInstance
|
| 51 |
-
letI : Fintype (Bool → Bool → Mat (Chan p) (Row p n)) := inferInstance
|
| 52 |
-
exact inferInstance
|
| 53 |
-
instance cgFin (p : Shape) (n : ℕ) : Fintype (CheckGram p n) := inferInstance
|
| 54 |
-
|
| 55 |
-
def testgram (p : Shape) {n} : Cross p n →ₗ[F] CheckGram p n where
|
| 56 |
-
toFun A := (scalarBlocks p A, scalarBlocks p (reciprocal p A))
|
| 57 |
-
map_add' A B := by
|
| 58 |
-
apply Prod.ext <;>
|
| 59 |
-
· ext; simp only [Pi.add_apply,Prod.fst_add,Prod.snd_add,
|
| 60 |
-
scalarBlocks,channelOut,reciprocal,Matrix.add_apply,Matrix.add_mul,Matrix.transpose_add]
|
| 61 |
-
map_smul' a A := by
|
| 62 |
-
apply Prod.ext <;>
|
| 63 |
-
· ext; simp only [Pi.smul_apply,Prod.smul_fst,Prod.smul_snd,
|
| 64 |
-
scalarBlocks,channelOut,reciprocal,Matrix.smul_apply,Matrix.smul_mul,Matrix.transpose_smul,
|
| 65 |
-
RingHom.id_apply]
|
| 66 |
-
|
| 67 |
-
theorem checkgram_dim :
|
| 68 |
-
dim (CheckGram p n)=16*ncComp p*p.h*Fintype.card (Row p n) := by
|
| 69 |
-
classical
|
| 70 |
-
let r := p.h*Fintype.card (Row p n)
|
| 71 |
-
let T := Mat (Chan p) (Row p n)
|
| 72 |
-
have hf : finrank F T=r := (dim_mat _ _).trans (by simp [r,Chan])
|
| 73 |
-
have hg {I V : Type} [Fintype I] [AddCommGroup V] [Module F V] [FiniteDimensional F V] :
|
| 74 |
-
finrank F (I→V) = Fintype.card I * finrank F V := by
|
| 75 |
-
rw [finrank_pi_fintype]; simp
|
| 76 |
-
have h : finrank F (CheckOne p n)=8*ncComp p*r := by
|
| 77 |
-
unfold CheckOne
|
| 78 |
-
rw [hg,hg,hg,hf]
|
| 79 |
-
simp [ncComp,Place]
|
| 80 |
-
ring
|
| 81 |
-
unfold CheckGram dim
|
| 82 |
-
rw [Module.finrank_prod,h]
|
| 83 |
-
unfold r; ring
|
| 84 |
-
|
| 85 |
-
theorem indicator_test {V A : Type} [Fintype A] [AddCommGroup V] [Module F V]
|
| 86 |
-
[Fintype V] (s : A → V) (w : Wgt A) (hw : IsLaw w) (ε : ℝ) (he : 0≤ε)
|
| 87 |
-
(hc : ∀ f : Module.Dual F V, let Y := avg w (fun x => wsign (f (s x))); Y=1 ∨ |Y|≤ε) :
|
| 88 |
-
bp (-(dim V:ℝ))- ε ≤ pr w (fun x => s x=0) := by
|
| 89 |
-
classical
|
| 90 |
-
let T := Module.Dual F V
|
| 91 |
-
have : Finite T := Finite.of_injective _ DFunLike.coe_injective
|
| 92 |
-
let : Fintype T := Fintype.ofFinite T
|
| 93 |
-
have h (v : V) : ind (v=0) = avg unif (fun f : T => wsign (f v)) := by
|
| 94 |
-
have h := wsign_lin (Module.evalEquiv F V v)
|
| 95 |
-
rw [map_eq_zero_iff _ (Module.evalEquiv F V).injective] at h
|
| 96 |
-
exact h.symm
|
| 97 |
-
unfold pr
|
| 98 |
-
simp_rw [h]
|
| 99 |
-
rw [avg_avg]
|
| 100 |
-
let E (v : T) := ind (v=0)
|
| 101 |
-
have hE : avg unif E = bp (-(dim V:ℝ)) := by
|
| 102 |
-
change pr unif (fun v : T => v=0)=_
|
| 103 |
-
rw [pr_point',unif_apply,card_space,
|
| 104 |
-
show dim T=dim V from Subspace.dual_finrank_eq,bp_neg]
|
| 105 |
-
rw [← hE,show avg unif E - ε= avg unif (fun v : T => E v-ε) from (by
|
| 106 |
-
rw [avg_sub,unif_law.avg_const])]
|
| 107 |
-
refine avg_mono unif_law.nz fun x => ?_
|
| 108 |
-
by_cases hh : x=0
|
| 109 |
-
· subst x
|
| 110 |
-
change ind (0= (0:T))-ε ≤ avg w (fun _ => wsign 0)
|
| 111 |
-
rw [ind_one rfl,hw.avg_const,wsign_zero]; linarith
|
| 112 |
-
unfold E
|
| 113 |
-
rw [ind_zero hh,zero_sub]
|
| 114 |
-
rcases hc x with hi|hi
|
| 115 |
-
· rw [hi]; linarith
|
| 116 |
-
exact (abs_le.mp hi).1
|
| 117 |
-
|
| 118 |
-
theorem gram_hit (Q : Cross p n) {u w : Wgt (UnitType p n N)}
|
| 119 |
-
(hu : IsLaw u) (hw : IsLaw w) {f b : Pin p n N}
|
| 120 |
-
(hc : f.clear 0.05 u) (hd : b.clear 0.05 w)
|
| 121 |
-
(h : ∀ x,u x≠0 → ∀ y,w y≠0 → rowAgree f.sp (actual p x y) Q ∧
|
| 122 |
-
rowAgree b.sp (actual p y x) (reciprocal p Q))
|
| 123 |
-
(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ)≤0.01*N) :
|
| 124 |
-
hit N ≤ pr (pairW u w) (fun x =>
|
| 125 |
-
testgram p (actual p x.1 x.2)=testgram p Q) := by
|
| 126 |
-
classical
|
| 127 |
-
let v := pairW u w
|
| 128 |
-
let s (x : UnitType p n N × UnitType p n N) := testgram p (actual p x.1 x.2 - Q)
|
| 129 |
-
have hh (g : Module.Dual F (CheckGram p n)) :
|
| 130 |
-
let Y := avg v (fun x => wsign (g (s x)))
|
| 131 |
-
Y=1 ∨ |Y|≤bp (-0.45*N) := by
|
| 132 |
-
obtain ⟨M,hM⟩ := cp_rep (g ∘ₗ testgram p)
|
| 133 |
-
have hf x := LinearMap.congr_fun hM x
|
| 134 |
-
have he x : g (s x) = cpDual p M _ := (hf (actual p x.1 x.2-Q)).symm
|
| 135 |
-
dsimp only
|
| 136 |
-
simp_rw [he]
|
| 137 |
-
exact gramCharacter Q M hu hw hc hd h
|
| 138 |
-
have hg := indicator_test s v (pairW_law hu hw) (bp (-0.45*N)) (bp_pos _).le hh
|
| 139 |
-
have he : pr v (fun x => s x=0)=pr v (fun x => testgram p (actual p x.1 x.2)=testgram p Q) := by
|
| 140 |
-
apply congrArg (pr v)
|
| 141 |
-
funext x; apply propext
|
| 142 |
-
unfold s
|
| 143 |
-
have he (A : Cross p n) : testgram p (A+Q) = testgram p A+testgram p Q := (testgram p).map_add' _ _
|
| 144 |
-
rw [show actual p x.1 x.2-Q=actual p x.1 x.2+Q from ZModModule.sub_eq_add ..,he, ← ZModModule.sub_eq_add,sub_eq_zero]
|
| 145 |
-
rw [he] at hg
|
| 146 |
-
refine le_trans ?_ hg
|
| 147 |
-
have hn : 100≤(N:ℝ) := by exact_mod_cast hN
|
| 148 |
-
unfold hit
|
| 149 |
-
have heq := bp_le (show -0.45*N≤-0.02*(N:ℝ) by linarith only [hn])
|
| 150 |
-
have heq' : 2*bp (-0.02*N) ≤ bp (-(dim (CheckGram p n):ℝ)) := by
|
| 151 |
-
rw [← bp_one,← bp_add]; apply bp_le; linarith only [hn,hT]
|
| 152 |
-
linarith only [heq,heq']
|
| 153 |
-
|
| 154 |
-
end HadwigerCounterexample
|
| 155 |
-
|
| 156 |
-
end
|
| 157 |
-
|
| 158 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.GramCharacterQuotients
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Primal Channel Tests -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Module Submodule Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ}
|
| 12 |
+
|
| 13 |
+
private theorem cp_rep (f : Module.Dual F (Cross p n)) :
|
| 14 |
+
∃ M : Cross p n,cpDual p M=f := by
|
| 15 |
+
classical
|
| 16 |
+
let B : Cross p n →ₗ[F] Module.Dual F (Cross p n) := {
|
| 17 |
+
toFun := cpDual p
|
| 18 |
+
map_add' := by
|
| 19 |
+
intro x y
|
| 20 |
+
refine LinearMap.ext fun w => ?_
|
| 21 |
+
rw [LinearMap.add_apply]
|
| 22 |
+
simp only [cpDual_val,Pi.add_apply,mpair_add, Finset.sum_add_distrib]
|
| 23 |
+
map_smul' := by
|
| 24 |
+
intro a x
|
| 25 |
+
refine LinearMap.ext fun w => ?_
|
| 26 |
+
rw [LinearMap.smul_apply]
|
| 27 |
+
simp only [cpDual_val,Pi.smul_apply,mpair_smul,RingHom.id_apply,smul_eq_mul,Finset.mul_sum] }
|
| 28 |
+
have hb : Function.Injective B := by
|
| 29 |
+
rw [← LinearMap.ker_eq_bot]
|
| 30 |
+
refine le_bot_iff.mp (fun x hx => ?_)
|
| 31 |
+
have h1 : x = 0 := by
|
| 32 |
+
funext i
|
| 33 |
+
apply mpair_nondeg
|
| 34 |
+
refine LinearMap.ext fun y => ?_
|
| 35 |
+
change cpDual p x=0 at hx
|
| 36 |
+
have h := LinearMap.congr_fun hx (Pi.single i y)
|
| 37 |
+
rw [cpDual_val,Finset.sum_eq_single i] at h
|
| 38 |
+
· rwa [Pi.single_eq_same] at h
|
| 39 |
+
· intro j _ hj; simp [hj]
|
| 40 |
+
simp
|
| 41 |
+
rw [h1]; exact Submodule.zero_mem _
|
| 42 |
+
exact rk_surj.mpr ((rk_inj.mp hb).trans Subspace.dual_finrank_eq.symm) f
|
| 43 |
+
|
| 44 |
+
abbrev CheckOne (p : Shape) (n : ℕ) :=
|
| 45 |
+
Place p → Bool → Bool → Mat (Chan p) (Row p n)
|
| 46 |
+
abbrev CheckGram (p : Shape) (n : ℕ) :=
|
| 47 |
+
CheckOne p n × CheckOne p n
|
| 48 |
+
instance cgOneFin (p : Shape) (n : ℕ) : Fintype (CheckOne p n) := by
|
| 49 |
+
classical
|
| 50 |
+
letI : Fintype (Mat (Chan p) (Row p n)) := inferInstance
|
| 51 |
+
letI : Fintype (Bool → Bool → Mat (Chan p) (Row p n)) := inferInstance
|
| 52 |
+
exact inferInstance
|
| 53 |
+
instance cgFin (p : Shape) (n : ℕ) : Fintype (CheckGram p n) := inferInstance
|
| 54 |
+
|
| 55 |
+
def testgram (p : Shape) {n} : Cross p n →ₗ[F] CheckGram p n where
|
| 56 |
+
toFun A := (scalarBlocks p A, scalarBlocks p (reciprocal p A))
|
| 57 |
+
map_add' A B := by
|
| 58 |
+
apply Prod.ext <;>
|
| 59 |
+
· ext; simp only [Pi.add_apply,Prod.fst_add,Prod.snd_add,
|
| 60 |
+
scalarBlocks,channelOut,reciprocal,Matrix.add_apply,Matrix.add_mul,Matrix.transpose_add]
|
| 61 |
+
map_smul' a A := by
|
| 62 |
+
apply Prod.ext <;>
|
| 63 |
+
· ext; simp only [Pi.smul_apply,Prod.smul_fst,Prod.smul_snd,
|
| 64 |
+
scalarBlocks,channelOut,reciprocal,Matrix.smul_apply,Matrix.smul_mul,Matrix.transpose_smul,
|
| 65 |
+
RingHom.id_apply]
|
| 66 |
+
|
| 67 |
+
theorem checkgram_dim :
|
| 68 |
+
dim (CheckGram p n)=16*ncComp p*p.h*Fintype.card (Row p n) := by
|
| 69 |
+
classical
|
| 70 |
+
let r := p.h*Fintype.card (Row p n)
|
| 71 |
+
let T := Mat (Chan p) (Row p n)
|
| 72 |
+
have hf : finrank F T=r := (dim_mat _ _).trans (by simp [r,Chan])
|
| 73 |
+
have hg {I V : Type} [Fintype I] [AddCommGroup V] [Module F V] [FiniteDimensional F V] :
|
| 74 |
+
finrank F (I→V) = Fintype.card I * finrank F V := by
|
| 75 |
+
rw [finrank_pi_fintype]; simp
|
| 76 |
+
have h : finrank F (CheckOne p n)=8*ncComp p*r := by
|
| 77 |
+
unfold CheckOne
|
| 78 |
+
rw [hg,hg,hg,hf]
|
| 79 |
+
simp [ncComp,Place]
|
| 80 |
+
ring
|
| 81 |
+
unfold CheckGram dim
|
| 82 |
+
rw [Module.finrank_prod,h]
|
| 83 |
+
unfold r; ring
|
| 84 |
+
|
| 85 |
+
theorem indicator_test {V A : Type} [Fintype A] [AddCommGroup V] [Module F V]
|
| 86 |
+
[Fintype V] (s : A → V) (w : Wgt A) (hw : IsLaw w) (ε : ℝ) (he : 0≤ε)
|
| 87 |
+
(hc : ∀ f : Module.Dual F V, let Y := avg w (fun x => wsign (f (s x))); Y=1 ∨ |Y|≤ε) :
|
| 88 |
+
bp (-(dim V:ℝ))- ε ≤ pr w (fun x => s x=0) := by
|
| 89 |
+
classical
|
| 90 |
+
let T := Module.Dual F V
|
| 91 |
+
have : Finite T := Finite.of_injective _ DFunLike.coe_injective
|
| 92 |
+
let : Fintype T := Fintype.ofFinite T
|
| 93 |
+
have h (v : V) : ind (v=0) = avg unif (fun f : T => wsign (f v)) := by
|
| 94 |
+
have h := wsign_lin (Module.evalEquiv F V v)
|
| 95 |
+
rw [map_eq_zero_iff _ (Module.evalEquiv F V).injective] at h
|
| 96 |
+
exact h.symm
|
| 97 |
+
unfold pr
|
| 98 |
+
simp_rw [h]
|
| 99 |
+
rw [avg_avg]
|
| 100 |
+
let E (v : T) := ind (v=0)
|
| 101 |
+
have hE : avg unif E = bp (-(dim V:ℝ)) := by
|
| 102 |
+
change pr unif (fun v : T => v=0)=_
|
| 103 |
+
rw [pr_point',unif_apply,card_space,
|
| 104 |
+
show dim T=dim V from Subspace.dual_finrank_eq,bp_neg]
|
| 105 |
+
rw [← hE,show avg unif E - ε= avg unif (fun v : T => E v-ε) from (by
|
| 106 |
+
rw [avg_sub,unif_law.avg_const])]
|
| 107 |
+
refine avg_mono unif_law.nz fun x => ?_
|
| 108 |
+
by_cases hh : x=0
|
| 109 |
+
· subst x
|
| 110 |
+
change ind (0= (0:T))-ε ≤ avg w (fun _ => wsign 0)
|
| 111 |
+
rw [ind_one rfl,hw.avg_const,wsign_zero]; linarith
|
| 112 |
+
unfold E
|
| 113 |
+
rw [ind_zero hh,zero_sub]
|
| 114 |
+
rcases hc x with hi|hi
|
| 115 |
+
· rw [hi]; linarith
|
| 116 |
+
exact (abs_le.mp hi).1
|
| 117 |
+
|
| 118 |
+
theorem gram_hit (Q : Cross p n) {u w : Wgt (UnitType p n N)}
|
| 119 |
+
(hu : IsLaw u) (hw : IsLaw w) {f b : Pin p n N}
|
| 120 |
+
(hc : f.clear 0.05 u) (hd : b.clear 0.05 w)
|
| 121 |
+
(h : ∀ x,u x≠0 → ∀ y,w y≠0 → rowAgree f.sp (actual p x y) Q ∧
|
| 122 |
+
rowAgree b.sp (actual p y x) (reciprocal p Q))
|
| 123 |
+
(hN : 100 ≤ N) (hT : (dim (CheckGram p n) : ℝ)≤0.01*N) :
|
| 124 |
+
hit N ≤ pr (pairW u w) (fun x =>
|
| 125 |
+
testgram p (actual p x.1 x.2)=testgram p Q) := by
|
| 126 |
+
classical
|
| 127 |
+
let v := pairW u w
|
| 128 |
+
let s (x : UnitType p n N × UnitType p n N) := testgram p (actual p x.1 x.2 - Q)
|
| 129 |
+
have hh (g : Module.Dual F (CheckGram p n)) :
|
| 130 |
+
let Y := avg v (fun x => wsign (g (s x)))
|
| 131 |
+
Y=1 ∨ |Y|≤bp (-0.45*N) := by
|
| 132 |
+
obtain ⟨M,hM⟩ := cp_rep (g ∘ₗ testgram p)
|
| 133 |
+
have hf x := LinearMap.congr_fun hM x
|
| 134 |
+
have he x : g (s x) = cpDual p M _ := (hf (actual p x.1 x.2-Q)).symm
|
| 135 |
+
dsimp only
|
| 136 |
+
simp_rw [he]
|
| 137 |
+
exact gramCharacter Q M hu hw hc hd h
|
| 138 |
+
have hg := indicator_test s v (pairW_law hu hw) (bp (-0.45*N)) (bp_pos _).le hh
|
| 139 |
+
have he : pr v (fun x => s x=0)=pr v (fun x => testgram p (actual p x.1 x.2)=testgram p Q) := by
|
| 140 |
+
apply congrArg (pr v)
|
| 141 |
+
funext x; apply propext
|
| 142 |
+
unfold s
|
| 143 |
+
have he (A : Cross p n) : testgram p (A+Q) = testgram p A+testgram p Q := (testgram p).map_add' _ _
|
| 144 |
+
rw [show actual p x.1 x.2-Q=actual p x.1 x.2+Q from ZModModule.sub_eq_add ..,he, ← ZModModule.sub_eq_add,sub_eq_zero]
|
| 145 |
+
rw [he] at hg
|
| 146 |
+
refine le_trans ?_ hg
|
| 147 |
+
have hn : 100≤(N:ℝ) := by exact_mod_cast hN
|
| 148 |
+
unfold hit
|
| 149 |
+
have heq := bp_le (show -0.45*N≤-0.02*(N:ℝ) by linarith only [hn])
|
| 150 |
+
have heq' : 2*bp (-0.02*N) ≤ bp (-(dim (CheckGram p n):ℝ)) := by
|
| 151 |
+
rw [← bp_one,← bp_add]; apply bp_le; linarith only [hn,hT]
|
| 152 |
+
linarith only [heq,heq']
|
| 153 |
+
|
| 154 |
+
end HadwigerCounterexample
|
| 155 |
+
|
| 156 |
+
end
|
| 157 |
+
|
| 158 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/PrimalSpaceCompression.lean
CHANGED
|
@@ -1,199 +1,199 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RankEfficientDecomposition
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Primal Space Compression -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Module Submodule Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ} {I J : Type} [Fintype I] [Fintype J]
|
| 12 |
-
|
| 13 |
-
private theorem exists_cover (S : J→Space (Vec I)) (D : ℕ) (h : ∀ j,dim (S j)≤D) :
|
| 14 |
-
∃ A : Space (Vec I),(∀ j,S j ≤ A) ∧ dim A≤Fintype.card J*D := by
|
| 15 |
-
classical
|
| 16 |
-
have hh (s : Finset J) :
|
| 17 |
-
∃ A : Space (Vec I),(∀ j∈s,S j≤A) ∧ dim A≤s.card*D := by
|
| 18 |
-
induction s using Finset.induction with
|
| 19 |
-
| empty => exact ⟨⊥,by simp, by simp [dim]⟩
|
| 20 |
-
| insert a s ha ih =>
|
| 21 |
-
obtain ⟨A,hA,hD⟩ := ih
|
| 22 |
-
refine ⟨S a⊔A,fun j hj => ?_,?_⟩
|
| 23 |
-
· rcases Finset.mem_insert.mp hj with rfl|g
|
| 24 |
-
· exact le_sup_left
|
| 25 |
-
exact (hA _ g).trans le_sup_right
|
| 26 |
-
simpa only [Finset.card_insert_of_notMem ha,Nat.add_mul,one_mul,add_comm D] using
|
| 27 |
-
((Submodule.finrank_add_le_finrank_add_finrank (S a) A).trans (add_le_add (h a) hD))
|
| 28 |
-
simpa only [Finset.mem_univ,true_imp_iff,card_univ] using hh Finset.univ
|
| 29 |
-
|
| 30 |
-
theorem compact_endo (S T : Space (Vec I)) :
|
| 31 |
-
∃ A : Mat I I,(∀ x∈S,A *ᵥ x=x) ∧ (∀ x∈T,Aᵀ *ᵥ x=x) ∧ A.rank≤dim S+dim T := by
|
| 32 |
-
classical
|
| 33 |
-
obtain ⟨A,hA⟩ := proj_exists S ⊥ disjoint_bot_right
|
| 34 |
-
obtain ⟨B,hB⟩ := proj_exists T ⊥ disjoint_bot_right
|
| 35 |
-
refine ⟨A+Bᵀ * (1-A),fun x hx => ?_,fun x hx => ?_,?_⟩
|
| 36 |
-
· rw [Matrix.add_mulVec,←Matrix.mulVec_mulVec,Matrix.sub_mulVec,hA.fixes x hx,
|
| 37 |
-
Matrix.one_mulVec,sub_self,Matrix.mulVec_zero,add_zero]
|
| 38 |
-
· rw [Matrix.transpose_add,Matrix.add_mulVec,Matrix.transpose_mul,Matrix.transpose_transpose,
|
| 39 |
-
← mulVec_mulVec,hB.fixes x hx,Matrix.transpose_sub,Matrix.sub_mulVec,Matrix.transpose_one,
|
| 40 |
-
Matrix.one_mulVec,add_sub_cancel]
|
| 41 |
-
exact (mrk_add_le ..).trans (add_le_add (rank_maps S hA.onto) ((Matrix.rank_mul_le_left ..).trans
|
| 42 |
-
(by rw [Matrix.rank_transpose]; exact rank_maps T hB.onto)))
|
| 43 |
-
|
| 44 |
-
abbrev Sel (p : Shape) := SelIdx p.b p.j
|
| 45 |
-
abbrev Nendo (p : Shape) (n : ℕ) := Block p.g→ Mat (Fin n) (Fin n)
|
| 46 |
-
def iFix (p : Shape) (n : ℕ) : Mat (Row p n) (Sel p) := embedMat (fun s => (s,none))
|
| 47 |
-
def iCoeff (p : Shape) (n : ℕ) (s : Sel p) (d : Block p.g) :
|
| 48 |
-
Mat (Row p n) (Fin n) := embedMat (fun i => (s,some (d,i)))
|
| 49 |
-
|
| 50 |
-
/-- induced row vector transform. -/
|
| 51 |
-
def rowShrink (p : Shape) {n} (A : Nendo p n) : Mat (Row p n) (Row p n) :=
|
| 52 |
-
iFix p n*(iFix p n)ᵀ +
|
| 53 |
-
∑ i : Sel p,∑ d : Block p.g,iCoeff p n i d*A d*(iCoeff p n i d)ᵀ
|
| 54 |
-
|
| 55 |
-
def readCoeff (p : Shape) {n} (s : Sel p) (d : Block p.g) (v : Ray p n) :=
|
| 56 |
-
fun i => v (s,some (d,i))
|
| 57 |
-
|
| 58 |
-
theorem readCoeff_val (s : Sel p) (d : Block p.g) (v : Ray p n) :
|
| 59 |
-
(iCoeff p n s d)ᵀ *ᵥ v=readCoeff p s d v := embedMatT _ _
|
| 60 |
-
|
| 61 |
-
theorem shrink_transpose (A : Nendo p n) :
|
| 62 |
-
(rowShrink p A)ᵀ=rowShrink p (fun i => (A i)ᵀ) := by
|
| 63 |
-
simp only [rowShrink,Matrix.transpose_add,Matrix.transpose_mul,
|
| 64 |
-
Matrix.transpose_sum,Matrix.transpose_transpose,Matrix.mul_assoc]
|
| 65 |
-
|
| 66 |
-
private theorem coeff_none (A : Nendo p n) (v : Ray p n) (s : Sel p) :
|
| 67 |
-
(rowShrink p A *ᵥ v) (s,none)=v (s,none) := by
|
| 68 |
-
classical
|
| 69 |
-
simp only [rowShrink,Matrix.add_mulVec, Matrix.sum_mulVec,←Matrix.mulVec_mulVec,readCoeff_val]
|
| 70 |
-
unfold iFix iCoeff
|
| 71 |
-
rw [embedMatT]
|
| 72 |
-
simp [embedMat,Matrix.mulVec,dotProduct,Finset.sum_apply,Matrix.mul_apply]
|
| 73 |
-
|
| 74 |
-
set_option maxHeartbeats 600000 in
|
| 75 |
-
private theorem coeff_some (A : Nendo p n) (v : Ray p n) (s : Sel p)
|
| 76 |
-
(d : Block p.g) (i : Fin n) :
|
| 77 |
-
(rowShrink p A *ᵥ v) (s,some (d,i))=(A d *ᵥ (readCoeff p s d v)) i := by
|
| 78 |
-
classical
|
| 79 |
-
simp only [rowShrink,Matrix.add_mulVec, Matrix.sum_mulVec,←Matrix.mulVec_mulVec,readCoeff_val]
|
| 80 |
-
simp only [Pi.add_apply,Finset.sum_apply]
|
| 81 |
-
have hz (x) : (iFix p n *ᵥ x) (s,some (d,i))=0 := by
|
| 82 |
-
simp [iFix,embedMat,Matrix.mulVec,dotProduct]
|
| 83 |
-
rw [hz,zero_add]
|
| 84 |
-
have hh (t : Sel p) (a : Block p.g) (x : Vec (Fin n)) :
|
| 85 |
-
(iCoeff p n t a *ᵥ x) (s,some (d,i)) =
|
| 86 |
-
if s=t then (if d=a then x i else 0) else 0 := by
|
| 87 |
-
by_cases e : s=t <;> by_cases g : d=a <;> simp [iCoeff,embedMat,Matrix.mulVec,dotProduct,e,g]
|
| 88 |
-
simp_rw [hh]
|
| 89 |
-
rw [Finset.sum_eq_single s]
|
| 90 |
-
· simp only [ite_true,Finset.sum_ite_eq,mem_univ]
|
| 91 |
-
· intro a _ ha; simp only [ite_eq_right (Ne.symm ha),Finset.sum_const_zero]
|
| 92 |
-
simp
|
| 93 |
-
|
| 94 |
-
private theorem coeff_fixes (A : Nendo p n) (v : Ray p n)
|
| 95 |
-
(h : ∀ d s, A d *ᵥ (readCoeff p s d v) = readCoeff p s d v) :
|
| 96 |
-
rowShrink p A *ᵥ v=v := by
|
| 97 |
-
funext i
|
| 98 |
-
rcases i with ⟨s, _|⟨d,i⟩⟩
|
| 99 |
-
· rw [coeff_none]
|
| 100 |
-
rw [coeff_some,h]
|
| 101 |
-
rfl
|
| 102 |
-
|
| 103 |
-
def nbBlock (p : Shape) := Fintype.card (Block p.g)
|
| 104 |
-
def ncComp (p : Shape) := Fintype.card (Comp p.g)
|
| 105 |
-
|
| 106 |
-
theorem shrink_rank (A : Nendo p n) (D : ℕ) (h : ∀ i,(A i).rank ≤ D) :
|
| 107 |
-
(rowShrink p A).rank≤ psize p+ psize p* (nbBlock p*D) := by
|
| 108 |
-
apply le_trans (mrk_add_le ..)
|
| 109 |
-
apply add_le_add
|
| 110 |
-
· exact (Matrix.rank_mul_le_left ..).trans (iFix p n).rank_le_card_width
|
| 111 |
-
refine (mrk_sum_le ..).trans ((Finset.sum_le_sum (g:=fun _ => nbBlock p*D) (fun i _ => ?_)).trans_eq
|
| 112 |
-
(by simp [psize,Sel]))
|
| 113 |
-
refine (mrk_sum_le ..).trans ((Finset.sum_le_sum (g:=fun _ => D) (fun i _ => ?_)).trans_eq
|
| 114 |
-
(by simp [nbBlock]))
|
| 115 |
-
exact ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_right ..)).trans (h i)
|
| 116 |
-
|
| 117 |
-
def dbits (p : Shape) (T R : ℕ) := ncComp p*2* psize p*(T+R)
|
| 118 |
-
def drow (p : Shape) (T R : ℕ) := psize p+psize p*(nbBlock p*dbits p T R)
|
| 119 |
-
|
| 120 |
-
theorem shrink_both (S T : Place p → Space (Ray p n)) (K R : ℕ)
|
| 121 |
-
(hk : ∀ z,dim (S z) ≤K) (hr : ∀ z,dim (T z)≤R) :
|
| 122 |
-
∃ A : Nendo p n,
|
| 123 |
-
(∀ z,∀ x∈S z,rowShrink p A *ᵥ x=x) ∧
|
| 124 |
-
(∀ z,∀ x∈T z,(rowShrink p A)ᵀ *ᵥ x=x) ∧
|
| 125 |
-
(rowShrink p A).rank ≤ drow p K R := by
|
| 126 |
-
classical
|
| 127 |
-
let W := Place p×Sel p
|
| 128 |
-
have hp : Fintype.card (Place p×Sel p)=ncComp p*2*psize p := by
|
| 129 |
-
simp only [Place,Fintype.card_prod,ncComp,Fintype.card_bool,psize,Sel]
|
| 130 |
-
let G d (S : Place p → Space (Ray p n)) (z : Place p×Sel p) :=
|
| 131 |
-
(S z.1).map (iCoeff p n z.2 d)ᵀ.mulVecLin
|
| 132 |
-
obtain ⟨A,hA,hT,hL⟩ :
|
| 133 |
-
∃ A : Nendo p n,
|
| 134 |
-
(∀ d z,∀ x∈G d S z,A d *ᵥ x=x) ∧
|
| 135 |
-
(∀ d z,∀ x∈G d T z,(A d)ᵀ *ᵥ x=x) ∧ ∀ i,(A i).rank≤dbits p K R := by
|
| 136 |
-
have he (d : Block p.g) :
|
| 137 |
-
∃ A : Mat (Fin n) (Fin n), (∀ z,∀ x∈G d S z,A *ᵥ x=x) ∧
|
| 138 |
-
(∀ z,∀ x∈G d T z,Aᵀ *ᵥ x=x) ∧ A.rank≤dbits p K R := by
|
| 139 |
-
obtain ⟨X,hX,hD⟩ := exists_cover (G d S) K (fun j => (Submodule.finrank_map_le ..).trans
|
| 140 |
-
(hk j.1))
|
| 141 |
-
obtain ⟨Y,hY,hD'⟩ := exists_cover (G d T) R (fun j => (Submodule.finrank_map_le ..).trans
|
| 142 |
-
(hr j.1))
|
| 143 |
-
obtain ⟨A,hA,hZ,hL⟩ := compact_endo X Y
|
| 144 |
-
refine ⟨A,(fun z x hx => hA x (hX z hx)),(fun z x hx => hZ x (hY z hx)),?_⟩
|
| 145 |
-
rw [hp] at hD hD'
|
| 146 |
-
exact hL.trans ((add_le_add hD hD').trans_eq (Nat.mul_add ..).symm)
|
| 147 |
-
choose A hA hZ hL using he
|
| 148 |
-
exact ⟨A,hA,hZ,hL⟩
|
| 149 |
-
have he (X : Place p → Space (Ray p n)) (z)
|
| 150 |
-
(x : Ray p n) (hx : x∈X z) (d s) : readCoeff p s d x∈ G d X (z,s) :=
|
| 151 |
-
⟨x,hx,readCoeff_val ..⟩
|
| 152 |
-
refine ⟨A,fun z x hx => ?_,fun z x hx => ?_,shrink_rank A _ hL⟩
|
| 153 |
-
· exact coeff_fixes A x (fun d s => hA _ (z,s) _ (he S z x hx d s))
|
| 154 |
-
rw [shrink_transpose]
|
| 155 |
-
exact coeff_fixes _ _ (fun d s => hT _ (z,s) _ (he T z x hx d s))
|
| 156 |
-
|
| 157 |
-
private def shrinkBase (A : Nendo p n) (v : Base p.g n) : Base p.g n :=
|
| 158 |
-
fun x => (A x.1 *ᵥ (fun j => v (x.1,j))) x.2
|
| 159 |
-
|
| 160 |
-
private theorem shrink_point (A : Nendo p n) (s : Label p.b) (z : Base p.g n) :
|
| 161 |
-
rowShrink p A *ᵥ point p s z=point p s (shrinkBase (p:=p) A z) := by
|
| 162 |
-
classical
|
| 163 |
-
funext i
|
| 164 |
-
rcases i with ⟨r,_|⟨d,i⟩⟩
|
| 165 |
-
· rw [coeff_none]; rfl
|
| 166 |
-
rw [coeff_some]
|
| 167 |
-
simp only [point_eval,readCoeff,shrinkBase,Matrix.mulVec,dotProduct,
|
| 168 |
-
baseV,Option.elim',Finset.mul_sum]
|
| 169 |
-
exact Finset.sum_congr rfl fun i _ => mul_left_comm ..
|
| 170 |
-
|
| 171 |
-
private theorem shrink_tag (A : Nendo p n) (l : Tag p.g) (M : Moment p n) (h : M∈Wtag p n l) :
|
| 172 |
-
liftM (rowShrink p A) (rowShrink p A) M∈Wtag p n l := by
|
| 173 |
-
classical
|
| 174 |
-
unfold Wtag at h
|
| 175 |
-
induction h using Submodule.span_induction with
|
| 176 |
-
| mem m hm =>
|
| 177 |
-
obtain ⟨s,z,hz,rfl⟩ := hm
|
| 178 |
-
simp only [mom,liftM_outer,shrink_point]
|
| 179 |
-
apply Submodule.subset_span
|
| 180 |
-
refine ⟨s,shrinkBase (p:=p) A z,?_,rfl⟩
|
| 181 |
-
intro d t hd i
|
| 182 |
-
change (A (Block.O d t) *ᵥ _) i = _
|
| 183 |
-
simp only [Matrix.mulVec,dotProduct,hz _ _ hd,mul_zero,Finset.sum_const_zero]
|
| 184 |
-
| zero => rw [map_zero]; exact Submodule.zero_mem _
|
| 185 |
-
| add x y hx hy ih ih' => rw [map_add]; exact Submodule.add_mem _ ih ih'
|
| 186 |
-
| smul a x hx ih => rw [map_smul]; exact Submodule.smul_mem _ _ ih
|
| 187 |
-
|
| 188 |
-
theorem shrink_X (A : Nendo p n) (M : Profile p n) (h : M∈Xspace p n) :
|
| 189 |
-
(fun e : Comp p.g => liftM (rowShrink p A) (rowShrink p A) (M e))∈Xspace p n := by
|
| 190 |
-
obtain ⟨w,hw,rfl⟩ := mem_X.mp h
|
| 191 |
-
refine mem_X.mpr ⟨_,(fun l => shrink_tag A l _ (hw l)),?_⟩
|
| 192 |
-
funext i
|
| 193 |
-
exact (map_add (liftM (rowShrink p A) (rowShrink p A)) _ _).symm
|
| 194 |
-
|
| 195 |
-
end HadwigerCounterexample
|
| 196 |
-
|
| 197 |
-
end
|
| 198 |
-
|
| 199 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RankEfficientDecomposition
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Primal Space Compression -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Module Submodule Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ} {I J : Type} [Fintype I] [Fintype J]
|
| 12 |
+
|
| 13 |
+
private theorem exists_cover (S : J→Space (Vec I)) (D : ℕ) (h : ∀ j,dim (S j)≤D) :
|
| 14 |
+
∃ A : Space (Vec I),(∀ j,S j ≤ A) ∧ dim A≤Fintype.card J*D := by
|
| 15 |
+
classical
|
| 16 |
+
have hh (s : Finset J) :
|
| 17 |
+
∃ A : Space (Vec I),(∀ j∈s,S j≤A) ∧ dim A≤s.card*D := by
|
| 18 |
+
induction s using Finset.induction with
|
| 19 |
+
| empty => exact ⟨⊥,by simp, by simp [dim]⟩
|
| 20 |
+
| insert a s ha ih =>
|
| 21 |
+
obtain ⟨A,hA,hD⟩ := ih
|
| 22 |
+
refine ⟨S a⊔A,fun j hj => ?_,?_⟩
|
| 23 |
+
· rcases Finset.mem_insert.mp hj with rfl|g
|
| 24 |
+
· exact le_sup_left
|
| 25 |
+
exact (hA _ g).trans le_sup_right
|
| 26 |
+
simpa only [Finset.card_insert_of_notMem ha,Nat.add_mul,one_mul,add_comm D] using
|
| 27 |
+
((Submodule.finrank_add_le_finrank_add_finrank (S a) A).trans (add_le_add (h a) hD))
|
| 28 |
+
simpa only [Finset.mem_univ,true_imp_iff,card_univ] using hh Finset.univ
|
| 29 |
+
|
| 30 |
+
theorem compact_endo (S T : Space (Vec I)) :
|
| 31 |
+
∃ A : Mat I I,(∀ x∈S,A *ᵥ x=x) ∧ (∀ x∈T,Aᵀ *ᵥ x=x) ∧ A.rank≤dim S+dim T := by
|
| 32 |
+
classical
|
| 33 |
+
obtain ⟨A,hA⟩ := proj_exists S ⊥ disjoint_bot_right
|
| 34 |
+
obtain ⟨B,hB⟩ := proj_exists T ⊥ disjoint_bot_right
|
| 35 |
+
refine ⟨A+Bᵀ * (1-A),fun x hx => ?_,fun x hx => ?_,?_⟩
|
| 36 |
+
· rw [Matrix.add_mulVec,←Matrix.mulVec_mulVec,Matrix.sub_mulVec,hA.fixes x hx,
|
| 37 |
+
Matrix.one_mulVec,sub_self,Matrix.mulVec_zero,add_zero]
|
| 38 |
+
· rw [Matrix.transpose_add,Matrix.add_mulVec,Matrix.transpose_mul,Matrix.transpose_transpose,
|
| 39 |
+
← mulVec_mulVec,hB.fixes x hx,Matrix.transpose_sub,Matrix.sub_mulVec,Matrix.transpose_one,
|
| 40 |
+
Matrix.one_mulVec,add_sub_cancel]
|
| 41 |
+
exact (mrk_add_le ..).trans (add_le_add (rank_maps S hA.onto) ((Matrix.rank_mul_le_left ..).trans
|
| 42 |
+
(by rw [Matrix.rank_transpose]; exact rank_maps T hB.onto)))
|
| 43 |
+
|
| 44 |
+
abbrev Sel (p : Shape) := SelIdx p.b p.j
|
| 45 |
+
abbrev Nendo (p : Shape) (n : ℕ) := Block p.g→ Mat (Fin n) (Fin n)
|
| 46 |
+
def iFix (p : Shape) (n : ℕ) : Mat (Row p n) (Sel p) := embedMat (fun s => (s,none))
|
| 47 |
+
def iCoeff (p : Shape) (n : ℕ) (s : Sel p) (d : Block p.g) :
|
| 48 |
+
Mat (Row p n) (Fin n) := embedMat (fun i => (s,some (d,i)))
|
| 49 |
+
|
| 50 |
+
/-- induced row vector transform. -/
|
| 51 |
+
def rowShrink (p : Shape) {n} (A : Nendo p n) : Mat (Row p n) (Row p n) :=
|
| 52 |
+
iFix p n*(iFix p n)ᵀ +
|
| 53 |
+
∑ i : Sel p,∑ d : Block p.g,iCoeff p n i d*A d*(iCoeff p n i d)ᵀ
|
| 54 |
+
|
| 55 |
+
def readCoeff (p : Shape) {n} (s : Sel p) (d : Block p.g) (v : Ray p n) :=
|
| 56 |
+
fun i => v (s,some (d,i))
|
| 57 |
+
|
| 58 |
+
theorem readCoeff_val (s : Sel p) (d : Block p.g) (v : Ray p n) :
|
| 59 |
+
(iCoeff p n s d)ᵀ *ᵥ v=readCoeff p s d v := embedMatT _ _
|
| 60 |
+
|
| 61 |
+
theorem shrink_transpose (A : Nendo p n) :
|
| 62 |
+
(rowShrink p A)ᵀ=rowShrink p (fun i => (A i)ᵀ) := by
|
| 63 |
+
simp only [rowShrink,Matrix.transpose_add,Matrix.transpose_mul,
|
| 64 |
+
Matrix.transpose_sum,Matrix.transpose_transpose,Matrix.mul_assoc]
|
| 65 |
+
|
| 66 |
+
private theorem coeff_none (A : Nendo p n) (v : Ray p n) (s : Sel p) :
|
| 67 |
+
(rowShrink p A *ᵥ v) (s,none)=v (s,none) := by
|
| 68 |
+
classical
|
| 69 |
+
simp only [rowShrink,Matrix.add_mulVec, Matrix.sum_mulVec,←Matrix.mulVec_mulVec,readCoeff_val]
|
| 70 |
+
unfold iFix iCoeff
|
| 71 |
+
rw [embedMatT]
|
| 72 |
+
simp [embedMat,Matrix.mulVec,dotProduct,Finset.sum_apply,Matrix.mul_apply]
|
| 73 |
+
|
| 74 |
+
set_option maxHeartbeats 600000 in
|
| 75 |
+
private theorem coeff_some (A : Nendo p n) (v : Ray p n) (s : Sel p)
|
| 76 |
+
(d : Block p.g) (i : Fin n) :
|
| 77 |
+
(rowShrink p A *ᵥ v) (s,some (d,i))=(A d *ᵥ (readCoeff p s d v)) i := by
|
| 78 |
+
classical
|
| 79 |
+
simp only [rowShrink,Matrix.add_mulVec, Matrix.sum_mulVec,←Matrix.mulVec_mulVec,readCoeff_val]
|
| 80 |
+
simp only [Pi.add_apply,Finset.sum_apply]
|
| 81 |
+
have hz (x) : (iFix p n *ᵥ x) (s,some (d,i))=0 := by
|
| 82 |
+
simp [iFix,embedMat,Matrix.mulVec,dotProduct]
|
| 83 |
+
rw [hz,zero_add]
|
| 84 |
+
have hh (t : Sel p) (a : Block p.g) (x : Vec (Fin n)) :
|
| 85 |
+
(iCoeff p n t a *ᵥ x) (s,some (d,i)) =
|
| 86 |
+
if s=t then (if d=a then x i else 0) else 0 := by
|
| 87 |
+
by_cases e : s=t <;> by_cases g : d=a <;> simp [iCoeff,embedMat,Matrix.mulVec,dotProduct,e,g]
|
| 88 |
+
simp_rw [hh]
|
| 89 |
+
rw [Finset.sum_eq_single s]
|
| 90 |
+
· simp only [ite_true,Finset.sum_ite_eq,mem_univ]
|
| 91 |
+
· intro a _ ha; simp only [ite_eq_right (Ne.symm ha),Finset.sum_const_zero]
|
| 92 |
+
simp
|
| 93 |
+
|
| 94 |
+
private theorem coeff_fixes (A : Nendo p n) (v : Ray p n)
|
| 95 |
+
(h : ∀ d s, A d *ᵥ (readCoeff p s d v) = readCoeff p s d v) :
|
| 96 |
+
rowShrink p A *ᵥ v=v := by
|
| 97 |
+
funext i
|
| 98 |
+
rcases i with ⟨s, _|⟨d,i⟩⟩
|
| 99 |
+
· rw [coeff_none]
|
| 100 |
+
rw [coeff_some,h]
|
| 101 |
+
rfl
|
| 102 |
+
|
| 103 |
+
def nbBlock (p : Shape) := Fintype.card (Block p.g)
|
| 104 |
+
def ncComp (p : Shape) := Fintype.card (Comp p.g)
|
| 105 |
+
|
| 106 |
+
theorem shrink_rank (A : Nendo p n) (D : ℕ) (h : ∀ i,(A i).rank ≤ D) :
|
| 107 |
+
(rowShrink p A).rank≤ psize p+ psize p* (nbBlock p*D) := by
|
| 108 |
+
apply le_trans (mrk_add_le ..)
|
| 109 |
+
apply add_le_add
|
| 110 |
+
· exact (Matrix.rank_mul_le_left ..).trans (iFix p n).rank_le_card_width
|
| 111 |
+
refine (mrk_sum_le ..).trans ((Finset.sum_le_sum (g:=fun _ => nbBlock p*D) (fun i _ => ?_)).trans_eq
|
| 112 |
+
(by simp [psize,Sel]))
|
| 113 |
+
refine (mrk_sum_le ..).trans ((Finset.sum_le_sum (g:=fun _ => D) (fun i _ => ?_)).trans_eq
|
| 114 |
+
(by simp [nbBlock]))
|
| 115 |
+
exact ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_mul_le_right ..)).trans (h i)
|
| 116 |
+
|
| 117 |
+
def dbits (p : Shape) (T R : ℕ) := ncComp p*2* psize p*(T+R)
|
| 118 |
+
def drow (p : Shape) (T R : ℕ) := psize p+psize p*(nbBlock p*dbits p T R)
|
| 119 |
+
|
| 120 |
+
theorem shrink_both (S T : Place p → Space (Ray p n)) (K R : ℕ)
|
| 121 |
+
(hk : ∀ z,dim (S z) ≤K) (hr : ∀ z,dim (T z)≤R) :
|
| 122 |
+
∃ A : Nendo p n,
|
| 123 |
+
(∀ z,∀ x∈S z,rowShrink p A *ᵥ x=x) ∧
|
| 124 |
+
(∀ z,∀ x∈T z,(rowShrink p A)ᵀ *ᵥ x=x) ∧
|
| 125 |
+
(rowShrink p A).rank ≤ drow p K R := by
|
| 126 |
+
classical
|
| 127 |
+
let W := Place p×Sel p
|
| 128 |
+
have hp : Fintype.card (Place p×Sel p)=ncComp p*2*psize p := by
|
| 129 |
+
simp only [Place,Fintype.card_prod,ncComp,Fintype.card_bool,psize,Sel]
|
| 130 |
+
let G d (S : Place p → Space (Ray p n)) (z : Place p×Sel p) :=
|
| 131 |
+
(S z.1).map (iCoeff p n z.2 d)ᵀ.mulVecLin
|
| 132 |
+
obtain ⟨A,hA,hT,hL⟩ :
|
| 133 |
+
∃ A : Nendo p n,
|
| 134 |
+
(∀ d z,∀ x∈G d S z,A d *ᵥ x=x) ∧
|
| 135 |
+
(∀ d z,∀ x∈G d T z,(A d)ᵀ *ᵥ x=x) ∧ ∀ i,(A i).rank≤dbits p K R := by
|
| 136 |
+
have he (d : Block p.g) :
|
| 137 |
+
∃ A : Mat (Fin n) (Fin n), (∀ z,∀ x∈G d S z,A *ᵥ x=x) ∧
|
| 138 |
+
(∀ z,∀ x∈G d T z,Aᵀ *ᵥ x=x) ∧ A.rank≤dbits p K R := by
|
| 139 |
+
obtain ⟨X,hX,hD⟩ := exists_cover (G d S) K (fun j => (Submodule.finrank_map_le ..).trans
|
| 140 |
+
(hk j.1))
|
| 141 |
+
obtain ⟨Y,hY,hD'⟩ := exists_cover (G d T) R (fun j => (Submodule.finrank_map_le ..).trans
|
| 142 |
+
(hr j.1))
|
| 143 |
+
obtain ⟨A,hA,hZ,hL⟩ := compact_endo X Y
|
| 144 |
+
refine ⟨A,(fun z x hx => hA x (hX z hx)),(fun z x hx => hZ x (hY z hx)),?_⟩
|
| 145 |
+
rw [hp] at hD hD'
|
| 146 |
+
exact hL.trans ((add_le_add hD hD').trans_eq (Nat.mul_add ..).symm)
|
| 147 |
+
choose A hA hZ hL using he
|
| 148 |
+
exact ⟨A,hA,hZ,hL⟩
|
| 149 |
+
have he (X : Place p → Space (Ray p n)) (z)
|
| 150 |
+
(x : Ray p n) (hx : x∈X z) (d s) : readCoeff p s d x∈ G d X (z,s) :=
|
| 151 |
+
⟨x,hx,readCoeff_val ..⟩
|
| 152 |
+
refine ⟨A,fun z x hx => ?_,fun z x hx => ?_,shrink_rank A _ hL⟩
|
| 153 |
+
· exact coeff_fixes A x (fun d s => hA _ (z,s) _ (he S z x hx d s))
|
| 154 |
+
rw [shrink_transpose]
|
| 155 |
+
exact coeff_fixes _ _ (fun d s => hT _ (z,s) _ (he T z x hx d s))
|
| 156 |
+
|
| 157 |
+
private def shrinkBase (A : Nendo p n) (v : Base p.g n) : Base p.g n :=
|
| 158 |
+
fun x => (A x.1 *ᵥ (fun j => v (x.1,j))) x.2
|
| 159 |
+
|
| 160 |
+
private theorem shrink_point (A : Nendo p n) (s : Label p.b) (z : Base p.g n) :
|
| 161 |
+
rowShrink p A *ᵥ point p s z=point p s (shrinkBase (p:=p) A z) := by
|
| 162 |
+
classical
|
| 163 |
+
funext i
|
| 164 |
+
rcases i with ⟨r,_|⟨d,i⟩⟩
|
| 165 |
+
· rw [coeff_none]; rfl
|
| 166 |
+
rw [coeff_some]
|
| 167 |
+
simp only [point_eval,readCoeff,shrinkBase,Matrix.mulVec,dotProduct,
|
| 168 |
+
baseV,Option.elim',Finset.mul_sum]
|
| 169 |
+
exact Finset.sum_congr rfl fun i _ => mul_left_comm ..
|
| 170 |
+
|
| 171 |
+
private theorem shrink_tag (A : Nendo p n) (l : Tag p.g) (M : Moment p n) (h : M∈Wtag p n l) :
|
| 172 |
+
liftM (rowShrink p A) (rowShrink p A) M∈Wtag p n l := by
|
| 173 |
+
classical
|
| 174 |
+
unfold Wtag at h
|
| 175 |
+
induction h using Submodule.span_induction with
|
| 176 |
+
| mem m hm =>
|
| 177 |
+
obtain ⟨s,z,hz,rfl⟩ := hm
|
| 178 |
+
simp only [mom,liftM_outer,shrink_point]
|
| 179 |
+
apply Submodule.subset_span
|
| 180 |
+
refine ⟨s,shrinkBase (p:=p) A z,?_,rfl⟩
|
| 181 |
+
intro d t hd i
|
| 182 |
+
change (A (Block.O d t) *ᵥ _) i = _
|
| 183 |
+
simp only [Matrix.mulVec,dotProduct,hz _ _ hd,mul_zero,Finset.sum_const_zero]
|
| 184 |
+
| zero => rw [map_zero]; exact Submodule.zero_mem _
|
| 185 |
+
| add x y hx hy ih ih' => rw [map_add]; exact Submodule.add_mem _ ih ih'
|
| 186 |
+
| smul a x hx ih => rw [map_smul]; exact Submodule.smul_mem _ _ ih
|
| 187 |
+
|
| 188 |
+
theorem shrink_X (A : Nendo p n) (M : Profile p n) (h : M∈Xspace p n) :
|
| 189 |
+
(fun e : Comp p.g => liftM (rowShrink p A) (rowShrink p A) (M e))∈Xspace p n := by
|
| 190 |
+
obtain ⟨w,hw,rfl⟩ := mem_X.mp h
|
| 191 |
+
refine mem_X.mpr ⟨_,(fun l => shrink_tag A l _ (hw l)),?_⟩
|
| 192 |
+
funext i
|
| 193 |
+
exact (map_add (liftM (rowShrink p A) (rowShrink p A)) _ _).symm
|
| 194 |
+
|
| 195 |
+
end HadwigerCounterexample
|
| 196 |
+
|
| 197 |
+
end
|
| 198 |
+
|
| 199 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProbePointMasses.lean
CHANGED
|
@@ -1,208 +1,208 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.OffsetEnergy
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Probe Point Masses -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix Module Submodule LinearMap Finset Function
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {q t : Place p→ℕ}
|
| 12 |
-
|
| 13 |
-
def initCap (p : Shape) {n} (N : ℕ) (m : Mixer p n) (ε : ℝ) :=
|
| 14 |
-
∀ a : Pin p n N,pr (pairW (raw m N) (raw m N)) a.agree ≤ fee N ε (planRank a.sp)
|
| 15 |
-
|
| 16 |
-
def bySide (p : Shape) {n N} (w : Wgt (UnitType p n N))
|
| 17 |
-
(m : Mixer p n) (c : ℝ) :=
|
| 18 |
-
∀ i x, mapW w (fun y => onSide y i) x ≤ c*raw m N x
|
| 19 |
-
|
| 20 |
-
theorem side_same {A : Type} [Fintype A] (i : Bool) (w : Wgt A) (hw : IsLaw w)
|
| 21 |
-
(v : Wgt (A × A)) {H : ℝ}
|
| 22 |
-
(h : ∀ x,mapW v (fun x => onSide x i) x≤H * w x)
|
| 23 |
-
(P : A×A→Prop) (he : ∀ x y,onSide x i=onSide y i → (P x↔P y)) :
|
| 24 |
-
pr v P ≤ H * pr (pairW w w) P := by
|
| 25 |
-
classical
|
| 26 |
-
let Q := fun x => P (x,x)
|
| 27 |
-
have hq : P=fun x => Q (onSide x i) := by
|
| 28 |
-
funext x; exact propext (he x _ (by cases i <;> rfl))
|
| 29 |
-
rw [hq,←mapW_pr v (fun x => onSide x i) Q]
|
| 30 |
-
refine (pr_cap h Q).trans_eq ?_
|
| 31 |
-
have hh : pr (pairW w w) (fun x => Q (onSide x i)) = pr w Q := by
|
| 32 |
-
cases i
|
| 33 |
-
· change pr (pairW w w) (fun x => Q x.2)=pr w Q
|
| 34 |
-
simpa only [true_and, pr_true,hw.total,one_mul] using pairW_pr w w (fun _ => True) Q
|
| 35 |
-
change pr (pairW w w) (fun x => Q x.1)=pr w Q
|
| 36 |
-
simpa only [and_true,pr_true,hw.total,mul_one] using pairW_pr w w Q (fun _ => True)
|
| 37 |
-
rw [hh]
|
| 38 |
-
|
| 39 |
-
def basisFrom (p : Shape) {n N} (x : UnitType p n N) (i : Bool)
|
| 40 |
-
{q : Place p→ℕ} (Z : DTuple (p:=p) q N) :=
|
| 41 |
-
∀ z,Injective (Z z).mulVec ∧ colSp (Z z) ≤ imageP p x i (flipZ p z)
|
| 42 |
-
|
| 43 |
-
def ctot (p : Shape) (r : Place p→ℕ) := ∑ i,r i
|
| 44 |
-
abbrev Among (p : Shape) (n : ℕ) (q : Place p→ℕ) :=
|
| 45 |
-
∀ z, Mat (Row p n) (Fin (q z))
|
| 46 |
-
def csignal (p : Shape) {n} (i : Bool) {q : Place p → ℕ}
|
| 47 |
-
(S : Among p n q) : WTuple (p:=p) q n :=
|
| 48 |
-
fun z => IP p n i * S z
|
| 49 |
-
|
| 50 |
-
def poke (p : Shape) {n N} {q t : Place p → ℕ}
|
| 51 |
-
(B : WTuple (p:=p) q n) (C : WTuple (p:=p) t n)
|
| 52 |
-
(Z : DTuple (p:=p) q N) (A : DTuple (p:=p) t N)
|
| 53 |
-
(x : UnitType p n N) :=
|
| 54 |
-
∀ z, images x (flipZ p z) * B z=Z z ∧ images x z * C z = A z
|
| 55 |
-
|
| 56 |
-
set_option maxHeartbeats 600000 in
|
| 57 |
-
theorem poke_cap (B : WTuple (p:=p) q n) (C : WTuple (p:=p) t n)
|
| 58 |
-
(Z : DTuple (p:=p) q N) (A : DTuple (p:=p) t N)
|
| 59 |
-
(m : Mixer p n) {ε : ℝ} (he : initCap p N m ε)
|
| 60 |
-
(hB : ∀ z, Injective (B z).mulVec)
|
| 61 |
-
(hC : ∀ z, Injective (C z).mulVec)
|
| 62 |
-
(hD : ∀ z, Disjoint (colSp (B z)) (colSp (C (flipZ p z)))) :
|
| 63 |
-
pr (pairW (raw m N) (raw m N)) (poke p B C Z A) ≤
|
| 64 |
-
fee N ε (ctot p q+ctot p t) := by
|
| 65 |
-
classical
|
| 66 |
-
let μ := raw m N
|
| 67 |
-
let w := pairW μ μ
|
| 68 |
-
have hw (x) : 0 ≤ w x := mul_nonneg (raw_nonneg m _) (raw_nonneg m _)
|
| 69 |
-
by_cases h : 0 < pr w (poke p B C Z A)
|
| 70 |
-
· obtain ⟨x,hx,_⟩ := exists_of_pr_pos hw h
|
| 71 |
-
let U : Plan p n := fun z => colSp (B (flipZ p z)) ⊔ colSp (C z)
|
| 72 |
-
let V := Pin.make U x
|
| 73 |
-
refine (pr_mono hw (q:=V.agree) fun y hy => ?_).trans ((he V).trans ?_)
|
| 74 |
-
· intro z v hv
|
| 75 |
-
change images y z *ᵥ v=images x z *ᵥ v
|
| 76 |
-
obtain ⟨l,⟨t,rfl⟩,r,⟨u,rfl⟩,rfl⟩ := Submodule.mem_sup.mp
|
| 77 |
-
(show v∈colSp (B (flipZ p z))⊔colSp (C z) from hv)
|
| 78 |
-
have h1 := (hx (flipZ p z)).1.trans (hy (flipZ p z)).1.symm
|
| 79 |
-
simp only [flipZ_flip] at h1
|
| 80 |
-
simp only [mulVecLin_apply, Matrix.mulVec_add, Matrix.mulVec_mulVec,h1,
|
| 81 |
-
(hx z).2,(hy z).2]
|
| 82 |
-
· have hF (z) : dim (U z)=q (flipZ p z)+t z := by
|
| 83 |
-
have hi := Submodule.finrank_sup_add_finrank_inf_eq (colSp (B (flipZ p z))) (colSp (C z))
|
| 84 |
-
have hy := hD (flipZ p z)
|
| 85 |
-
rw [flipZ_flip] at hy
|
| 86 |
-
rw [hy.eq_bot,finrank_bot,add_zero] at hi
|
| 87 |
-
exact hi.trans (congrArg₂ (·+·) ((mrk_inj.mp (hB (flipZ p z))).trans (Fintype.card_fin _))
|
| 88 |
-
((mrk_inj.mp (hC z)).trans (Fintype.card_fin _)))
|
| 89 |
-
have ht : planRank V.sp=ctot p q+ctot p t := by
|
| 90 |
-
unfold planRank ctot
|
| 91 |
-
change ∑ z,dim (U z)= _
|
| 92 |
-
simp_rw [hF,Finset.sum_add_distrib]
|
| 93 |
-
exact congrArg (fun x => x + ∑ z,t z) (Equiv.sum_comp (flipEquiv p) q)
|
| 94 |
-
rw [ht]
|
| 95 |
-
exact (not_lt.mp h).trans (bp_pos _).le
|
| 96 |
-
|
| 97 |
-
def heatRate (p : Shape) (n N : ℕ) (ε : ℝ) (x y : ℕ) :=
|
| 98 |
-
bp (num (Row p n)* x+ 2*p.h*y)*fee N ε (x+y)
|
| 99 |
-
|
| 100 |
-
instance amongFintype (p : Shape) (n : ℕ) (r : Place p→ℕ) : Fintype (Among p n r) := by
|
| 101 |
-
classical exact inferInstanceAs (Fintype (Among p n r))
|
| 102 |
-
|
| 103 |
-
private theorem format_size :
|
| 104 |
-
num (Among p n q × (Bool → DTuple (p:=p) t p.h)) =
|
| 105 |
-
bp (num (Row p n)*ctot p q+2*p.h*ctot p t) := by
|
| 106 |
-
classical
|
| 107 |
-
unfold num
|
| 108 |
-
rw [card_space,dim,Module.finrank_prod, Nat.cast_add]
|
| 109 |
-
have he : finrank F (Among p n q)=Fintype.card (Row p n)*ctot p q := by
|
| 110 |
-
unfold Among
|
| 111 |
-
rw [finrank_pi_fintype]
|
| 112 |
-
unfold ctot; rw [Finset.mul_sum]
|
| 113 |
-
refine Finset.sum_congr rfl fun i _ => (dim_mat ..).trans (by rw [Fintype.card_fin])
|
| 114 |
-
have hf :
|
| 115 |
-
finrank F (Bool → DTuple (p:=p) t p.h)=2*p.h*ctot p t := by
|
| 116 |
-
rw [finrank_pi_fintype,Fintype.sum_bool]
|
| 117 |
-
change dim (DTuple ..)+dim (DTuple ..)=_
|
| 118 |
-
rw [tuple_dim]
|
| 119 |
-
unfold ctot; ring
|
| 120 |
-
rw [he,hf]
|
| 121 |
-
push_cast; rfl
|
| 122 |
-
|
| 123 |
-
set_option maxHeartbeats 800000 in
|
| 124 |
-
theorem heat_rate (i : Bool) (S : Party) (hi : S i=1)
|
| 125 |
-
(A : DTuple (p:=p) t N)
|
| 126 |
-
(B : DTuple (p:=p) t N) (Z : DTuple (p:=p) q N)
|
| 127 |
-
(m : Mixer p n) {ε : ℝ} (he : initCap p N m ε) :
|
| 128 |
-
pr (pairW (raw m N) (raw m N)) (fun x =>
|
| 129 |
-
basisFrom p x i Z ∧ glimpse p x i A ∧ thermal p x S A=B)
|
| 130 |
-
≤ heatRate p n N ε (ctot p q) (ctot p t) := by
|
| 131 |
-
classical
|
| 132 |
-
let M := Among p n q × (Bool → DTuple (p:=p) t p.h)
|
| 133 |
-
let P (v : M) (x : UnitType p n N) :=
|
| 134 |
-
let X := csignal p i v.1
|
| 135 |
-
let Y := hfused p n _ v.2
|
| 136 |
-
(∀ z, Injective (X z).mulVec ∧ Injective (Y z).mulVec) ∧ poke p X Y Z B x
|
| 137 |
-
let w := pairW (raw m N) (raw m N)
|
| 138 |
-
have hw x : 0 ≤ w x := mul_nonneg (raw_nonneg m _) (raw_nonneg m _)
|
| 139 |
-
have h : ∀ x : UnitType p n N,basisFrom p x i Z ∧ glimpse p x i A ∧ thermal p x S A=B →
|
| 140 |
-
∃ v, P v x := by
|
| 141 |
-
rintro x ⟨hF,hT,hU⟩
|
| 142 |
-
choose A' hA using fun z => pull_cols (fpAt p (onSide x i) (flipZ p z)) (Z z) (hF z).2
|
| 143 |
-
let C := sparks p x S A
|
| 144 |
-
let Y := hfused p n _ C
|
| 145 |
-
let X := csignal p i A'
|
| 146 |
-
have hh z : images x (flipZ p z)*X z=Z z := by
|
| 147 |
-
unfold X csignal
|
| 148 |
-
rw [← Matrix.mul_assoc, images_ip]
|
| 149 |
-
exact hA z
|
| 150 |
-
refine ⟨(A',C),fun z => ⟨?_,hotfused x S A i hi hT z⟩, fun z => ?_⟩
|
| 151 |
-
· have hg := (hF z).1
|
| 152 |
-
rw [← hh z] at hg
|
| 153 |
-
intro p' q he
|
| 154 |
-
apply hg
|
| 155 |
-
change X z *ᵥ p' = X z*ᵥ q at he
|
| 156 |
-
rw [← Matrix.mulVec_mulVec,← Matrix.mulVec_mulVec,he]
|
| 157 |
-
exact ⟨hh z,(fuse_val x S A z).trans (congr_fun hU z)⟩
|
| 158 |
-
have hg (v : M) :
|
| 159 |
-
pr w (P v) ≤ fee N ε (ctot p q+ctot p t) := by
|
| 160 |
-
let X := csignal p i v.1
|
| 161 |
-
let Y := hfused p n _ v.2
|
| 162 |
-
by_cases hh : ∀ z, Injective (X z).mulVec ∧ Injective (Y z).mulVec
|
| 163 |
-
· refine (pr_mono hw (p:=P v) (q:=poke p X Y Z B) fun x h => h.2).trans
|
| 164 |
-
(poke_cap X Y _ _ m he (fun z => (hh z).1) (fun z => (hh z).2) ?_)
|
| 165 |
-
intro z
|
| 166 |
-
exact (channels_disjoint (p:=p) (n:=n)).mono
|
| 167 |
-
((col_follow ..).trans (ip_le_primal i)) (fused_support v.2 _)
|
| 168 |
-
have heq : P v=(fun _ => False) := funext fun x => propext (iff_false_intro (fun h => hh h.1))
|
| 169 |
-
rw [heq,pr_false]; exact (bp_pos _).le
|
| 170 |
-
refine ((pr_mono hw h).trans (pr_exists_le hw P)).trans ?_
|
| 171 |
-
refine (Finset.sum_le_sum fun i _ => hg i).trans_eq ?_
|
| 172 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
|
| 173 |
-
change num (Among p n q × _) *_= _
|
| 174 |
-
rw [format_size]; rfl
|
| 175 |
-
|
| 176 |
-
theorem heat_one (i : Bool)
|
| 177 |
-
(A : DTuple (p:=p) t N) (B : DTuple (p:=p) t N)
|
| 178 |
-
(Z : DTuple (p:=p) q N)
|
| 179 |
-
{w : Wgt (UnitType p n N)} {H : ℝ} (hH : 0 ≤ H)
|
| 180 |
-
(m : Mixer p n) {ε : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 181 |
-
(hw : bySide p w m H) :
|
| 182 |
-
pr w (fun x => basisFrom p x i Z ∧ glimpse p x i A ∧ thermal p x (unary i) A=B) ≤
|
| 183 |
-
H*heatRate p n N ε (ctot p q) (ctot p t) := by
|
| 184 |
-
refine (side_same i _ hm w (hw i) _ ?_).trans
|
| 185 |
-
(mul_le_mul_of_nonneg_left (heat_rate i (unary i) (by simp [unary]) A B Z m he) hH)
|
| 186 |
-
intro x y h
|
| 187 |
-
unfold basisFrom glimpse thermal imageP
|
| 188 |
-
simp_rw [heat_unary,h]
|
| 189 |
-
|
| 190 |
-
theorem heat_none (i : Bool) (Z : DTuple (p:=p) q N)
|
| 191 |
-
{w : Wgt (UnitType p n N)} {H : ℝ} (hH : 0 ≤ H)
|
| 192 |
-
(m : Mixer p n) {ε : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 193 |
-
(hw : bySide p w m H) :
|
| 194 |
-
pr w (fun x => basisFrom p x i Z) ≤ H*heatRate p n N ε (ctot p q) 0 := by
|
| 195 |
-
classical
|
| 196 |
-
let t : Place p→ℕ := fun _ => 0
|
| 197 |
-
let B : DTuple (p:=p) t N := 0
|
| 198 |
-
have hh := heat_one i B B Z hH m hm he hw
|
| 199 |
-
have h1 (x : UnitType p n N) : glimpse p x i B := fun z v v' h => Subsingleton.elim v v'
|
| 200 |
-
have h2 (x : UnitType p n N) : thermal p x (unary i) B=B := Subsingleton.elim _ _
|
| 201 |
-
simp_rw [h1,h2,and_true] at hh
|
| 202 |
-
simpa only [ctot,t,Finset.sum_const_zero] using hh
|
| 203 |
-
|
| 204 |
-
end HadwigerCounterexample
|
| 205 |
-
|
| 206 |
-
end
|
| 207 |
-
|
| 208 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.OffsetEnergy
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Probe Point Masses -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix Module Submodule LinearMap Finset Function
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {q t : Place p→ℕ}
|
| 12 |
+
|
| 13 |
+
def initCap (p : Shape) {n} (N : ℕ) (m : Mixer p n) (ε : ℝ) :=
|
| 14 |
+
∀ a : Pin p n N,pr (pairW (raw m N) (raw m N)) a.agree ≤ fee N ε (planRank a.sp)
|
| 15 |
+
|
| 16 |
+
def bySide (p : Shape) {n N} (w : Wgt (UnitType p n N))
|
| 17 |
+
(m : Mixer p n) (c : ℝ) :=
|
| 18 |
+
∀ i x, mapW w (fun y => onSide y i) x ≤ c*raw m N x
|
| 19 |
+
|
| 20 |
+
theorem side_same {A : Type} [Fintype A] (i : Bool) (w : Wgt A) (hw : IsLaw w)
|
| 21 |
+
(v : Wgt (A × A)) {H : ℝ}
|
| 22 |
+
(h : ∀ x,mapW v (fun x => onSide x i) x≤H * w x)
|
| 23 |
+
(P : A×A→Prop) (he : ∀ x y,onSide x i=onSide y i → (P x↔P y)) :
|
| 24 |
+
pr v P ≤ H * pr (pairW w w) P := by
|
| 25 |
+
classical
|
| 26 |
+
let Q := fun x => P (x,x)
|
| 27 |
+
have hq : P=fun x => Q (onSide x i) := by
|
| 28 |
+
funext x; exact propext (he x _ (by cases i <;> rfl))
|
| 29 |
+
rw [hq,←mapW_pr v (fun x => onSide x i) Q]
|
| 30 |
+
refine (pr_cap h Q).trans_eq ?_
|
| 31 |
+
have hh : pr (pairW w w) (fun x => Q (onSide x i)) = pr w Q := by
|
| 32 |
+
cases i
|
| 33 |
+
· change pr (pairW w w) (fun x => Q x.2)=pr w Q
|
| 34 |
+
simpa only [true_and, pr_true,hw.total,one_mul] using pairW_pr w w (fun _ => True) Q
|
| 35 |
+
change pr (pairW w w) (fun x => Q x.1)=pr w Q
|
| 36 |
+
simpa only [and_true,pr_true,hw.total,mul_one] using pairW_pr w w Q (fun _ => True)
|
| 37 |
+
rw [hh]
|
| 38 |
+
|
| 39 |
+
def basisFrom (p : Shape) {n N} (x : UnitType p n N) (i : Bool)
|
| 40 |
+
{q : Place p→ℕ} (Z : DTuple (p:=p) q N) :=
|
| 41 |
+
∀ z,Injective (Z z).mulVec ∧ colSp (Z z) ≤ imageP p x i (flipZ p z)
|
| 42 |
+
|
| 43 |
+
def ctot (p : Shape) (r : Place p→ℕ) := ∑ i,r i
|
| 44 |
+
abbrev Among (p : Shape) (n : ℕ) (q : Place p→ℕ) :=
|
| 45 |
+
∀ z, Mat (Row p n) (Fin (q z))
|
| 46 |
+
def csignal (p : Shape) {n} (i : Bool) {q : Place p → ℕ}
|
| 47 |
+
(S : Among p n q) : WTuple (p:=p) q n :=
|
| 48 |
+
fun z => IP p n i * S z
|
| 49 |
+
|
| 50 |
+
def poke (p : Shape) {n N} {q t : Place p → ℕ}
|
| 51 |
+
(B : WTuple (p:=p) q n) (C : WTuple (p:=p) t n)
|
| 52 |
+
(Z : DTuple (p:=p) q N) (A : DTuple (p:=p) t N)
|
| 53 |
+
(x : UnitType p n N) :=
|
| 54 |
+
∀ z, images x (flipZ p z) * B z=Z z ∧ images x z * C z = A z
|
| 55 |
+
|
| 56 |
+
set_option maxHeartbeats 600000 in
|
| 57 |
+
theorem poke_cap (B : WTuple (p:=p) q n) (C : WTuple (p:=p) t n)
|
| 58 |
+
(Z : DTuple (p:=p) q N) (A : DTuple (p:=p) t N)
|
| 59 |
+
(m : Mixer p n) {ε : ℝ} (he : initCap p N m ε)
|
| 60 |
+
(hB : ∀ z, Injective (B z).mulVec)
|
| 61 |
+
(hC : ∀ z, Injective (C z).mulVec)
|
| 62 |
+
(hD : ∀ z, Disjoint (colSp (B z)) (colSp (C (flipZ p z)))) :
|
| 63 |
+
pr (pairW (raw m N) (raw m N)) (poke p B C Z A) ≤
|
| 64 |
+
fee N ε (ctot p q+ctot p t) := by
|
| 65 |
+
classical
|
| 66 |
+
let μ := raw m N
|
| 67 |
+
let w := pairW μ μ
|
| 68 |
+
have hw (x) : 0 ≤ w x := mul_nonneg (raw_nonneg m _) (raw_nonneg m _)
|
| 69 |
+
by_cases h : 0 < pr w (poke p B C Z A)
|
| 70 |
+
· obtain ⟨x,hx,_⟩ := exists_of_pr_pos hw h
|
| 71 |
+
let U : Plan p n := fun z => colSp (B (flipZ p z)) ⊔ colSp (C z)
|
| 72 |
+
let V := Pin.make U x
|
| 73 |
+
refine (pr_mono hw (q:=V.agree) fun y hy => ?_).trans ((he V).trans ?_)
|
| 74 |
+
· intro z v hv
|
| 75 |
+
change images y z *ᵥ v=images x z *ᵥ v
|
| 76 |
+
obtain ⟨l,⟨t,rfl⟩,r,⟨u,rfl⟩,rfl⟩ := Submodule.mem_sup.mp
|
| 77 |
+
(show v∈colSp (B (flipZ p z))⊔colSp (C z) from hv)
|
| 78 |
+
have h1 := (hx (flipZ p z)).1.trans (hy (flipZ p z)).1.symm
|
| 79 |
+
simp only [flipZ_flip] at h1
|
| 80 |
+
simp only [mulVecLin_apply, Matrix.mulVec_add, Matrix.mulVec_mulVec,h1,
|
| 81 |
+
(hx z).2,(hy z).2]
|
| 82 |
+
· have hF (z) : dim (U z)=q (flipZ p z)+t z := by
|
| 83 |
+
have hi := Submodule.finrank_sup_add_finrank_inf_eq (colSp (B (flipZ p z))) (colSp (C z))
|
| 84 |
+
have hy := hD (flipZ p z)
|
| 85 |
+
rw [flipZ_flip] at hy
|
| 86 |
+
rw [hy.eq_bot,finrank_bot,add_zero] at hi
|
| 87 |
+
exact hi.trans (congrArg₂ (·+·) ((mrk_inj.mp (hB (flipZ p z))).trans (Fintype.card_fin _))
|
| 88 |
+
((mrk_inj.mp (hC z)).trans (Fintype.card_fin _)))
|
| 89 |
+
have ht : planRank V.sp=ctot p q+ctot p t := by
|
| 90 |
+
unfold planRank ctot
|
| 91 |
+
change ∑ z,dim (U z)= _
|
| 92 |
+
simp_rw [hF,Finset.sum_add_distrib]
|
| 93 |
+
exact congrArg (fun x => x + ∑ z,t z) (Equiv.sum_comp (flipEquiv p) q)
|
| 94 |
+
rw [ht]
|
| 95 |
+
exact (not_lt.mp h).trans (bp_pos _).le
|
| 96 |
+
|
| 97 |
+
def heatRate (p : Shape) (n N : ℕ) (ε : ℝ) (x y : ℕ) :=
|
| 98 |
+
bp (num (Row p n)* x+ 2*p.h*y)*fee N ε (x+y)
|
| 99 |
+
|
| 100 |
+
instance amongFintype (p : Shape) (n : ℕ) (r : Place p→ℕ) : Fintype (Among p n r) := by
|
| 101 |
+
classical exact inferInstanceAs (Fintype (Among p n r))
|
| 102 |
+
|
| 103 |
+
private theorem format_size :
|
| 104 |
+
num (Among p n q × (Bool → DTuple (p:=p) t p.h)) =
|
| 105 |
+
bp (num (Row p n)*ctot p q+2*p.h*ctot p t) := by
|
| 106 |
+
classical
|
| 107 |
+
unfold num
|
| 108 |
+
rw [card_space,dim,Module.finrank_prod, Nat.cast_add]
|
| 109 |
+
have he : finrank F (Among p n q)=Fintype.card (Row p n)*ctot p q := by
|
| 110 |
+
unfold Among
|
| 111 |
+
rw [finrank_pi_fintype]
|
| 112 |
+
unfold ctot; rw [Finset.mul_sum]
|
| 113 |
+
refine Finset.sum_congr rfl fun i _ => (dim_mat ..).trans (by rw [Fintype.card_fin])
|
| 114 |
+
have hf :
|
| 115 |
+
finrank F (Bool → DTuple (p:=p) t p.h)=2*p.h*ctot p t := by
|
| 116 |
+
rw [finrank_pi_fintype,Fintype.sum_bool]
|
| 117 |
+
change dim (DTuple ..)+dim (DTuple ..)=_
|
| 118 |
+
rw [tuple_dim]
|
| 119 |
+
unfold ctot; ring
|
| 120 |
+
rw [he,hf]
|
| 121 |
+
push_cast; rfl
|
| 122 |
+
|
| 123 |
+
set_option maxHeartbeats 800000 in
|
| 124 |
+
theorem heat_rate (i : Bool) (S : Party) (hi : S i=1)
|
| 125 |
+
(A : DTuple (p:=p) t N)
|
| 126 |
+
(B : DTuple (p:=p) t N) (Z : DTuple (p:=p) q N)
|
| 127 |
+
(m : Mixer p n) {ε : ℝ} (he : initCap p N m ε) :
|
| 128 |
+
pr (pairW (raw m N) (raw m N)) (fun x =>
|
| 129 |
+
basisFrom p x i Z ∧ glimpse p x i A ∧ thermal p x S A=B)
|
| 130 |
+
≤ heatRate p n N ε (ctot p q) (ctot p t) := by
|
| 131 |
+
classical
|
| 132 |
+
let M := Among p n q × (Bool → DTuple (p:=p) t p.h)
|
| 133 |
+
let P (v : M) (x : UnitType p n N) :=
|
| 134 |
+
let X := csignal p i v.1
|
| 135 |
+
let Y := hfused p n _ v.2
|
| 136 |
+
(∀ z, Injective (X z).mulVec ∧ Injective (Y z).mulVec) ∧ poke p X Y Z B x
|
| 137 |
+
let w := pairW (raw m N) (raw m N)
|
| 138 |
+
have hw x : 0 ≤ w x := mul_nonneg (raw_nonneg m _) (raw_nonneg m _)
|
| 139 |
+
have h : ∀ x : UnitType p n N,basisFrom p x i Z ∧ glimpse p x i A ∧ thermal p x S A=B →
|
| 140 |
+
∃ v, P v x := by
|
| 141 |
+
rintro x ⟨hF,hT,hU⟩
|
| 142 |
+
choose A' hA using fun z => pull_cols (fpAt p (onSide x i) (flipZ p z)) (Z z) (hF z).2
|
| 143 |
+
let C := sparks p x S A
|
| 144 |
+
let Y := hfused p n _ C
|
| 145 |
+
let X := csignal p i A'
|
| 146 |
+
have hh z : images x (flipZ p z)*X z=Z z := by
|
| 147 |
+
unfold X csignal
|
| 148 |
+
rw [← Matrix.mul_assoc, images_ip]
|
| 149 |
+
exact hA z
|
| 150 |
+
refine ⟨(A',C),fun z => ⟨?_,hotfused x S A i hi hT z⟩, fun z => ?_⟩
|
| 151 |
+
· have hg := (hF z).1
|
| 152 |
+
rw [← hh z] at hg
|
| 153 |
+
intro p' q he
|
| 154 |
+
apply hg
|
| 155 |
+
change X z *ᵥ p' = X z*ᵥ q at he
|
| 156 |
+
rw [← Matrix.mulVec_mulVec,← Matrix.mulVec_mulVec,he]
|
| 157 |
+
exact ⟨hh z,(fuse_val x S A z).trans (congr_fun hU z)⟩
|
| 158 |
+
have hg (v : M) :
|
| 159 |
+
pr w (P v) ≤ fee N ε (ctot p q+ctot p t) := by
|
| 160 |
+
let X := csignal p i v.1
|
| 161 |
+
let Y := hfused p n _ v.2
|
| 162 |
+
by_cases hh : ∀ z, Injective (X z).mulVec ∧ Injective (Y z).mulVec
|
| 163 |
+
· refine (pr_mono hw (p:=P v) (q:=poke p X Y Z B) fun x h => h.2).trans
|
| 164 |
+
(poke_cap X Y _ _ m he (fun z => (hh z).1) (fun z => (hh z).2) ?_)
|
| 165 |
+
intro z
|
| 166 |
+
exact (channels_disjoint (p:=p) (n:=n)).mono
|
| 167 |
+
((col_follow ..).trans (ip_le_primal i)) (fused_support v.2 _)
|
| 168 |
+
have heq : P v=(fun _ => False) := funext fun x => propext (iff_false_intro (fun h => hh h.1))
|
| 169 |
+
rw [heq,pr_false]; exact (bp_pos _).le
|
| 170 |
+
refine ((pr_mono hw h).trans (pr_exists_le hw P)).trans ?_
|
| 171 |
+
refine (Finset.sum_le_sum fun i _ => hg i).trans_eq ?_
|
| 172 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul]
|
| 173 |
+
change num (Among p n q × _) *_= _
|
| 174 |
+
rw [format_size]; rfl
|
| 175 |
+
|
| 176 |
+
theorem heat_one (i : Bool)
|
| 177 |
+
(A : DTuple (p:=p) t N) (B : DTuple (p:=p) t N)
|
| 178 |
+
(Z : DTuple (p:=p) q N)
|
| 179 |
+
{w : Wgt (UnitType p n N)} {H : ℝ} (hH : 0 ≤ H)
|
| 180 |
+
(m : Mixer p n) {ε : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 181 |
+
(hw : bySide p w m H) :
|
| 182 |
+
pr w (fun x => basisFrom p x i Z ∧ glimpse p x i A ∧ thermal p x (unary i) A=B) ≤
|
| 183 |
+
H*heatRate p n N ε (ctot p q) (ctot p t) := by
|
| 184 |
+
refine (side_same i _ hm w (hw i) _ ?_).trans
|
| 185 |
+
(mul_le_mul_of_nonneg_left (heat_rate i (unary i) (by simp [unary]) A B Z m he) hH)
|
| 186 |
+
intro x y h
|
| 187 |
+
unfold basisFrom glimpse thermal imageP
|
| 188 |
+
simp_rw [heat_unary,h]
|
| 189 |
+
|
| 190 |
+
theorem heat_none (i : Bool) (Z : DTuple (p:=p) q N)
|
| 191 |
+
{w : Wgt (UnitType p n N)} {H : ℝ} (hH : 0 ≤ H)
|
| 192 |
+
(m : Mixer p n) {ε : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 193 |
+
(hw : bySide p w m H) :
|
| 194 |
+
pr w (fun x => basisFrom p x i Z) ≤ H*heatRate p n N ε (ctot p q) 0 := by
|
| 195 |
+
classical
|
| 196 |
+
let t : Place p→ℕ := fun _ => 0
|
| 197 |
+
let B : DTuple (p:=p) t N := 0
|
| 198 |
+
have hh := heat_one i B B Z hH m hm he hw
|
| 199 |
+
have h1 (x : UnitType p n N) : glimpse p x i B := fun z v v' h => Subsingleton.elim v v'
|
| 200 |
+
have h2 (x : UnitType p n N) : thermal p x (unary i) B=B := Subsingleton.elim _ _
|
| 201 |
+
simp_rw [h1,h2,and_true] at hh
|
| 202 |
+
simpa only [ctot,t,Finset.sum_const_zero] using hh
|
| 203 |
+
|
| 204 |
+
end HadwigerCounterexample
|
| 205 |
+
|
| 206 |
+
end
|
| 207 |
+
|
| 208 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProductCharacterTests.lean
CHANGED
|
@@ -1,135 +1,135 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ConditionedCorrelations
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Product Character Tests -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Filter Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J A Z D : Type} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
|
| 12 |
-
variable [Fintype A]
|
| 13 |
-
|
| 14 |
-
def Pipe (P : A→Z→ ℝ) :=
|
| 15 |
-
∃ (f : A→ℝ) (g : Z→ℝ),(∀ i, |f i|≤1) ∧ (∀ i, |g i|≤1) ∧ ∀ x y,P x y=f x*g y
|
| 16 |
-
|
| 17 |
-
omit [Fintype I] [Fintype A] in
|
| 18 |
-
private theorem pipe_prod (s : Finset I) (P : I → A→Z→ℝ)
|
| 19 |
-
(h : ∀ i∈s,Pipe (P i)) :
|
| 20 |
-
Pipe (fun x y => ∏ i∈s,P i x y) := by
|
| 21 |
-
classical
|
| 22 |
-
induction s using Finset.induction_on with
|
| 23 |
-
| empty =>
|
| 24 |
-
exact ⟨fun _ =>1,fun _=>1,(by simp),(by simp),fun _ _=>by simp⟩
|
| 25 |
-
| @insert i s hi ih =>
|
| 26 |
-
obtain ⟨f,g,hf,hg,hH⟩ := h i (by simp)
|
| 27 |
-
obtain ⟨u,v,hu,hv,hU⟩ := ih (fun j hj => h j (mem_insert_of_mem hj))
|
| 28 |
-
have he (f g : ℝ) (hf : |f|≤1) (hg : |g|≤1) :
|
| 29 |
-
|f*g|≤1 := by rw [abs_mul]; exact (mul_le_mul hf hg (abs_nonneg _) zero_le_one).trans_eq
|
| 30 |
-
(by ring)
|
| 31 |
-
exact ⟨fun x => f x*u x,fun x => g x*v x,(fun x=>he _ _ (hf x) (hu x)),
|
| 32 |
-
(fun x => he _ _ (hg x) (hv x)),fun x y => by dsimp only at *; rw [prod_insert hi,hH,hU]; ring⟩
|
| 33 |
-
|
| 34 |
-
structure Stage (I J : Type) where
|
| 35 |
-
first : J→I
|
| 36 |
-
nextP : J→I
|
| 37 |
-
diff k : first k ≠ nextP k
|
| 38 |
-
once k j : first k=first j → nextP k=nextP j → k=j
|
| 39 |
-
anti k j : first k=nextP j → nextP k≠first j
|
| 40 |
-
|
| 41 |
-
variable (s : Stage I J)
|
| 42 |
-
|
| 43 |
-
set_option maxHeartbeats 600000 in
|
| 44 |
-
theorem far_avg (w : I→Wgt A) (hw : ∀ i,IsLaw (w i)) (F : Wgt (I→A)) (i j : I)
|
| 45 |
-
(_ : i ≠ j) :
|
| 46 |
-
let U := prodW w
|
| 47 |
-
avg U F = avg U (fun x => avg (pairW (w i) (w j)) (fun y => F (update (update x i y.1) j y.2))) := by
|
| 48 |
-
classical
|
| 49 |
-
intro U
|
| 50 |
-
rw [update_avg w j F (hw j),update_avg w i _ (hw i)]
|
| 51 |
-
simp only [U,pairW_avg]
|
| 52 |
-
private def moveInputs (i j : I) (x : I→A) (p q : A) := update (update x i p) j q
|
| 53 |
-
|
| 54 |
-
set_option maxHeartbeats 800000 in
|
| 55 |
-
theorem band_res (w : I→ Wgt A) (hw : ∀ i,IsLaw (w i))
|
| 56 |
-
(f : I→ Wgt A) (hf : ∀ i x,|f i x|≤1)
|
| 57 |
-
(u : J→ A→ A→ℝ) (hu : ∀ k x y,|u k x y|≤1)
|
| 58 |
-
(k : J) (η : ℝ)
|
| 59 |
-
(h : ∀ p q : Wgt A,(∀ i, |p i|≤1)→(∀ i,|q i|≤1) →
|
| 60 |
-
|avg (pairW (w (s.first k)) (w (s.nextP k))) (fun x =>
|
| 61 |
-
u k x.1 x.2 * (p x.1*q x.2))|≤η) :
|
| 62 |
-
|avg (prodW w) (fun x => (∏ j:J,u j (x (s.first j)) (x (s.nextP j)))*prodW f x)|≤η := by
|
| 63 |
-
classical
|
| 64 |
-
let i:=s.first k; let j:=s.nextP k
|
| 65 |
-
have hj : i≠ j := s.diff k
|
| 66 |
-
let W (x : I→ A) := (∏ j':J,u j' (x (s.first j')) (x (s.nextP j')))*prodW f x
|
| 67 |
-
have hi (z : I→A) :
|
| 68 |
-
|avg (pairW (w i) (w j)) (fun x => W (moveInputs i j z x.1 x.2))|≤ η := by
|
| 69 |
-
let C a b := moveInputs i j z a b
|
| 70 |
-
let g (v : J⊕I) (a b : A) :=
|
| 71 |
-
match v with
|
| 72 |
-
| .inl t => if t=k then 1 else u t (C a b (s.first t)) (C a b (s.nextP t))
|
| 73 |
-
| .inr t => f t (C a b t)
|
| 74 |
-
have he a b :
|
| 75 |
-
W (C a b)=u k a b * ∏ l:J ⊕ I,g l a b := by
|
| 76 |
-
unfold W prodW; rw [Fintype.prod_sum_type]
|
| 77 |
-
rw [← mul_prod_erase _ _ (mem_univ k),←mul_prod_erase _
|
| 78 |
-
(fun t:J=>g (.inl t) a b) (mem_univ k)]
|
| 79 |
-
have he (t:J) (h : t∈univ.erase k) :
|
| 80 |
-
g (Sum.inl t) a b=u t (C a b (s.first t)) (C a b (s.nextP t)) :=
|
| 81 |
-
ite_eq_right (mem_erase.mp h).1
|
| 82 |
-
rw [Finset.prod_congr rfl (g:=fun t:J => u t (C a b (s.first t)) (C a b (s.nextP t))) he]
|
| 83 |
-
change (u k (C a b i) (C a b j)*_) *_=_
|
| 84 |
-
rw [show C a b i=a from (by simp [C,moveInputs,hj]),
|
| 85 |
-
show C a b j=b from (by simp [C,moveInputs]),show g (.inl k) a b=1 from
|
| 86 |
-
(by simp [g]),one_mul,mul_assoc]
|
| 87 |
-
let d := z i
|
| 88 |
-
have hp : ∀ x:J ⊕ I,Pipe (g x) := by
|
| 89 |
-
have he (t : I) (h : t ≠ j) (a b : A) : C a b t=C a d t := by
|
| 90 |
-
unfold C moveInputs; rw [update_of_ne h,update_of_ne h]
|
| 91 |
-
have hu' (t : I) (h : t ≠ i) (a b : A) : C a b t=C d b t := by
|
| 92 |
-
unfold C moveInputs
|
| 93 |
-
by_cases hx : t=j <;> simp [hx,h]
|
| 94 |
-
have h1 (x:J⊕I) (h : ∀ a b,|g x a b|≤1)
|
| 95 |
-
(e : (∀ a b,g x a b=g x a d)∨(∀ a b,g x a b=g x d b)) :
|
| 96 |
-
Pipe (g x) := by
|
| 97 |
-
rcases e with e|e
|
| 98 |
-
· exact ⟨fun a=>g x a d,fun _=>1,fun i=>h _ _,(by simp),fun i j=> (e i j).trans
|
| 99 |
-
(by rw [mul_one])⟩
|
| 100 |
-
exact ⟨fun _=>1,g x d,(by simp),h d,fun i j=> (e i j).trans (by rw [one_mul])⟩
|
| 101 |
-
rintro (l|l)
|
| 102 |
-
· by_cases hh : l=k
|
| 103 |
-
· subst l; exact h1 (Sum.inl k) (by simp [g]) (Or.inl (by simp [g]))
|
| 104 |
-
apply h1 (Sum.inl l) (fun a b => by simp only [g,ite_eq_right hh]; exact hu _ _ _)
|
| 105 |
-
have hh1 :
|
| 106 |
-
(s.first l≠j∧s.nextP l≠j) ∨(s.first l≠i∧s.nextP l≠i) := by
|
| 107 |
-
by_contra! ha
|
| 108 |
-
by_cases hx : s.first l=j
|
| 109 |
-
· have hy : s.first l≠i := hx ▸ Ne.symm hj
|
| 110 |
-
exact s.anti l k hx (ha.2 hy)
|
| 111 |
-
have ht := ha.1 hx
|
| 112 |
-
have hs : s.first l=i := by_contra (fun h=>hj ((ha.2 h).symm.trans ht))
|
| 113 |
-
exact hh (s.once l k hs ht)
|
| 114 |
-
simp only [g,ite_eq_right hh]; rcases hh1 with ⟨h,h'⟩|⟨h,h'⟩
|
| 115 |
-
· left; intro a b; rw [he _ h,he _ h']
|
| 116 |
-
right; intro a b; rw [hu' _ h,hu' _ h']
|
| 117 |
-
apply h1 (Sum.inr l) (fun a b => hf _ _)
|
| 118 |
-
unfold g
|
| 119 |
-
by_cases h : l=i
|
| 120 |
-
· exact Or.inl fun a b => congrArg _ (he _ (h.symm ▸ hj) _ _)
|
| 121 |
-
exact Or.inr fun a b=> congrArg _ (hu' l h a b)
|
| 122 |
-
obtain ⟨p,q,hp,hq,ht⟩ := pipe_prod univ g (fun i _ => hp i)
|
| 123 |
-
have heq (x : A×A) : W (moveInputs i j z x.1 x.2)=u k x.1 x.2*(p x.1*q x.2) := by
|
| 124 |
-
change W (C _ _)=_
|
| 125 |
-
rw [he]; exact congrArg (_ * ·) (ht x.1 x.2)
|
| 126 |
-
simp_rw [heq]
|
| 127 |
-
exact h p q hp hq
|
| 128 |
-
change |avg _ W|≤η
|
| 129 |
-
rw [far_avg w hw W i j hj]
|
| 130 |
-
exact (abs_avg_le (prodW_law hw).nz).trans ((prodW_law hw).avg_le hi)
|
| 131 |
-
end HadwigerCounterexample
|
| 132 |
-
|
| 133 |
-
end
|
| 134 |
-
|
| 135 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ConditionedCorrelations
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Product Character Tests -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Filter Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J A Z D : Type} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
|
| 12 |
+
variable [Fintype A]
|
| 13 |
+
|
| 14 |
+
def Pipe (P : A→Z→ ℝ) :=
|
| 15 |
+
∃ (f : A→ℝ) (g : Z→ℝ),(∀ i, |f i|≤1) ∧ (∀ i, |g i|≤1) ∧ ∀ x y,P x y=f x*g y
|
| 16 |
+
|
| 17 |
+
omit [Fintype I] [Fintype A] in
|
| 18 |
+
private theorem pipe_prod (s : Finset I) (P : I → A→Z→ℝ)
|
| 19 |
+
(h : ∀ i∈s,Pipe (P i)) :
|
| 20 |
+
Pipe (fun x y => ∏ i∈s,P i x y) := by
|
| 21 |
+
classical
|
| 22 |
+
induction s using Finset.induction_on with
|
| 23 |
+
| empty =>
|
| 24 |
+
exact ⟨fun _ =>1,fun _=>1,(by simp),(by simp),fun _ _=>by simp⟩
|
| 25 |
+
| @insert i s hi ih =>
|
| 26 |
+
obtain ⟨f,g,hf,hg,hH⟩ := h i (by simp)
|
| 27 |
+
obtain ⟨u,v,hu,hv,hU⟩ := ih (fun j hj => h j (mem_insert_of_mem hj))
|
| 28 |
+
have he (f g : ℝ) (hf : |f|≤1) (hg : |g|≤1) :
|
| 29 |
+
|f*g|≤1 := by rw [abs_mul]; exact (mul_le_mul hf hg (abs_nonneg _) zero_le_one).trans_eq
|
| 30 |
+
(by ring)
|
| 31 |
+
exact ⟨fun x => f x*u x,fun x => g x*v x,(fun x=>he _ _ (hf x) (hu x)),
|
| 32 |
+
(fun x => he _ _ (hg x) (hv x)),fun x y => by dsimp only at *; rw [prod_insert hi,hH,hU]; ring⟩
|
| 33 |
+
|
| 34 |
+
structure Stage (I J : Type) where
|
| 35 |
+
first : J→I
|
| 36 |
+
nextP : J→I
|
| 37 |
+
diff k : first k ≠ nextP k
|
| 38 |
+
once k j : first k=first j → nextP k=nextP j → k=j
|
| 39 |
+
anti k j : first k=nextP j → nextP k≠first j
|
| 40 |
+
|
| 41 |
+
variable (s : Stage I J)
|
| 42 |
+
|
| 43 |
+
set_option maxHeartbeats 600000 in
|
| 44 |
+
theorem far_avg (w : I→Wgt A) (hw : ∀ i,IsLaw (w i)) (F : Wgt (I→A)) (i j : I)
|
| 45 |
+
(_ : i ≠ j) :
|
| 46 |
+
let U := prodW w
|
| 47 |
+
avg U F = avg U (fun x => avg (pairW (w i) (w j)) (fun y => F (update (update x i y.1) j y.2))) := by
|
| 48 |
+
classical
|
| 49 |
+
intro U
|
| 50 |
+
rw [update_avg w j F (hw j),update_avg w i _ (hw i)]
|
| 51 |
+
simp only [U,pairW_avg]
|
| 52 |
+
private def moveInputs (i j : I) (x : I→A) (p q : A) := update (update x i p) j q
|
| 53 |
+
|
| 54 |
+
set_option maxHeartbeats 800000 in
|
| 55 |
+
theorem band_res (w : I→ Wgt A) (hw : ∀ i,IsLaw (w i))
|
| 56 |
+
(f : I→ Wgt A) (hf : ∀ i x,|f i x|≤1)
|
| 57 |
+
(u : J→ A→ A→ℝ) (hu : ∀ k x y,|u k x y|≤1)
|
| 58 |
+
(k : J) (η : ℝ)
|
| 59 |
+
(h : ∀ p q : Wgt A,(∀ i, |p i|≤1)→(∀ i,|q i|≤1) →
|
| 60 |
+
|avg (pairW (w (s.first k)) (w (s.nextP k))) (fun x =>
|
| 61 |
+
u k x.1 x.2 * (p x.1*q x.2))|≤η) :
|
| 62 |
+
|avg (prodW w) (fun x => (∏ j:J,u j (x (s.first j)) (x (s.nextP j)))*prodW f x)|≤η := by
|
| 63 |
+
classical
|
| 64 |
+
let i:=s.first k; let j:=s.nextP k
|
| 65 |
+
have hj : i≠ j := s.diff k
|
| 66 |
+
let W (x : I→ A) := (∏ j':J,u j' (x (s.first j')) (x (s.nextP j')))*prodW f x
|
| 67 |
+
have hi (z : I→A) :
|
| 68 |
+
|avg (pairW (w i) (w j)) (fun x => W (moveInputs i j z x.1 x.2))|≤ η := by
|
| 69 |
+
let C a b := moveInputs i j z a b
|
| 70 |
+
let g (v : J⊕I) (a b : A) :=
|
| 71 |
+
match v with
|
| 72 |
+
| .inl t => if t=k then 1 else u t (C a b (s.first t)) (C a b (s.nextP t))
|
| 73 |
+
| .inr t => f t (C a b t)
|
| 74 |
+
have he a b :
|
| 75 |
+
W (C a b)=u k a b * ∏ l:J ⊕ I,g l a b := by
|
| 76 |
+
unfold W prodW; rw [Fintype.prod_sum_type]
|
| 77 |
+
rw [← mul_prod_erase _ _ (mem_univ k),←mul_prod_erase _
|
| 78 |
+
(fun t:J=>g (.inl t) a b) (mem_univ k)]
|
| 79 |
+
have he (t:J) (h : t∈univ.erase k) :
|
| 80 |
+
g (Sum.inl t) a b=u t (C a b (s.first t)) (C a b (s.nextP t)) :=
|
| 81 |
+
ite_eq_right (mem_erase.mp h).1
|
| 82 |
+
rw [Finset.prod_congr rfl (g:=fun t:J => u t (C a b (s.first t)) (C a b (s.nextP t))) he]
|
| 83 |
+
change (u k (C a b i) (C a b j)*_) *_=_
|
| 84 |
+
rw [show C a b i=a from (by simp [C,moveInputs,hj]),
|
| 85 |
+
show C a b j=b from (by simp [C,moveInputs]),show g (.inl k) a b=1 from
|
| 86 |
+
(by simp [g]),one_mul,mul_assoc]
|
| 87 |
+
let d := z i
|
| 88 |
+
have hp : ∀ x:J ⊕ I,Pipe (g x) := by
|
| 89 |
+
have he (t : I) (h : t ≠ j) (a b : A) : C a b t=C a d t := by
|
| 90 |
+
unfold C moveInputs; rw [update_of_ne h,update_of_ne h]
|
| 91 |
+
have hu' (t : I) (h : t ≠ i) (a b : A) : C a b t=C d b t := by
|
| 92 |
+
unfold C moveInputs
|
| 93 |
+
by_cases hx : t=j <;> simp [hx,h]
|
| 94 |
+
have h1 (x:J⊕I) (h : ∀ a b,|g x a b|≤1)
|
| 95 |
+
(e : (∀ a b,g x a b=g x a d)∨(∀ a b,g x a b=g x d b)) :
|
| 96 |
+
Pipe (g x) := by
|
| 97 |
+
rcases e with e|e
|
| 98 |
+
· exact ⟨fun a=>g x a d,fun _=>1,fun i=>h _ _,(by simp),fun i j=> (e i j).trans
|
| 99 |
+
(by rw [mul_one])⟩
|
| 100 |
+
exact ⟨fun _=>1,g x d,(by simp),h d,fun i j=> (e i j).trans (by rw [one_mul])⟩
|
| 101 |
+
rintro (l|l)
|
| 102 |
+
· by_cases hh : l=k
|
| 103 |
+
· subst l; exact h1 (Sum.inl k) (by simp [g]) (Or.inl (by simp [g]))
|
| 104 |
+
apply h1 (Sum.inl l) (fun a b => by simp only [g,ite_eq_right hh]; exact hu _ _ _)
|
| 105 |
+
have hh1 :
|
| 106 |
+
(s.first l≠j∧s.nextP l≠j) ∨(s.first l≠i∧s.nextP l≠i) := by
|
| 107 |
+
by_contra! ha
|
| 108 |
+
by_cases hx : s.first l=j
|
| 109 |
+
· have hy : s.first l≠i := hx ▸ Ne.symm hj
|
| 110 |
+
exact s.anti l k hx (ha.2 hy)
|
| 111 |
+
have ht := ha.1 hx
|
| 112 |
+
have hs : s.first l=i := by_contra (fun h=>hj ((ha.2 h).symm.trans ht))
|
| 113 |
+
exact hh (s.once l k hs ht)
|
| 114 |
+
simp only [g,ite_eq_right hh]; rcases hh1 with ⟨h,h'⟩|⟨h,h'⟩
|
| 115 |
+
· left; intro a b; rw [he _ h,he _ h']
|
| 116 |
+
right; intro a b; rw [hu' _ h,hu' _ h']
|
| 117 |
+
apply h1 (Sum.inr l) (fun a b => hf _ _)
|
| 118 |
+
unfold g
|
| 119 |
+
by_cases h : l=i
|
| 120 |
+
· exact Or.inl fun a b => congrArg _ (he _ (h.symm ▸ hj) _ _)
|
| 121 |
+
exact Or.inr fun a b=> congrArg _ (hu' l h a b)
|
| 122 |
+
obtain ⟨p,q,hp,hq,ht⟩ := pipe_prod univ g (fun i _ => hp i)
|
| 123 |
+
have heq (x : A×A) : W (moveInputs i j z x.1 x.2)=u k x.1 x.2*(p x.1*q x.2) := by
|
| 124 |
+
change W (C _ _)=_
|
| 125 |
+
rw [he]; exact congrArg (_ * ·) (ht x.1 x.2)
|
| 126 |
+
simp_rw [heq]
|
| 127 |
+
exact h p q hp hq
|
| 128 |
+
change |avg _ W|≤η
|
| 129 |
+
rw [far_avg w hw W i j hj]
|
| 130 |
+
exact (abs_avg_le (prodW_law hw).nz).trans ((prodW_law hw).avg_le hi)
|
| 131 |
+
end HadwigerCounterexample
|
| 132 |
+
|
| 133 |
+
end
|
| 134 |
+
|
| 135 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProductComparisonScales.lean
CHANGED
|
@@ -1,130 +1,130 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RecursiveComparisonErrors
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Product Comparison Scales -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module Function Finset Filter
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N M : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
-
namespace Template
|
| 13 |
-
variable (v : Template p I)
|
| 14 |
-
|
| 15 |
-
def play (v : Template p I) (M : ℕ) (C b ε : ℝ) :=
|
| 16 |
-
∃ (r : ℕ) (c : ℝ),0<c ∧ ∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ (q : I→F)
|
| 17 |
-
(U : Wgt (Keys (p:=p) v.t N)), (∀ i, |U i|≤ b) →
|
| 18 |
-
∃ T,design v T b r∧ shadowed v q (U-T) ε ∧ engaged v q (U-T) n C (bp (-c*n)) ε
|
| 19 |
-
|
| 20 |
-
theorem play_empty (v : Template p I) (M : ℕ) (C b ε : ℝ) [IsEmpty I]
|
| 21 |
-
(hε : 0≤ε) :
|
| 22 |
-
play v M C b ε := by
|
| 23 |
-
classical
|
| 24 |
-
refine ⟨1,1,zero_lt_one,.of_forall (fun n => ?_)⟩
|
| 25 |
-
intro N q U hU
|
| 26 |
-
let i : Keys (p:=p) v.t N := 0
|
| 27 |
-
refine ⟨U, ⟨fun _ => ⟨U i,fun _ _=> True⟩,?_,fun _=>hU _⟩,fun f h=>?_,
|
| 28 |
-
fun m hN w hw s x h hh =>?_⟩
|
| 29 |
-
· funext x
|
| 30 |
-
simp only [mural,Paint.cost,prodW,ind_true,prod_const_one,mul_one,sum_const,
|
| 31 |
-
card_univ,Fintype.card_fin,one_smul]
|
| 32 |
-
exact congrArg U (Subsingleton.elim x i)
|
| 33 |
-
· simp only [board,sub_self,curtain,Pi.zero_apply,mul_zero,zero_mul,avg_zero,abs_zero]
|
| 34 |
-
exact hε
|
| 35 |
-
· have ht o : ¬ exceeds v q (U-U) s m x ε o := by
|
| 36 |
-
rintro ⟨f,_,hh⟩
|
| 37 |
-
simp only [scene,protean,curtain,sub_self,Pi.zero_apply,mul_zero,zero_mul,avg_zero,
|
| 38 |
-
abs_zero] at hh
|
| 39 |
-
exact (not_lt_of_ge hε) hh
|
| 40 |
-
rw [show exceeds _ _ _ _ _ _ _=(fun _=>False) from funext fun i=>propext ⟨ht i,False.elim⟩,
|
| 41 |
-
pr_false]; exact (bp_pos _).le
|
| 42 |
-
|
| 43 |
-
set_option maxHeartbeats 1200000 in
|
| 44 |
-
theorem play_step (v : Template p I) (j : I) (M : ℕ) (hM : 1≤ M) (C b ε : ℝ)
|
| 45 |
-
(hb : 0≤b) (hε : 0<ε)
|
| 46 |
-
(h : play (v.beyond j) M C b (ε/2)) :
|
| 47 |
-
play v M C b ε := by
|
| 48 |
-
classical
|
| 49 |
-
let u:= ε/2; let L:=1+2*b; have hu : 0<u := by positivity
|
| 50 |
-
have hL : 0<L := by positivity
|
| 51 |
-
obtain ⟨δ,hδ,hh⟩ := shade_calendar v j M hM C (u/L) (by positivity)
|
| 52 |
-
let d := min δ (u/L)
|
| 53 |
-
have hd : 0<d := lt_min hδ (by positivity)
|
| 54 |
-
obtain ⟨s,hs⟩ := shattered v j b L d hL hb (by unfold L; linarith) hd
|
| 55 |
-
obtain ⟨r,c,hc,h⟩ := h
|
| 56 |
-
let t := min (1/16:ℝ) c
|
| 57 |
-
have ht : 0<t := lt_min (by norm_num) hc
|
| 58 |
-
refine ⟨s*r,t/2,by linarith,?_⟩
|
| 59 |
-
filter_upwards [hh,h,pay_nat (a:=t) (b:=t/2) ((s:ℝ)+1) (by linarith)]
|
| 60 |
-
with n hn h ha N q U hU
|
| 61 |
-
obtain ⟨l,hl,a,B,hb',hs,hQ,hW⟩ := hs N q U hU
|
| 62 |
-
let V:= patched v j a B
|
| 63 |
-
let W := U-V
|
| 64 |
-
let R i := curtain v q W i/L
|
| 65 |
-
let T:=v.beyond j
|
| 66 |
-
let Q:= v.boundTail j q
|
| 67 |
-
choose g h1 h2 h3 using fun i=> h Q (B i) (hb' i)
|
| 68 |
-
let D := patched v j a g
|
| 69 |
-
have hT : shadowed v q W u := by
|
| 70 |
-
have he := chair_board v j q W L d hL hQ
|
| 71 |
-
have hm : d*L ≤ u := (le_div_iff₀ hL).mp (min_le_right ..)
|
| 72 |
-
exact fun i hi => (he i hi).trans hm
|
| 73 |
-
have hx : engaged v q W n C (bp (-(1/16:ℝ)*n)) u := by
|
| 74 |
-
intro m hN w hw s x hx hz
|
| 75 |
-
have he : chairCut v j R δ :=
|
| 76 |
-
fun i hi k hk=> (hQ i hi k hk).trans (min_le_left ..)
|
| 77 |
-
have hg (x) : |propel v s m x|≤1 := by
|
| 78 |
-
unfold propel; rw [abs_of_nonneg (ind_nonneg _)]
|
| 79 |
-
exact ind_le_one _
|
| 80 |
-
obtain ⟨hw,hv,h',hm'⟩ := hw
|
| 81 |
-
have h4 := hn q R (propel v s m) x hs he hW hg hx hz m hN w hw hv h' hm'
|
| 82 |
-
refine (pr_mono hw.nz (fun i hh => ?_)).trans h4
|
| 83 |
-
obtain ⟨f,hf,hg⟩ := hh
|
| 84 |
-
refine ⟨f,hf,?_⟩
|
| 85 |
-
unfold R
|
| 86 |
-
rw [put_back v q W L,abs_div,abs_of_pos hL]
|
| 87 |
-
exact div_lt_div_of_pos_right hg hL
|
| 88 |
-
have hg := gild_play v j q n N l a B g U C u _ _ hT hx h2 h3
|
| 89 |
-
have heq : u+u=ε := by unfold u; ring
|
| 90 |
-
dsimp only at hg
|
| 91 |
-
rw [heq] at hg
|
| 92 |
-
refine ⟨D,design_mono v D b _ (s*r) hb (Nat.mul_le_mul_right r hl)
|
| 93 |
-
(design_patch v j l r a g b h1),hg.1,?_⟩
|
| 94 |
-
intro m hN w hw s' x hx hz
|
| 95 |
-
apply (hg.2 m hN w hw s' x hx hz).trans
|
| 96 |
-
apply le_trans ?_ ha
|
| 97 |
-
let z := bp (-t*n)
|
| 98 |
-
have h1 : bp (-c*n)≤ z := bp_le (by gcongr; exact min_le_right ..)
|
| 99 |
-
have h2 : bp (-(1/16:ℝ)*n)≤ z := bp_le (by gcongr; exact min_le_left ..)
|
| 100 |
-
exact (add_le_add h2 (mul_le_mul (by exact_mod_cast hl) h1 (bp_pos _).le
|
| 101 |
-
(Nat.cast_nonneg s))).trans_eq (by ring)
|
| 102 |
-
|
| 103 |
-
theorem plays_calendar (p : Shape) (M : ℕ) (hM : 1≤M) (C b : ℝ) (hb : 0 ≤ b)
|
| 104 |
-
(r : ℕ) :
|
| 105 |
-
∀ (I : Type) [Fintype I] [DecidableEq I],Fintype.card I≤r →
|
| 106 |
-
∀ v : Template p I,∀ ε : ℝ,0< ε→play v M C b ε := by
|
| 107 |
-
classical
|
| 108 |
-
induction r with
|
| 109 |
-
| zero =>
|
| 110 |
-
intro I inst h hi v ε he
|
| 111 |
-
have : IsEmpty I := Fintype.card_eq_zero_iff.mp (Nat.eq_zero_of_le_zero hi)
|
| 112 |
-
exact play_empty v M C b ε he.le
|
| 113 |
-
| succ r ih =>
|
| 114 |
-
intro I _ _ h v ε he
|
| 115 |
-
cases isEmpty_or_nonempty I
|
| 116 |
-
next => exact play_empty v M C b ε he.le
|
| 117 |
-
next hi =>
|
| 118 |
-
obtain ⟨i⟩:=hi
|
| 119 |
-
apply play_step v i M hM C b ε hb he
|
| 120 |
-
refine ih _ ?_ _ _ (half_pos he)
|
| 121 |
-
have hh : Fintype.card (Aside i)+1=Fintype.card I := by
|
| 122 |
-
have hg := Fintype.card_congr (Equiv.optionSubtypeNe i)
|
| 123 |
-
simpa only [Aside,Fintype.card_option] using hg
|
| 124 |
-
omega
|
| 125 |
-
end Template
|
| 126 |
-
end HadwigerCounterexample
|
| 127 |
-
|
| 128 |
-
end
|
| 129 |
-
|
| 130 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RecursiveComparisonErrors
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Product Comparison Scales -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module Function Finset Filter
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N M : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
+
namespace Template
|
| 13 |
+
variable (v : Template p I)
|
| 14 |
+
|
| 15 |
+
def play (v : Template p I) (M : ℕ) (C b ε : ℝ) :=
|
| 16 |
+
∃ (r : ℕ) (c : ℝ),0<c ∧ ∀ᶠ n : ℕ in atTop, let N:=M*n; ∀ (q : I→F)
|
| 17 |
+
(U : Wgt (Keys (p:=p) v.t N)), (∀ i, |U i|≤ b) →
|
| 18 |
+
∃ T,design v T b r∧ shadowed v q (U-T) ε ∧ engaged v q (U-T) n C (bp (-c*n)) ε
|
| 19 |
+
|
| 20 |
+
theorem play_empty (v : Template p I) (M : ℕ) (C b ε : ℝ) [IsEmpty I]
|
| 21 |
+
(hε : 0≤ε) :
|
| 22 |
+
play v M C b ε := by
|
| 23 |
+
classical
|
| 24 |
+
refine ⟨1,1,zero_lt_one,.of_forall (fun n => ?_)⟩
|
| 25 |
+
intro N q U hU
|
| 26 |
+
let i : Keys (p:=p) v.t N := 0
|
| 27 |
+
refine ⟨U, ⟨fun _ => ⟨U i,fun _ _=> True⟩,?_,fun _=>hU _⟩,fun f h=>?_,
|
| 28 |
+
fun m hN w hw s x h hh =>?_⟩
|
| 29 |
+
· funext x
|
| 30 |
+
simp only [mural,Paint.cost,prodW,ind_true,prod_const_one,mul_one,sum_const,
|
| 31 |
+
card_univ,Fintype.card_fin,one_smul]
|
| 32 |
+
exact congrArg U (Subsingleton.elim x i)
|
| 33 |
+
· simp only [board,sub_self,curtain,Pi.zero_apply,mul_zero,zero_mul,avg_zero,abs_zero]
|
| 34 |
+
exact hε
|
| 35 |
+
· have ht o : ¬ exceeds v q (U-U) s m x ε o := by
|
| 36 |
+
rintro ⟨f,_,hh⟩
|
| 37 |
+
simp only [scene,protean,curtain,sub_self,Pi.zero_apply,mul_zero,zero_mul,avg_zero,
|
| 38 |
+
abs_zero] at hh
|
| 39 |
+
exact (not_lt_of_ge hε) hh
|
| 40 |
+
rw [show exceeds _ _ _ _ _ _ _=(fun _=>False) from funext fun i=>propext ⟨ht i,False.elim⟩,
|
| 41 |
+
pr_false]; exact (bp_pos _).le
|
| 42 |
+
|
| 43 |
+
set_option maxHeartbeats 1200000 in
|
| 44 |
+
theorem play_step (v : Template p I) (j : I) (M : ℕ) (hM : 1≤ M) (C b ε : ℝ)
|
| 45 |
+
(hb : 0≤b) (hε : 0<ε)
|
| 46 |
+
(h : play (v.beyond j) M C b (ε/2)) :
|
| 47 |
+
play v M C b ε := by
|
| 48 |
+
classical
|
| 49 |
+
let u:= ε/2; let L:=1+2*b; have hu : 0<u := by positivity
|
| 50 |
+
have hL : 0<L := by positivity
|
| 51 |
+
obtain ⟨δ,hδ,hh⟩ := shade_calendar v j M hM C (u/L) (by positivity)
|
| 52 |
+
let d := min δ (u/L)
|
| 53 |
+
have hd : 0<d := lt_min hδ (by positivity)
|
| 54 |
+
obtain ⟨s,hs⟩ := shattered v j b L d hL hb (by unfold L; linarith) hd
|
| 55 |
+
obtain ⟨r,c,hc,h⟩ := h
|
| 56 |
+
let t := min (1/16:ℝ) c
|
| 57 |
+
have ht : 0<t := lt_min (by norm_num) hc
|
| 58 |
+
refine ⟨s*r,t/2,by linarith,?_⟩
|
| 59 |
+
filter_upwards [hh,h,pay_nat (a:=t) (b:=t/2) ((s:ℝ)+1) (by linarith)]
|
| 60 |
+
with n hn h ha N q U hU
|
| 61 |
+
obtain ⟨l,hl,a,B,hb',hs,hQ,hW⟩ := hs N q U hU
|
| 62 |
+
let V:= patched v j a B
|
| 63 |
+
let W := U-V
|
| 64 |
+
let R i := curtain v q W i/L
|
| 65 |
+
let T:=v.beyond j
|
| 66 |
+
let Q:= v.boundTail j q
|
| 67 |
+
choose g h1 h2 h3 using fun i=> h Q (B i) (hb' i)
|
| 68 |
+
let D := patched v j a g
|
| 69 |
+
have hT : shadowed v q W u := by
|
| 70 |
+
have he := chair_board v j q W L d hL hQ
|
| 71 |
+
have hm : d*L ≤ u := (le_div_iff₀ hL).mp (min_le_right ..)
|
| 72 |
+
exact fun i hi => (he i hi).trans hm
|
| 73 |
+
have hx : engaged v q W n C (bp (-(1/16:ℝ)*n)) u := by
|
| 74 |
+
intro m hN w hw s x hx hz
|
| 75 |
+
have he : chairCut v j R δ :=
|
| 76 |
+
fun i hi k hk=> (hQ i hi k hk).trans (min_le_left ..)
|
| 77 |
+
have hg (x) : |propel v s m x|≤1 := by
|
| 78 |
+
unfold propel; rw [abs_of_nonneg (ind_nonneg _)]
|
| 79 |
+
exact ind_le_one _
|
| 80 |
+
obtain ⟨hw,hv,h',hm'⟩ := hw
|
| 81 |
+
have h4 := hn q R (propel v s m) x hs he hW hg hx hz m hN w hw hv h' hm'
|
| 82 |
+
refine (pr_mono hw.nz (fun i hh => ?_)).trans h4
|
| 83 |
+
obtain ⟨f,hf,hg⟩ := hh
|
| 84 |
+
refine ⟨f,hf,?_⟩
|
| 85 |
+
unfold R
|
| 86 |
+
rw [put_back v q W L,abs_div,abs_of_pos hL]
|
| 87 |
+
exact div_lt_div_of_pos_right hg hL
|
| 88 |
+
have hg := gild_play v j q n N l a B g U C u _ _ hT hx h2 h3
|
| 89 |
+
have heq : u+u=ε := by unfold u; ring
|
| 90 |
+
dsimp only at hg
|
| 91 |
+
rw [heq] at hg
|
| 92 |
+
refine ⟨D,design_mono v D b _ (s*r) hb (Nat.mul_le_mul_right r hl)
|
| 93 |
+
(design_patch v j l r a g b h1),hg.1,?_⟩
|
| 94 |
+
intro m hN w hw s' x hx hz
|
| 95 |
+
apply (hg.2 m hN w hw s' x hx hz).trans
|
| 96 |
+
apply le_trans ?_ ha
|
| 97 |
+
let z := bp (-t*n)
|
| 98 |
+
have h1 : bp (-c*n)≤ z := bp_le (by gcongr; exact min_le_right ..)
|
| 99 |
+
have h2 : bp (-(1/16:ℝ)*n)≤ z := bp_le (by gcongr; exact min_le_left ..)
|
| 100 |
+
exact (add_le_add h2 (mul_le_mul (by exact_mod_cast hl) h1 (bp_pos _).le
|
| 101 |
+
(Nat.cast_nonneg s))).trans_eq (by ring)
|
| 102 |
+
|
| 103 |
+
theorem plays_calendar (p : Shape) (M : ℕ) (hM : 1≤M) (C b : ℝ) (hb : 0 ≤ b)
|
| 104 |
+
(r : ℕ) :
|
| 105 |
+
∀ (I : Type) [Fintype I] [DecidableEq I],Fintype.card I≤r →
|
| 106 |
+
∀ v : Template p I,∀ ε : ℝ,0< ε→play v M C b ε := by
|
| 107 |
+
classical
|
| 108 |
+
induction r with
|
| 109 |
+
| zero =>
|
| 110 |
+
intro I inst h hi v ε he
|
| 111 |
+
have : IsEmpty I := Fintype.card_eq_zero_iff.mp (Nat.eq_zero_of_le_zero hi)
|
| 112 |
+
exact play_empty v M C b ε he.le
|
| 113 |
+
| succ r ih =>
|
| 114 |
+
intro I _ _ h v ε he
|
| 115 |
+
cases isEmpty_or_nonempty I
|
| 116 |
+
next => exact play_empty v M C b ε he.le
|
| 117 |
+
next hi =>
|
| 118 |
+
obtain ⟨i⟩:=hi
|
| 119 |
+
apply play_step v i M hM C b ε hb he
|
| 120 |
+
refine ih _ ?_ _ _ (half_pos he)
|
| 121 |
+
have hh : Fintype.card (Aside i)+1=Fintype.card I := by
|
| 122 |
+
have hg := Fintype.card_congr (Equiv.optionSubtypeNe i)
|
| 123 |
+
simpa only [Aside,Fintype.card_option] using hg
|
| 124 |
+
omega
|
| 125 |
+
end Template
|
| 126 |
+
end HadwigerCounterexample
|
| 127 |
+
|
| 128 |
+
end
|
| 129 |
+
|
| 130 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProductCoordinateReplacement.lean
CHANGED
|
@@ -1,58 +1,58 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PairedRankBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Product Coordinate Replacement -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J K : Type} {A : Type} [Fintype I] [DecidableEq I] [Fintype A]
|
| 12 |
-
|
| 13 |
-
set_option maxHeartbeats 600000 in
|
| 14 |
-
theorem update_avg (p : I→ Wgt A) (i : I) (f : Wgt (I→A)) (hp : IsLaw (p i)) :
|
| 15 |
-
avg (prodW p) f = avg (prodW p) (fun x => avg (p i) (fun y => f (update x i y))) := by
|
| 16 |
-
classical
|
| 17 |
-
|
| 18 |
-
let e : ((I→A)×A)≃ ((I→A)×A) := {
|
| 19 |
-
toFun x := (update x.1 i x.2,x.1 i)
|
| 20 |
-
invFun x := (update x.1 i x.2,x.1 i)
|
| 21 |
-
left_inv x := by simp
|
| 22 |
-
right_inv x := by simp }
|
| 23 |
-
let μ := pairW (prodW p) (p i)
|
| 24 |
-
have he (x : (I→A)×A) : μ (e x)=μ x := by
|
| 25 |
-
unfold μ pairW prodW
|
| 26 |
-
let s := Finset.univ.erase i
|
| 27 |
-
rw [←Finset.mul_prod_erase _ _ (mem_univ i),←Finset.mul_prod_erase _
|
| 28 |
-
(fun i => p i (x.1 i)) (mem_univ i)]
|
| 29 |
-
have h :
|
| 30 |
-
∏ j∈s,p j (update x.1 i x.2 j)=∏ j∈s,p j (x.1 j) := by
|
| 31 |
-
refine prod_congr rfl fun j hj => ?_
|
| 32 |
-
rw [update_of_ne ((mem_erase.mp hj).1)]
|
| 33 |
-
change p i _ * (∏ j∈s,p j (update x.1 i x.2 j))*p i (x.1 i)=_
|
| 34 |
-
rw [h]
|
| 35 |
-
change p i (Function.update x.1 i (x.2) i) * _ * _=_
|
| 36 |
-
rw [Function.update_self]; ac_rfl
|
| 37 |
-
have ht := avg_bij e μ (fun x => f x.1)
|
| 38 |
-
simp_rw [he] at ht
|
| 39 |
-
unfold μ at ht; simp only [pairW_avg,hp.avg_const] at ht
|
| 40 |
-
exact ht.symm
|
| 41 |
-
|
| 42 |
-
theorem update2_avg (p q : I→Wgt A) (i : I) (f : Wgt ((I→A)×(I→A))) (hp : IsLaw (p i))
|
| 43 |
-
(hq : IsLaw (q i)) :
|
| 44 |
-
let u := pairW (prodW p) (prodW q)
|
| 45 |
-
avg u f = avg u (fun x => avg (pairW (p i) (q i))
|
| 46 |
-
(fun y => f (update x.1 i y.1,update x.2 i y.2))) := by
|
| 47 |
-
intro u
|
| 48 |
-
simp only [u,pairW_avg]
|
| 49 |
-
conv_lhs => rw [update_avg p i _ hp]
|
| 50 |
-
apply avg_congr; intro x _
|
| 51 |
-
|
| 52 |
-
conv_rhs => rw [avg_avg]
|
| 53 |
-
exact avg_congr (fun _ _ => update_avg q i _ hq)
|
| 54 |
-
end HadwigerCounterexample
|
| 55 |
-
|
| 56 |
-
end
|
| 57 |
-
|
| 58 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PairedRankBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Product Coordinate Replacement -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J K : Type} {A : Type} [Fintype I] [DecidableEq I] [Fintype A]
|
| 12 |
+
|
| 13 |
+
set_option maxHeartbeats 600000 in
|
| 14 |
+
theorem update_avg (p : I→ Wgt A) (i : I) (f : Wgt (I→A)) (hp : IsLaw (p i)) :
|
| 15 |
+
avg (prodW p) f = avg (prodW p) (fun x => avg (p i) (fun y => f (update x i y))) := by
|
| 16 |
+
classical
|
| 17 |
+
|
| 18 |
+
let e : ((I→A)×A)≃ ((I→A)×A) := {
|
| 19 |
+
toFun x := (update x.1 i x.2,x.1 i)
|
| 20 |
+
invFun x := (update x.1 i x.2,x.1 i)
|
| 21 |
+
left_inv x := by simp
|
| 22 |
+
right_inv x := by simp }
|
| 23 |
+
let μ := pairW (prodW p) (p i)
|
| 24 |
+
have he (x : (I→A)×A) : μ (e x)=μ x := by
|
| 25 |
+
unfold μ pairW prodW
|
| 26 |
+
let s := Finset.univ.erase i
|
| 27 |
+
rw [←Finset.mul_prod_erase _ _ (mem_univ i),←Finset.mul_prod_erase _
|
| 28 |
+
(fun i => p i (x.1 i)) (mem_univ i)]
|
| 29 |
+
have h :
|
| 30 |
+
∏ j∈s,p j (update x.1 i x.2 j)=∏ j∈s,p j (x.1 j) := by
|
| 31 |
+
refine prod_congr rfl fun j hj => ?_
|
| 32 |
+
rw [update_of_ne ((mem_erase.mp hj).1)]
|
| 33 |
+
change p i _ * (∏ j∈s,p j (update x.1 i x.2 j))*p i (x.1 i)=_
|
| 34 |
+
rw [h]
|
| 35 |
+
change p i (Function.update x.1 i (x.2) i) * _ * _=_
|
| 36 |
+
rw [Function.update_self]; ac_rfl
|
| 37 |
+
have ht := avg_bij e μ (fun x => f x.1)
|
| 38 |
+
simp_rw [he] at ht
|
| 39 |
+
unfold μ at ht; simp only [pairW_avg,hp.avg_const] at ht
|
| 40 |
+
exact ht.symm
|
| 41 |
+
|
| 42 |
+
theorem update2_avg (p q : I→Wgt A) (i : I) (f : Wgt ((I→A)×(I→A))) (hp : IsLaw (p i))
|
| 43 |
+
(hq : IsLaw (q i)) :
|
| 44 |
+
let u := pairW (prodW p) (prodW q)
|
| 45 |
+
avg u f = avg u (fun x => avg (pairW (p i) (q i))
|
| 46 |
+
(fun y => f (update x.1 i y.1,update x.2 i y.2))) := by
|
| 47 |
+
intro u
|
| 48 |
+
simp only [u,pairW_avg]
|
| 49 |
+
conv_lhs => rw [update_avg p i _ hp]
|
| 50 |
+
apply avg_congr; intro x _
|
| 51 |
+
|
| 52 |
+
conv_rhs => rw [avg_avg]
|
| 53 |
+
exact avg_congr (fun _ _ => update_avg q i _ hq)
|
| 54 |
+
end HadwigerCounterexample
|
| 55 |
+
|
| 56 |
+
end
|
| 57 |
+
|
| 58 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProductLaws.lean
CHANGED
|
@@ -1,119 +1,119 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteLaws
|
| 2 |
-
import Mathlib.Data.Fintype.Pi
|
| 3 |
-
import Mathlib.Algebra.BigOperators.GroupWithZero.Finset
|
| 4 |
-
|
| 5 |
-
namespace OAI
|
| 6 |
-
|
| 7 |
-
/-! # Product Laws -/
|
| 8 |
-
|
| 9 |
-
noncomputable section
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
namespace HadwigerCounterexample
|
| 12 |
-
|
| 13 |
-
theorem ind_all {ι : Type*} [Fintype ι] (p : ι → Prop) :
|
| 14 |
-
ind (∀ i, p i) = ∏ i, ind (p i) := by
|
| 15 |
-
classical
|
| 16 |
-
simp [ind, Fintype.prod_ite_zero]
|
| 17 |
-
|
| 18 |
-
variable {ι κ α : Type*}
|
| 19 |
-
variable {β : ι → Type*}
|
| 20 |
-
|
| 21 |
-
def prodW [Fintype ι] (w : ∀ i, Wgt (β i)) : Wgt (∀ i, β i) := fun x => ∏ i, w i (x i)
|
| 22 |
-
|
| 23 |
-
section
|
| 24 |
-
variable [Fintype ι] [DecidableEq ι] [∀ i, Fintype (β i)]
|
| 25 |
-
|
| 26 |
-
theorem prodW_tot (w : ∀ i, Wgt (β i)) : tot (prodW w) = ∏ i, tot (w i) :=
|
| 27 |
-
(Fintype.prod_sum w).symm
|
| 28 |
-
|
| 29 |
-
theorem prodW_avg (w f : ∀ i, Wgt (β i)) :
|
| 30 |
-
avg (prodW w) (prodW f) = ∏ i, avg (w i) (f i) := by
|
| 31 |
-
simp only [avg, prodW]
|
| 32 |
-
rw [Fintype.prod_sum]
|
| 33 |
-
simp only [Finset.prod_mul_distrib]
|
| 34 |
-
|
| 35 |
-
theorem prodW_pr (w : ∀ i, Wgt (β i)) (p : ∀ i, β i → Prop) :
|
| 36 |
-
pr (prodW w) (fun x => ∀ i, p i (x i)) = ∏ i, pr (w i) (p i) := by
|
| 37 |
-
simp_rw [pr, ind_all]
|
| 38 |
-
exact prodW_avg w (fun i x => ind (p i x))
|
| 39 |
-
|
| 40 |
-
omit [DecidableEq ι] [∀ i, Fintype (β i)] in
|
| 41 |
-
theorem prodW_nonneg {w : ∀ i, Wgt (β i)} (h : ∀ i x, 0 ≤ w i x) (x) : 0 ≤ prodW w x :=
|
| 42 |
-
Finset.prod_nonneg (fun i _ => h i _)
|
| 43 |
-
|
| 44 |
-
theorem prodW_law {w : ∀ i, Wgt (β i)} (hw : ∀ i, IsLaw (w i)) : IsLaw (prodW w) := by
|
| 45 |
-
refine ⟨prodW_nonneg (fun i => (hw i).nz), ?_⟩
|
| 46 |
-
rw [prodW_tot]
|
| 47 |
-
simp_rw [(hw _).total]
|
| 48 |
-
simp
|
| 49 |
-
|
| 50 |
-
end
|
| 51 |
-
|
| 52 |
-
section
|
| 53 |
-
variable [Fintype ι] [Fintype κ] [Fintype α] [DecidableEq κ]
|
| 54 |
-
/-- Observe distinct coordinates of a (constant-type) product law. -/
|
| 55 |
-
theorem prodW_pr_inj {e : ι → κ} (he : Function.Injective e)
|
| 56 |
-
{w : κ → Wgt α} (hw : ∀ k, IsLaw (w k)) (p : ι → α → Prop) :
|
| 57 |
-
pr (prodW (β:=fun _ => α) w) (fun x => ∀ i, p i (x (e i))) =
|
| 58 |
-
∏ i, pr (w (e i)) (p i) := by
|
| 59 |
-
classical
|
| 60 |
-
let P (k : κ) (x : α) := ∀ i, e i = k → p i x
|
| 61 |
-
have h (x : κ → α) : (∀ i, p i (x (e i))) ↔ ∀ k, P k (x k) :=
|
| 62 |
-
⟨fun h k i hi => hi ▸ h i, fun h i => h (e i) i rfl⟩
|
| 63 |
-
simp_rw [h]
|
| 64 |
-
rw [prodW_pr _ P]
|
| 65 |
-
let f (k : κ) (i : ι) := if e i = k then pr (w k) (p i) else 1
|
| 66 |
-
have hf (k : κ) : pr (w k) (P k) = ∏ i, f k i := by
|
| 67 |
-
by_cases hk : ∃ i, e i = k
|
| 68 |
-
· obtain ⟨i, rfl⟩ := hk
|
| 69 |
-
have hP : P (e i) = p i := funext fun x => propext
|
| 70 |
-
⟨fun h => h i rfl, fun h j hj => (he hj).symm ▸ h⟩
|
| 71 |
-
rw [hP]
|
| 72 |
-
symm
|
| 73 |
-
rw [Finset.prod_eq_single i]
|
| 74 |
-
· simp [f]
|
| 75 |
-
· intro j _ hj
|
| 76 |
-
simp [f, show e j ≠ e i from he.ne hj]
|
| 77 |
-
· simp
|
| 78 |
-
· push Not at hk
|
| 79 |
-
have hP : P k = (fun _ => True) := funext fun _ => propext
|
| 80 |
-
⟨fun _ => trivial, fun _ j hj => (hk j hj).elim⟩
|
| 81 |
-
simp [hP, (hw k).total, f, hk]
|
| 82 |
-
simp_rw [hf]
|
| 83 |
-
rw [Finset.prod_comm]
|
| 84 |
-
simp [f]
|
| 85 |
-
|
| 86 |
-
theorem prodW_map_inj {e : ι → κ} (he : Function.Injective e)
|
| 87 |
-
{w : κ → Wgt α} (hw : ∀ k, IsLaw (w k)) :
|
| 88 |
-
mapW (prodW (β := fun _ => α) w) (fun x : κ → α => fun i : ι => x (e i)) =
|
| 89 |
-
prodW (β := fun _ => α) (fun i => w (e i)) := by
|
| 90 |
-
funext x
|
| 91 |
-
unfold mapW
|
| 92 |
-
simp_rw [funext_iff]
|
| 93 |
-
have h := prodW_pr_inj he hw (fun i y => y = x i)
|
| 94 |
-
simp_rw [pr_point'] at h
|
| 95 |
-
exact h
|
| 96 |
-
|
| 97 |
-
/-- Mapping to ordered pairs along a disjoint family of positions. -/
|
| 98 |
-
theorem prodW_map_pairs (e : ι ⊕ ι → κ) (he : Function.Injective e)
|
| 99 |
-
{w : Wgt α} (hw : IsLaw w) :
|
| 100 |
-
mapW (prodW (fun _ : κ => w))
|
| 101 |
-
(fun x i => (x (e (.inl i)), x (e (.inr i)))) =
|
| 102 |
-
prodW (fun _ : ι => pairW w w) := by
|
| 103 |
-
funext y
|
| 104 |
-
let p (j : ι ⊕ ι) (x : α) := j.elim (fun i => x = (y i).1) (fun i => x = (y i).2)
|
| 105 |
-
have heq (x : κ → α) :
|
| 106 |
-
((fun i => (x (e (.inl i)), x (e (.inr i)))) = y) ↔ ∀ j, p j (x (e j)) := by
|
| 107 |
-
simp [funext_iff, Prod.ext_iff, p, Sum.forall, forall_and]
|
| 108 |
-
unfold mapW
|
| 109 |
-
simp_rw [heq]
|
| 110 |
-
have h := prodW_pr_inj he (w:=fun _ => w) (fun _ => hw) p
|
| 111 |
-
rw [h]
|
| 112 |
-
simp [Fintype.prod_sum_type, p, prodW, pairW, Finset.prod_mul_distrib]
|
| 113 |
-
|
| 114 |
-
end
|
| 115 |
-
end HadwigerCounterexample
|
| 116 |
-
|
| 117 |
-
end
|
| 118 |
-
|
| 119 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteLaws
|
| 2 |
+
import Mathlib.Data.Fintype.Pi
|
| 3 |
+
import Mathlib.Algebra.BigOperators.GroupWithZero.Finset
|
| 4 |
+
|
| 5 |
+
namespace OAI
|
| 6 |
+
|
| 7 |
+
/-! # Product Laws -/
|
| 8 |
+
|
| 9 |
+
noncomputable section
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
namespace HadwigerCounterexample
|
| 12 |
+
|
| 13 |
+
theorem ind_all {ι : Type*} [Fintype ι] (p : ι → Prop) :
|
| 14 |
+
ind (∀ i, p i) = ∏ i, ind (p i) := by
|
| 15 |
+
classical
|
| 16 |
+
simp [ind, Fintype.prod_ite_zero]
|
| 17 |
+
|
| 18 |
+
variable {ι κ α : Type*}
|
| 19 |
+
variable {β : ι → Type*}
|
| 20 |
+
|
| 21 |
+
def prodW [Fintype ι] (w : ∀ i, Wgt (β i)) : Wgt (∀ i, β i) := fun x => ∏ i, w i (x i)
|
| 22 |
+
|
| 23 |
+
section
|
| 24 |
+
variable [Fintype ι] [DecidableEq ι] [∀ i, Fintype (β i)]
|
| 25 |
+
|
| 26 |
+
theorem prodW_tot (w : ∀ i, Wgt (β i)) : tot (prodW w) = ∏ i, tot (w i) :=
|
| 27 |
+
(Fintype.prod_sum w).symm
|
| 28 |
+
|
| 29 |
+
theorem prodW_avg (w f : ∀ i, Wgt (β i)) :
|
| 30 |
+
avg (prodW w) (prodW f) = ∏ i, avg (w i) (f i) := by
|
| 31 |
+
simp only [avg, prodW]
|
| 32 |
+
rw [Fintype.prod_sum]
|
| 33 |
+
simp only [Finset.prod_mul_distrib]
|
| 34 |
+
|
| 35 |
+
theorem prodW_pr (w : ∀ i, Wgt (β i)) (p : ∀ i, β i → Prop) :
|
| 36 |
+
pr (prodW w) (fun x => ∀ i, p i (x i)) = ∏ i, pr (w i) (p i) := by
|
| 37 |
+
simp_rw [pr, ind_all]
|
| 38 |
+
exact prodW_avg w (fun i x => ind (p i x))
|
| 39 |
+
|
| 40 |
+
omit [DecidableEq ι] [∀ i, Fintype (β i)] in
|
| 41 |
+
theorem prodW_nonneg {w : ∀ i, Wgt (β i)} (h : ∀ i x, 0 ≤ w i x) (x) : 0 ≤ prodW w x :=
|
| 42 |
+
Finset.prod_nonneg (fun i _ => h i _)
|
| 43 |
+
|
| 44 |
+
theorem prodW_law {w : ∀ i, Wgt (β i)} (hw : ∀ i, IsLaw (w i)) : IsLaw (prodW w) := by
|
| 45 |
+
refine ⟨prodW_nonneg (fun i => (hw i).nz), ?_⟩
|
| 46 |
+
rw [prodW_tot]
|
| 47 |
+
simp_rw [(hw _).total]
|
| 48 |
+
simp
|
| 49 |
+
|
| 50 |
+
end
|
| 51 |
+
|
| 52 |
+
section
|
| 53 |
+
variable [Fintype ι] [Fintype κ] [Fintype α] [DecidableEq κ]
|
| 54 |
+
/-- Observe distinct coordinates of a (constant-type) product law. -/
|
| 55 |
+
theorem prodW_pr_inj {e : ι → κ} (he : Function.Injective e)
|
| 56 |
+
{w : κ → Wgt α} (hw : ∀ k, IsLaw (w k)) (p : ι → α → Prop) :
|
| 57 |
+
pr (prodW (β:=fun _ => α) w) (fun x => ∀ i, p i (x (e i))) =
|
| 58 |
+
∏ i, pr (w (e i)) (p i) := by
|
| 59 |
+
classical
|
| 60 |
+
let P (k : κ) (x : α) := ∀ i, e i = k → p i x
|
| 61 |
+
have h (x : κ → α) : (∀ i, p i (x (e i))) ↔ ∀ k, P k (x k) :=
|
| 62 |
+
⟨fun h k i hi => hi ▸ h i, fun h i => h (e i) i rfl⟩
|
| 63 |
+
simp_rw [h]
|
| 64 |
+
rw [prodW_pr _ P]
|
| 65 |
+
let f (k : κ) (i : ι) := if e i = k then pr (w k) (p i) else 1
|
| 66 |
+
have hf (k : κ) : pr (w k) (P k) = ∏ i, f k i := by
|
| 67 |
+
by_cases hk : ∃ i, e i = k
|
| 68 |
+
· obtain ⟨i, rfl⟩ := hk
|
| 69 |
+
have hP : P (e i) = p i := funext fun x => propext
|
| 70 |
+
⟨fun h => h i rfl, fun h j hj => (he hj).symm ▸ h⟩
|
| 71 |
+
rw [hP]
|
| 72 |
+
symm
|
| 73 |
+
rw [Finset.prod_eq_single i]
|
| 74 |
+
· simp [f]
|
| 75 |
+
· intro j _ hj
|
| 76 |
+
simp [f, show e j ≠ e i from he.ne hj]
|
| 77 |
+
· simp
|
| 78 |
+
· push Not at hk
|
| 79 |
+
have hP : P k = (fun _ => True) := funext fun _ => propext
|
| 80 |
+
⟨fun _ => trivial, fun _ j hj => (hk j hj).elim⟩
|
| 81 |
+
simp [hP, (hw k).total, f, hk]
|
| 82 |
+
simp_rw [hf]
|
| 83 |
+
rw [Finset.prod_comm]
|
| 84 |
+
simp [f]
|
| 85 |
+
|
| 86 |
+
theorem prodW_map_inj {e : ι → κ} (he : Function.Injective e)
|
| 87 |
+
{w : κ → Wgt α} (hw : ∀ k, IsLaw (w k)) :
|
| 88 |
+
mapW (prodW (β := fun _ => α) w) (fun x : κ → α => fun i : ι => x (e i)) =
|
| 89 |
+
prodW (β := fun _ => α) (fun i => w (e i)) := by
|
| 90 |
+
funext x
|
| 91 |
+
unfold mapW
|
| 92 |
+
simp_rw [funext_iff]
|
| 93 |
+
have h := prodW_pr_inj he hw (fun i y => y = x i)
|
| 94 |
+
simp_rw [pr_point'] at h
|
| 95 |
+
exact h
|
| 96 |
+
|
| 97 |
+
/-- Mapping to ordered pairs along a disjoint family of positions. -/
|
| 98 |
+
theorem prodW_map_pairs (e : ι ⊕ ι → κ) (he : Function.Injective e)
|
| 99 |
+
{w : Wgt α} (hw : IsLaw w) :
|
| 100 |
+
mapW (prodW (fun _ : κ => w))
|
| 101 |
+
(fun x i => (x (e (.inl i)), x (e (.inr i)))) =
|
| 102 |
+
prodW (fun _ : ι => pairW w w) := by
|
| 103 |
+
funext y
|
| 104 |
+
let p (j : ι ⊕ ι) (x : α) := j.elim (fun i => x = (y i).1) (fun i => x = (y i).2)
|
| 105 |
+
have heq (x : κ → α) :
|
| 106 |
+
((fun i => (x (e (.inl i)), x (e (.inr i)))) = y) ↔ ∀ j, p j (x (e j)) := by
|
| 107 |
+
simp [funext_iff, Prod.ext_iff, p, Sum.forall, forall_and]
|
| 108 |
+
unfold mapW
|
| 109 |
+
simp_rw [heq]
|
| 110 |
+
have h := prodW_pr_inj he (w:=fun _ => w) (fun _ => hw) p
|
| 111 |
+
rw [h]
|
| 112 |
+
simp [Fintype.prod_sum_type, p, prodW, pairW, Finset.prod_mul_distrib]
|
| 113 |
+
|
| 114 |
+
end
|
| 115 |
+
end HadwigerCounterexample
|
| 116 |
+
|
| 117 |
+
end
|
| 118 |
+
|
| 119 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProjectedSurrogates.lean
CHANGED
|
@@ -1,159 +1,159 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.CommonPartitions
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Projected Surrogates -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B I J : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J]
|
| 12 |
-
|
| 13 |
-
def bower (f : Wgt A) := (∀ i,0≤ f i)∧ (∀ i,f i≤1)
|
| 14 |
-
omit [Fintype B] in
|
| 15 |
-
theorem book_order (w : Wgt A) (p : A→ B) (hw : IsLaw w)
|
| 16 |
-
(f g : Wgt A) (h : ∀ i, f i≤ g i) (x) :
|
| 17 |
-
cashbook w p f x ≤ cashbook w p g x := by
|
| 18 |
-
apply div_le_div_of_nonneg_right _ (map_nz hw.nz p x)
|
| 19 |
-
exact pr_mono_left (fun i=> mul_le_mul_of_nonneg_left (h i) (hw.nz i)) _
|
| 20 |
-
omit [Fintype B] in
|
| 21 |
-
theorem book_nonneg (w : Wgt A) (p : A→B) (hw : IsLaw w) (f : Wgt A) (hf : ∀ i,0 ≤ f i) (x) :
|
| 22 |
-
0 ≤ cashbook w p f x := div_nonneg (pr_nonneg (fun i=>mul_nonneg (hw.nz i) (hf i))) (map_nz hw.nz p x)
|
| 23 |
-
omit [Fintype B] in
|
| 24 |
-
theorem garden (w f : Wgt A) (p : A→B) (hw : IsLaw w) (hf : bower f) :
|
| 25 |
-
bower (banner w p f) := by
|
| 26 |
-
refine ⟨fun i=> book_nonneg w p hw f hf.1 _,fun i=>?_⟩
|
| 27 |
-
exact (le_abs_self _).trans (cashbook_bound w hw.nz p f 1 zero_le_one (fun i=>by
|
| 28 |
-
rw [abs_of_nonneg (hf.1 _)]; exact hf.2 _) _)
|
| 29 |
-
theorem projected_min (w : Wgt A) (p : A→B) (hw : IsLaw w) (f g : Wgt A)
|
| 30 |
-
(hf : bower f) (hg : bower g) :
|
| 31 |
-
dip w f g ^2 ≤ dip w (banner w p f) (banner w p g) := by
|
| 32 |
-
let h i := f i*g i
|
| 33 |
-
let u := banner w p h
|
| 34 |
-
have hi : dip w f g=avg w u := by
|
| 35 |
-
have hh := cash_orth w hw.nz p h (fun _=>1)
|
| 36 |
-
simpa only [dip,u,Function.comp_apply,mul_one,h] using hh.symm
|
| 37 |
-
have hh (i) :
|
| 38 |
-
u i^2 ≤ banner w p f i*banner w p g i := by
|
| 39 |
-
have h0 : bower u := garden w h p hw ⟨fun i=>mul_nonneg (hf.1 _) (hg.1 _),fun i=>
|
| 40 |
-
(mul_le_mul (hf.2 _) (hg.2 _) (hg.1 _) zero_le_one).trans_eq (one_mul _)⟩
|
| 41 |
-
have h1 (i) : h i≤ f i :=
|
| 42 |
-
((mul_le_mul_of_nonneg_left (hg.2 _) (hf.1 _)).trans_eq (mul_one _))
|
| 43 |
-
have h2 (i) : h i≤g i :=
|
| 44 |
-
((mul_le_mul_of_nonneg_right (hf.2 _) (hg.1 _)).trans_eq (one_mul _))
|
| 45 |
-
rw [pow_two]; exact mul_le_mul (book_order w p hw h f h1 _) (book_order w p hw h g h2 _)
|
| 46 |
-
(h0.1 i) ((garden w f p hw hf).1 i)
|
| 47 |
-
rw [hi]; exact (mean_sq w hw u).trans (avg_mono hw.nz hh)
|
| 48 |
-
|
| 49 |
-
def trayLoss (R : ℝ) (u f : Wgt A) := pr f (fun i => R≤density u f i)
|
| 50 |
-
omit [Fintype A] in
|
| 51 |
-
theorem dresso (u f : Wgt A) (h : lsupp f u) : f = fun i => u i*density u f i := by
|
| 52 |
-
funext i; unfold density
|
| 53 |
-
by_cases he : f i=0
|
| 54 |
-
· simp only [he,zero_div,mul_zero]
|
| 55 |
-
have hh := h i he
|
| 56 |
-
field_simp
|
| 57 |
-
|
| 58 |
-
theorem density_error (w : Wgt A) (p : A→B) (hw : IsLaw w) (f g : Wgt A) (hz : lsupp g w) :
|
| 59 |
-
lcost w (banner w p f) (banner w p (density w g))≤
|
| 60 |
-
varOne (mapW (fun i=>w i*f i) p) (mapW g p) := by
|
| 61 |
-
classical
|
| 62 |
-
let x i := |cashbook w p f i-cashbook w p (density w g) i|
|
| 63 |
-
have he :
|
| 64 |
-
lcost w (banner w p f) (banner w p (density w g))=avg (mapW w p) x :=
|
| 65 |
-
(mapW_avg w p x).symm
|
| 66 |
-
rw [he]; unfold avg varOne
|
| 67 |
-
refine sum_le_sum fun i _=>?_
|
| 68 |
-
let V:=mapW w p i; let A:= mapW (fun i=> w i*f i) p i; let B:= mapW g p i
|
| 69 |
-
have hh : x i= |A-B|/V := by
|
| 70 |
-
unfold x cashbook A B V
|
| 71 |
-
rw [← dresso w g hz,←sub_div,abs_div,abs_of_nonneg (map_nz hw.nz ..)]
|
| 72 |
-
rw [hh]
|
| 73 |
-
by_cases h : V=0
|
| 74 |
-
· change V*_ ≤_
|
| 75 |
-
rw [h,zero_mul]; exact abs_nonneg _
|
| 76 |
-
change V*(|A-B|/V)≤ |A-B|
|
| 77 |
-
exact le_of_eq (by field_simp)
|
| 78 |
-
|
| 79 |
-
theorem density_trim (u f : Wgt A) (h : ∀ i,0≤f i) (hu : IsLaw u)
|
| 80 |
-
(R : ℝ) (hR : 0≤R) :
|
| 81 |
-
(∀ i,mcut R u f i ≤ density u f i) ∧ lcost u (density u f) (mcut R u f)≤trayLoss R u f := by
|
| 82 |
-
have h1 (i:A) : 0≤density u f i := div_nonneg (h _) (hu.nz _)
|
| 83 |
-
have h2 (i) :
|
| 84 |
-
mcut R u f i=min (density u f i) R := congrArg (fun x=>min x R) (max_eq_left (h1 _))
|
| 85 |
-
have h3 (i) := show mcut R u f i ≤ density u f i from le_trans (le_of_eq (h2 i)) (min_le_left ..)
|
| 86 |
-
refine ⟨h3,Finset.sum_le_sum (fun i _=>?_)⟩
|
| 87 |
-
change u i*|density u f i-mcut R u f i| ≤ f i* ind _
|
| 88 |
-
rw [abs_of_nonneg (sub_nonneg.mpr (h3 _)),h2]
|
| 89 |
-
by_cases hz : R≤density u f i
|
| 90 |
-
· rw [ind_one hz,mul_one,min_eq_right hz]
|
| 91 |
-
have hm := hu.nz i
|
| 92 |
-
by_cases hg : u i=0
|
| 93 |
-
· rw [hg,zero_mul]; exact h _
|
| 94 |
-
apply le_trans (mul_le_mul_of_nonneg_left (sub_le_self _ hR) hm) (le_of_eq ?_)
|
| 95 |
-
unfold density; field_simp
|
| 96 |
-
rw [ind_zero hz,mul_zero,min_eq_left (le_of_not_ge hz),sub_self,mul_zero]
|
| 97 |
-
|
| 98 |
-
private theorem cost_gap (u : Wgt A) (p : A→B) (f g : Wgt A) (h : ∀ i,g i≤ f i)
|
| 99 |
-
(hu : IsLaw u) :
|
| 100 |
-
lcost u (banner u p f) (banner u p g)=lcost u f g := by
|
| 101 |
-
have hf (i : A) : |banner u p f i-banner u p g i|=banner u p f i-banner u p g i :=
|
| 102 |
-
abs_of_nonneg (sub_nonneg.mpr (book_order u p hu g f h _))
|
| 103 |
-
have hg (f : Wgt A) : avg u f = avg u (banner u p f) := by
|
| 104 |
-
have hh := cash_orth u hu.nz p f (fun _=>1); simpa only [dip,Function.comp_apply,mul_one] using hh.symm
|
| 105 |
-
unfold lcost; simp_rw [hf, abs_of_nonneg (sub_nonneg.mpr (h _)), avg_sub]
|
| 106 |
-
rw [← hg f, ← hg g]
|
| 107 |
-
|
| 108 |
-
set_option maxHeartbeats 800000 in
|
| 109 |
-
theorem density_mend (u : Wgt A) (hu : IsLaw u) (p : A→B) (R : ℝ) (hR : 0≤ R)
|
| 110 |
-
(f g x y : Wgt A) (hf : bower f) (hg : bower g) (hx : SubLaw x)
|
| 111 |
-
(hy : SubLaw y) (h1 : lsupp x u) (h2 : lsupp y u) :
|
| 112 |
-
let V f g := varOne (mapW (fun i=>u i*f i) p) (mapW g p)+trayLoss R u g
|
| 113 |
-
dip u f g ^ 2 ≤ overlap u x y + |rebate u (mcut R u x) (mcut R u y) p|+
|
| 114 |
-
(V f x+V g y) := by
|
| 115 |
-
classical
|
| 116 |
-
intro V
|
| 117 |
-
let F:=banner u p f; let G:=banner u p g
|
| 118 |
-
let X:=banner u p (mcut R u x); let Y:=banner u p (mcut R u y)
|
| 119 |
-
have he (f x : Wgt A) (hx : SubLaw x) (h : lsupp x u) :
|
| 120 |
-
lcost u (banner u p f) (banner u p (mcut R u x)) ≤ V f x := by
|
| 121 |
-
let F := banner u p f; let X:=banner u p (density u x); let Z:=banner u p (mcut R u x)
|
| 122 |
-
obtain ⟨h1,h2⟩:=density_trim u x hx.nz hu R hR
|
| 123 |
-
have hh : lcost u F Z≤lcost u F X+lcost u X Z := by
|
| 124 |
-
unfold lcost; rw [← avg_add]; exact avg_mono hu.nz fun i=>abs_sub_le _ _ _
|
| 125 |
-
exact hh.trans (add_le_add (density_error u p hu f x h)
|
| 126 |
-
(le_trans (cost_gap u p (density u x) _ h1 hu).le h2))
|
| 127 |
-
have hh i : F i*G i ≤ X i*Y i + (|F i-X i|+|G i-Y i|) := by
|
| 128 |
-
have hA := (garden u f p hu hf).2 i; have hB := (garden u g p hu hg).2 i
|
| 129 |
-
have ht : 0≤X i := book_nonneg u p hu _ (fun i=> (mcut_range _ _ _ hR i).1) _
|
| 130 |
-
have hq : 0≤Y i := book_nonneg u p hu _ (fun i=> (mcut_range _ _ _ hR i).1) _
|
| 131 |
-
have hp := (garden u f p hu hf).1 i
|
| 132 |
-
by_cases h : X i≤F i
|
| 133 |
-
· by_cases h' : Y i≤ G i
|
| 134 |
-
· nlinarith only [ht,hq,h,h',hA,hB, le_abs_self (F i-X i),le_abs_self (G i-Y i)]
|
| 135 |
-
have hz := le_of_not_ge h'
|
| 136 |
-
nlinarith only [h,hB,hz,le_abs_self (F i-X i),abs_nonneg (G i-Y i),ht]
|
| 137 |
-
have hz := le_of_not_ge h
|
| 138 |
-
by_cases h' : Y i≤ G i
|
| 139 |
-
· nlinarith only [hA,hq,h',hz,abs_nonneg (F i-X i),le_abs_self (G i-Y i)]
|
| 140 |
-
have hi := le_of_not_ge h'
|
| 141 |
-
nlinarith only [hz,hq,hi,hp,abs_nonneg (F i-X i), abs_nonneg (G i-Y i)]
|
| 142 |
-
let A:= mcut R u x; let B:=mcut R u y
|
| 143 |
-
have hz : dip u A B≤overlap u x y :=
|
| 144 |
-
avg_mono hu.nz (fun i=>mul_le_mul ((density_trim u x hx.nz hu _ hR).1 _)
|
| 145 |
-
((density_trim u y hy.nz hu _ hR).1 _) ((mcut_range R u y hR i).1)
|
| 146 |
-
(div_nonneg (hx.nz _) (hu.nz _)))
|
| 147 |
-
have h :
|
| 148 |
-
dip u X Y≤overlap u x y + |rebate u A B p| := by
|
| 149 |
-
have h : dip u X Y-dip u A B ≤|dip u A B-dip u X Y| := by rw [abs_sub_comm]; exact le_abs_self _
|
| 150 |
-
change _≤ _+ |dip u A B - dip u X Y|; linarith only [h,hz]
|
| 151 |
-
have hp := avg_mono hu.nz hh
|
| 152 |
-
rw [avg_add,avg_add] at hp
|
| 153 |
-
exact (le_trans (projected_min u p hu f g hf hg) hp).trans
|
| 154 |
-
(add_le_add h (add_le_add (he f x hx h1) (he g y hy h2)))
|
| 155 |
-
end HadwigerCounterexample
|
| 156 |
-
|
| 157 |
-
end
|
| 158 |
-
|
| 159 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.CommonPartitions
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Projected Surrogates -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B I J : Type} [Fintype A] [Fintype B] [Fintype I] [Fintype J]
|
| 12 |
+
|
| 13 |
+
def bower (f : Wgt A) := (∀ i,0≤ f i)∧ (∀ i,f i≤1)
|
| 14 |
+
omit [Fintype B] in
|
| 15 |
+
theorem book_order (w : Wgt A) (p : A→ B) (hw : IsLaw w)
|
| 16 |
+
(f g : Wgt A) (h : ∀ i, f i≤ g i) (x) :
|
| 17 |
+
cashbook w p f x ≤ cashbook w p g x := by
|
| 18 |
+
apply div_le_div_of_nonneg_right _ (map_nz hw.nz p x)
|
| 19 |
+
exact pr_mono_left (fun i=> mul_le_mul_of_nonneg_left (h i) (hw.nz i)) _
|
| 20 |
+
omit [Fintype B] in
|
| 21 |
+
theorem book_nonneg (w : Wgt A) (p : A→B) (hw : IsLaw w) (f : Wgt A) (hf : ∀ i,0 ≤ f i) (x) :
|
| 22 |
+
0 ≤ cashbook w p f x := div_nonneg (pr_nonneg (fun i=>mul_nonneg (hw.nz i) (hf i))) (map_nz hw.nz p x)
|
| 23 |
+
omit [Fintype B] in
|
| 24 |
+
theorem garden (w f : Wgt A) (p : A→B) (hw : IsLaw w) (hf : bower f) :
|
| 25 |
+
bower (banner w p f) := by
|
| 26 |
+
refine ⟨fun i=> book_nonneg w p hw f hf.1 _,fun i=>?_⟩
|
| 27 |
+
exact (le_abs_self _).trans (cashbook_bound w hw.nz p f 1 zero_le_one (fun i=>by
|
| 28 |
+
rw [abs_of_nonneg (hf.1 _)]; exact hf.2 _) _)
|
| 29 |
+
theorem projected_min (w : Wgt A) (p : A→B) (hw : IsLaw w) (f g : Wgt A)
|
| 30 |
+
(hf : bower f) (hg : bower g) :
|
| 31 |
+
dip w f g ^2 ≤ dip w (banner w p f) (banner w p g) := by
|
| 32 |
+
let h i := f i*g i
|
| 33 |
+
let u := banner w p h
|
| 34 |
+
have hi : dip w f g=avg w u := by
|
| 35 |
+
have hh := cash_orth w hw.nz p h (fun _=>1)
|
| 36 |
+
simpa only [dip,u,Function.comp_apply,mul_one,h] using hh.symm
|
| 37 |
+
have hh (i) :
|
| 38 |
+
u i^2 ≤ banner w p f i*banner w p g i := by
|
| 39 |
+
have h0 : bower u := garden w h p hw ⟨fun i=>mul_nonneg (hf.1 _) (hg.1 _),fun i=>
|
| 40 |
+
(mul_le_mul (hf.2 _) (hg.2 _) (hg.1 _) zero_le_one).trans_eq (one_mul _)⟩
|
| 41 |
+
have h1 (i) : h i≤ f i :=
|
| 42 |
+
((mul_le_mul_of_nonneg_left (hg.2 _) (hf.1 _)).trans_eq (mul_one _))
|
| 43 |
+
have h2 (i) : h i≤g i :=
|
| 44 |
+
((mul_le_mul_of_nonneg_right (hf.2 _) (hg.1 _)).trans_eq (one_mul _))
|
| 45 |
+
rw [pow_two]; exact mul_le_mul (book_order w p hw h f h1 _) (book_order w p hw h g h2 _)
|
| 46 |
+
(h0.1 i) ((garden w f p hw hf).1 i)
|
| 47 |
+
rw [hi]; exact (mean_sq w hw u).trans (avg_mono hw.nz hh)
|
| 48 |
+
|
| 49 |
+
def trayLoss (R : ℝ) (u f : Wgt A) := pr f (fun i => R≤density u f i)
|
| 50 |
+
omit [Fintype A] in
|
| 51 |
+
theorem dresso (u f : Wgt A) (h : lsupp f u) : f = fun i => u i*density u f i := by
|
| 52 |
+
funext i; unfold density
|
| 53 |
+
by_cases he : f i=0
|
| 54 |
+
· simp only [he,zero_div,mul_zero]
|
| 55 |
+
have hh := h i he
|
| 56 |
+
field_simp
|
| 57 |
+
|
| 58 |
+
theorem density_error (w : Wgt A) (p : A→B) (hw : IsLaw w) (f g : Wgt A) (hz : lsupp g w) :
|
| 59 |
+
lcost w (banner w p f) (banner w p (density w g))≤
|
| 60 |
+
varOne (mapW (fun i=>w i*f i) p) (mapW g p) := by
|
| 61 |
+
classical
|
| 62 |
+
let x i := |cashbook w p f i-cashbook w p (density w g) i|
|
| 63 |
+
have he :
|
| 64 |
+
lcost w (banner w p f) (banner w p (density w g))=avg (mapW w p) x :=
|
| 65 |
+
(mapW_avg w p x).symm
|
| 66 |
+
rw [he]; unfold avg varOne
|
| 67 |
+
refine sum_le_sum fun i _=>?_
|
| 68 |
+
let V:=mapW w p i; let A:= mapW (fun i=> w i*f i) p i; let B:= mapW g p i
|
| 69 |
+
have hh : x i= |A-B|/V := by
|
| 70 |
+
unfold x cashbook A B V
|
| 71 |
+
rw [← dresso w g hz,←sub_div,abs_div,abs_of_nonneg (map_nz hw.nz ..)]
|
| 72 |
+
rw [hh]
|
| 73 |
+
by_cases h : V=0
|
| 74 |
+
· change V*_ ≤_
|
| 75 |
+
rw [h,zero_mul]; exact abs_nonneg _
|
| 76 |
+
change V*(|A-B|/V)≤ |A-B|
|
| 77 |
+
exact le_of_eq (by field_simp)
|
| 78 |
+
|
| 79 |
+
theorem density_trim (u f : Wgt A) (h : ∀ i,0≤f i) (hu : IsLaw u)
|
| 80 |
+
(R : ℝ) (hR : 0≤R) :
|
| 81 |
+
(∀ i,mcut R u f i ≤ density u f i) ∧ lcost u (density u f) (mcut R u f)≤trayLoss R u f := by
|
| 82 |
+
have h1 (i:A) : 0≤density u f i := div_nonneg (h _) (hu.nz _)
|
| 83 |
+
have h2 (i) :
|
| 84 |
+
mcut R u f i=min (density u f i) R := congrArg (fun x=>min x R) (max_eq_left (h1 _))
|
| 85 |
+
have h3 (i) := show mcut R u f i ≤ density u f i from le_trans (le_of_eq (h2 i)) (min_le_left ..)
|
| 86 |
+
refine ⟨h3,Finset.sum_le_sum (fun i _=>?_)⟩
|
| 87 |
+
change u i*|density u f i-mcut R u f i| ≤ f i* ind _
|
| 88 |
+
rw [abs_of_nonneg (sub_nonneg.mpr (h3 _)),h2]
|
| 89 |
+
by_cases hz : R≤density u f i
|
| 90 |
+
· rw [ind_one hz,mul_one,min_eq_right hz]
|
| 91 |
+
have hm := hu.nz i
|
| 92 |
+
by_cases hg : u i=0
|
| 93 |
+
· rw [hg,zero_mul]; exact h _
|
| 94 |
+
apply le_trans (mul_le_mul_of_nonneg_left (sub_le_self _ hR) hm) (le_of_eq ?_)
|
| 95 |
+
unfold density; field_simp
|
| 96 |
+
rw [ind_zero hz,mul_zero,min_eq_left (le_of_not_ge hz),sub_self,mul_zero]
|
| 97 |
+
|
| 98 |
+
private theorem cost_gap (u : Wgt A) (p : A→B) (f g : Wgt A) (h : ∀ i,g i≤ f i)
|
| 99 |
+
(hu : IsLaw u) :
|
| 100 |
+
lcost u (banner u p f) (banner u p g)=lcost u f g := by
|
| 101 |
+
have hf (i : A) : |banner u p f i-banner u p g i|=banner u p f i-banner u p g i :=
|
| 102 |
+
abs_of_nonneg (sub_nonneg.mpr (book_order u p hu g f h _))
|
| 103 |
+
have hg (f : Wgt A) : avg u f = avg u (banner u p f) := by
|
| 104 |
+
have hh := cash_orth u hu.nz p f (fun _=>1); simpa only [dip,Function.comp_apply,mul_one] using hh.symm
|
| 105 |
+
unfold lcost; simp_rw [hf, abs_of_nonneg (sub_nonneg.mpr (h _)), avg_sub]
|
| 106 |
+
rw [← hg f, ← hg g]
|
| 107 |
+
|
| 108 |
+
set_option maxHeartbeats 800000 in
|
| 109 |
+
theorem density_mend (u : Wgt A) (hu : IsLaw u) (p : A→B) (R : ℝ) (hR : 0≤ R)
|
| 110 |
+
(f g x y : Wgt A) (hf : bower f) (hg : bower g) (hx : SubLaw x)
|
| 111 |
+
(hy : SubLaw y) (h1 : lsupp x u) (h2 : lsupp y u) :
|
| 112 |
+
let V f g := varOne (mapW (fun i=>u i*f i) p) (mapW g p)+trayLoss R u g
|
| 113 |
+
dip u f g ^ 2 ≤ overlap u x y + |rebate u (mcut R u x) (mcut R u y) p|+
|
| 114 |
+
(V f x+V g y) := by
|
| 115 |
+
classical
|
| 116 |
+
intro V
|
| 117 |
+
let F:=banner u p f; let G:=banner u p g
|
| 118 |
+
let X:=banner u p (mcut R u x); let Y:=banner u p (mcut R u y)
|
| 119 |
+
have he (f x : Wgt A) (hx : SubLaw x) (h : lsupp x u) :
|
| 120 |
+
lcost u (banner u p f) (banner u p (mcut R u x)) ≤ V f x := by
|
| 121 |
+
let F := banner u p f; let X:=banner u p (density u x); let Z:=banner u p (mcut R u x)
|
| 122 |
+
obtain ⟨h1,h2⟩:=density_trim u x hx.nz hu R hR
|
| 123 |
+
have hh : lcost u F Z≤lcost u F X+lcost u X Z := by
|
| 124 |
+
unfold lcost; rw [← avg_add]; exact avg_mono hu.nz fun i=>abs_sub_le _ _ _
|
| 125 |
+
exact hh.trans (add_le_add (density_error u p hu f x h)
|
| 126 |
+
(le_trans (cost_gap u p (density u x) _ h1 hu).le h2))
|
| 127 |
+
have hh i : F i*G i ≤ X i*Y i + (|F i-X i|+|G i-Y i|) := by
|
| 128 |
+
have hA := (garden u f p hu hf).2 i; have hB := (garden u g p hu hg).2 i
|
| 129 |
+
have ht : 0≤X i := book_nonneg u p hu _ (fun i=> (mcut_range _ _ _ hR i).1) _
|
| 130 |
+
have hq : 0≤Y i := book_nonneg u p hu _ (fun i=> (mcut_range _ _ _ hR i).1) _
|
| 131 |
+
have hp := (garden u f p hu hf).1 i
|
| 132 |
+
by_cases h : X i≤F i
|
| 133 |
+
· by_cases h' : Y i≤ G i
|
| 134 |
+
· nlinarith only [ht,hq,h,h',hA,hB, le_abs_self (F i-X i),le_abs_self (G i-Y i)]
|
| 135 |
+
have hz := le_of_not_ge h'
|
| 136 |
+
nlinarith only [h,hB,hz,le_abs_self (F i-X i),abs_nonneg (G i-Y i),ht]
|
| 137 |
+
have hz := le_of_not_ge h
|
| 138 |
+
by_cases h' : Y i≤ G i
|
| 139 |
+
· nlinarith only [hA,hq,h',hz,abs_nonneg (F i-X i),le_abs_self (G i-Y i)]
|
| 140 |
+
have hi := le_of_not_ge h'
|
| 141 |
+
nlinarith only [hz,hq,hi,hp,abs_nonneg (F i-X i), abs_nonneg (G i-Y i)]
|
| 142 |
+
let A:= mcut R u x; let B:=mcut R u y
|
| 143 |
+
have hz : dip u A B≤overlap u x y :=
|
| 144 |
+
avg_mono hu.nz (fun i=>mul_le_mul ((density_trim u x hx.nz hu _ hR).1 _)
|
| 145 |
+
((density_trim u y hy.nz hu _ hR).1 _) ((mcut_range R u y hR i).1)
|
| 146 |
+
(div_nonneg (hx.nz _) (hu.nz _)))
|
| 147 |
+
have h :
|
| 148 |
+
dip u X Y≤overlap u x y + |rebate u A B p| := by
|
| 149 |
+
have h : dip u X Y-dip u A B ≤|dip u A B-dip u X Y| := by rw [abs_sub_comm]; exact le_abs_self _
|
| 150 |
+
change _≤ _+ |dip u A B - dip u X Y|; linarith only [h,hz]
|
| 151 |
+
have hp := avg_mono hu.nz hh
|
| 152 |
+
rw [avg_add,avg_add] at hp
|
| 153 |
+
exact (le_trans (projected_min u p hu f g hf hg) hp).trans
|
| 154 |
+
(add_le_add h (add_le_add (he f x hx h1) (he g y hy h2)))
|
| 155 |
+
end HadwigerCounterexample
|
| 156 |
+
|
| 157 |
+
end
|
| 158 |
+
|
| 159 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProjectionEnergy.lean
CHANGED
|
@@ -1,129 +1,129 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RelativeEntropy
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Projection Energy -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 12 |
-
|
| 13 |
-
theorem map_mass (p : Wgt A) (f : A→B) : tot (mapW p f)=tot p := by
|
| 14 |
-
simpa only [avg_const,mul_one] using mapW_avg p f (fun _ => 1)
|
| 15 |
-
omit [Fintype B] in
|
| 16 |
-
theorem map_nz {p : Wgt A} (hp : ∀ i, 0 ≤ p i) (f : A→B) (i : B) :
|
| 17 |
-
0 ≤ mapW p f i := pr_nonneg hp
|
| 18 |
-
omit [Fintype B] in
|
| 19 |
-
theorem lsupp_witness {p : Wgt A} {f : A→B} {i}
|
| 20 |
-
(h : mapW p f i≠0) : ∃ x,p x≠0 ∧ f x=i := by
|
| 21 |
-
classical
|
| 22 |
-
by_contra! hh
|
| 23 |
-
refine h (Finset.sum_eq_zero (fun x _ => ?_))
|
| 24 |
-
by_cases h : p x=0
|
| 25 |
-
· change p x * ind _=0
|
| 26 |
-
rw [h,zero_mul]
|
| 27 |
-
exact (congrArg (p x * ·) (ind_zero (hh x h))).trans (mul_zero _)
|
| 28 |
-
|
| 29 |
-
omit [Fintype B] in
|
| 30 |
-
theorem lsupp_hit {p : Wgt A} (hp : ∀ i,0 ≤ p i) (f : A→B) (x : A) (h : p x≠0) :
|
| 31 |
-
mapW p f (f x)≠0 := by
|
| 32 |
-
have h' := lt_of_le_of_ne (hp x) (Ne.symm h)
|
| 33 |
-
have he := weight_le_tot (fun y => mul_nonneg (hp y) (ind_nonneg (f y = f x))) x
|
| 34 |
-
simp only [ind_true,mul_one] at he
|
| 35 |
-
exact (h'.trans_le he).ne'
|
| 36 |
-
|
| 37 |
-
omit [Fintype B] in
|
| 38 |
-
theorem lsupp.map {p q : Wgt A} (h : lsupp p q) (hq : ∀ i,0 ≤ q i)
|
| 39 |
-
(f : A→B) : lsupp (mapW p f) (mapW q f) := by
|
| 40 |
-
intro i hi
|
| 41 |
-
obtain ⟨x,hx,rfl⟩ := lsupp_witness hi
|
| 42 |
-
exact lsupp_hit hq f x (h x hx)
|
| 43 |
-
|
| 44 |
-
omit [Fintype C] in
|
| 45 |
-
theorem map_nested {p : Wgt A} (f : A→B) (g : B→C) :
|
| 46 |
-
mapW (mapW p f) g = mapW p (g ∘ f) := funext fun _ => mapW_pr p f _
|
| 47 |
-
|
| 48 |
-
omit [Fintype C] in
|
| 49 |
-
theorem map_mix (w : Wgt A) (p : A→ Wgt B) (f : B→C) :
|
| 50 |
-
mapW (mixW w p) f = mixW w (fun i => mapW (p i) f) := funext fun _ => mixW_avg ..
|
| 51 |
-
|
| 52 |
-
omit [Fintype B] in
|
| 53 |
-
theorem map_resize (p : Wgt A) (f : A→B) (u : Wgt B) :
|
| 54 |
-
mapW (fun i => p i*u (f i)) f = (fun i => mapW p f i * u i) := by
|
| 55 |
-
funext i
|
| 56 |
-
unfold mapW pr avg
|
| 57 |
-
rw [Finset.sum_mul]
|
| 58 |
-
apply sum_congr rfl
|
| 59 |
-
intro j _
|
| 60 |
-
by_cases h : f j=i
|
| 61 |
-
· simp only [h,ind_true,mul_one]
|
| 62 |
-
simp only [ind_zero h,mul_zero,zero_mul]
|
| 63 |
-
|
| 64 |
-
def pour (q : Wgt A) (f : A→B) (w : Wgt B) :=
|
| 65 |
-
fun i => q i * (w (f i) / mapW q f (f i))
|
| 66 |
-
|
| 67 |
-
omit [Fintype B] in
|
| 68 |
-
theorem map_pour (q : Wgt A) (f : A → B) (w : Wgt B) (h : lsupp w (mapW q f)) :
|
| 69 |
-
mapW (pour q f w) f=w := by
|
| 70 |
-
unfold pour
|
| 71 |
-
rw [map_resize (u:=fun i => w i / mapW q f i)]
|
| 72 |
-
funext i
|
| 73 |
-
by_cases he : w i=0
|
| 74 |
-
· simp only [he,zero_div,mul_zero]
|
| 75 |
-
have hm := h i he
|
| 76 |
-
field_simp
|
| 77 |
-
|
| 78 |
-
def bucket (q : Wgt A) (f : A→B) (p : Wgt A) := pour q f (mapW p f)
|
| 79 |
-
|
| 80 |
-
omit [Fintype B] in
|
| 81 |
-
theorem pour_nz {q : Wgt A} {u : Wgt B} (f : A→B)
|
| 82 |
-
(hq : ∀ i,0 ≤ q i) (hu : ∀ i,0 ≤ u i) (i) : 0 ≤ pour q f u i :=
|
| 83 |
-
mul_nonneg (hq i) (div_nonneg (hu _) (map_nz hq f _))
|
| 84 |
-
|
| 85 |
-
omit [Fintype B] in
|
| 86 |
-
theorem bucket_scale (q p : Wgt A) (hq : ∀ i,0≤q i) (h : lsupp p q) (f : A→B) :
|
| 87 |
-
mapW (bucket q f p) f=mapW p f := map_pour q f _ (lsupp.map h hq f)
|
| 88 |
-
|
| 89 |
-
theorem bucket_law {q p : Wgt A} (hp : IsLaw p)
|
| 90 |
-
(f : A→B) (hq : ∀ i,0≤q i) (h : lsupp p q) :
|
| 91 |
-
IsLaw (bucket q f p) := by
|
| 92 |
-
refine ⟨pour_nz f hq (map_nz hp.nz f),?_⟩
|
| 93 |
-
rw [←map_mass _ f,bucket_scale q p hq h,map_mass,hp.total]
|
| 94 |
-
|
| 95 |
-
omit [Fintype B] in
|
| 96 |
-
theorem lsupp_bucket {p q : Wgt A} (f : A → B) (hp : ∀ i, 0 ≤ p i)
|
| 97 |
-
(hq : ∀ i,0 ≤ q i) (h : lsupp p q) : lsupp p (bucket q f p) :=
|
| 98 |
-
fun x hx => mul_ne_zero (h x hx) (div_ne_zero (lsupp_hit hp f x hx) (lsupp_hit hq f x (h x hx)))
|
| 99 |
-
|
| 100 |
-
omit [Fintype C] in
|
| 101 |
-
theorem bucket_nested (q p : Wgt A) (f : A→B) (g : B→C) :
|
| 102 |
-
mapW (bucket q (g ∘ f) p) f=bucket (mapW q f) g (mapW p f) := by
|
| 103 |
-
unfold bucket pour
|
| 104 |
-
rw [map_nested,map_nested]
|
| 105 |
-
have h := map_resize q f (fun i=>mapW p (g∘f) (g i)/mapW q (g∘f) (g i))
|
| 106 |
-
exact h
|
| 107 |
-
|
| 108 |
-
omit [Fintype B] in
|
| 109 |
-
theorem bucket_mix (q : Wgt A) (f : A → B) (w : Wgt C) (p : C→ Wgt A) :
|
| 110 |
-
bucket q f (mixW w p)=mixW w (fun y => bucket q f (p y)) := by
|
| 111 |
-
unfold bucket pour
|
| 112 |
-
rw [map_mix]
|
| 113 |
-
funext i; simp only [mixW,avg_mul',avg_div]
|
| 114 |
-
|
| 115 |
-
theorem tension_stage (p q : Wgt A) (hp : ∀ i,0 ≤ p i) (hq : ∀ i, 0≤ q i)
|
| 116 |
-
(h : lsupp p q) (f : A→B) :
|
| 117 |
-
tension p q=tension p (bucket q f p)+tension (mapW p f) (mapW q f) := by
|
| 118 |
-
unfold tension
|
| 119 |
-
rw [mapW_avg, ← avg_add]
|
| 120 |
-
refine avg_congr (fun i hi => ?_)
|
| 121 |
-
have hu := h i hi; have hw := lsupp_hit hp f i hi; have hv := lsupp_hit hq f i hu
|
| 122 |
-
dsimp only [bucket,pour]
|
| 123 |
-
rw [log_mul hu (div_ne_zero hw hv),log_div hw hv]
|
| 124 |
-
ring
|
| 125 |
-
end HadwigerCounterexample
|
| 126 |
-
|
| 127 |
-
end
|
| 128 |
-
|
| 129 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RelativeEntropy
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Projection Energy -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 12 |
+
|
| 13 |
+
theorem map_mass (p : Wgt A) (f : A→B) : tot (mapW p f)=tot p := by
|
| 14 |
+
simpa only [avg_const,mul_one] using mapW_avg p f (fun _ => 1)
|
| 15 |
+
omit [Fintype B] in
|
| 16 |
+
theorem map_nz {p : Wgt A} (hp : ∀ i, 0 ≤ p i) (f : A→B) (i : B) :
|
| 17 |
+
0 ≤ mapW p f i := pr_nonneg hp
|
| 18 |
+
omit [Fintype B] in
|
| 19 |
+
theorem lsupp_witness {p : Wgt A} {f : A→B} {i}
|
| 20 |
+
(h : mapW p f i≠0) : ∃ x,p x≠0 ∧ f x=i := by
|
| 21 |
+
classical
|
| 22 |
+
by_contra! hh
|
| 23 |
+
refine h (Finset.sum_eq_zero (fun x _ => ?_))
|
| 24 |
+
by_cases h : p x=0
|
| 25 |
+
· change p x * ind _=0
|
| 26 |
+
rw [h,zero_mul]
|
| 27 |
+
exact (congrArg (p x * ·) (ind_zero (hh x h))).trans (mul_zero _)
|
| 28 |
+
|
| 29 |
+
omit [Fintype B] in
|
| 30 |
+
theorem lsupp_hit {p : Wgt A} (hp : ∀ i,0 ≤ p i) (f : A→B) (x : A) (h : p x≠0) :
|
| 31 |
+
mapW p f (f x)≠0 := by
|
| 32 |
+
have h' := lt_of_le_of_ne (hp x) (Ne.symm h)
|
| 33 |
+
have he := weight_le_tot (fun y => mul_nonneg (hp y) (ind_nonneg (f y = f x))) x
|
| 34 |
+
simp only [ind_true,mul_one] at he
|
| 35 |
+
exact (h'.trans_le he).ne'
|
| 36 |
+
|
| 37 |
+
omit [Fintype B] in
|
| 38 |
+
theorem lsupp.map {p q : Wgt A} (h : lsupp p q) (hq : ∀ i,0 ≤ q i)
|
| 39 |
+
(f : A→B) : lsupp (mapW p f) (mapW q f) := by
|
| 40 |
+
intro i hi
|
| 41 |
+
obtain ⟨x,hx,rfl⟩ := lsupp_witness hi
|
| 42 |
+
exact lsupp_hit hq f x (h x hx)
|
| 43 |
+
|
| 44 |
+
omit [Fintype C] in
|
| 45 |
+
theorem map_nested {p : Wgt A} (f : A→B) (g : B→C) :
|
| 46 |
+
mapW (mapW p f) g = mapW p (g ∘ f) := funext fun _ => mapW_pr p f _
|
| 47 |
+
|
| 48 |
+
omit [Fintype C] in
|
| 49 |
+
theorem map_mix (w : Wgt A) (p : A→ Wgt B) (f : B→C) :
|
| 50 |
+
mapW (mixW w p) f = mixW w (fun i => mapW (p i) f) := funext fun _ => mixW_avg ..
|
| 51 |
+
|
| 52 |
+
omit [Fintype B] in
|
| 53 |
+
theorem map_resize (p : Wgt A) (f : A→B) (u : Wgt B) :
|
| 54 |
+
mapW (fun i => p i*u (f i)) f = (fun i => mapW p f i * u i) := by
|
| 55 |
+
funext i
|
| 56 |
+
unfold mapW pr avg
|
| 57 |
+
rw [Finset.sum_mul]
|
| 58 |
+
apply sum_congr rfl
|
| 59 |
+
intro j _
|
| 60 |
+
by_cases h : f j=i
|
| 61 |
+
· simp only [h,ind_true,mul_one]
|
| 62 |
+
simp only [ind_zero h,mul_zero,zero_mul]
|
| 63 |
+
|
| 64 |
+
def pour (q : Wgt A) (f : A→B) (w : Wgt B) :=
|
| 65 |
+
fun i => q i * (w (f i) / mapW q f (f i))
|
| 66 |
+
|
| 67 |
+
omit [Fintype B] in
|
| 68 |
+
theorem map_pour (q : Wgt A) (f : A → B) (w : Wgt B) (h : lsupp w (mapW q f)) :
|
| 69 |
+
mapW (pour q f w) f=w := by
|
| 70 |
+
unfold pour
|
| 71 |
+
rw [map_resize (u:=fun i => w i / mapW q f i)]
|
| 72 |
+
funext i
|
| 73 |
+
by_cases he : w i=0
|
| 74 |
+
· simp only [he,zero_div,mul_zero]
|
| 75 |
+
have hm := h i he
|
| 76 |
+
field_simp
|
| 77 |
+
|
| 78 |
+
def bucket (q : Wgt A) (f : A→B) (p : Wgt A) := pour q f (mapW p f)
|
| 79 |
+
|
| 80 |
+
omit [Fintype B] in
|
| 81 |
+
theorem pour_nz {q : Wgt A} {u : Wgt B} (f : A→B)
|
| 82 |
+
(hq : ∀ i,0 ≤ q i) (hu : ∀ i,0 ≤ u i) (i) : 0 ≤ pour q f u i :=
|
| 83 |
+
mul_nonneg (hq i) (div_nonneg (hu _) (map_nz hq f _))
|
| 84 |
+
|
| 85 |
+
omit [Fintype B] in
|
| 86 |
+
theorem bucket_scale (q p : Wgt A) (hq : ∀ i,0≤q i) (h : lsupp p q) (f : A→B) :
|
| 87 |
+
mapW (bucket q f p) f=mapW p f := map_pour q f _ (lsupp.map h hq f)
|
| 88 |
+
|
| 89 |
+
theorem bucket_law {q p : Wgt A} (hp : IsLaw p)
|
| 90 |
+
(f : A→B) (hq : ∀ i,0≤q i) (h : lsupp p q) :
|
| 91 |
+
IsLaw (bucket q f p) := by
|
| 92 |
+
refine ⟨pour_nz f hq (map_nz hp.nz f),?_⟩
|
| 93 |
+
rw [←map_mass _ f,bucket_scale q p hq h,map_mass,hp.total]
|
| 94 |
+
|
| 95 |
+
omit [Fintype B] in
|
| 96 |
+
theorem lsupp_bucket {p q : Wgt A} (f : A → B) (hp : ∀ i, 0 ≤ p i)
|
| 97 |
+
(hq : ∀ i,0 ≤ q i) (h : lsupp p q) : lsupp p (bucket q f p) :=
|
| 98 |
+
fun x hx => mul_ne_zero (h x hx) (div_ne_zero (lsupp_hit hp f x hx) (lsupp_hit hq f x (h x hx)))
|
| 99 |
+
|
| 100 |
+
omit [Fintype C] in
|
| 101 |
+
theorem bucket_nested (q p : Wgt A) (f : A→B) (g : B→C) :
|
| 102 |
+
mapW (bucket q (g ∘ f) p) f=bucket (mapW q f) g (mapW p f) := by
|
| 103 |
+
unfold bucket pour
|
| 104 |
+
rw [map_nested,map_nested]
|
| 105 |
+
have h := map_resize q f (fun i=>mapW p (g∘f) (g i)/mapW q (g∘f) (g i))
|
| 106 |
+
exact h
|
| 107 |
+
|
| 108 |
+
omit [Fintype B] in
|
| 109 |
+
theorem bucket_mix (q : Wgt A) (f : A → B) (w : Wgt C) (p : C→ Wgt A) :
|
| 110 |
+
bucket q f (mixW w p)=mixW w (fun y => bucket q f (p y)) := by
|
| 111 |
+
unfold bucket pour
|
| 112 |
+
rw [map_mix]
|
| 113 |
+
funext i; simp only [mixW,avg_mul',avg_div]
|
| 114 |
+
|
| 115 |
+
theorem tension_stage (p q : Wgt A) (hp : ∀ i,0 ≤ p i) (hq : ∀ i, 0≤ q i)
|
| 116 |
+
(h : lsupp p q) (f : A→B) :
|
| 117 |
+
tension p q=tension p (bucket q f p)+tension (mapW p f) (mapW q f) := by
|
| 118 |
+
unfold tension
|
| 119 |
+
rw [mapW_avg, ← avg_add]
|
| 120 |
+
refine avg_congr (fun i hi => ?_)
|
| 121 |
+
have hu := h i hi; have hw := lsupp_hit hp f i hi; have hv := lsupp_hit hq f i hu
|
| 122 |
+
dsimp only [bucket,pour]
|
| 123 |
+
rw [log_mul hu (div_ne_zero hw hv),log_div hw hv]
|
| 124 |
+
ring
|
| 125 |
+
end HadwigerCounterexample
|
| 126 |
+
|
| 127 |
+
end
|
| 128 |
+
|
| 129 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProjectionError.lean
CHANGED
|
@@ -1,100 +1,100 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ResidualRegularity
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Projection Error -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix LinearMap Module Filter Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B I : Type} [Fintype A] [Fintype B] [Fintype I]
|
| 12 |
-
|
| 13 |
-
def rebate (u f g : Wgt A) (p : A→B) :=
|
| 14 |
-
dip u f g - dip u (banner u p f) (banner u p g)
|
| 15 |
-
omit [Fintype B] in
|
| 16 |
-
theorem rebate_sym (u f g : Wgt A) (p : A→B) :
|
| 17 |
-
rebate u f g p=rebate u g f p := by unfold rebate; rw [dip_sym u f,dip_sym u (banner u p f)]
|
| 18 |
-
theorem rebate_calc (u f g : Wgt A) (p : A→B) (hu : ∀ i,0≤u i) :
|
| 19 |
-
rebate u f g p=dip u (fun i=>f i-banner u p f i) g := by
|
| 20 |
-
unfold rebate
|
| 21 |
-
rw [dip_sub,dip_sym u (banner u p f) (banner u p g)]
|
| 22 |
-
exact congrArg (dip u f g - ·) ((show dip u (banner u p g) (banner u p f)=dip u g (banner u p f) from
|
| 23 |
-
cash_orth u hu p g (cashbook u p f)).trans (dip_sym ..))
|
| 24 |
-
def lcost (u f g : Wgt A) := avg u (fun i=>|f i-g i|)
|
| 25 |
-
|
| 26 |
-
theorem rebate_cost (u f g f' : Wgt A) (p : A→B) (hu : ∀ i,0≤u i)
|
| 27 |
-
(r : ℝ) (hr : 0 ≤ r) (h : ∀ i,|g i|≤r) :
|
| 28 |
-
|rebate u f g p-rebate u f' g p| ≤ lcost u f f' * (2*r) := by
|
| 29 |
-
rw [rebate_sym u f g,rebate_sym u f' g,rebate_calc u g f p hu,rebate_calc u g f' p hu]
|
| 30 |
-
unfold dip; rw [←avg_sub]
|
| 31 |
-
apply (abs_avg_le hu).trans
|
| 32 |
-
have hz i : |g i-banner u p g i|≤2*r :=
|
| 33 |
-
((abs_sub ..).trans (add_le_add (h i) (cashbook_bound u hu p g r hr h (p i)))).trans_eq
|
| 34 |
-
(two_mul _).symm
|
| 35 |
-
unfold lcost; rw [←avg_mul]; apply avg_mono hu
|
| 36 |
-
intro i
|
| 37 |
-
dsimp only
|
| 38 |
-
rw [←mul_sub,abs_mul,mul_comm]
|
| 39 |
-
exact mul_le_mul_of_nonneg_left (hz _) (abs_nonneg _)
|
| 40 |
-
|
| 41 |
-
def syrup (r : ℝ) (x : ℝ) := min (max x 0) r
|
| 42 |
-
def mcut (r : ℝ) (u : Wgt A) (f : Wgt A) := syrup r ∘ density u f
|
| 43 |
-
theorem syrup_range (r x : ℝ) (h : 0≤r) :
|
| 44 |
-
0≤ syrup r x∧ syrup r x ≤ r := ⟨le_min (le_max_right ..) h,min_le_right ..⟩
|
| 45 |
-
omit [Fintype A] in
|
| 46 |
-
theorem mcut_range (r : ℝ) (u f : Wgt A) (h : 0≤r) (x) :
|
| 47 |
-
0≤mcut r u f x∧mcut r u f x ≤ r := syrup_range _ _ h
|
| 48 |
-
|
| 49 |
-
private theorem jelly (r x y : ℝ) :
|
| 50 |
-
|syrup r x-syrup r y| ≤ |x-y| := by
|
| 51 |
-
wlog hh : x≤y generalizing x y
|
| 52 |
-
· rw [abs_sub_comm,abs_sub_comm x y]; exact this y x (le_of_not_ge hh)
|
| 53 |
-
have hr : syrup r x ≤ syrup r y := min_le_min (max_le_max hh le_rfl) le_rfl
|
| 54 |
-
rw [abs_of_nonpos (sub_nonpos.mpr hh),abs_of_nonpos (sub_nonpos.mpr hr)]
|
| 55 |
-
unfold syrup
|
| 56 |
-
rcases le_total x 0 with h|h <;> rcases le_total y 0 with he|he
|
| 57 |
-
· rw [max_eq_right h,max_eq_right he]; linarith only [hh]
|
| 58 |
-
· rw [max_eq_right h,max_eq_left he]; rcases le_total 0 r with h'|h'
|
| 59 |
-
· rw [min_eq_left h']
|
| 60 |
-
linarith only [h, min_le_left y r]
|
| 61 |
-
rw [min_eq_right h',min_eq_right (by linarith)]
|
| 62 |
-
linarith
|
| 63 |
-
· obtain rfl : x=y := by linarith
|
| 64 |
-
simp
|
| 65 |
-
rw [max_eq_left h,max_eq_left he]
|
| 66 |
-
rcases le_total x r with h'|h'
|
| 67 |
-
· rw [min_eq_left h']; linarith only [min_le_left y r]
|
| 68 |
-
rw [min_eq_right h',min_eq_right (by linarith)]; linarith
|
| 69 |
-
|
| 70 |
-
theorem mcut_cost (r : ℝ) (u f g : Wgt A) (hu : ∀ i,0≤u i) :
|
| 71 |
-
lcost u (mcut r u f) (mcut r u g)≤ varOne f g := by
|
| 72 |
-
unfold lcost avg varOne; refine sum_le_sum fun i _ => ?_
|
| 73 |
-
apply (mul_le_mul_of_nonneg_left (jelly r (density u f i) (density u g i)) (hu i)).trans
|
| 74 |
-
by_cases hx : u i=0
|
| 75 |
-
· rw [hx,zero_mul]; exact abs_nonneg _
|
| 76 |
-
unfold density; rw [←sub_div,abs_div,abs_of_nonneg (hu _)]
|
| 77 |
-
exact le_of_eq (by field_simp)
|
| 78 |
-
|
| 79 |
-
set_option maxHeartbeats 500000 in
|
| 80 |
-
theorem roster_clip (r : ℝ) (u : Wgt A) (hu : IsLaw u) (hr : 0≤r) (Q : Wgt A→ Prop)
|
| 81 |
-
(k : ℕ) (ε : ℝ) (h : roster Q k ε) :
|
| 82 |
-
∃ f : Fin (k+1)→Wgt A,(∀ i x,|f i x|≤r) ∧
|
| 83 |
-
∀ w,Q w→∃ i,lcost u (mcut r u w) (f i)≤ ε := by
|
| 84 |
-
classical
|
| 85 |
-
obtain ⟨t,ht,v,hv⟩:=h
|
| 86 |
-
let W:= fun i : Fin (k+1)=> if h:i.val<t then mcut r u (v (⟨i.val,h⟩)) else (fun i:A => 0)
|
| 87 |
-
refine ⟨W,fun i x=>?_,fun i hi=>?_⟩
|
| 88 |
-
· unfold W; split
|
| 89 |
-
next h =>
|
| 90 |
-
obtain ⟨he,hy⟩:=mcut_range r u (v (⟨i.val,h⟩)) hr x
|
| 91 |
-
rwa [abs_of_nonneg he]
|
| 92 |
-
simpa only [abs_zero] using hr
|
| 93 |
-
obtain ⟨j,hj⟩:=hv i hi
|
| 94 |
-
exact ⟨⟨j.val,Nat.lt_succ_of_lt (j.isLt.trans_le ht)⟩,by
|
| 95 |
-
unfold W; rw [dite_eq_left j.isLt]; exact (mcut_cost r u i _ hu.nz).trans hj⟩
|
| 96 |
-
end HadwigerCounterexample
|
| 97 |
-
|
| 98 |
-
end
|
| 99 |
-
|
| 100 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ResidualRegularity
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Projection Error -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix LinearMap Module Filter Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B I : Type} [Fintype A] [Fintype B] [Fintype I]
|
| 12 |
+
|
| 13 |
+
def rebate (u f g : Wgt A) (p : A→B) :=
|
| 14 |
+
dip u f g - dip u (banner u p f) (banner u p g)
|
| 15 |
+
omit [Fintype B] in
|
| 16 |
+
theorem rebate_sym (u f g : Wgt A) (p : A→B) :
|
| 17 |
+
rebate u f g p=rebate u g f p := by unfold rebate; rw [dip_sym u f,dip_sym u (banner u p f)]
|
| 18 |
+
theorem rebate_calc (u f g : Wgt A) (p : A→B) (hu : ∀ i,0≤u i) :
|
| 19 |
+
rebate u f g p=dip u (fun i=>f i-banner u p f i) g := by
|
| 20 |
+
unfold rebate
|
| 21 |
+
rw [dip_sub,dip_sym u (banner u p f) (banner u p g)]
|
| 22 |
+
exact congrArg (dip u f g - ·) ((show dip u (banner u p g) (banner u p f)=dip u g (banner u p f) from
|
| 23 |
+
cash_orth u hu p g (cashbook u p f)).trans (dip_sym ..))
|
| 24 |
+
def lcost (u f g : Wgt A) := avg u (fun i=>|f i-g i|)
|
| 25 |
+
|
| 26 |
+
theorem rebate_cost (u f g f' : Wgt A) (p : A→B) (hu : ∀ i,0≤u i)
|
| 27 |
+
(r : ℝ) (hr : 0 ≤ r) (h : ∀ i,|g i|≤r) :
|
| 28 |
+
|rebate u f g p-rebate u f' g p| ≤ lcost u f f' * (2*r) := by
|
| 29 |
+
rw [rebate_sym u f g,rebate_sym u f' g,rebate_calc u g f p hu,rebate_calc u g f' p hu]
|
| 30 |
+
unfold dip; rw [←avg_sub]
|
| 31 |
+
apply (abs_avg_le hu).trans
|
| 32 |
+
have hz i : |g i-banner u p g i|≤2*r :=
|
| 33 |
+
((abs_sub ..).trans (add_le_add (h i) (cashbook_bound u hu p g r hr h (p i)))).trans_eq
|
| 34 |
+
(two_mul _).symm
|
| 35 |
+
unfold lcost; rw [←avg_mul]; apply avg_mono hu
|
| 36 |
+
intro i
|
| 37 |
+
dsimp only
|
| 38 |
+
rw [←mul_sub,abs_mul,mul_comm]
|
| 39 |
+
exact mul_le_mul_of_nonneg_left (hz _) (abs_nonneg _)
|
| 40 |
+
|
| 41 |
+
def syrup (r : ℝ) (x : ℝ) := min (max x 0) r
|
| 42 |
+
def mcut (r : ℝ) (u : Wgt A) (f : Wgt A) := syrup r ∘ density u f
|
| 43 |
+
theorem syrup_range (r x : ℝ) (h : 0≤r) :
|
| 44 |
+
0≤ syrup r x∧ syrup r x ≤ r := ⟨le_min (le_max_right ..) h,min_le_right ..⟩
|
| 45 |
+
omit [Fintype A] in
|
| 46 |
+
theorem mcut_range (r : ℝ) (u f : Wgt A) (h : 0≤r) (x) :
|
| 47 |
+
0≤mcut r u f x∧mcut r u f x ≤ r := syrup_range _ _ h
|
| 48 |
+
|
| 49 |
+
private theorem jelly (r x y : ℝ) :
|
| 50 |
+
|syrup r x-syrup r y| ≤ |x-y| := by
|
| 51 |
+
wlog hh : x≤y generalizing x y
|
| 52 |
+
· rw [abs_sub_comm,abs_sub_comm x y]; exact this y x (le_of_not_ge hh)
|
| 53 |
+
have hr : syrup r x ≤ syrup r y := min_le_min (max_le_max hh le_rfl) le_rfl
|
| 54 |
+
rw [abs_of_nonpos (sub_nonpos.mpr hh),abs_of_nonpos (sub_nonpos.mpr hr)]
|
| 55 |
+
unfold syrup
|
| 56 |
+
rcases le_total x 0 with h|h <;> rcases le_total y 0 with he|he
|
| 57 |
+
· rw [max_eq_right h,max_eq_right he]; linarith only [hh]
|
| 58 |
+
· rw [max_eq_right h,max_eq_left he]; rcases le_total 0 r with h'|h'
|
| 59 |
+
· rw [min_eq_left h']
|
| 60 |
+
linarith only [h, min_le_left y r]
|
| 61 |
+
rw [min_eq_right h',min_eq_right (by linarith)]
|
| 62 |
+
linarith
|
| 63 |
+
· obtain rfl : x=y := by linarith
|
| 64 |
+
simp
|
| 65 |
+
rw [max_eq_left h,max_eq_left he]
|
| 66 |
+
rcases le_total x r with h'|h'
|
| 67 |
+
· rw [min_eq_left h']; linarith only [min_le_left y r]
|
| 68 |
+
rw [min_eq_right h',min_eq_right (by linarith)]; linarith
|
| 69 |
+
|
| 70 |
+
theorem mcut_cost (r : ℝ) (u f g : Wgt A) (hu : ∀ i,0≤u i) :
|
| 71 |
+
lcost u (mcut r u f) (mcut r u g)≤ varOne f g := by
|
| 72 |
+
unfold lcost avg varOne; refine sum_le_sum fun i _ => ?_
|
| 73 |
+
apply (mul_le_mul_of_nonneg_left (jelly r (density u f i) (density u g i)) (hu i)).trans
|
| 74 |
+
by_cases hx : u i=0
|
| 75 |
+
· rw [hx,zero_mul]; exact abs_nonneg _
|
| 76 |
+
unfold density; rw [←sub_div,abs_div,abs_of_nonneg (hu _)]
|
| 77 |
+
exact le_of_eq (by field_simp)
|
| 78 |
+
|
| 79 |
+
set_option maxHeartbeats 500000 in
|
| 80 |
+
theorem roster_clip (r : ℝ) (u : Wgt A) (hu : IsLaw u) (hr : 0≤r) (Q : Wgt A→ Prop)
|
| 81 |
+
(k : ℕ) (ε : ℝ) (h : roster Q k ε) :
|
| 82 |
+
∃ f : Fin (k+1)→Wgt A,(∀ i x,|f i x|≤r) ∧
|
| 83 |
+
∀ w,Q w→∃ i,lcost u (mcut r u w) (f i)≤ ε := by
|
| 84 |
+
classical
|
| 85 |
+
obtain ⟨t,ht,v,hv⟩:=h
|
| 86 |
+
let W:= fun i : Fin (k+1)=> if h:i.val<t then mcut r u (v (⟨i.val,h⟩)) else (fun i:A => 0)
|
| 87 |
+
refine ⟨W,fun i x=>?_,fun i hi=>?_⟩
|
| 88 |
+
· unfold W; split
|
| 89 |
+
next h =>
|
| 90 |
+
obtain ⟨he,hy⟩:=mcut_range r u (v (⟨i.val,h⟩)) hr x
|
| 91 |
+
rwa [abs_of_nonneg he]
|
| 92 |
+
simpa only [abs_zero] using hr
|
| 93 |
+
obtain ⟨j,hj⟩:=hv i hi
|
| 94 |
+
exact ⟨⟨j.val,Nat.lt_succ_of_lt (j.isLt.trans_le ht)⟩,by
|
| 95 |
+
unfold W; rw [dite_eq_left j.isLt]; exact (mcut_cost r u i _ hu.nz).trans hj⟩
|
| 96 |
+
end HadwigerCounterexample
|
| 97 |
+
|
| 98 |
+
end
|
| 99 |
+
|
| 100 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ProjectionNets.lean
CHANGED
|
@@ -1,106 +1,106 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RoundedRefinements
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Projection Nets -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Filter Matrix Real Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C D : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype D]
|
| 12 |
-
|
| 13 |
-
theorem stamina_equiv (p : Wgt A) (e : A≃C) (a : ℝ)
|
| 14 |
-
(h : stamina p a) :
|
| 15 |
-
stamina (mapW p e) a := by
|
| 16 |
-
intro i hi; rw [mapW_equiv_val] at *
|
| 17 |
-
exact h _ hi
|
| 18 |
-
|
| 19 |
-
theorem tension_equiv (p q : Wgt A) (e : A≃C) :
|
| 20 |
-
tension (mapW p e) (mapW q e)=tension p q := by
|
| 21 |
-
unfold tension
|
| 22 |
-
rw [mapW_avg]
|
| 23 |
-
simp_rw [mapW_equiv_val,Equiv.symm_apply_apply]
|
| 24 |
-
|
| 25 |
-
theorem budget_equiv (μ : Wgt A) (p : A → Wgt B) (f : B→C) (e : C≃D) :
|
| 26 |
-
budget μ p (e ∘ f)=budget μ p f := by
|
| 27 |
-
unfold budget
|
| 28 |
-
simp_rw [←map_nested f _,tension_equiv]
|
| 29 |
-
|
| 30 |
-
def ample (μ : Wgt A) (p : A→Wgt B) (r : ℕ) (ε : ℝ) :=
|
| 31 |
-
∃ t : ℕ,t ≤ r ∧ ∃ f : B → Fin t,∀ w,catalog μ p w →
|
| 32 |
-
varOne w (bucket unif f w) ≤ ε
|
| 33 |
-
|
| 34 |
-
set_option maxHeartbeats 800000 in
|
| 35 |
-
theorem ample_thresh (V ε : ℝ) (hε : 0<ε) :
|
| 36 |
-
∃ (r : ℕ) (δ : ℝ),0<δ ∧ ∀ (A B : Type) [Fintype A] [Fintype B] [Nonempty B]
|
| 37 |
-
(μ : Wgt A) (p : A→ Wgt B), Ultra μ p →
|
| 38 |
-
tariffs μ p r δ V → ample μ p r ε := by
|
| 39 |
-
classical
|
| 40 |
-
let c := ε/8
|
| 41 |
-
have hc : 0<c := by positivity
|
| 42 |
-
obtain ⟨α,hα,hα',hh⟩ := ui_threshold V c hc
|
| 43 |
-
obtain ⟨D,hD⟩ := exists_nat_gt (max 0 (V/c^2))
|
| 44 |
-
have hd := (max_lt_iff.mp hD).2
|
| 45 |
-
rw [div_lt_iff₀ (by positivity)] at hd
|
| 46 |
-
let r := 2^(D+1)
|
| 47 |
-
have h0 : 0<(r:ℝ) := by unfold r; positivity
|
| 48 |
-
let k := min (min α c/r) (1/2)
|
| 49 |
-
have hk : 0<k := lt_min (div_pos (lt_min hα hc) h0) (by norm_num)
|
| 50 |
-
have hk0 : k≤1/2 := min_le_right ..
|
| 51 |
-
have hk' : k≤1 := le_trans hk0 (by norm_num)
|
| 52 |
-
let δ := min α (k^D)
|
| 53 |
-
have hδ : 0<δ := lt_min hα (pow_pos hk D)
|
| 54 |
-
refine ⟨r,δ,hδ,fun A B _ _ _ μ p hw hV => ?_⟩
|
| 55 |
-
let e : Wgt B := unif
|
| 56 |
-
have he : IsLaw e := unif_law
|
| 57 |
-
by_contra h
|
| 58 |
-
have hr2 : 2≤r := by
|
| 59 |
-
unfold r; rw [pow_succ]
|
| 60 |
-
have : 0<2^D := by positivity
|
| 61 |
-
omega
|
| 62 |
-
have ht := hh A B μ p hw (tariffs_monotone hV hr2 (min_le_left ..))
|
| 63 |
-
have hstep (n : ℕ) (hn : n≤ D) :
|
| 64 |
-
∃ f : B → Fin (2^n), stamina (mapW e f) (k^n) ∧
|
| 65 |
-
↑n*c^2 ≤ budget μ p f := by
|
| 66 |
-
induction n with
|
| 67 |
-
| zero =>
|
| 68 |
-
let f := fun _ : B => (0 : Fin (2^0))
|
| 69 |
-
refine ⟨f,?_,by simpa using budget_nonneg hw f⟩
|
| 70 |
-
intro i hi
|
| 71 |
-
have hi : i = 0 := by
|
| 72 |
-
have hh := i.isLt; norm_num at hh
|
| 73 |
-
exact Fin.ext (by simp only [Fin.val_zero]; omega)
|
| 74 |
-
subst i; change 1 ≤ pr e (fun x => f x=0)
|
| 75 |
-
simp [f,he.total]
|
| 76 |
-
| succ i ih =>
|
| 77 |
-
obtain ⟨f,hf,hB⟩ := ih (by omega)
|
| 78 |
-
let t := 2^i
|
| 79 |
-
have he' : ∃ w,catalog μ p w ∧ 8*c<varOne w (bucket unif f w) := by
|
| 80 |
-
by_contra! hh
|
| 81 |
-
apply h; refine ⟨t,Nat.pow_le_pow_right (by decide) (by omega),f,?_⟩
|
| 82 |
-
rwa [show 8*c=ε by unfold c; ring] at hh
|
| 83 |
-
obtain ⟨w,hw',hwv⟩ := he'
|
| 84 |
-
have hz : num (Fin t × Bool)*k ≤ min α c := by
|
| 85 |
-
have h1 : Fintype.card (Fin t × Bool) ≤ r :=
|
| 86 |
-
calc _ = 2^(i+1) := by simp [pow_succ,t]
|
| 87 |
-
_ ≤ r := Nat.pow_le_pow_right (by decide) (by omega)
|
| 88 |
-
have h2 := min_le_left (min α c/r) (1/2)
|
| 89 |
-
change k ≤ min α c/r at h2
|
| 90 |
-
rw [le_div_iff₀ h0,mul_comm k] at h2
|
| 91 |
-
exact (mul_le_mul_of_nonneg_right (by exact_mod_cast h1) hk.le).trans h2
|
| 92 |
-
obtain ⟨F,hF',hF⟩ := divide_progress hw c (k^i) α k hc hk (by linarith)
|
| 93 |
-
(pow_pos hk _) (pow_le_one₀ hk.le hk') ht f hf hz w hw' hwv
|
| 94 |
-
let E : (Fin t×Bool)≃ Fin (2^(i+1)) := Fintype.equivFinOfCardEq (by simp [pow_succ,t])
|
| 95 |
-
refine ⟨E ∘ F,?_,?_⟩
|
| 96 |
-
· rw [←map_nested,pow_succ' k]; exact stamina_equiv _ E _ hF'
|
| 97 |
-
rw [budget_equiv,Nat.cast_add,Nat.cast_one]; linarith only [hF,hB]
|
| 98 |
-
obtain ⟨f,hf,hf'⟩ := hstep D le_rfl
|
| 99 |
-
have he' : stamina (mapW unif f) δ := fun i hi => (min_le_right ..).trans (hf i hi)
|
| 100 |
-
have hz := hV _ (f:=f) (by simp; unfold r; rw [pow_succ]; omega) he'
|
| 101 |
-
exact (not_lt_of_ge (le_trans hf' hz)) hd
|
| 102 |
-
end HadwigerCounterexample
|
| 103 |
-
|
| 104 |
-
end
|
| 105 |
-
|
| 106 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RoundedRefinements
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Projection Nets -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Filter Matrix Real Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C D : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype D]
|
| 12 |
+
|
| 13 |
+
theorem stamina_equiv (p : Wgt A) (e : A≃C) (a : ℝ)
|
| 14 |
+
(h : stamina p a) :
|
| 15 |
+
stamina (mapW p e) a := by
|
| 16 |
+
intro i hi; rw [mapW_equiv_val] at *
|
| 17 |
+
exact h _ hi
|
| 18 |
+
|
| 19 |
+
theorem tension_equiv (p q : Wgt A) (e : A≃C) :
|
| 20 |
+
tension (mapW p e) (mapW q e)=tension p q := by
|
| 21 |
+
unfold tension
|
| 22 |
+
rw [mapW_avg]
|
| 23 |
+
simp_rw [mapW_equiv_val,Equiv.symm_apply_apply]
|
| 24 |
+
|
| 25 |
+
theorem budget_equiv (μ : Wgt A) (p : A → Wgt B) (f : B→C) (e : C≃D) :
|
| 26 |
+
budget μ p (e ∘ f)=budget μ p f := by
|
| 27 |
+
unfold budget
|
| 28 |
+
simp_rw [←map_nested f _,tension_equiv]
|
| 29 |
+
|
| 30 |
+
def ample (μ : Wgt A) (p : A→Wgt B) (r : ℕ) (ε : ℝ) :=
|
| 31 |
+
∃ t : ℕ,t ≤ r ∧ ∃ f : B → Fin t,∀ w,catalog μ p w →
|
| 32 |
+
varOne w (bucket unif f w) ≤ ε
|
| 33 |
+
|
| 34 |
+
set_option maxHeartbeats 800000 in
|
| 35 |
+
theorem ample_thresh (V ε : ℝ) (hε : 0<ε) :
|
| 36 |
+
∃ (r : ℕ) (δ : ℝ),0<δ ∧ ∀ (A B : Type) [Fintype A] [Fintype B] [Nonempty B]
|
| 37 |
+
(μ : Wgt A) (p : A→ Wgt B), Ultra μ p →
|
| 38 |
+
tariffs μ p r δ V → ample μ p r ε := by
|
| 39 |
+
classical
|
| 40 |
+
let c := ε/8
|
| 41 |
+
have hc : 0<c := by positivity
|
| 42 |
+
obtain ⟨α,hα,hα',hh⟩ := ui_threshold V c hc
|
| 43 |
+
obtain ⟨D,hD⟩ := exists_nat_gt (max 0 (V/c^2))
|
| 44 |
+
have hd := (max_lt_iff.mp hD).2
|
| 45 |
+
rw [div_lt_iff₀ (by positivity)] at hd
|
| 46 |
+
let r := 2^(D+1)
|
| 47 |
+
have h0 : 0<(r:ℝ) := by unfold r; positivity
|
| 48 |
+
let k := min (min α c/r) (1/2)
|
| 49 |
+
have hk : 0<k := lt_min (div_pos (lt_min hα hc) h0) (by norm_num)
|
| 50 |
+
have hk0 : k≤1/2 := min_le_right ..
|
| 51 |
+
have hk' : k≤1 := le_trans hk0 (by norm_num)
|
| 52 |
+
let δ := min α (k^D)
|
| 53 |
+
have hδ : 0<δ := lt_min hα (pow_pos hk D)
|
| 54 |
+
refine ⟨r,δ,hδ,fun A B _ _ _ μ p hw hV => ?_⟩
|
| 55 |
+
let e : Wgt B := unif
|
| 56 |
+
have he : IsLaw e := unif_law
|
| 57 |
+
by_contra h
|
| 58 |
+
have hr2 : 2≤r := by
|
| 59 |
+
unfold r; rw [pow_succ]
|
| 60 |
+
have : 0<2^D := by positivity
|
| 61 |
+
omega
|
| 62 |
+
have ht := hh A B μ p hw (tariffs_monotone hV hr2 (min_le_left ..))
|
| 63 |
+
have hstep (n : ℕ) (hn : n≤ D) :
|
| 64 |
+
∃ f : B → Fin (2^n), stamina (mapW e f) (k^n) ∧
|
| 65 |
+
↑n*c^2 ≤ budget μ p f := by
|
| 66 |
+
induction n with
|
| 67 |
+
| zero =>
|
| 68 |
+
let f := fun _ : B => (0 : Fin (2^0))
|
| 69 |
+
refine ⟨f,?_,by simpa using budget_nonneg hw f⟩
|
| 70 |
+
intro i hi
|
| 71 |
+
have hi : i = 0 := by
|
| 72 |
+
have hh := i.isLt; norm_num at hh
|
| 73 |
+
exact Fin.ext (by simp only [Fin.val_zero]; omega)
|
| 74 |
+
subst i; change 1 ≤ pr e (fun x => f x=0)
|
| 75 |
+
simp [f,he.total]
|
| 76 |
+
| succ i ih =>
|
| 77 |
+
obtain ⟨f,hf,hB⟩ := ih (by omega)
|
| 78 |
+
let t := 2^i
|
| 79 |
+
have he' : ∃ w,catalog μ p w ∧ 8*c<varOne w (bucket unif f w) := by
|
| 80 |
+
by_contra! hh
|
| 81 |
+
apply h; refine ⟨t,Nat.pow_le_pow_right (by decide) (by omega),f,?_⟩
|
| 82 |
+
rwa [show 8*c=ε by unfold c; ring] at hh
|
| 83 |
+
obtain ⟨w,hw',hwv⟩ := he'
|
| 84 |
+
have hz : num (Fin t × Bool)*k ≤ min α c := by
|
| 85 |
+
have h1 : Fintype.card (Fin t × Bool) ≤ r :=
|
| 86 |
+
calc _ = 2^(i+1) := by simp [pow_succ,t]
|
| 87 |
+
_ ≤ r := Nat.pow_le_pow_right (by decide) (by omega)
|
| 88 |
+
have h2 := min_le_left (min α c/r) (1/2)
|
| 89 |
+
change k ≤ min α c/r at h2
|
| 90 |
+
rw [le_div_iff₀ h0,mul_comm k] at h2
|
| 91 |
+
exact (mul_le_mul_of_nonneg_right (by exact_mod_cast h1) hk.le).trans h2
|
| 92 |
+
obtain ⟨F,hF',hF⟩ := divide_progress hw c (k^i) α k hc hk (by linarith)
|
| 93 |
+
(pow_pos hk _) (pow_le_one₀ hk.le hk') ht f hf hz w hw' hwv
|
| 94 |
+
let E : (Fin t×Bool)≃ Fin (2^(i+1)) := Fintype.equivFinOfCardEq (by simp [pow_succ,t])
|
| 95 |
+
refine ⟨E ∘ F,?_,?_⟩
|
| 96 |
+
· rw [←map_nested,pow_succ' k]; exact stamina_equiv _ E _ hF'
|
| 97 |
+
rw [budget_equiv,Nat.cast_add,Nat.cast_one]; linarith only [hF,hB]
|
| 98 |
+
obtain ⟨f,hf,hf'⟩ := hstep D le_rfl
|
| 99 |
+
have he' : stamina (mapW unif f) δ := fun i hi => (min_le_right ..).trans (hf i hi)
|
| 100 |
+
have hz := hV _ (f:=f) (by simp; unfold r; rw [pow_succ]; omega) he'
|
| 101 |
+
exact (not_lt_of_ge (le_trans hf' hz)) hd
|
| 102 |
+
end HadwigerCounterexample
|
| 103 |
+
|
| 104 |
+
end
|
| 105 |
+
|
| 106 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/QuadraticFourier.lean
CHANGED
|
@@ -1,83 +1,83 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FreeBlockFourier
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Quadratic Fourier -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix Module LinearMap Submodule Function Finset
|
| 11 |
-
variable {I J : Type} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
|
| 12 |
-
|
| 13 |
-
theorem phase_trans (t : Vec I) (f : Wgt (Vec I)) :
|
| 14 |
-
avg unif (fun y => f (y+t))=avg unif f := by
|
| 15 |
-
let E : Vec I ≃ Vec I := ⟨(·+t),(·+t),add_polar t,add_polar t⟩
|
| 16 |
-
exact avg_bij E unif f
|
| 17 |
-
|
| 18 |
-
theorem half_power (x a : ℝ) (ha : x^2 ≤ bp a) : |x|≤ bp (a/2) :=
|
| 19 |
-
le_of_pow_le_pow_left₀ (by decide : 2≠0) (bp_pos _).le (by
|
| 20 |
-
rw [sq_abs,pow_two (bp _),←bp_add,show a/2+a/2=a by ring]; exact ha)
|
| 21 |
-
|
| 22 |
-
def polarize (f : Vec I→F) (M : Mat I I) :=
|
| 23 |
-
∀ x y,f (x+y)+f x=f y+f 0+dotProduct y (M *ᵥ x)
|
| 24 |
-
|
| 25 |
-
set_option maxHeartbeats 600000 in
|
| 26 |
-
theorem flare_rank (f : Vec I→F) (M : Mat I I) (h : polarize f M) :
|
| 27 |
-
|avg unif (fun x => wsign (f x))| ≤ bp (-(M.rank:ℝ)/2) := by
|
| 28 |
-
classical
|
| 29 |
-
let g (x : Vec I) := wsign (f x)
|
| 30 |
-
have hh :
|
| 31 |
-
avg unif g ^ 2 = avg unif (fun x : Vec I => avg unif (fun y : Vec I =>
|
| 32 |
-
g (x+y)*g y)) := by
|
| 33 |
-
have hi (i : Vec I) : avg unif (fun x => g (x+i)*g i)=avg unif g*g i := by
|
| 34 |
-
rw [avg_mul,phase_trans]
|
| 35 |
-
rw [avg_avg]; simp_rw [hi,avg_mul']
|
| 36 |
-
ring
|
| 37 |
-
let L := Mᵀ
|
| 38 |
-
have hg x y : g (x+y)*g y= wsign (f x+f 0)*wsign (dotL (L *ᵥ x) y) := by
|
| 39 |
-
unfold g; rw [← wsign_add,← wsign_add,add_comm x y,h y x]
|
| 40 |
-
unfold L
|
| 41 |
-
congr 2
|
| 42 |
-
change dotProduct x (M *ᵥ y)=dotProduct _ y
|
| 43 |
-
rw [dotProduct_comm _ y,dotProduct_transpose_mulVec]
|
| 44 |
-
have hi (x : Vec I) :
|
| 45 |
-
avg unif (fun y : Vec I => g (x+y)*g y) ≤ ind ((L *ᵥ x)=0) := by
|
| 46 |
-
simp_rw [hg x,avg_mul',wsign_lin]
|
| 47 |
-
have he : dotL (L *ᵥ x)=0 ↔ L *ᵥ x=0 := by
|
| 48 |
-
constructor
|
| 49 |
-
· exact fun h => dot_ext_zero fun y => by rw [dotProduct_comm]; exact LinearMap.congr_fun h y
|
| 50 |
-
intro h; rw [h]; exact LinearMap.ext (fun x => zero_dotProduct x)
|
| 51 |
-
rw [he]
|
| 52 |
-
exact (mul_le_mul_of_nonneg_right ((le_abs_self _).trans_eq (wsign_abs _))
|
| 53 |
-
(ind_nonneg _)).trans_eq (one_mul _)
|
| 54 |
-
refine half_power _ _ (?_)
|
| 55 |
-
change avg unif g^2≤_
|
| 56 |
-
rw [hh]
|
| 57 |
-
refine (avg_mono unif_law.nz hi).trans_eq ?_
|
| 58 |
-
have he : pr unif (fun x => L.mulVecLin x=0) = _ := pr_unif_lin L.mulVecLin 0
|
| 59 |
-
rw [ind_one (LinearMap.range L.mulVecLin).zero_mem,one_mul] at he
|
| 60 |
-
change pr unif _=_
|
| 61 |
-
exact he.trans (by change bp (-(L.rank:ℝ))=_; rw [show L=Mᵀ from rfl,Matrix.rank_transpose])
|
| 62 |
-
|
| 63 |
-
omit [DecidableEq I] [DecidableEq J] in
|
| 64 |
-
theorem flare_affine (M : Mat J J) (P : Mat J I) (k : Vec J) (a : F) (i : Vec I) :
|
| 65 |
-
let Q := fun x => dotProduct i x + (a + evmat M (P *ᵥ x+k) (P *ᵥ x+k))
|
| 66 |
-
polarize Q (pullM P P (M+Mᵀ)) := by
|
| 67 |
-
intro Q x y
|
| 68 |
-
have he : dotProduct y ((pullM P P (M+Mᵀ)) *ᵥ x)=
|
| 69 |
-
evmat M (P *ᵥ y) (P *ᵥ x) + evmat M (P *ᵥ x) (P *ᵥ y) := by
|
| 70 |
-
change evmat _ _ _=_
|
| 71 |
-
rw [evmat_pull,evmat_addM, evmat_transpose]
|
| 72 |
-
rw [he]
|
| 73 |
-
unfold Q evmat
|
| 74 |
-
simp only [dotProduct_zero,Matrix.mulVec_zero,mulVec_add,dotProduct_add,add_dotProduct,
|
| 75 |
-
zero_add]
|
| 76 |
-
|
| 77 |
-
ring_nf
|
| 78 |
-
simp only [mul_two,char_two,add_zero,zero_add]
|
| 79 |
-
end HadwigerCounterexample
|
| 80 |
-
|
| 81 |
-
end
|
| 82 |
-
|
| 83 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FreeBlockFourier
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Quadratic Fourier -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix Module LinearMap Submodule Function Finset
|
| 11 |
+
variable {I J : Type} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J]
|
| 12 |
+
|
| 13 |
+
theorem phase_trans (t : Vec I) (f : Wgt (Vec I)) :
|
| 14 |
+
avg unif (fun y => f (y+t))=avg unif f := by
|
| 15 |
+
let E : Vec I ≃ Vec I := ⟨(·+t),(·+t),add_polar t,add_polar t⟩
|
| 16 |
+
exact avg_bij E unif f
|
| 17 |
+
|
| 18 |
+
theorem half_power (x a : ℝ) (ha : x^2 ≤ bp a) : |x|≤ bp (a/2) :=
|
| 19 |
+
le_of_pow_le_pow_left₀ (by decide : 2≠0) (bp_pos _).le (by
|
| 20 |
+
rw [sq_abs,pow_two (bp _),←bp_add,show a/2+a/2=a by ring]; exact ha)
|
| 21 |
+
|
| 22 |
+
def polarize (f : Vec I→F) (M : Mat I I) :=
|
| 23 |
+
∀ x y,f (x+y)+f x=f y+f 0+dotProduct y (M *ᵥ x)
|
| 24 |
+
|
| 25 |
+
set_option maxHeartbeats 600000 in
|
| 26 |
+
theorem flare_rank (f : Vec I→F) (M : Mat I I) (h : polarize f M) :
|
| 27 |
+
|avg unif (fun x => wsign (f x))| ≤ bp (-(M.rank:ℝ)/2) := by
|
| 28 |
+
classical
|
| 29 |
+
let g (x : Vec I) := wsign (f x)
|
| 30 |
+
have hh :
|
| 31 |
+
avg unif g ^ 2 = avg unif (fun x : Vec I => avg unif (fun y : Vec I =>
|
| 32 |
+
g (x+y)*g y)) := by
|
| 33 |
+
have hi (i : Vec I) : avg unif (fun x => g (x+i)*g i)=avg unif g*g i := by
|
| 34 |
+
rw [avg_mul,phase_trans]
|
| 35 |
+
rw [avg_avg]; simp_rw [hi,avg_mul']
|
| 36 |
+
ring
|
| 37 |
+
let L := Mᵀ
|
| 38 |
+
have hg x y : g (x+y)*g y= wsign (f x+f 0)*wsign (dotL (L *ᵥ x) y) := by
|
| 39 |
+
unfold g; rw [← wsign_add,← wsign_add,add_comm x y,h y x]
|
| 40 |
+
unfold L
|
| 41 |
+
congr 2
|
| 42 |
+
change dotProduct x (M *ᵥ y)=dotProduct _ y
|
| 43 |
+
rw [dotProduct_comm _ y,dotProduct_transpose_mulVec]
|
| 44 |
+
have hi (x : Vec I) :
|
| 45 |
+
avg unif (fun y : Vec I => g (x+y)*g y) ≤ ind ((L *ᵥ x)=0) := by
|
| 46 |
+
simp_rw [hg x,avg_mul',wsign_lin]
|
| 47 |
+
have he : dotL (L *ᵥ x)=0 ↔ L *ᵥ x=0 := by
|
| 48 |
+
constructor
|
| 49 |
+
· exact fun h => dot_ext_zero fun y => by rw [dotProduct_comm]; exact LinearMap.congr_fun h y
|
| 50 |
+
intro h; rw [h]; exact LinearMap.ext (fun x => zero_dotProduct x)
|
| 51 |
+
rw [he]
|
| 52 |
+
exact (mul_le_mul_of_nonneg_right ((le_abs_self _).trans_eq (wsign_abs _))
|
| 53 |
+
(ind_nonneg _)).trans_eq (one_mul _)
|
| 54 |
+
refine half_power _ _ (?_)
|
| 55 |
+
change avg unif g^2≤_
|
| 56 |
+
rw [hh]
|
| 57 |
+
refine (avg_mono unif_law.nz hi).trans_eq ?_
|
| 58 |
+
have he : pr unif (fun x => L.mulVecLin x=0) = _ := pr_unif_lin L.mulVecLin 0
|
| 59 |
+
rw [ind_one (LinearMap.range L.mulVecLin).zero_mem,one_mul] at he
|
| 60 |
+
change pr unif _=_
|
| 61 |
+
exact he.trans (by change bp (-(L.rank:ℝ))=_; rw [show L=Mᵀ from rfl,Matrix.rank_transpose])
|
| 62 |
+
|
| 63 |
+
omit [DecidableEq I] [DecidableEq J] in
|
| 64 |
+
theorem flare_affine (M : Mat J J) (P : Mat J I) (k : Vec J) (a : F) (i : Vec I) :
|
| 65 |
+
let Q := fun x => dotProduct i x + (a + evmat M (P *ᵥ x+k) (P *ᵥ x+k))
|
| 66 |
+
polarize Q (pullM P P (M+Mᵀ)) := by
|
| 67 |
+
intro Q x y
|
| 68 |
+
have he : dotProduct y ((pullM P P (M+Mᵀ)) *ᵥ x)=
|
| 69 |
+
evmat M (P *ᵥ y) (P *ᵥ x) + evmat M (P *ᵥ x) (P *ᵥ y) := by
|
| 70 |
+
change evmat _ _ _=_
|
| 71 |
+
rw [evmat_pull,evmat_addM, evmat_transpose]
|
| 72 |
+
rw [he]
|
| 73 |
+
unfold Q evmat
|
| 74 |
+
simp only [dotProduct_zero,Matrix.mulVec_zero,mulVec_add,dotProduct_add,add_dotProduct,
|
| 75 |
+
zero_add]
|
| 76 |
+
|
| 77 |
+
ring_nf
|
| 78 |
+
simp only [mul_two,char_two,add_zero,zero_add]
|
| 79 |
+
end HadwigerCounterexample
|
| 80 |
+
|
| 81 |
+
end
|
| 82 |
+
|
| 83 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/QuadraticTesters.lean
CHANGED
|
@@ -1,163 +1,163 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.MomentCoordinates
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Quadratic Testers -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
|
| 12 |
-
theorem pair_outers {I J : Type} [Fintype I] [Fintype J] (x x' : Vec I) (y y' : Vec J) :
|
| 13 |
-
mpair (vecMulVec x y) (vecMulVec x' y') =
|
| 14 |
-
dotProduct x x' * dotProduct y y' := by
|
| 15 |
-
simp only [mpair, dotProduct,vecMulVec_apply,LinearMap.coe_mk,AddHom.coe_mk,
|
| 16 |
-
Finset.sum_mul,Finset.mul_sum]
|
| 17 |
-
rw [Finset.sum_comm]
|
| 18 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 19 |
-
refine Finset.sum_congr rfl fun j _ => ?_
|
| 20 |
-
ring
|
| 21 |
-
|
| 22 |
-
theorem mpair_sum {I J : Type} [Fintype I] [Fintype J] (m : Mat I J)
|
| 23 |
-
{α : Type*} (s : Finset α) (f : α → Mat I J) :
|
| 24 |
-
mpair (∑ i ∈ s, f i) m = ∑ i ∈ s, mpair (f i) m := by
|
| 25 |
-
rw [mpair_comm,map_sum]
|
| 26 |
-
exact Finset.sum_congr rfl fun i _ => mpair_comm _ _
|
| 27 |
-
|
| 28 |
-
theorem mpair_add {I J : Type} [Fintype I] [Fintype J] (A B M : Mat I J) :
|
| 29 |
-
mpair (A+B) M = mpair A M + mpair B M := by rw [mpair_comm,map_add,mpair_comm M,mpair_comm M]
|
| 30 |
-
|
| 31 |
-
theorem mpair_smul {I J : Type} [Fintype I] [Fintype J] (b : F) (A M : Mat I J) :
|
| 32 |
-
mpair (b • A) M = b * mpair A M := by rw [mpair_comm,map_smul,mpair_comm M, smul_eq_mul]
|
| 33 |
-
|
| 34 |
-
variable (p : Shape)
|
| 35 |
-
|
| 36 |
-
def pick (n : ℕ) (u : SelIdx p.b p.j) (d : Block p.g) (i : ℕ) : Ray p n :=
|
| 37 |
-
if h : i < n then Pi.single (u,some (d,⟨i,h⟩)) 1 else 0
|
| 38 |
-
|
| 39 |
-
def readBit {n g} (z : Base g n) (d : Block g) (i : ℕ) : F :=
|
| 40 |
-
if h : i < n then z (d,⟨i,h⟩) else 0
|
| 41 |
-
|
| 42 |
-
def testM (n : ℕ) (d : Block p.g) : Moment p n :=
|
| 43 |
-
∑ i : Fin p.r, vecMulVec (pick p n emptySel d (2*i.val))
|
| 44 |
-
(pick p n emptySel d (2*i.val+1))
|
| 45 |
-
|
| 46 |
-
def etab (n) (d : Block p.g) : Moment p n →ₗ[F] F := mpair (testM p n d)
|
| 47 |
-
|
| 48 |
-
def test (n : ℕ) (d : Block p.g) (z z' : Base p.g n) : F :=
|
| 49 |
-
∑ i : Fin p.r, readBit z d (2*i.val) * readBit z' d (2*i.val+1)
|
| 50 |
-
|
| 51 |
-
theorem pick_point {n} (s) (z : Base p.g n) (u : SelIdx p.b p.j)
|
| 52 |
-
(d : Block p.g) (i : ℕ) :
|
| 53 |
-
dotProduct (pick p n u d i) (point p s z) = selV _ s u * readBit z d i := by
|
| 54 |
-
by_cases hi : i < n
|
| 55 |
-
· rw [pick,dite_eq_left hi,single_one_dotProduct,readBit,dite_eq_left hi]; rfl
|
| 56 |
-
· rw [pick,dite_eq_right hi,zero_dotProduct, readBit,dite_eq_right hi,mul_zero]
|
| 57 |
-
|
| 58 |
-
theorem etab_point {n} (d : Block p.g) (s s') (z z' : Base p.g n) :
|
| 59 |
-
etab p n d (vecMulVec (point p s z) (point p s' z')) = test p n d z z' := by
|
| 60 |
-
unfold etab testM test
|
| 61 |
-
simp only [mpair_sum,pair_outers,pick_point]
|
| 62 |
-
simp [selV,emptySel]
|
| 63 |
-
|
| 64 |
-
theorem etab_disabled {n} {l d : Tag p.g} (h : ¬allowed d l) (t : Tag p.g)
|
| 65 |
-
{m : Moment p n} (hm : m ∈ Wtag p n l) :
|
| 66 |
-
etab p n (Block.O d t) m = 0 := by
|
| 67 |
-
unfold Wtag at hm
|
| 68 |
-
induction hm using Submodule.span_induction with
|
| 69 |
-
| mem m hm =>
|
| 70 |
-
obtain ⟨s,z,hz,rfl⟩ := hm
|
| 71 |
-
rw [mom,etab_point]
|
| 72 |
-
have h' (i : ℕ) : readBit z (Block.O d t) i = 0 := by
|
| 73 |
-
simp [readBit,hz d t h]
|
| 74 |
-
simp only [test,h',mul_zero,Finset.sum_const_zero]
|
| 75 |
-
| zero => rw [map_zero]
|
| 76 |
-
| add _ _ _ _ h g => rw [map_add,h,g,add_zero]
|
| 77 |
-
| smul _ _ _ h => rw [map_smul,h,smul_zero]
|
| 78 |
-
|
| 79 |
-
/-- all O testers. -/
|
| 80 |
-
def etaO (n) : Moment p n →ₗ[F] F :=
|
| 81 |
-
∑ (d : Tag p.g), ∑ (t : Tag p.g), etab p n (Block.O d t)
|
| 82 |
-
|
| 83 |
-
def eta (n) : Moment p n →ₗ[F] F := etaO p n + etab p n Block.S
|
| 84 |
-
|
| 85 |
-
/-- a_t read on full ambient profile using allowed tags with partner d. -/
|
| 86 |
-
def roleT (n : ℕ) (t : Tag p.g) : Profile p n →ₗ[F] F :=
|
| 87 |
-
∑ (l : Tag p.g), ∑ d ∈ Finset.univ.filter (fun d => allowed d l),
|
| 88 |
-
etab p n (Block.O d t) ∘ₗ getPair p n l d
|
| 89 |
-
|
| 90 |
-
theorem roleT_cut {n} (t : Tag p.g) (w : Tag p.g → Moment p n)
|
| 91 |
-
(hw : ∀ i, w i ∈ Wtag p n i) :
|
| 92 |
-
roleT p n t (cut p n w) =
|
| 93 |
-
∑ (l : Tag p.g), ∑ (d : Tag p.g), etab p n (Block.O d t) (w l) := by
|
| 94 |
-
simp only [roleT,LinearMap.sum_apply,LinearMap.comp_apply,getPair_cut,map_add]
|
| 95 |
-
refine Finset.sum_congr rfl fun l _ => ?_
|
| 96 |
-
rw [Finset.sum_filter]
|
| 97 |
-
refine Finset.sum_congr rfl fun d _ => ?_
|
| 98 |
-
by_cases h : allowed d l
|
| 99 |
-
· rw [ite_eq_left h,etab_disabled p (not_allowed d) t (hw d),add_zero]
|
| 100 |
-
· rw [ite_eq_right h,etab_disabled p h t (hw l)]
|
| 101 |
-
|
| 102 |
-
def role (n : ℕ) := ∑ t : Tag p.g, roleT p n t
|
| 103 |
-
|
| 104 |
-
theorem role_cut {n} (w : Tag p.g → Moment p n) (hw : ∀ i,w i ∈ Wtag p n i) :
|
| 105 |
-
role p n (cut p n w) = ∑ i, etaO p n (w i) := by
|
| 106 |
-
simp only [role,LinearMap.sum_apply,roleT_cut _ _ _ hw]
|
| 107 |
-
rw [Finset.sum_comm]
|
| 108 |
-
refine Finset.sum_congr rfl fun l _ => ?_
|
| 109 |
-
rw [Finset.sum_comm]
|
| 110 |
-
simp only [etaO,LinearMap.sum_apply]
|
| 111 |
-
|
| 112 |
-
/-- b_t read on the full ambient profile. -/
|
| 113 |
-
def sharedT (n : ℕ) (t : Tag p.g) : Profile p n →ₗ[F] F :=
|
| 114 |
-
∑ (l : Tag p.g), etab p n Block.S ∘ₗ getPair p n l t
|
| 115 |
-
|
| 116 |
-
theorem sharedT_cut {n} (hg : Odd p.g) (t : Tag p.g) (w : Tag p.g → Moment p n) :
|
| 117 |
-
sharedT p n t (cut p n w) =
|
| 118 |
-
(∑ i, etab p n Block.S (w i)) + etab p n Block.S (w t) := by
|
| 119 |
-
simp only [sharedT,LinearMap.sum_apply,LinearMap.comp_apply,getPair_cut,map_add,
|
| 120 |
-
Finset.sum_add_distrib,Finset.sum_const, Finset.card_univ]
|
| 121 |
-
simp [Tag,odd_smul_bit hg]
|
| 122 |
-
|
| 123 |
-
def sharpPick (n : ℕ) (a : Fin p.b) (i : Fin n) : Ray p n :=
|
| 124 |
-
if h : 1 ≤ p.j then pick p n ⟨{a},by simp [h]⟩ Block.sharp i.val else 0
|
| 125 |
-
|
| 126 |
-
def sharpM (n : ℕ) (Y : Fin p.b → Mat (Fin n) (Fin n)) : Moment p n :=
|
| 127 |
-
∑ a : Fin p.b, ∑ i : Fin n, ∑ j : Fin n,
|
| 128 |
-
Y a i j • (vecMulVec (sharpPick p n a i) (pick p n emptySel Block.sharp j.val) +
|
| 129 |
-
vecMulVec (pick p n emptySel Block.sharp i.val) (sharpPick p n a j))
|
| 130 |
-
|
| 131 |
-
theorem sharpM_point {n} (hj : 1 ≤ p.j) (Y) (s s') (z z' : Base p.g n) :
|
| 132 |
-
mpair (sharpM p n Y) (vecMulVec (point p s z) (point p s' z')) =
|
| 133 |
-
∑ a : Fin p.b, (s a + s' a) *
|
| 134 |
-
evmat (Y a) (fun i => z (Block.sharp,i)) (fun i => z' (Block.sharp,i)) := by
|
| 135 |
-
simp only [sharpM,mpair_sum,mpair_smul,mpair_add,pair_outers,
|
| 136 |
-
sharpPick,dite_eq_left hj,pick_point,readBit,dite_eq_left (Fin.isLt _)]
|
| 137 |
-
simp [selV,emptySel,evmat,dotProduct,mulVec,Finset.mul_sum]
|
| 138 |
-
refine Finset.sum_congr rfl fun a _ => Finset.sum_congr rfl fun i _ =>
|
| 139 |
-
Finset.sum_congr rfl fun j _ => ?_
|
| 140 |
-
ring
|
| 141 |
-
|
| 142 |
-
def selfM (n) (Y : Fin p.b → Mat (Fin n) (Fin n)) : Moment p n :=
|
| 143 |
-
((∑ d : Tag p.g, ∑ t : Tag p.g, testM p n (Block.O d t)) +
|
| 144 |
-
testM p n Block.S) + sharpM p n Y
|
| 145 |
-
|
| 146 |
-
theorem selfM_pair {n} (hj : 1 ≤ p.j) (Y) {m : Moment p n} (hm : m ∈ Wspace p n) :
|
| 147 |
-
mpair (selfM p n Y) m = eta p n m := by
|
| 148 |
-
unfold Wspace at hm
|
| 149 |
-
induction hm using Submodule.span_induction with
|
| 150 |
-
| mem m h =>
|
| 151 |
-
obtain ⟨s,z,rfl⟩ := h
|
| 152 |
-
simp only [selfM,mpair_sum,mpair_add,mom,sharpM_point p hj,char_two,zero_mul,
|
| 153 |
-
Finset.sum_const_zero, add_zero,eta,etaO,etab,LinearMap.add_apply,
|
| 154 |
-
LinearMap.sum_apply]
|
| 155 |
-
| zero => simp only [map_zero]
|
| 156 |
-
| add _ _ _ _ h g => rw [map_add,h,g,map_add]
|
| 157 |
-
| smul _ _ _ h => rw [map_smul,h,map_smul]
|
| 158 |
-
|
| 159 |
-
end HadwigerCounterexample
|
| 160 |
-
|
| 161 |
-
end
|
| 162 |
-
|
| 163 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.MomentCoordinates
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Quadratic Testers -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
theorem pair_outers {I J : Type} [Fintype I] [Fintype J] (x x' : Vec I) (y y' : Vec J) :
|
| 13 |
+
mpair (vecMulVec x y) (vecMulVec x' y') =
|
| 14 |
+
dotProduct x x' * dotProduct y y' := by
|
| 15 |
+
simp only [mpair, dotProduct,vecMulVec_apply,LinearMap.coe_mk,AddHom.coe_mk,
|
| 16 |
+
Finset.sum_mul,Finset.mul_sum]
|
| 17 |
+
rw [Finset.sum_comm]
|
| 18 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 19 |
+
refine Finset.sum_congr rfl fun j _ => ?_
|
| 20 |
+
ring
|
| 21 |
+
|
| 22 |
+
theorem mpair_sum {I J : Type} [Fintype I] [Fintype J] (m : Mat I J)
|
| 23 |
+
{α : Type*} (s : Finset α) (f : α → Mat I J) :
|
| 24 |
+
mpair (∑ i ∈ s, f i) m = ∑ i ∈ s, mpair (f i) m := by
|
| 25 |
+
rw [mpair_comm,map_sum]
|
| 26 |
+
exact Finset.sum_congr rfl fun i _ => mpair_comm _ _
|
| 27 |
+
|
| 28 |
+
theorem mpair_add {I J : Type} [Fintype I] [Fintype J] (A B M : Mat I J) :
|
| 29 |
+
mpair (A+B) M = mpair A M + mpair B M := by rw [mpair_comm,map_add,mpair_comm M,mpair_comm M]
|
| 30 |
+
|
| 31 |
+
theorem mpair_smul {I J : Type} [Fintype I] [Fintype J] (b : F) (A M : Mat I J) :
|
| 32 |
+
mpair (b • A) M = b * mpair A M := by rw [mpair_comm,map_smul,mpair_comm M, smul_eq_mul]
|
| 33 |
+
|
| 34 |
+
variable (p : Shape)
|
| 35 |
+
|
| 36 |
+
def pick (n : ℕ) (u : SelIdx p.b p.j) (d : Block p.g) (i : ℕ) : Ray p n :=
|
| 37 |
+
if h : i < n then Pi.single (u,some (d,⟨i,h⟩)) 1 else 0
|
| 38 |
+
|
| 39 |
+
def readBit {n g} (z : Base g n) (d : Block g) (i : ℕ) : F :=
|
| 40 |
+
if h : i < n then z (d,⟨i,h⟩) else 0
|
| 41 |
+
|
| 42 |
+
def testM (n : ℕ) (d : Block p.g) : Moment p n :=
|
| 43 |
+
∑ i : Fin p.r, vecMulVec (pick p n emptySel d (2*i.val))
|
| 44 |
+
(pick p n emptySel d (2*i.val+1))
|
| 45 |
+
|
| 46 |
+
def etab (n) (d : Block p.g) : Moment p n →ₗ[F] F := mpair (testM p n d)
|
| 47 |
+
|
| 48 |
+
def test (n : ℕ) (d : Block p.g) (z z' : Base p.g n) : F :=
|
| 49 |
+
∑ i : Fin p.r, readBit z d (2*i.val) * readBit z' d (2*i.val+1)
|
| 50 |
+
|
| 51 |
+
theorem pick_point {n} (s) (z : Base p.g n) (u : SelIdx p.b p.j)
|
| 52 |
+
(d : Block p.g) (i : ℕ) :
|
| 53 |
+
dotProduct (pick p n u d i) (point p s z) = selV _ s u * readBit z d i := by
|
| 54 |
+
by_cases hi : i < n
|
| 55 |
+
· rw [pick,dite_eq_left hi,single_one_dotProduct,readBit,dite_eq_left hi]; rfl
|
| 56 |
+
· rw [pick,dite_eq_right hi,zero_dotProduct, readBit,dite_eq_right hi,mul_zero]
|
| 57 |
+
|
| 58 |
+
theorem etab_point {n} (d : Block p.g) (s s') (z z' : Base p.g n) :
|
| 59 |
+
etab p n d (vecMulVec (point p s z) (point p s' z')) = test p n d z z' := by
|
| 60 |
+
unfold etab testM test
|
| 61 |
+
simp only [mpair_sum,pair_outers,pick_point]
|
| 62 |
+
simp [selV,emptySel]
|
| 63 |
+
|
| 64 |
+
theorem etab_disabled {n} {l d : Tag p.g} (h : ¬allowed d l) (t : Tag p.g)
|
| 65 |
+
{m : Moment p n} (hm : m ∈ Wtag p n l) :
|
| 66 |
+
etab p n (Block.O d t) m = 0 := by
|
| 67 |
+
unfold Wtag at hm
|
| 68 |
+
induction hm using Submodule.span_induction with
|
| 69 |
+
| mem m hm =>
|
| 70 |
+
obtain ⟨s,z,hz,rfl⟩ := hm
|
| 71 |
+
rw [mom,etab_point]
|
| 72 |
+
have h' (i : ℕ) : readBit z (Block.O d t) i = 0 := by
|
| 73 |
+
simp [readBit,hz d t h]
|
| 74 |
+
simp only [test,h',mul_zero,Finset.sum_const_zero]
|
| 75 |
+
| zero => rw [map_zero]
|
| 76 |
+
| add _ _ _ _ h g => rw [map_add,h,g,add_zero]
|
| 77 |
+
| smul _ _ _ h => rw [map_smul,h,smul_zero]
|
| 78 |
+
|
| 79 |
+
/-- all O testers. -/
|
| 80 |
+
def etaO (n) : Moment p n →ₗ[F] F :=
|
| 81 |
+
∑ (d : Tag p.g), ∑ (t : Tag p.g), etab p n (Block.O d t)
|
| 82 |
+
|
| 83 |
+
def eta (n) : Moment p n →ₗ[F] F := etaO p n + etab p n Block.S
|
| 84 |
+
|
| 85 |
+
/-- a_t read on full ambient profile using allowed tags with partner d. -/
|
| 86 |
+
def roleT (n : ℕ) (t : Tag p.g) : Profile p n →ₗ[F] F :=
|
| 87 |
+
∑ (l : Tag p.g), ∑ d ∈ Finset.univ.filter (fun d => allowed d l),
|
| 88 |
+
etab p n (Block.O d t) ∘ₗ getPair p n l d
|
| 89 |
+
|
| 90 |
+
theorem roleT_cut {n} (t : Tag p.g) (w : Tag p.g → Moment p n)
|
| 91 |
+
(hw : ∀ i, w i ∈ Wtag p n i) :
|
| 92 |
+
roleT p n t (cut p n w) =
|
| 93 |
+
∑ (l : Tag p.g), ∑ (d : Tag p.g), etab p n (Block.O d t) (w l) := by
|
| 94 |
+
simp only [roleT,LinearMap.sum_apply,LinearMap.comp_apply,getPair_cut,map_add]
|
| 95 |
+
refine Finset.sum_congr rfl fun l _ => ?_
|
| 96 |
+
rw [Finset.sum_filter]
|
| 97 |
+
refine Finset.sum_congr rfl fun d _ => ?_
|
| 98 |
+
by_cases h : allowed d l
|
| 99 |
+
· rw [ite_eq_left h,etab_disabled p (not_allowed d) t (hw d),add_zero]
|
| 100 |
+
· rw [ite_eq_right h,etab_disabled p h t (hw l)]
|
| 101 |
+
|
| 102 |
+
def role (n : ℕ) := ∑ t : Tag p.g, roleT p n t
|
| 103 |
+
|
| 104 |
+
theorem role_cut {n} (w : Tag p.g → Moment p n) (hw : ∀ i,w i ∈ Wtag p n i) :
|
| 105 |
+
role p n (cut p n w) = ∑ i, etaO p n (w i) := by
|
| 106 |
+
simp only [role,LinearMap.sum_apply,roleT_cut _ _ _ hw]
|
| 107 |
+
rw [Finset.sum_comm]
|
| 108 |
+
refine Finset.sum_congr rfl fun l _ => ?_
|
| 109 |
+
rw [Finset.sum_comm]
|
| 110 |
+
simp only [etaO,LinearMap.sum_apply]
|
| 111 |
+
|
| 112 |
+
/-- b_t read on the full ambient profile. -/
|
| 113 |
+
def sharedT (n : ℕ) (t : Tag p.g) : Profile p n →ₗ[F] F :=
|
| 114 |
+
∑ (l : Tag p.g), etab p n Block.S ∘ₗ getPair p n l t
|
| 115 |
+
|
| 116 |
+
theorem sharedT_cut {n} (hg : Odd p.g) (t : Tag p.g) (w : Tag p.g → Moment p n) :
|
| 117 |
+
sharedT p n t (cut p n w) =
|
| 118 |
+
(∑ i, etab p n Block.S (w i)) + etab p n Block.S (w t) := by
|
| 119 |
+
simp only [sharedT,LinearMap.sum_apply,LinearMap.comp_apply,getPair_cut,map_add,
|
| 120 |
+
Finset.sum_add_distrib,Finset.sum_const, Finset.card_univ]
|
| 121 |
+
simp [Tag,odd_smul_bit hg]
|
| 122 |
+
|
| 123 |
+
def sharpPick (n : ℕ) (a : Fin p.b) (i : Fin n) : Ray p n :=
|
| 124 |
+
if h : 1 ≤ p.j then pick p n ⟨{a},by simp [h]⟩ Block.sharp i.val else 0
|
| 125 |
+
|
| 126 |
+
def sharpM (n : ℕ) (Y : Fin p.b → Mat (Fin n) (Fin n)) : Moment p n :=
|
| 127 |
+
∑ a : Fin p.b, ∑ i : Fin n, ∑ j : Fin n,
|
| 128 |
+
Y a i j • (vecMulVec (sharpPick p n a i) (pick p n emptySel Block.sharp j.val) +
|
| 129 |
+
vecMulVec (pick p n emptySel Block.sharp i.val) (sharpPick p n a j))
|
| 130 |
+
|
| 131 |
+
theorem sharpM_point {n} (hj : 1 ≤ p.j) (Y) (s s') (z z' : Base p.g n) :
|
| 132 |
+
mpair (sharpM p n Y) (vecMulVec (point p s z) (point p s' z')) =
|
| 133 |
+
∑ a : Fin p.b, (s a + s' a) *
|
| 134 |
+
evmat (Y a) (fun i => z (Block.sharp,i)) (fun i => z' (Block.sharp,i)) := by
|
| 135 |
+
simp only [sharpM,mpair_sum,mpair_smul,mpair_add,pair_outers,
|
| 136 |
+
sharpPick,dite_eq_left hj,pick_point,readBit,dite_eq_left (Fin.isLt _)]
|
| 137 |
+
simp [selV,emptySel,evmat,dotProduct,mulVec,Finset.mul_sum]
|
| 138 |
+
refine Finset.sum_congr rfl fun a _ => Finset.sum_congr rfl fun i _ =>
|
| 139 |
+
Finset.sum_congr rfl fun j _ => ?_
|
| 140 |
+
ring
|
| 141 |
+
|
| 142 |
+
def selfM (n) (Y : Fin p.b → Mat (Fin n) (Fin n)) : Moment p n :=
|
| 143 |
+
((∑ d : Tag p.g, ∑ t : Tag p.g, testM p n (Block.O d t)) +
|
| 144 |
+
testM p n Block.S) + sharpM p n Y
|
| 145 |
+
|
| 146 |
+
theorem selfM_pair {n} (hj : 1 ≤ p.j) (Y) {m : Moment p n} (hm : m ∈ Wspace p n) :
|
| 147 |
+
mpair (selfM p n Y) m = eta p n m := by
|
| 148 |
+
unfold Wspace at hm
|
| 149 |
+
induction hm using Submodule.span_induction with
|
| 150 |
+
| mem m h =>
|
| 151 |
+
obtain ⟨s,z,rfl⟩ := h
|
| 152 |
+
simp only [selfM,mpair_sum,mpair_add,mom,sharpM_point p hj,char_two,zero_mul,
|
| 153 |
+
Finset.sum_const_zero, add_zero,eta,etaO,etab,LinearMap.add_apply,
|
| 154 |
+
LinearMap.sum_apply]
|
| 155 |
+
| zero => simp only [map_zero]
|
| 156 |
+
| add _ _ _ _ h g => rw [map_add,h,g,map_add]
|
| 157 |
+
| smul _ _ _ h => rw [map_smul,h,map_smul]
|
| 158 |
+
|
| 159 |
+
end HadwigerCounterexample
|
| 160 |
+
|
| 161 |
+
end
|
| 162 |
+
|
| 163 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/QueryConcentration.lean
CHANGED
|
@@ -1,172 +1,172 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.GroupedQueryIndependence
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Query Concentration -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Module Matrix Finset Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {I G A K D : Type} [Fintype I] [Fintype G] [Fintype A]
|
| 12 |
-
variable [Fintype K] [Fintype D] [DecidableEq I] [DecidableEq G] [DecidableEq K]
|
| 13 |
-
|
| 14 |
-
structure Program (p : Shape) (n : ℕ) {I G : Type} (g : Route I G) (A : Type) where
|
| 15 |
-
left : A→NomQuery p n g
|
| 16 |
-
right : A→NomQuery p n g
|
| 17 |
-
|
| 18 |
-
variable {g : Route I G}
|
| 19 |
-
|
| 20 |
-
namespace Program
|
| 21 |
-
variable (s : Program p n g A)
|
| 22 |
-
|
| 23 |
-
def free (x : K→ A) :=
|
| 24 |
-
(∀ i,Injective (pooled (s.left ∘ x) i).mulVec)∧
|
| 25 |
-
(∀ i,Injective (pooled (s.right ∘ x) i).mulVec)
|
| 26 |
-
|
| 27 |
-
def showKey (x : A) (o : Forum p n N G) :=
|
| 28 |
-
peekR p g (s.left x) (s.right x) o
|
| 29 |
-
|
| 30 |
-
def oexpect (w : Wgt A) (F : A → Rack I N → ℝ) (o : Forum p n N G) :=
|
| 31 |
-
avg w (fun x => F x (s.showKey x o))
|
| 32 |
-
end Program
|
| 33 |
-
|
| 34 |
-
theorem forum_law (m : Mixer p n) {N : ℕ} (hN : 2*num (Full p n)<N) :
|
| 35 |
-
IsLaw (forumLaw m N (G:=G)) :=
|
| 36 |
-
prodW_law (fun _ => unifOn_law (framesAt_exists (gramCond_exists m)
|
| 37 |
-
(by rw [←two_mul]; simpa only [num,Fintype.card_fin] using hN)))
|
| 38 |
-
|
| 39 |
-
theorem avg_bound1 {w : Wgt A} (hw : IsLaw w) (f : Wgt A) (hf : ∀ x,|f x|≤1) :
|
| 40 |
-
|avg w f|≤1 := (abs_avg_le hw.nz).trans (hw.avg_le hf)
|
| 41 |
-
theorem avg_cross_sq (w : Wgt A) (f : Wgt A) :
|
| 42 |
-
avg w f ^ 2=avg (draws Bool w) (fun q => f (q true)* f (q false)) := by
|
| 43 |
-
let g (i : Bool) := f
|
| 44 |
-
have hh := prodW_avg (fun _ : Bool => w) g
|
| 45 |
-
have he : prodW g=(fun q => f (q true)* f (q false)) := by ext; unfold prodW; rw [Fintype.prod_bool]
|
| 46 |
-
rw [he,Fintype.prod_bool] at hh; rw [pow_two]; exact hh.symm
|
| 47 |
-
|
| 48 |
-
theorem avg_var (w : Wgt A) (f : Wgt A) (hw : IsLaw w) :
|
| 49 |
-
avg w (fun x => (f x-avg w f)^2) = avg w (fun x => f x^2) - (avg w f)^2 := by
|
| 50 |
-
let g := avg w f
|
| 51 |
-
have hh (x) : (f x-g)^2=f x^2-2*g*f x+g^2 := by ring
|
| 52 |
-
change avg w (fun x => (f x-g)^2)=_
|
| 53 |
-
simp_rw [hh,avg_add,avg_sub,avg_mul',hw.avg_const]
|
| 54 |
-
unfold g; ring
|
| 55 |
-
|
| 56 |
-
namespace Program
|
| 57 |
-
variable {s : Program p n g A}
|
| 58 |
-
|
| 59 |
-
set_option maxHeartbeats 800000 in
|
| 60 |
-
theorem oVar (m : Mixer p n) (hN : 2*num (Full p n) < N)
|
| 61 |
-
(T : A→Wgt (Rack I N))
|
| 62 |
-
(w : Wgt A) (hw : IsLaw w) (hT : ∀ i x,|T i x|≤1)
|
| 63 |
-
(k : ℝ) (hk : ∀ i,num (Port (tied g Bool) i)≤k)
|
| 64 |
-
(hK : 2*k-N≤-1)
|
| 65 |
-
(r : ℝ) (hr : pr (draws Bool w) (fun x => ¬ s.free x) ≤ r) :
|
| 66 |
-
let v := forumLaw (G:=G) m N
|
| 67 |
-
let f := s.oexpect w T
|
| 68 |
-
avg v (fun o => (f o-avg v f)^2) ≤
|
| 69 |
-
2*r + 2*netFact (tied g Bool)*twinkle (tied g Bool) k N := by
|
| 70 |
-
classical
|
| 71 |
-
let v := forumLaw (G:=G) m N
|
| 72 |
-
let f := s.oexpect w T
|
| 73 |
-
let F (x : A) := fun o => T x (s.showKey x o)
|
| 74 |
-
let D := draws Bool w
|
| 75 |
-
let B := 2*netFact (tied g Bool)*twinkle (tied g Bool) k N
|
| 76 |
-
have hD : IsLaw D := draws_law hw
|
| 77 |
-
have hv : IsLaw v := forum_law _ hN
|
| 78 |
-
let V (x : Bool→A) := avg v (fun o => F (x true) o * F (x false) o)
|
| 79 |
-
let W (x : Bool→A) := avg v (F (x true))*avg v (F (x false))
|
| 80 |
-
have hW :
|
| 81 |
-
(avg v f)^2 = avg D W := by
|
| 82 |
-
unfold f oexpect
|
| 83 |
-
rw [avg_avg,avg_cross_sq]
|
| 84 |
-
have hV :
|
| 85 |
-
avg v (fun x => f x^2) = avg D V := by
|
| 86 |
-
unfold f oexpect; simp_rw [avg_cross_sq]; rw [avg_avg]
|
| 87 |
-
have hi x :
|
| 88 |
-
V x-W x ≤ 2*ind (¬s.free x)+B := by
|
| 89 |
-
by_cases he : s.free x
|
| 90 |
-
· have hh := pooled_batch (s.left ∘ x) (s.right ∘ x) m hN k hk hK he.1 he.2
|
| 91 |
-
(T ∘ x) (fun i y => hT _ _)
|
| 92 |
-
simp_rw [Fintype.prod_bool] at hh
|
| 93 |
-
rw [ind_zero (fun h => h he),mul_zero,zero_add]
|
| 94 |
-
exact (le_abs_self _).trans hh
|
| 95 |
-
have h1 (a b : ℝ) (h : |a|≤1) (g : |b|≤1) : |a*b|≤1 := by
|
| 96 |
-
rw [abs_mul]
|
| 97 |
-
exact (mul_le_mul h g (abs_nonneg _) zero_le_one).trans_eq (by ring)
|
| 98 |
-
have hh : |W x|≤1 := h1 _ _ (avg_bound1 hv _ (fun y => hT _ _)) (avg_bound1 hv _
|
| 99 |
-
(fun y => hT _ _))
|
| 100 |
-
have hg : |V x|≤1 := avg_bound1 hv _ (fun i => h1 _ _ (hT _ _) (hT _ _))
|
| 101 |
-
have ht : 0 ≤ twinkle (tied g Bool) k N := add_nonneg (mul_nonneg (Nat.cast_nonneg _)
|
| 102 |
-
(mul_nonneg (by norm_num) (bp_pos _).le)) (bp_pos _).le
|
| 103 |
-
have h2 : 0 ≤ B := mul_nonneg (mul_nonneg (by norm_num) netFact_pos.le) ht
|
| 104 |
-
rw [ind_one he,mul_one]
|
| 105 |
-
exact sub_le_iff_le_add.mpr (by linarith [(abs_le.mp hh).1,(abs_le.mp hg).2])
|
| 106 |
-
change avg v _ ≤ _
|
| 107 |
-
rw [avg_var v f hv,hW,hV,← avg_sub]
|
| 108 |
-
apply (avg_mono hD.nz hi).trans
|
| 109 |
-
rw [avg_add,avg_mul',hD.avg_const]
|
| 110 |
-
exact add_le_add_left (mul_le_mul_of_nonneg_left hr (by norm_num)) _
|
| 111 |
-
|
| 112 |
-
def oFreq (w : Wgt A) (F : A → Rack I N→Prop) (o : Forum p n N G)
|
| 113 |
-
(s : Program p n g A) :=
|
| 114 |
-
pr w (fun i => F i (s.showKey i o))
|
| 115 |
-
|
| 116 |
-
set_option maxHeartbeats 800000 in
|
| 117 |
-
theorem oTail (m : Mixer p n) (hN : 2*num (Full p n) < N)
|
| 118 |
-
(T : A→Rack I N →Prop)
|
| 119 |
-
(w : Wgt A) (hw : IsLaw w)
|
| 120 |
-
{k : ℝ} {l : ℕ} (hk : ∀ i,num (Port (tied g (Fin l)) i)≤k)
|
| 121 |
-
(hK : 2*k-N≤-1)
|
| 122 |
-
(r : ℝ) (hr : pr (draws (Fin l) w) (fun x => ¬ s.free x) ≤ r)
|
| 123 |
-
{ε : ℝ} (hε : 0 ≤ ε) :
|
| 124 |
-
let v := forumLaw (G:=G) m N
|
| 125 |
-
let f := (fun o => oFreq w T o s)
|
| 126 |
-
(ε^l - r)*pr v (fun x => ε ≤ f x) ≤ netFact (tied g (Fin l))* (avg v f)^l := by
|
| 127 |
-
classical
|
| 128 |
-
let v := forumLaw (G:=G) m N
|
| 129 |
-
let f := (fun o : Forum p n N G => oFreq w T o s)
|
| 130 |
-
have hv : IsLaw v := forum_law _ hN
|
| 131 |
-
let F := draws (Fin l) w
|
| 132 |
-
have hF : IsLaw F := draws_law hw
|
| 133 |
-
let P (x) (y : Fin l→A) := ∀ i,T (y i) (s.showKey (y i) x)
|
| 134 |
-
have hh (x) : pr F (fun y => P x y)= f x ^ l := by
|
| 135 |
-
unfold P F draws
|
| 136 |
-
rw [prodW_pr (fun (_ : Fin l) => w) (fun _ i => T i (s.showKey i x))]
|
| 137 |
-
simp only [Finset.prod_const, Finset.card_univ,Fintype.card_fin]
|
| 138 |
-
rfl
|
| 139 |
-
let Q (x : Fin l → A) := s.free x
|
| 140 |
-
let S (o) (x : Fin l→A) := P o x ∧ Q x
|
| 141 |
-
have hi (o) :
|
| 142 |
-
(ε^l-r)*ind (ε≤f o)≤ pr F (S o) := by
|
| 143 |
-
by_cases ht : ε≤f o
|
| 144 |
-
· rw [ind_one ht,mul_one]
|
| 145 |
-
refine (sub_le_sub (pow_le_pow_left₀ hε ht l) hr).trans ?_
|
| 146 |
-
rw [←hh]; exact pr_shield hF.nz _ _
|
| 147 |
-
rw [ind_zero ht,mul_zero]; exact pr_nonneg hF.nz
|
| 148 |
-
let W (x) := pr v (fun i => T x (s.showKey x i))
|
| 149 |
-
let C := netFact (tied g (Fin l))
|
| 150 |
-
have hq (x : Fin l → A) :
|
| 151 |
-
pr v (fun i => S i x) ≤ C*∏ i:Fin l,W (x i) := by
|
| 152 |
-
by_cases he : Q x
|
| 153 |
-
· have hg := pool_upper (s.left ∘ x) (s.right ∘ x) m hN he.1 he.2
|
| 154 |
-
(fun i => by linarith only [hk i,hK]) (T ∘ x)
|
| 155 |
-
simp only [S,he,and_true]
|
| 156 |
-
exact hg
|
| 157 |
-
simp only [S,he,and_false,pr_false]; exact mul_nonneg netFact_pos.le
|
| 158 |
-
(Finset.prod_nonneg fun i _ => pr_nonneg hv.nz)
|
| 159 |
-
have hg : avg v f=avg w W := avg_avg _ _ _
|
| 160 |
-
have he := avg_mono hv.nz hi
|
| 161 |
-
rw [avg_mul'] at he
|
| 162 |
-
change _ ≤ _
|
| 163 |
-
apply le_trans he
|
| 164 |
-
calc avg v (fun x => pr F (S x)) = avg F (fun y => pr v (fun x => S x y)) := avg_avg _ _ _
|
| 165 |
-
_ ≤ avg F (fun x => C*∏ i,W (x i)) := avg_mono hF.nz hq
|
| 166 |
-
_ = netFact _ * (avg v f)^l := by rw [avg_mul',hg, poweravg]
|
| 167 |
-
end Program
|
| 168 |
-
end HadwigerCounterexample
|
| 169 |
-
|
| 170 |
-
end
|
| 171 |
-
|
| 172 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.GroupedQueryIndependence
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Query Concentration -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Module Matrix Finset Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {I G A K D : Type} [Fintype I] [Fintype G] [Fintype A]
|
| 12 |
+
variable [Fintype K] [Fintype D] [DecidableEq I] [DecidableEq G] [DecidableEq K]
|
| 13 |
+
|
| 14 |
+
structure Program (p : Shape) (n : ℕ) {I G : Type} (g : Route I G) (A : Type) where
|
| 15 |
+
left : A→NomQuery p n g
|
| 16 |
+
right : A→NomQuery p n g
|
| 17 |
+
|
| 18 |
+
variable {g : Route I G}
|
| 19 |
+
|
| 20 |
+
namespace Program
|
| 21 |
+
variable (s : Program p n g A)
|
| 22 |
+
|
| 23 |
+
def free (x : K→ A) :=
|
| 24 |
+
(∀ i,Injective (pooled (s.left ∘ x) i).mulVec)∧
|
| 25 |
+
(∀ i,Injective (pooled (s.right ∘ x) i).mulVec)
|
| 26 |
+
|
| 27 |
+
def showKey (x : A) (o : Forum p n N G) :=
|
| 28 |
+
peekR p g (s.left x) (s.right x) o
|
| 29 |
+
|
| 30 |
+
def oexpect (w : Wgt A) (F : A → Rack I N → ℝ) (o : Forum p n N G) :=
|
| 31 |
+
avg w (fun x => F x (s.showKey x o))
|
| 32 |
+
end Program
|
| 33 |
+
|
| 34 |
+
theorem forum_law (m : Mixer p n) {N : ℕ} (hN : 2*num (Full p n)<N) :
|
| 35 |
+
IsLaw (forumLaw m N (G:=G)) :=
|
| 36 |
+
prodW_law (fun _ => unifOn_law (framesAt_exists (gramCond_exists m)
|
| 37 |
+
(by rw [←two_mul]; simpa only [num,Fintype.card_fin] using hN)))
|
| 38 |
+
|
| 39 |
+
theorem avg_bound1 {w : Wgt A} (hw : IsLaw w) (f : Wgt A) (hf : ∀ x,|f x|≤1) :
|
| 40 |
+
|avg w f|≤1 := (abs_avg_le hw.nz).trans (hw.avg_le hf)
|
| 41 |
+
theorem avg_cross_sq (w : Wgt A) (f : Wgt A) :
|
| 42 |
+
avg w f ^ 2=avg (draws Bool w) (fun q => f (q true)* f (q false)) := by
|
| 43 |
+
let g (i : Bool) := f
|
| 44 |
+
have hh := prodW_avg (fun _ : Bool => w) g
|
| 45 |
+
have he : prodW g=(fun q => f (q true)* f (q false)) := by ext; unfold prodW; rw [Fintype.prod_bool]
|
| 46 |
+
rw [he,Fintype.prod_bool] at hh; rw [pow_two]; exact hh.symm
|
| 47 |
+
|
| 48 |
+
theorem avg_var (w : Wgt A) (f : Wgt A) (hw : IsLaw w) :
|
| 49 |
+
avg w (fun x => (f x-avg w f)^2) = avg w (fun x => f x^2) - (avg w f)^2 := by
|
| 50 |
+
let g := avg w f
|
| 51 |
+
have hh (x) : (f x-g)^2=f x^2-2*g*f x+g^2 := by ring
|
| 52 |
+
change avg w (fun x => (f x-g)^2)=_
|
| 53 |
+
simp_rw [hh,avg_add,avg_sub,avg_mul',hw.avg_const]
|
| 54 |
+
unfold g; ring
|
| 55 |
+
|
| 56 |
+
namespace Program
|
| 57 |
+
variable {s : Program p n g A}
|
| 58 |
+
|
| 59 |
+
set_option maxHeartbeats 800000 in
|
| 60 |
+
theorem oVar (m : Mixer p n) (hN : 2*num (Full p n) < N)
|
| 61 |
+
(T : A→Wgt (Rack I N))
|
| 62 |
+
(w : Wgt A) (hw : IsLaw w) (hT : ∀ i x,|T i x|≤1)
|
| 63 |
+
(k : ℝ) (hk : ∀ i,num (Port (tied g Bool) i)≤k)
|
| 64 |
+
(hK : 2*k-N≤-1)
|
| 65 |
+
(r : ℝ) (hr : pr (draws Bool w) (fun x => ¬ s.free x) ≤ r) :
|
| 66 |
+
let v := forumLaw (G:=G) m N
|
| 67 |
+
let f := s.oexpect w T
|
| 68 |
+
avg v (fun o => (f o-avg v f)^2) ≤
|
| 69 |
+
2*r + 2*netFact (tied g Bool)*twinkle (tied g Bool) k N := by
|
| 70 |
+
classical
|
| 71 |
+
let v := forumLaw (G:=G) m N
|
| 72 |
+
let f := s.oexpect w T
|
| 73 |
+
let F (x : A) := fun o => T x (s.showKey x o)
|
| 74 |
+
let D := draws Bool w
|
| 75 |
+
let B := 2*netFact (tied g Bool)*twinkle (tied g Bool) k N
|
| 76 |
+
have hD : IsLaw D := draws_law hw
|
| 77 |
+
have hv : IsLaw v := forum_law _ hN
|
| 78 |
+
let V (x : Bool→A) := avg v (fun o => F (x true) o * F (x false) o)
|
| 79 |
+
let W (x : Bool→A) := avg v (F (x true))*avg v (F (x false))
|
| 80 |
+
have hW :
|
| 81 |
+
(avg v f)^2 = avg D W := by
|
| 82 |
+
unfold f oexpect
|
| 83 |
+
rw [avg_avg,avg_cross_sq]
|
| 84 |
+
have hV :
|
| 85 |
+
avg v (fun x => f x^2) = avg D V := by
|
| 86 |
+
unfold f oexpect; simp_rw [avg_cross_sq]; rw [avg_avg]
|
| 87 |
+
have hi x :
|
| 88 |
+
V x-W x ≤ 2*ind (¬s.free x)+B := by
|
| 89 |
+
by_cases he : s.free x
|
| 90 |
+
· have hh := pooled_batch (s.left ∘ x) (s.right ∘ x) m hN k hk hK he.1 he.2
|
| 91 |
+
(T ∘ x) (fun i y => hT _ _)
|
| 92 |
+
simp_rw [Fintype.prod_bool] at hh
|
| 93 |
+
rw [ind_zero (fun h => h he),mul_zero,zero_add]
|
| 94 |
+
exact (le_abs_self _).trans hh
|
| 95 |
+
have h1 (a b : ℝ) (h : |a|≤1) (g : |b|≤1) : |a*b|≤1 := by
|
| 96 |
+
rw [abs_mul]
|
| 97 |
+
exact (mul_le_mul h g (abs_nonneg _) zero_le_one).trans_eq (by ring)
|
| 98 |
+
have hh : |W x|≤1 := h1 _ _ (avg_bound1 hv _ (fun y => hT _ _)) (avg_bound1 hv _
|
| 99 |
+
(fun y => hT _ _))
|
| 100 |
+
have hg : |V x|≤1 := avg_bound1 hv _ (fun i => h1 _ _ (hT _ _) (hT _ _))
|
| 101 |
+
have ht : 0 ≤ twinkle (tied g Bool) k N := add_nonneg (mul_nonneg (Nat.cast_nonneg _)
|
| 102 |
+
(mul_nonneg (by norm_num) (bp_pos _).le)) (bp_pos _).le
|
| 103 |
+
have h2 : 0 ≤ B := mul_nonneg (mul_nonneg (by norm_num) netFact_pos.le) ht
|
| 104 |
+
rw [ind_one he,mul_one]
|
| 105 |
+
exact sub_le_iff_le_add.mpr (by linarith [(abs_le.mp hh).1,(abs_le.mp hg).2])
|
| 106 |
+
change avg v _ ≤ _
|
| 107 |
+
rw [avg_var v f hv,hW,hV,← avg_sub]
|
| 108 |
+
apply (avg_mono hD.nz hi).trans
|
| 109 |
+
rw [avg_add,avg_mul',hD.avg_const]
|
| 110 |
+
exact add_le_add_left (mul_le_mul_of_nonneg_left hr (by norm_num)) _
|
| 111 |
+
|
| 112 |
+
def oFreq (w : Wgt A) (F : A → Rack I N→Prop) (o : Forum p n N G)
|
| 113 |
+
(s : Program p n g A) :=
|
| 114 |
+
pr w (fun i => F i (s.showKey i o))
|
| 115 |
+
|
| 116 |
+
set_option maxHeartbeats 800000 in
|
| 117 |
+
theorem oTail (m : Mixer p n) (hN : 2*num (Full p n) < N)
|
| 118 |
+
(T : A→Rack I N →Prop)
|
| 119 |
+
(w : Wgt A) (hw : IsLaw w)
|
| 120 |
+
{k : ℝ} {l : ℕ} (hk : ∀ i,num (Port (tied g (Fin l)) i)≤k)
|
| 121 |
+
(hK : 2*k-N≤-1)
|
| 122 |
+
(r : ℝ) (hr : pr (draws (Fin l) w) (fun x => ¬ s.free x) ≤ r)
|
| 123 |
+
{ε : ℝ} (hε : 0 ≤ ε) :
|
| 124 |
+
let v := forumLaw (G:=G) m N
|
| 125 |
+
let f := (fun o => oFreq w T o s)
|
| 126 |
+
(ε^l - r)*pr v (fun x => ε ≤ f x) ≤ netFact (tied g (Fin l))* (avg v f)^l := by
|
| 127 |
+
classical
|
| 128 |
+
let v := forumLaw (G:=G) m N
|
| 129 |
+
let f := (fun o : Forum p n N G => oFreq w T o s)
|
| 130 |
+
have hv : IsLaw v := forum_law _ hN
|
| 131 |
+
let F := draws (Fin l) w
|
| 132 |
+
have hF : IsLaw F := draws_law hw
|
| 133 |
+
let P (x) (y : Fin l→A) := ∀ i,T (y i) (s.showKey (y i) x)
|
| 134 |
+
have hh (x) : pr F (fun y => P x y)= f x ^ l := by
|
| 135 |
+
unfold P F draws
|
| 136 |
+
rw [prodW_pr (fun (_ : Fin l) => w) (fun _ i => T i (s.showKey i x))]
|
| 137 |
+
simp only [Finset.prod_const, Finset.card_univ,Fintype.card_fin]
|
| 138 |
+
rfl
|
| 139 |
+
let Q (x : Fin l → A) := s.free x
|
| 140 |
+
let S (o) (x : Fin l→A) := P o x ∧ Q x
|
| 141 |
+
have hi (o) :
|
| 142 |
+
(ε^l-r)*ind (ε≤f o)≤ pr F (S o) := by
|
| 143 |
+
by_cases ht : ε≤f o
|
| 144 |
+
· rw [ind_one ht,mul_one]
|
| 145 |
+
refine (sub_le_sub (pow_le_pow_left₀ hε ht l) hr).trans ?_
|
| 146 |
+
rw [←hh]; exact pr_shield hF.nz _ _
|
| 147 |
+
rw [ind_zero ht,mul_zero]; exact pr_nonneg hF.nz
|
| 148 |
+
let W (x) := pr v (fun i => T x (s.showKey x i))
|
| 149 |
+
let C := netFact (tied g (Fin l))
|
| 150 |
+
have hq (x : Fin l → A) :
|
| 151 |
+
pr v (fun i => S i x) ≤ C*∏ i:Fin l,W (x i) := by
|
| 152 |
+
by_cases he : Q x
|
| 153 |
+
· have hg := pool_upper (s.left ∘ x) (s.right ∘ x) m hN he.1 he.2
|
| 154 |
+
(fun i => by linarith only [hk i,hK]) (T ∘ x)
|
| 155 |
+
simp only [S,he,and_true]
|
| 156 |
+
exact hg
|
| 157 |
+
simp only [S,he,and_false,pr_false]; exact mul_nonneg netFact_pos.le
|
| 158 |
+
(Finset.prod_nonneg fun i _ => pr_nonneg hv.nz)
|
| 159 |
+
have hg : avg v f=avg w W := avg_avg _ _ _
|
| 160 |
+
have he := avg_mono hv.nz hi
|
| 161 |
+
rw [avg_mul'] at he
|
| 162 |
+
change _ ≤ _
|
| 163 |
+
apply le_trans he
|
| 164 |
+
calc avg v (fun x => pr F (S x)) = avg F (fun y => pr v (fun x => S x y)) := avg_avg _ _ _
|
| 165 |
+
_ ≤ avg F (fun x => C*∏ i,W (x i)) := avg_mono hF.nz hq
|
| 166 |
+
_ = netFact _ * (avg v f)^l := by rw [avg_mul',hg, poweravg]
|
| 167 |
+
end Program
|
| 168 |
+
end HadwigerCounterexample
|
| 169 |
+
|
| 170 |
+
end
|
| 171 |
+
|
| 172 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RandomBinaryMixing.lean
CHANGED
|
@@ -1,120 +1,120 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BinaryEvaluationForms
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Random Binary Mixing -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
|
| 10 |
-
instance momFintype (p : Shape) (n : ℕ) : Fintype (Moment p n) := inferInstance
|
| 11 |
-
instance idxDec (p : Shape) : DecidableEq (MIdx p) := inferInstance
|
| 12 |
-
instance arrFintype (p : Shape) (n : ℕ) : Fintype (MArr p n) := inferInstance
|
| 13 |
-
instance drawFintype (p : Shape) (n : ℕ) : Fintype (Draw p n) := inferInstance
|
| 14 |
-
|
| 15 |
-
open Filter Matrix Function
|
| 16 |
-
open scoped BigOperators Topology
|
| 17 |
-
|
| 18 |
-
variable {p : Shape} {n : ℕ}
|
| 19 |
-
|
| 20 |
-
theorem rank_fifth_bound (m n : ℕ) (hm : n/2≤m) (hn : 100 ≤ n) :
|
| 21 |
-
pr unif (fun M : Mat (Fin m) (Fin m) => 5*M.rank<n) ≤ bp (- (n:ℝ)) := by
|
| 22 |
-
apply le_trans (pr_mono unif_law.nz (q:=fun M => M.rank≤ n/5) (fun M h => by omega))
|
| 23 |
-
refine (pr_matrix_rank _).trans ?_
|
| 24 |
-
apply bp_le
|
| 25 |
-
simp only [num,Fintype.card_fin]
|
| 26 |
-
let r := n/5
|
| 27 |
-
have h1 : 5*r≤n := by unfold r; omega
|
| 28 |
-
have h2 : n≤2*m+1 := by omega
|
| 29 |
-
have h3 : 45≤m := by omega
|
| 30 |
-
have hi : (m+m)*r+n≤m*m := by
|
| 31 |
-
nlinarith only [h1,h2,h3,
|
| 32 |
-
Nat.mul_le_mul_left m h1,Nat.mul_le_mul_left m h2,Nat.mul_le_mul_left m h3]
|
| 33 |
-
have hh : ((m:ℝ)+m)*r+n ≤ m*(m:ℝ) := by exact_mod_cast hi
|
| 34 |
-
unfold r at hh; linarith only [hh]
|
| 35 |
-
|
| 36 |
-
theorem pr_surj_rank {m} (hn : 100≤n) (hm : n/2≤m)
|
| 37 |
-
(A : Draw p n →ₗ[F] Mat (Fin m) (Fin m))
|
| 38 |
-
(h : Function.Surjective A) :
|
| 39 |
-
pr unif (fun x => 5*(A x).rank < n) ≤ bp (- (n:ℝ)) := by
|
| 40 |
-
classical
|
| 41 |
-
have he := mapW_pr unif A (fun x => 5*x.rank<n)
|
| 42 |
-
rw [map_unif_surjective A h] at he
|
| 43 |
-
exact he.symm.le.trans (rank_fifth_bound m n hm hn)
|
| 44 |
-
|
| 45 |
-
theorem ztest_prob (p : Shape) (s t : Label p.b) (hj : 1≤p.j)
|
| 46 |
-
(c : Vec (MBits p)) (b : Vec Bool) (hn : 100≤n) :
|
| 47 |
-
pr unif (fun x : Draw p n => s ≠ t ∧ c≠0 ∧
|
| 48 |
-
5*blockRank Block.Z s t (indexedSum (drawn x) c+selfSum (drawn x) b)<n)
|
| 49 |
-
≤ bp (- (n:ℝ)) := by
|
| 50 |
-
classical
|
| 51 |
-
by_cases h : s≠t ∧ c≠0
|
| 52 |
-
· simp only [← and_assoc (a:=s≠t),blockRank,map_add,obsZ_self,add_zero]
|
| 53 |
-
refine le_trans (pr_mono unif_law.nz ?_) (pr_surj_rank hn (by omega) (obsZ p n s t c) (obsZ_surj _ _ hj h.1 h.2))
|
| 54 |
-
exact fun x hx => hx.2
|
| 55 |
-
simp_rw [← and_assoc (a:=s≠t),h,false_and,pr_false]
|
| 56 |
-
exact (bp_pos _).le
|
| 57 |
-
|
| 58 |
-
theorem stest_prob (p : Shape) (s t : Label p.b) (hj : 1≤p.j)
|
| 59 |
-
(b : Vec Bool) (hn : 100≤n) :
|
| 60 |
-
pr unif (fun x : Draw p n => s ≠ t ∧ b≠0 ∧
|
| 61 |
-
5*blockRank Block.sharp s t (selfSum (drawn x) b)<n)
|
| 62 |
-
≤ bp (- (n:ℝ)) := by
|
| 63 |
-
classical
|
| 64 |
-
by_cases h : s≠t ∧ b≠0
|
| 65 |
-
· simp only [← and_assoc (a:=s≠t),blockRank,pull_selfPart _ _ hj]
|
| 66 |
-
let l := Fin.castLE (show n/2≤n by omega)
|
| 67 |
-
let r (i : Fin (n/2)) : Fin n := ⟨n/2+i.val,by have := i.isLt; omega⟩
|
| 68 |
-
have he : Function.Surjective (obsHalf p s t b n l r) := by
|
| 69 |
-
refine obsHalf_surj _ _ h.1 h.2 _ (Fin.castLE_injective _) (fun i j h => ?_) ?_
|
| 70 |
-
· exact Fin.ext (Nat.add_left_cancel (congrArg Fin.val h))
|
| 71 |
-
intro i j h
|
| 72 |
-
have he : i.val = n/2+j.val := congrArg Fin.val h
|
| 73 |
-
have hg := i.isLt; omega
|
| 74 |
-
apply le_trans _ (pr_surj_rank hn (by omega) (obsHalf p s t b n l r) he)
|
| 75 |
-
refine pr_mono unif_law.nz fun x hx => lt_of_le_of_lt ?_ hx.2
|
| 76 |
-
exact Nat.mul_le_mul_left _ ((selfPartial (p:=p) s t b x).rank_submatrix_le l r)
|
| 77 |
-
simp_rw [← and_assoc (a:=s≠t),h,false_and,pr_false]
|
| 78 |
-
exact (bp_pos _).le
|
| 79 |
-
|
| 80 |
-
theorem binary_likely (p : Shape) (hj : 1≤p.j) :
|
| 81 |
-
∀ᶠ n : ℕ in atTop,
|
| 82 |
-
pr unif (fun x : Draw p n => ¬binaryGood (drawn x)) < 1/4 := by
|
| 83 |
-
classical
|
| 84 |
-
let I := Label p.b × Label p.b × Vec (MBits p) × Vec Bool
|
| 85 |
-
let J := Label p.b × Label p.b × Vec Bool
|
| 86 |
-
let T := I⊕J
|
| 87 |
-
let m := num T
|
| 88 |
-
have h : Tendsto (fun n:ℕ=>m*bp (- (n:ℝ))) atTop (𝓝 0) := by
|
| 89 |
-
have h : Tendsto (fun n:ℕ=>bp (-(1:ℝ)*(n:ℝ))) atTop (𝓝 0) :=
|
| 90 |
-
(bp_tendsto_zero zero_lt_one).comp tendsto_natCast_atTop_atTop
|
| 91 |
-
simpa using h.const_mul m
|
| 92 |
-
filter_upwards [h.eventually (gt_mem_nhds (show (0:ℝ)<1/4 by norm_num)),
|
| 93 |
-
eventually_ge_atTop 100] with n hn hg
|
| 94 |
-
let bad (i : T) (x : Draw p n) :=
|
| 95 |
-
match i with
|
| 96 |
-
| .inl (s,t,c,b) => s≠t ∧ c≠0 ∧ 5*blockRank Block.Z s t
|
| 97 |
-
(indexedSum (drawn x) c+selfSum (drawn x) b)<n
|
| 98 |
-
| .inr (s,t,b) => s≠t ∧ b≠0 ∧ 5*blockRank Block.sharp s t (selfSum (drawn x) b)<n
|
| 99 |
-
have he (i : T) : pr unif (bad i) ≤ bp (- (n:ℝ)) := by
|
| 100 |
-
rcases i with ⟨s,t,c,b⟩|⟨s,t,b⟩
|
| 101 |
-
· exact ztest_prob _ _ _ hj _ _ hg
|
| 102 |
-
exact stest_prob _ _ _ hj _ hg
|
| 103 |
-
have hi : pr unif (fun x => ∃ i, bad i x) ≤ m*bp (- (n:ℝ)) :=
|
| 104 |
-
(pr_exists_le unif_law.nz bad).trans ((Finset.sum_le_sum (fun i _ => he i)).trans_eq (by
|
| 105 |
-
rw [Finset.sum_const, Finset.card_univ,nsmul_eq_mul]))
|
| 106 |
-
apply lt_of_le_of_lt (le_trans (pr_mono unif_law.nz ?_) hi) hn
|
| 107 |
-
intro x hx
|
| 108 |
-
by_contra! H
|
| 109 |
-
apply hx
|
| 110 |
-
intro s t hst
|
| 111 |
-
constructor
|
| 112 |
-
· intro c b hc
|
| 113 |
-
exact le_of_not_gt fun e => H (Sum.inl (s,t,c,b)) ⟨hst,hc,e⟩
|
| 114 |
-
intro b hb
|
| 115 |
-
exact le_of_not_gt fun e => H (Sum.inr (s,t,b)) ⟨hst,hb,e⟩
|
| 116 |
-
end HadwigerCounterexample
|
| 117 |
-
|
| 118 |
-
end
|
| 119 |
-
|
| 120 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BinaryEvaluationForms
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Random Binary Mixing -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
|
| 10 |
+
instance momFintype (p : Shape) (n : ℕ) : Fintype (Moment p n) := inferInstance
|
| 11 |
+
instance idxDec (p : Shape) : DecidableEq (MIdx p) := inferInstance
|
| 12 |
+
instance arrFintype (p : Shape) (n : ℕ) : Fintype (MArr p n) := inferInstance
|
| 13 |
+
instance drawFintype (p : Shape) (n : ℕ) : Fintype (Draw p n) := inferInstance
|
| 14 |
+
|
| 15 |
+
open Filter Matrix Function
|
| 16 |
+
open scoped BigOperators Topology
|
| 17 |
+
|
| 18 |
+
variable {p : Shape} {n : ℕ}
|
| 19 |
+
|
| 20 |
+
theorem rank_fifth_bound (m n : ℕ) (hm : n/2≤m) (hn : 100 ≤ n) :
|
| 21 |
+
pr unif (fun M : Mat (Fin m) (Fin m) => 5*M.rank<n) ≤ bp (- (n:ℝ)) := by
|
| 22 |
+
apply le_trans (pr_mono unif_law.nz (q:=fun M => M.rank≤ n/5) (fun M h => by omega))
|
| 23 |
+
refine (pr_matrix_rank _).trans ?_
|
| 24 |
+
apply bp_le
|
| 25 |
+
simp only [num,Fintype.card_fin]
|
| 26 |
+
let r := n/5
|
| 27 |
+
have h1 : 5*r≤n := by unfold r; omega
|
| 28 |
+
have h2 : n≤2*m+1 := by omega
|
| 29 |
+
have h3 : 45≤m := by omega
|
| 30 |
+
have hi : (m+m)*r+n≤m*m := by
|
| 31 |
+
nlinarith only [h1,h2,h3,
|
| 32 |
+
Nat.mul_le_mul_left m h1,Nat.mul_le_mul_left m h2,Nat.mul_le_mul_left m h3]
|
| 33 |
+
have hh : ((m:ℝ)+m)*r+n ≤ m*(m:ℝ) := by exact_mod_cast hi
|
| 34 |
+
unfold r at hh; linarith only [hh]
|
| 35 |
+
|
| 36 |
+
theorem pr_surj_rank {m} (hn : 100≤n) (hm : n/2≤m)
|
| 37 |
+
(A : Draw p n →ₗ[F] Mat (Fin m) (Fin m))
|
| 38 |
+
(h : Function.Surjective A) :
|
| 39 |
+
pr unif (fun x => 5*(A x).rank < n) ≤ bp (- (n:ℝ)) := by
|
| 40 |
+
classical
|
| 41 |
+
have he := mapW_pr unif A (fun x => 5*x.rank<n)
|
| 42 |
+
rw [map_unif_surjective A h] at he
|
| 43 |
+
exact he.symm.le.trans (rank_fifth_bound m n hm hn)
|
| 44 |
+
|
| 45 |
+
theorem ztest_prob (p : Shape) (s t : Label p.b) (hj : 1≤p.j)
|
| 46 |
+
(c : Vec (MBits p)) (b : Vec Bool) (hn : 100≤n) :
|
| 47 |
+
pr unif (fun x : Draw p n => s ≠ t ∧ c≠0 ∧
|
| 48 |
+
5*blockRank Block.Z s t (indexedSum (drawn x) c+selfSum (drawn x) b)<n)
|
| 49 |
+
≤ bp (- (n:ℝ)) := by
|
| 50 |
+
classical
|
| 51 |
+
by_cases h : s≠t ∧ c≠0
|
| 52 |
+
· simp only [← and_assoc (a:=s≠t),blockRank,map_add,obsZ_self,add_zero]
|
| 53 |
+
refine le_trans (pr_mono unif_law.nz ?_) (pr_surj_rank hn (by omega) (obsZ p n s t c) (obsZ_surj _ _ hj h.1 h.2))
|
| 54 |
+
exact fun x hx => hx.2
|
| 55 |
+
simp_rw [← and_assoc (a:=s≠t),h,false_and,pr_false]
|
| 56 |
+
exact (bp_pos _).le
|
| 57 |
+
|
| 58 |
+
theorem stest_prob (p : Shape) (s t : Label p.b) (hj : 1≤p.j)
|
| 59 |
+
(b : Vec Bool) (hn : 100≤n) :
|
| 60 |
+
pr unif (fun x : Draw p n => s ≠ t ∧ b≠0 ∧
|
| 61 |
+
5*blockRank Block.sharp s t (selfSum (drawn x) b)<n)
|
| 62 |
+
≤ bp (- (n:ℝ)) := by
|
| 63 |
+
classical
|
| 64 |
+
by_cases h : s≠t ∧ b≠0
|
| 65 |
+
· simp only [← and_assoc (a:=s≠t),blockRank,pull_selfPart _ _ hj]
|
| 66 |
+
let l := Fin.castLE (show n/2≤n by omega)
|
| 67 |
+
let r (i : Fin (n/2)) : Fin n := ⟨n/2+i.val,by have := i.isLt; omega⟩
|
| 68 |
+
have he : Function.Surjective (obsHalf p s t b n l r) := by
|
| 69 |
+
refine obsHalf_surj _ _ h.1 h.2 _ (Fin.castLE_injective _) (fun i j h => ?_) ?_
|
| 70 |
+
· exact Fin.ext (Nat.add_left_cancel (congrArg Fin.val h))
|
| 71 |
+
intro i j h
|
| 72 |
+
have he : i.val = n/2+j.val := congrArg Fin.val h
|
| 73 |
+
have hg := i.isLt; omega
|
| 74 |
+
apply le_trans _ (pr_surj_rank hn (by omega) (obsHalf p s t b n l r) he)
|
| 75 |
+
refine pr_mono unif_law.nz fun x hx => lt_of_le_of_lt ?_ hx.2
|
| 76 |
+
exact Nat.mul_le_mul_left _ ((selfPartial (p:=p) s t b x).rank_submatrix_le l r)
|
| 77 |
+
simp_rw [← and_assoc (a:=s≠t),h,false_and,pr_false]
|
| 78 |
+
exact (bp_pos _).le
|
| 79 |
+
|
| 80 |
+
theorem binary_likely (p : Shape) (hj : 1≤p.j) :
|
| 81 |
+
∀ᶠ n : ℕ in atTop,
|
| 82 |
+
pr unif (fun x : Draw p n => ¬binaryGood (drawn x)) < 1/4 := by
|
| 83 |
+
classical
|
| 84 |
+
let I := Label p.b × Label p.b × Vec (MBits p) × Vec Bool
|
| 85 |
+
let J := Label p.b × Label p.b × Vec Bool
|
| 86 |
+
let T := I⊕J
|
| 87 |
+
let m := num T
|
| 88 |
+
have h : Tendsto (fun n:ℕ=>m*bp (- (n:ℝ))) atTop (𝓝 0) := by
|
| 89 |
+
have h : Tendsto (fun n:ℕ=>bp (-(1:ℝ)*(n:ℝ))) atTop (𝓝 0) :=
|
| 90 |
+
(bp_tendsto_zero zero_lt_one).comp tendsto_natCast_atTop_atTop
|
| 91 |
+
simpa using h.const_mul m
|
| 92 |
+
filter_upwards [h.eventually (gt_mem_nhds (show (0:ℝ)<1/4 by norm_num)),
|
| 93 |
+
eventually_ge_atTop 100] with n hn hg
|
| 94 |
+
let bad (i : T) (x : Draw p n) :=
|
| 95 |
+
match i with
|
| 96 |
+
| .inl (s,t,c,b) => s≠t ∧ c≠0 ∧ 5*blockRank Block.Z s t
|
| 97 |
+
(indexedSum (drawn x) c+selfSum (drawn x) b)<n
|
| 98 |
+
| .inr (s,t,b) => s≠t ∧ b≠0 ∧ 5*blockRank Block.sharp s t (selfSum (drawn x) b)<n
|
| 99 |
+
have he (i : T) : pr unif (bad i) ≤ bp (- (n:ℝ)) := by
|
| 100 |
+
rcases i with ⟨s,t,c,b⟩|⟨s,t,b⟩
|
| 101 |
+
· exact ztest_prob _ _ _ hj _ _ hg
|
| 102 |
+
exact stest_prob _ _ _ hj _ hg
|
| 103 |
+
have hi : pr unif (fun x => ∃ i, bad i x) ≤ m*bp (- (n:ℝ)) :=
|
| 104 |
+
(pr_exists_le unif_law.nz bad).trans ((Finset.sum_le_sum (fun i _ => he i)).trans_eq (by
|
| 105 |
+
rw [Finset.sum_const, Finset.card_univ,nsmul_eq_mul]))
|
| 106 |
+
apply lt_of_le_of_lt (le_trans (pr_mono unif_law.nz ?_) hi) hn
|
| 107 |
+
intro x hx
|
| 108 |
+
by_contra! H
|
| 109 |
+
apply hx
|
| 110 |
+
intro s t hst
|
| 111 |
+
constructor
|
| 112 |
+
· intro c b hc
|
| 113 |
+
exact le_of_not_gt fun e => H (Sum.inl (s,t,c,b)) ⟨hst,hc,e⟩
|
| 114 |
+
intro b hb
|
| 115 |
+
exact le_of_not_gt fun e => H (Sum.inr (s,t,b)) ⟨hst,hb,e⟩
|
| 116 |
+
end HadwigerCounterexample
|
| 117 |
+
|
| 118 |
+
end
|
| 119 |
+
|
| 120 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RandomLinearTransforms.lean
CHANGED
|
@@ -1,141 +1,141 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FrameRotations
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Random Linear Transforms -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module LinearMap Submodule Finset Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J K : Type} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
|
| 12 |
-
[Fintype K] [DecidableEq K]
|
| 13 |
-
|
| 14 |
-
namespace Move
|
| 15 |
-
|
| 16 |
-
instance finiteMove (I : Type) [Fintype I] [DecidableEq I] : Fintype (Move I) := by
|
| 17 |
-
classical
|
| 18 |
-
let S := { z : Mat I I × Mat I I // z.1*z.2 = 1 ∧ z.2*z.1=1}
|
| 19 |
-
let e : S ≃ Move I := {
|
| 20 |
-
toFun z := ⟨z.val.1,z.val.2,z.property.1,z.property.2⟩
|
| 21 |
-
invFun z := ⟨(z.L,z.R),z.LR,z.RL⟩
|
| 22 |
-
left_inv _ := rfl
|
| 23 |
-
right_inv _ := rfl }
|
| 24 |
-
exact Fintype.ofEquiv S e
|
| 25 |
-
|
| 26 |
-
instance identity_move (I : Type) [Fintype I] [DecidableEq I] : Nonempty (Move I) :=
|
| 27 |
-
⟨1,1, Matrix.one_mul _,Matrix.mul_one _⟩
|
| 28 |
-
def combine (c d : Move I) : Move I :=
|
| 29 |
-
⟨c.L*d.L,d.R*c.R,by rw [Matrix.mul_assoc,←Matrix.mul_assoc d.L,d.LR,Matrix.one_mul,c.LR],
|
| 30 |
-
by rw [Matrix.mul_assoc,←Matrix.mul_assoc c.R,c.RL,Matrix.one_mul,d.RL]⟩
|
| 31 |
-
|
| 32 |
-
@[ext] theorem extn (p q : Move I) (h : p.L=q.L) (h' : p.R=q.R) : p=q := by
|
| 33 |
-
cases p; cases q; cases h; cases h'; rfl
|
| 34 |
-
def circShift (c : Move I) : Move I≃ Move I where
|
| 35 |
-
toFun := combine c
|
| 36 |
-
invFun := combine c.sym
|
| 37 |
-
left_inv d := extn _ _ (by simp only [combine,sym,←Matrix.mul_assoc,c.RL, Matrix.one_mul])
|
| 38 |
-
(by simp only [combine,sym,Matrix.mul_assoc,c.RL, Matrix.mul_one])
|
| 39 |
-
right_inv d := extn _ _ (by simp only [combine,sym,←Matrix.mul_assoc,c.LR, Matrix.one_mul])
|
| 40 |
-
(by simp only [combine,sym,Matrix.mul_assoc,c.LR, Matrix.mul_one])
|
| 41 |
-
def flipLines (I : Type) [Fintype I] [DecidableEq I] : Move I≃ Move I where
|
| 42 |
-
toFun := Move.dual
|
| 43 |
-
invFun := Move.dual
|
| 44 |
-
left_inv _ := rfl
|
| 45 |
-
right_inv _ := rfl
|
| 46 |
-
|
| 47 |
-
theorem flit_obs (M : Mat I J) (h : Injective M.mulVec) :
|
| 48 |
-
mapW unif (fun c : Move I => c.L*M)=unifOn (fun A => Injective A.mulVec) := by
|
| 49 |
-
classical
|
| 50 |
-
rw [← unifOn_true]
|
| 51 |
-
refine uniform_orbit _ (by obtain ⟨i⟩ := identity_move I; exact ⟨i,trivial⟩)
|
| 52 |
-
(fun x _ => inj_comp_mat _ _ x.L_inj h) ?_
|
| 53 |
-
intro x y hx hy
|
| 54 |
-
obtain ⟨c,hc⟩ := move_exists_one hx hy
|
| 55 |
-
refine ⟨circShift c,fun _ => Iff.rfl,fun w => ?_⟩
|
| 56 |
-
change w.L*M=x ↔ c.L*w.L*M=y
|
| 57 |
-
rw [←hc,Matrix.mul_assoc]; exact (c.permMat J).injective.eq_iff.symm
|
| 58 |
-
|
| 59 |
-
theorem flit_pmax (M Q : Mat I J) (h : Injective M.mulVec)
|
| 60 |
-
(ha : num J-num I≤ -1) :
|
| 61 |
-
pr unif (fun c : Move I => c.Rᵀ*M=Q) ≤ 2*bp (-num I*num J) := by
|
| 62 |
-
let P (M : Mat I J) := Injective M.mulVec
|
| 63 |
-
have ht :
|
| 64 |
-
pr unif (fun c : Move I=> c.Rᵀ*M=Q)=unifOn P Q := by
|
| 65 |
-
change pr unif (fun x : Move I => (flipLines I x).L*M=Q)=_
|
| 66 |
-
rw [← mapW_pr unif (flipLines I) (fun c => c.L*M=Q),unif_equiv]
|
| 67 |
-
exact congr_fun (flit_obs M h) Q
|
| 68 |
-
have hh : 2⁻¹ ≤ pr unif P := by
|
| 69 |
-
have hv := @unif_fail J I _ _ _ _
|
| 70 |
-
rw [pr_not,unif_law.total] at hv
|
| 71 |
-
have he := bp_le ha
|
| 72 |
-
rw [bp_neg,bp_one] at he; change 1-pr unif P ≤ _ at hv; linarith only [hv,he]
|
| 73 |
-
rw [ht,←on_unif]
|
| 74 |
-
have he : unif Q=bp (-num I*num J) := by rw [unif_apply,neg_mul,bp_neg,←cast_mat]
|
| 75 |
-
exact (on_mon unif_law.nz (show 0<(2:ℝ)⁻¹ from by norm_num) hh Q).trans_eq
|
| 76 |
-
(by rw [he,inv_inv])
|
| 77 |
-
|
| 78 |
-
variable {n : ℕ}
|
| 79 |
-
def plume {n : ℕ} (c : Flit n) (S : Space (Vec (Fin n))) :=
|
| 80 |
-
colSp (c.Rᵀ*pack S)
|
| 81 |
-
|
| 82 |
-
theorem plume_dim (c : Flit n) (S : Space (Vec (Fin n))) : dim (plume c S)=dim S := by
|
| 83 |
-
have hh := mrk_inj.mp (inj_comp_mat c.Rᵀ _ c.dual.L_inj (pack_inj S))
|
| 84 |
-
rw [plume,colSp_dim,hh,Fintype.card_fin]
|
| 85 |
-
|
| 86 |
-
omit [Fintype I] [DecidableEq I] [DecidableEq J] [DecidableEq K] in
|
| 87 |
-
private theorem smaller_cols (P : Mat I J) (Q : Mat I K) (h : colSp P ≤ colSp Q) :
|
| 88 |
-
∃ M : Mat K J,Q*M=P := by
|
| 89 |
-
classical
|
| 90 |
-
choose f hf using fun i : J =>
|
| 91 |
-
show ∃ z : Vec K,Q *ᵥ z=P.col i from h (colSp_mem i)
|
| 92 |
-
refine ⟨Matrix.of (fun i j => f j i),?_⟩
|
| 93 |
-
ext i j; exact congr_fun (hf j) i
|
| 94 |
-
|
| 95 |
-
set_option maxHeartbeats 800000 in
|
| 96 |
-
theorem plume_meets (n a : ℕ) (ha : a<n) (U V : Space (Vec (Fin n))) :
|
| 97 |
-
pr unif (fun c : Flit n => a≤dim (c.plume U ⊓ V : Space (Vec (Fin n))))≤
|
| 98 |
-
bp (1+((dim U:ℝ)+dim V-n)*a) := by
|
| 99 |
-
classical
|
| 100 |
-
let P := Mat (Fin (dim U)) (Fin a); let Q := Mat (Fin (dim V)) (Fin a)
|
| 101 |
-
let S (z : P×Q) := pack U*z.1
|
| 102 |
-
let q (p : P × Q) (c : Flit n) :=
|
| 103 |
-
Injective (S p).mulVec∧c.Rᵀ*S p=pack V*p.2
|
| 104 |
-
have hi (c : Flit n) (hc : a≤dim (c.plume U ⊓ V : Space (Vec (Fin n)))) :
|
| 105 |
-
∃ i,q i c := by
|
| 106 |
-
let w := c.plume U⊓V
|
| 107 |
-
obtain ⟨M,hM,hg⟩ := bounded_pack w a
|
| 108 |
-
have he : Injective M.mulVec := mrk_inj.mpr (by
|
| 109 |
-
rw [← colSp_dim,hg,Fintype.card_fin,min_eq_right hc])
|
| 110 |
-
have hU := le_trans hM (show w≤c.plume U from inf_le_left)
|
| 111 |
-
have hV : colSp M ≤ colSp (pack V) := by rw [colSp_pack]; exact le_trans hM inf_le_right
|
| 112 |
-
obtain ⟨P,hp⟩ := smaller_cols _ _ hU
|
| 113 |
-
obtain ⟨Q,hq
|
| 114 |
-
rw [Matrix.mul_assoc] at hp
|
| 115 |
-
refine ⟨(P,Q),?_,hp.trans hq.symm⟩
|
| 116 |
-
have hx (z : Vec (Fin a)) :
|
| 117 |
-
c.Rᵀ*ᵥ((pack U * P)*ᵥz)= M*ᵥz := by rw [mulVec_mulVec,hp]
|
| 118 |
-
intro i j hg; exact he ((hx i).symm.trans ((congrArg _ hg).trans (hx j)))
|
| 119 |
-
have ht (i : P × Q) :
|
| 120 |
-
pr unif (q i) ≤2*bp (-(n:ℝ)*a) := by
|
| 121 |
-
by_cases h : Injective (S i).mulVec
|
| 122 |
-
· unfold q; simp only [h,true_and]
|
| 123 |
-
have hx : num (Fin a)-num (Fin n) ≤ -1 := by
|
| 124 |
-
simp only [num,Fintype.card_fin]
|
| 125 |
-
have hi : (a:ℝ)+1≤n := by exact_mod_cast ha
|
| 126 |
-
linarith only [hi]
|
| 127 |
-
simpa only [num,Fintype.card_fin] using flit_pmax (S i) (pack V*i.2) h hx
|
| 128 |
-
simp only [q,h,false_and,pr_false]
|
| 129 |
-
exact mul_nonneg (by norm_num) (bp_pos _).le
|
| 130 |
-
refine (le_trans (pr_mono unif_law.nz hi) (pr_exists_le unif_law.nz q)).trans
|
| 131 |
-
((sum_le_sum (fun i _ => ht i)).trans_eq ?_)
|
| 132 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Fintype.card_prod,Nat.cast_mul]
|
| 133 |
-
change num P*num Q* _=_
|
| 134 |
-
unfold P Q; rw [cast_mat,cast_mat,←bp_one,←bp_add,←bp_add,←bp_add]
|
| 135 |
-
congr 1; simp only [num,Fintype.card_fin]; ring
|
| 136 |
-
end Move
|
| 137 |
-
end HadwigerCounterexample
|
| 138 |
-
|
| 139 |
-
end
|
| 140 |
-
|
| 141 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FrameRotations
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Random Linear Transforms -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module LinearMap Submodule Finset Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J K : Type} [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J]
|
| 12 |
+
[Fintype K] [DecidableEq K]
|
| 13 |
+
|
| 14 |
+
namespace Move
|
| 15 |
+
|
| 16 |
+
instance finiteMove (I : Type) [Fintype I] [DecidableEq I] : Fintype (Move I) := by
|
| 17 |
+
classical
|
| 18 |
+
let S := { z : Mat I I × Mat I I // z.1*z.2 = 1 ∧ z.2*z.1=1}
|
| 19 |
+
let e : S ≃ Move I := {
|
| 20 |
+
toFun z := ⟨z.val.1,z.val.2,z.property.1,z.property.2⟩
|
| 21 |
+
invFun z := ⟨(z.L,z.R),z.LR,z.RL⟩
|
| 22 |
+
left_inv _ := rfl
|
| 23 |
+
right_inv _ := rfl }
|
| 24 |
+
exact Fintype.ofEquiv S e
|
| 25 |
+
|
| 26 |
+
instance identity_move (I : Type) [Fintype I] [DecidableEq I] : Nonempty (Move I) :=
|
| 27 |
+
⟨1,1, Matrix.one_mul _,Matrix.mul_one _⟩
|
| 28 |
+
def combine (c d : Move I) : Move I :=
|
| 29 |
+
⟨c.L*d.L,d.R*c.R,by rw [Matrix.mul_assoc,←Matrix.mul_assoc d.L,d.LR,Matrix.one_mul,c.LR],
|
| 30 |
+
by rw [Matrix.mul_assoc,←Matrix.mul_assoc c.R,c.RL,Matrix.one_mul,d.RL]⟩
|
| 31 |
+
|
| 32 |
+
@[ext] theorem extn (p q : Move I) (h : p.L=q.L) (h' : p.R=q.R) : p=q := by
|
| 33 |
+
cases p; cases q; cases h; cases h'; rfl
|
| 34 |
+
def circShift (c : Move I) : Move I≃ Move I where
|
| 35 |
+
toFun := combine c
|
| 36 |
+
invFun := combine c.sym
|
| 37 |
+
left_inv d := extn _ _ (by simp only [combine,sym,←Matrix.mul_assoc,c.RL, Matrix.one_mul])
|
| 38 |
+
(by simp only [combine,sym,Matrix.mul_assoc,c.RL, Matrix.mul_one])
|
| 39 |
+
right_inv d := extn _ _ (by simp only [combine,sym,←Matrix.mul_assoc,c.LR, Matrix.one_mul])
|
| 40 |
+
(by simp only [combine,sym,Matrix.mul_assoc,c.LR, Matrix.mul_one])
|
| 41 |
+
def flipLines (I : Type) [Fintype I] [DecidableEq I] : Move I≃ Move I where
|
| 42 |
+
toFun := Move.dual
|
| 43 |
+
invFun := Move.dual
|
| 44 |
+
left_inv _ := rfl
|
| 45 |
+
right_inv _ := rfl
|
| 46 |
+
|
| 47 |
+
theorem flit_obs (M : Mat I J) (h : Injective M.mulVec) :
|
| 48 |
+
mapW unif (fun c : Move I => c.L*M)=unifOn (fun A => Injective A.mulVec) := by
|
| 49 |
+
classical
|
| 50 |
+
rw [← unifOn_true]
|
| 51 |
+
refine uniform_orbit _ (by obtain ⟨i⟩ := identity_move I; exact ⟨i,trivial⟩)
|
| 52 |
+
(fun x _ => inj_comp_mat _ _ x.L_inj h) ?_
|
| 53 |
+
intro x y hx hy
|
| 54 |
+
obtain ⟨c,hc⟩ := move_exists_one hx hy
|
| 55 |
+
refine ⟨circShift c,fun _ => Iff.rfl,fun w => ?_⟩
|
| 56 |
+
change w.L*M=x ↔ c.L*w.L*M=y
|
| 57 |
+
rw [←hc,Matrix.mul_assoc]; exact (c.permMat J).injective.eq_iff.symm
|
| 58 |
+
|
| 59 |
+
theorem flit_pmax (M Q : Mat I J) (h : Injective M.mulVec)
|
| 60 |
+
(ha : num J-num I≤ -1) :
|
| 61 |
+
pr unif (fun c : Move I => c.Rᵀ*M=Q) ≤ 2*bp (-num I*num J) := by
|
| 62 |
+
let P (M : Mat I J) := Injective M.mulVec
|
| 63 |
+
have ht :
|
| 64 |
+
pr unif (fun c : Move I=> c.Rᵀ*M=Q)=unifOn P Q := by
|
| 65 |
+
change pr unif (fun x : Move I => (flipLines I x).L*M=Q)=_
|
| 66 |
+
rw [← mapW_pr unif (flipLines I) (fun c => c.L*M=Q),unif_equiv]
|
| 67 |
+
exact congr_fun (flit_obs M h) Q
|
| 68 |
+
have hh : 2⁻¹ ≤ pr unif P := by
|
| 69 |
+
have hv := @unif_fail J I _ _ _ _
|
| 70 |
+
rw [pr_not,unif_law.total] at hv
|
| 71 |
+
have he := bp_le ha
|
| 72 |
+
rw [bp_neg,bp_one] at he; change 1-pr unif P ≤ _ at hv; linarith only [hv,he]
|
| 73 |
+
rw [ht,←on_unif]
|
| 74 |
+
have he : unif Q=bp (-num I*num J) := by rw [unif_apply,neg_mul,bp_neg,←cast_mat]
|
| 75 |
+
exact (on_mon unif_law.nz (show 0<(2:ℝ)⁻¹ from by norm_num) hh Q).trans_eq
|
| 76 |
+
(by rw [he,inv_inv])
|
| 77 |
+
|
| 78 |
+
variable {n : ℕ}
|
| 79 |
+
def plume {n : ℕ} (c : Flit n) (S : Space (Vec (Fin n))) :=
|
| 80 |
+
colSp (c.Rᵀ*pack S)
|
| 81 |
+
|
| 82 |
+
theorem plume_dim (c : Flit n) (S : Space (Vec (Fin n))) : dim (plume c S)=dim S := by
|
| 83 |
+
have hh := mrk_inj.mp (inj_comp_mat c.Rᵀ _ c.dual.L_inj (pack_inj S))
|
| 84 |
+
rw [plume,colSp_dim,hh,Fintype.card_fin]
|
| 85 |
+
|
| 86 |
+
omit [Fintype I] [DecidableEq I] [DecidableEq J] [DecidableEq K] in
|
| 87 |
+
private theorem smaller_cols (P : Mat I J) (Q : Mat I K) (h : colSp P ≤ colSp Q) :
|
| 88 |
+
∃ M : Mat K J,Q*M=P := by
|
| 89 |
+
classical
|
| 90 |
+
choose f hf using fun i : J =>
|
| 91 |
+
show ∃ z : Vec K,Q *ᵥ z=P.col i from h (colSp_mem i)
|
| 92 |
+
refine ⟨Matrix.of (fun i j => f j i),?_⟩
|
| 93 |
+
ext i j; exact congr_fun (hf j) i
|
| 94 |
+
|
| 95 |
+
set_option maxHeartbeats 800000 in
|
| 96 |
+
theorem plume_meets (n a : ℕ) (ha : a<n) (U V : Space (Vec (Fin n))) :
|
| 97 |
+
pr unif (fun c : Flit n => a≤dim (c.plume U ⊓ V : Space (Vec (Fin n))))≤
|
| 98 |
+
bp (1+((dim U:ℝ)+dim V-n)*a) := by
|
| 99 |
+
classical
|
| 100 |
+
let P := Mat (Fin (dim U)) (Fin a); let Q := Mat (Fin (dim V)) (Fin a)
|
| 101 |
+
let S (z : P×Q) := pack U*z.1
|
| 102 |
+
let q (p : P × Q) (c : Flit n) :=
|
| 103 |
+
Injective (S p).mulVec∧c.Rᵀ*S p=pack V*p.2
|
| 104 |
+
have hi (c : Flit n) (hc : a≤dim (c.plume U ⊓ V : Space (Vec (Fin n)))) :
|
| 105 |
+
∃ i,q i c := by
|
| 106 |
+
let w := c.plume U⊓V
|
| 107 |
+
obtain ⟨M,hM,hg⟩ := bounded_pack w a
|
| 108 |
+
have he : Injective M.mulVec := mrk_inj.mpr (by
|
| 109 |
+
rw [← colSp_dim,hg,Fintype.card_fin,min_eq_right hc])
|
| 110 |
+
have hU := le_trans hM (show w≤c.plume U from inf_le_left)
|
| 111 |
+
have hV : colSp M ≤ colSp (pack V) := by rw [colSp_pack]; exact le_trans hM inf_le_right
|
| 112 |
+
obtain ⟨P,hp⟩ := smaller_cols _ _ hU
|
| 113 |
+
obtain ⟨Q,hq⟩ := smaller_cols _ _ hV
|
| 114 |
+
rw [Matrix.mul_assoc] at hp
|
| 115 |
+
refine ⟨(P,Q),?_,hp.trans hq.symm⟩
|
| 116 |
+
have hx (z : Vec (Fin a)) :
|
| 117 |
+
c.Rᵀ*ᵥ((pack U * P)*ᵥz)= M*ᵥz := by rw [mulVec_mulVec,hp]
|
| 118 |
+
intro i j hg; exact he ((hx i).symm.trans ((congrArg _ hg).trans (hx j)))
|
| 119 |
+
have ht (i : P × Q) :
|
| 120 |
+
pr unif (q i) ≤2*bp (-(n:ℝ)*a) := by
|
| 121 |
+
by_cases h : Injective (S i).mulVec
|
| 122 |
+
· unfold q; simp only [h,true_and]
|
| 123 |
+
have hx : num (Fin a)-num (Fin n) ≤ -1 := by
|
| 124 |
+
simp only [num,Fintype.card_fin]
|
| 125 |
+
have hi : (a:ℝ)+1≤n := by exact_mod_cast ha
|
| 126 |
+
linarith only [hi]
|
| 127 |
+
simpa only [num,Fintype.card_fin] using flit_pmax (S i) (pack V*i.2) h hx
|
| 128 |
+
simp only [q,h,false_and,pr_false]
|
| 129 |
+
exact mul_nonneg (by norm_num) (bp_pos _).le
|
| 130 |
+
refine (le_trans (pr_mono unif_law.nz hi) (pr_exists_le unif_law.nz q)).trans
|
| 131 |
+
((sum_le_sum (fun i _ => ht i)).trans_eq ?_)
|
| 132 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Fintype.card_prod,Nat.cast_mul]
|
| 133 |
+
change num P*num Q* _=_
|
| 134 |
+
unfold P Q; rw [cast_mat,cast_mat,←bp_one,←bp_add,←bp_add,←bp_add]
|
| 135 |
+
congr 1; simp only [num,Fintype.card_fin]; ring
|
| 136 |
+
end Move
|
| 137 |
+
end HadwigerCounterexample
|
| 138 |
+
|
| 139 |
+
end
|
| 140 |
+
|
| 141 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RankEfficientDecomposition.lean
CHANGED
|
@@ -1,130 +1,130 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.DerivativeCompression
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rank Efficient Decomposition -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Module Submodule Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ} {I : Type} [Fintype I]
|
| 12 |
-
|
| 13 |
-
/-- Evaluation of individual matrices on Xpair -/
|
| 14 |
-
def obsI (p : Shape) {n} : Individual p n →ₗ[F] ReqF p n where
|
| 15 |
-
toFun A := combineF p (repF p A)
|
| 16 |
-
map_add' A B := by
|
| 17 |
-
rw [←map_add]; apply congrArg
|
| 18 |
-
funext i; refine LinearMap.ext fun x => ?_
|
| 19 |
-
change repF p (A+B) i x= repF p A i x+ repF p B i x
|
| 20 |
-
rw [repF_rep, repF_rep,repF_rep]
|
| 21 |
-
simp only [Pi.add_apply,mpair_add,Finset.sum_add_distrib]
|
| 22 |
-
map_smul' a A := by
|
| 23 |
-
change combineF p (repF p (a•A))=a • _
|
| 24 |
-
rw [←map_smul]; apply congrArg
|
| 25 |
-
funext i; refine LinearMap.ext fun x => ?_
|
| 26 |
-
change repF p (a•A) i x= a • (repF p A i x)
|
| 27 |
-
rw [repF_rep,repF_rep]
|
| 28 |
-
simp only [Pi.smul_apply,mpair_smul,smul_eq_mul,Finset.mul_sum]
|
| 29 |
-
|
| 30 |
-
theorem obsI_each (P : PureForms p n) :
|
| 31 |
-
obsI p (eachF p P)=obsPair p P :=
|
| 32 |
-
(obsPair_each P).symm
|
| 33 |
-
|
| 34 |
-
private theorem mrk_sub {I J : Type} [Fintype I] [Fintype J] (A B : Mat I J) :
|
| 35 |
-
(A-B).rank ≤ A.rank+B.rank := by rw [ZModModule.sub_eq_add]; exact mrk_add_le A B
|
| 36 |
-
|
| 37 |
-
theorem primary_initial (M : Individual p n) (f : Plan p n) (H R : ℕ)
|
| 38 |
-
(hF : ∀ z i,dim (sPin f z i) ≤ H) (hR : ∀ i e, (M i e).rank≤R) :
|
| 39 |
-
∃ P∈pureSpace p f, (∀ e,(P e).rank ≤ 2*R) ∧
|
| 40 |
-
(∀ i e, ((M-eachF p P) i e).rank≤2*H) := by
|
| 41 |
-
classical
|
| 42 |
-
let S := sPin f
|
| 43 |
-
choose A hA using fun z i => proj_exists (S z i) ⊥ disjoint_bot_right
|
| 44 |
-
let B (z i) := 1-A z i
|
| 45 |
-
let T : Individual p n := fun i e => pullM (B (e,true) i) (B (e,false) i) (M i e)
|
| 46 |
-
refine ⟨sumF p T,?_,fun e => ?_, fun i e => ?_⟩
|
| 47 |
-
· refine (pureSpace_mem _).mpr fun e => ?_
|
| 48 |
-
apply Submodule.sum_mem
|
| 49 |
-
intro i _
|
| 50 |
-
let P z := B (e,z) i * (IP p n i)ᵀ
|
| 51 |
-
have he (z : Bool) (x : Dir p n) (hx : x∈f (e,z)) : P z *ᵥ x=0 := by
|
| 52 |
-
unfold P B
|
| 53 |
-
let y := (IP p n i)ᵀ *ᵥ x
|
| 54 |
-
have hh : y∈ S (e,z) i := ⟨_,hx,rfl⟩
|
| 55 |
-
rw [←Matrix.mulVec_mulVec,Matrix.sub_mulVec,Matrix.one_mulVec]
|
| 56 |
-
change y - A (e,z) i *ᵥ y=0
|
| 57 |
-
rw [(hA _ _).fixes _ hh,sub_self]
|
| 58 |
-
have hh : liftM (IP p n i) (IP p n i) (T i e)=(P true)ᵀ * M i e * P false := by
|
| 59 |
-
simp only [liftM_def,T,pullM_def,P,Matrix.transpose_mul,Matrix.transpose_transpose,
|
| 60 |
-
Matrix.mul_assoc]
|
| 61 |
-
rw [hh,box_kill]
|
| 62 |
-
constructor
|
| 63 |
-
· intro x hx
|
| 64 |
-
simp only [transpose_mul,transpose_transpose,←mulVec_mulVec,he true x hx,mulVec_zero]
|
| 65 |
-
intro x hx
|
| 66 |
-
rw [← Matrix.mulVec_mulVec,he false x hx,mulVec_zero]
|
| 67 |
-
· refine (mrk_sum_le ..).trans ?_
|
| 68 |
-
have ht i : (liftM (IP p n i) (IP p n i) (T i e)).rank≤R := (rank_lift_le ..).trans
|
| 69 |
-
((rank_lift_le ..).trans (hR i e))
|
| 70 |
-
exact (Fintype.sum_bool _).le.trans ((Nat.add_le_add (ht _) (ht _)).trans_eq (two_mul R).symm)
|
| 71 |
-
· rw [each_sumF]
|
| 72 |
-
let z : Place p := (e,true)
|
| 73 |
-
let z' : Place p := (e,false)
|
| 74 |
-
let C := M i e
|
| 75 |
-
change (C-(T i e)).rank≤2*H
|
| 76 |
-
have he : C-T i e=(A z i)ᵀ*C+(B z i)ᵀ*C*A z' i := by
|
| 77 |
-
unfold T; rw [pullM_def]
|
| 78 |
-
dsimp only [B]
|
| 79 |
-
simp only [transpose_sub,Matrix.transpose_one,Matrix.mul_sub,Matrix.sub_mul,Matrix.mul_one,
|
| 80 |
-
Matrix.one_mul,C,z,z']
|
| 81 |
-
abel
|
| 82 |
-
have hh (z) : (A z i).rank ≤ H := (rank_maps (S z i) ((hA z i).onto)).trans (hF z i)
|
| 83 |
-
rw [he,two_mul]
|
| 84 |
-
refine (mrk_add_le ..).trans ?_
|
| 85 |
-
exact Nat.add_le_add ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_transpose (A z i) ▸ hh z))
|
| 86 |
-
((Matrix.rank_mul_le_right ..).trans (hh z'))
|
| 87 |
-
|
| 88 |
-
set_option maxHeartbeats 800000 in
|
| 89 |
-
theorem split_linear {M : Individual p n} {f b : Plan p n} {j : Bool}
|
| 90 |
-
{C D : ChanOut p n} {P : PureForms p n}
|
| 91 |
-
(R T H : ℕ) (ht : ∀ z i,dim (sPin f z i)≤T) (hm : ∀ i e,(M i e).rank≤R)
|
| 92 |
-
(hc : outSmall H C)
|
| 93 |
-
(hd : D∈deltaSpace p f b j) (hp : P∈pureSpace p f)
|
| 94 |
-
(hh : obsPair p (chanInner p C C)+obsPair p (chanDeriv p C D)+obsPair p P=obsI p M) :
|
| 95 |
-
∃ (B : ChanOut p n) (P' P0 : PureForms p n) (Mr : Individual p n),
|
| 96 |
-
B∈deltaSpace p f b j ∧ P'∈pureSpace p f ∧ P0∈pureSpace p f ∧
|
| 97 |
-
outSmall (3*H) (C+B) ∧ (∀ e,(P0 e).rank≤2*R) ∧
|
| 98 |
-
obsPair p (chanInner p (C+B) (C+B))+obsPair p (P'+P0)=obsI p M ∧
|
| 99 |
-
obsPair p P'=obsI p Mr ∧ ∀ i e, (Mr i e).rank ≤2*T+3*H := by
|
| 100 |
-
classical
|
| 101 |
-
obtain ⟨B,hB,hK,hZ⟩ := deriv_compress hc hd
|
| 102 |
-
obtain ⟨P0,hQ,hA,hL⟩ := primary_initial M f T R ht hm
|
| 103 |
-
let P' := P-chanInner p B B-P0
|
| 104 |
-
let CI := chanInner p (C+B) (C+B)
|
| 105 |
-
let E := eachF p CI
|
| 106 |
-
refine ⟨B,P',P0,M-eachF p P0-E,hB,(pureSpace p f).sub_mem
|
| 107 |
-
((pureSpace p f).sub_mem hp (chanInner_pure hB hB)) hQ,hQ,?_⟩
|
| 108 |
-
have hsmall : outSmall (3*H) (C+B) := by
|
| 109 |
-
intro z i
|
| 110 |
-
rw [Pi.add_apply,Matrix.add_mul]
|
| 111 |
-
apply le_trans (mrk_add_le ..)
|
| 112 |
-
exact (Nat.add_le_add (hc z i) ((Matrix.rank_mul_le_left ..).trans (hK z))).trans
|
| 113 |
-
(by omega)
|
| 114 |
-
have hg : obsPair p (chanInner p (C+B) (C+B)) + obsPair p (P'+P0)=obsI p M := by
|
| 115 |
-
rw [obsPair_chan_change,←hZ,show P'=P-chanInner p B B-P0 from rfl,sub_add_cancel,map_sub]
|
| 116 |
-
exact (show _=obsPair p (chanInner p C C)+obsPair p (chanDeriv p C D)+obsPair p P by
|
| 117 |
-
abel).trans hh
|
| 118 |
-
refine ⟨hsmall,hA,hg,?_,fun i e => ?_⟩
|
| 119 |
-
· rw [map_sub (obsI p) (M-eachF p P0) E,map_sub (obsI p),← hg]
|
| 120 |
-
rw [obsI_each,show E= eachF p CI from rfl,obsI_each]
|
| 121 |
-
unfold CI
|
| 122 |
-
rw [map_add]; abel
|
| 123 |
-
rw [Pi.sub_apply,Pi.sub_apply]
|
| 124 |
-
exact (mrk_sub ..).trans (Nat.add_le_add (hL i e) (show (E i e).rank≤_ from by
|
| 125 |
-
unfold E CI; rw [each_chan_val]; exact (Matrix.rank_mul_le_right ..).trans (hsmall _ i)))
|
| 126 |
-
end HadwigerCounterexample
|
| 127 |
-
|
| 128 |
-
end
|
| 129 |
-
|
| 130 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.DerivativeCompression
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rank Efficient Decomposition -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Module Submodule Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ} {I : Type} [Fintype I]
|
| 12 |
+
|
| 13 |
+
/-- Evaluation of individual matrices on Xpair -/
|
| 14 |
+
def obsI (p : Shape) {n} : Individual p n →ₗ[F] ReqF p n where
|
| 15 |
+
toFun A := combineF p (repF p A)
|
| 16 |
+
map_add' A B := by
|
| 17 |
+
rw [←map_add]; apply congrArg
|
| 18 |
+
funext i; refine LinearMap.ext fun x => ?_
|
| 19 |
+
change repF p (A+B) i x= repF p A i x+ repF p B i x
|
| 20 |
+
rw [repF_rep, repF_rep,repF_rep]
|
| 21 |
+
simp only [Pi.add_apply,mpair_add,Finset.sum_add_distrib]
|
| 22 |
+
map_smul' a A := by
|
| 23 |
+
change combineF p (repF p (a•A))=a • _
|
| 24 |
+
rw [←map_smul]; apply congrArg
|
| 25 |
+
funext i; refine LinearMap.ext fun x => ?_
|
| 26 |
+
change repF p (a•A) i x= a • (repF p A i x)
|
| 27 |
+
rw [repF_rep,repF_rep]
|
| 28 |
+
simp only [Pi.smul_apply,mpair_smul,smul_eq_mul,Finset.mul_sum]
|
| 29 |
+
|
| 30 |
+
theorem obsI_each (P : PureForms p n) :
|
| 31 |
+
obsI p (eachF p P)=obsPair p P :=
|
| 32 |
+
(obsPair_each P).symm
|
| 33 |
+
|
| 34 |
+
private theorem mrk_sub {I J : Type} [Fintype I] [Fintype J] (A B : Mat I J) :
|
| 35 |
+
(A-B).rank ≤ A.rank+B.rank := by rw [ZModModule.sub_eq_add]; exact mrk_add_le A B
|
| 36 |
+
|
| 37 |
+
theorem primary_initial (M : Individual p n) (f : Plan p n) (H R : ℕ)
|
| 38 |
+
(hF : ∀ z i,dim (sPin f z i) ≤ H) (hR : ∀ i e, (M i e).rank≤R) :
|
| 39 |
+
∃ P∈pureSpace p f, (∀ e,(P e).rank ≤ 2*R) ∧
|
| 40 |
+
(∀ i e, ((M-eachF p P) i e).rank≤2*H) := by
|
| 41 |
+
classical
|
| 42 |
+
let S := sPin f
|
| 43 |
+
choose A hA using fun z i => proj_exists (S z i) ⊥ disjoint_bot_right
|
| 44 |
+
let B (z i) := 1-A z i
|
| 45 |
+
let T : Individual p n := fun i e => pullM (B (e,true) i) (B (e,false) i) (M i e)
|
| 46 |
+
refine ⟨sumF p T,?_,fun e => ?_, fun i e => ?_⟩
|
| 47 |
+
· refine (pureSpace_mem _).mpr fun e => ?_
|
| 48 |
+
apply Submodule.sum_mem
|
| 49 |
+
intro i _
|
| 50 |
+
let P z := B (e,z) i * (IP p n i)ᵀ
|
| 51 |
+
have he (z : Bool) (x : Dir p n) (hx : x∈f (e,z)) : P z *ᵥ x=0 := by
|
| 52 |
+
unfold P B
|
| 53 |
+
let y := (IP p n i)ᵀ *ᵥ x
|
| 54 |
+
have hh : y∈ S (e,z) i := ⟨_,hx,rfl⟩
|
| 55 |
+
rw [←Matrix.mulVec_mulVec,Matrix.sub_mulVec,Matrix.one_mulVec]
|
| 56 |
+
change y - A (e,z) i *ᵥ y=0
|
| 57 |
+
rw [(hA _ _).fixes _ hh,sub_self]
|
| 58 |
+
have hh : liftM (IP p n i) (IP p n i) (T i e)=(P true)ᵀ * M i e * P false := by
|
| 59 |
+
simp only [liftM_def,T,pullM_def,P,Matrix.transpose_mul,Matrix.transpose_transpose,
|
| 60 |
+
Matrix.mul_assoc]
|
| 61 |
+
rw [hh,box_kill]
|
| 62 |
+
constructor
|
| 63 |
+
· intro x hx
|
| 64 |
+
simp only [transpose_mul,transpose_transpose,←mulVec_mulVec,he true x hx,mulVec_zero]
|
| 65 |
+
intro x hx
|
| 66 |
+
rw [← Matrix.mulVec_mulVec,he false x hx,mulVec_zero]
|
| 67 |
+
· refine (mrk_sum_le ..).trans ?_
|
| 68 |
+
have ht i : (liftM (IP p n i) (IP p n i) (T i e)).rank≤R := (rank_lift_le ..).trans
|
| 69 |
+
((rank_lift_le ..).trans (hR i e))
|
| 70 |
+
exact (Fintype.sum_bool _).le.trans ((Nat.add_le_add (ht _) (ht _)).trans_eq (two_mul R).symm)
|
| 71 |
+
· rw [each_sumF]
|
| 72 |
+
let z : Place p := (e,true)
|
| 73 |
+
let z' : Place p := (e,false)
|
| 74 |
+
let C := M i e
|
| 75 |
+
change (C-(T i e)).rank≤2*H
|
| 76 |
+
have he : C-T i e=(A z i)ᵀ*C+(B z i)ᵀ*C*A z' i := by
|
| 77 |
+
unfold T; rw [pullM_def]
|
| 78 |
+
dsimp only [B]
|
| 79 |
+
simp only [transpose_sub,Matrix.transpose_one,Matrix.mul_sub,Matrix.sub_mul,Matrix.mul_one,
|
| 80 |
+
Matrix.one_mul,C,z,z']
|
| 81 |
+
abel
|
| 82 |
+
have hh (z) : (A z i).rank ≤ H := (rank_maps (S z i) ((hA z i).onto)).trans (hF z i)
|
| 83 |
+
rw [he,two_mul]
|
| 84 |
+
refine (mrk_add_le ..).trans ?_
|
| 85 |
+
exact Nat.add_le_add ((Matrix.rank_mul_le_left ..).trans (Matrix.rank_transpose (A z i) ▸ hh z))
|
| 86 |
+
((Matrix.rank_mul_le_right ..).trans (hh z'))
|
| 87 |
+
|
| 88 |
+
set_option maxHeartbeats 800000 in
|
| 89 |
+
theorem split_linear {M : Individual p n} {f b : Plan p n} {j : Bool}
|
| 90 |
+
{C D : ChanOut p n} {P : PureForms p n}
|
| 91 |
+
(R T H : ℕ) (ht : ∀ z i,dim (sPin f z i)≤T) (hm : ∀ i e,(M i e).rank≤R)
|
| 92 |
+
(hc : outSmall H C)
|
| 93 |
+
(hd : D∈deltaSpace p f b j) (hp : P∈pureSpace p f)
|
| 94 |
+
(hh : obsPair p (chanInner p C C)+obsPair p (chanDeriv p C D)+obsPair p P=obsI p M) :
|
| 95 |
+
∃ (B : ChanOut p n) (P' P0 : PureForms p n) (Mr : Individual p n),
|
| 96 |
+
B∈deltaSpace p f b j ∧ P'∈pureSpace p f ∧ P0∈pureSpace p f ∧
|
| 97 |
+
outSmall (3*H) (C+B) ∧ (∀ e,(P0 e).rank≤2*R) ∧
|
| 98 |
+
obsPair p (chanInner p (C+B) (C+B))+obsPair p (P'+P0)=obsI p M ∧
|
| 99 |
+
obsPair p P'=obsI p Mr ∧ ∀ i e, (Mr i e).rank ≤2*T+3*H := by
|
| 100 |
+
classical
|
| 101 |
+
obtain ⟨B,hB,hK,hZ⟩ := deriv_compress hc hd
|
| 102 |
+
obtain ⟨P0,hQ,hA,hL⟩ := primary_initial M f T R ht hm
|
| 103 |
+
let P' := P-chanInner p B B-P0
|
| 104 |
+
let CI := chanInner p (C+B) (C+B)
|
| 105 |
+
let E := eachF p CI
|
| 106 |
+
refine ⟨B,P',P0,M-eachF p P0-E,hB,(pureSpace p f).sub_mem
|
| 107 |
+
((pureSpace p f).sub_mem hp (chanInner_pure hB hB)) hQ,hQ,?_⟩
|
| 108 |
+
have hsmall : outSmall (3*H) (C+B) := by
|
| 109 |
+
intro z i
|
| 110 |
+
rw [Pi.add_apply,Matrix.add_mul]
|
| 111 |
+
apply le_trans (mrk_add_le ..)
|
| 112 |
+
exact (Nat.add_le_add (hc z i) ((Matrix.rank_mul_le_left ..).trans (hK z))).trans
|
| 113 |
+
(by omega)
|
| 114 |
+
have hg : obsPair p (chanInner p (C+B) (C+B)) + obsPair p (P'+P0)=obsI p M := by
|
| 115 |
+
rw [obsPair_chan_change,←hZ,show P'=P-chanInner p B B-P0 from rfl,sub_add_cancel,map_sub]
|
| 116 |
+
exact (show _=obsPair p (chanInner p C C)+obsPair p (chanDeriv p C D)+obsPair p P by
|
| 117 |
+
abel).trans hh
|
| 118 |
+
refine ⟨hsmall,hA,hg,?_,fun i e => ?_⟩
|
| 119 |
+
· rw [map_sub (obsI p) (M-eachF p P0) E,map_sub (obsI p),← hg]
|
| 120 |
+
rw [obsI_each,show E= eachF p CI from rfl,obsI_each]
|
| 121 |
+
unfold CI
|
| 122 |
+
rw [map_add]; abel
|
| 123 |
+
rw [Pi.sub_apply,Pi.sub_apply]
|
| 124 |
+
exact (mrk_sub ..).trans (Nat.add_le_add (hL i e) (show (E i e).rank≤_ from by
|
| 125 |
+
unfold E CI; rw [each_chan_val]; exact (Matrix.rank_mul_le_right ..).trans (hsmall _ i)))
|
| 126 |
+
end HadwigerCounterexample
|
| 127 |
+
|
| 128 |
+
end
|
| 129 |
+
|
| 130 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RankSubrectangles.lean
CHANGED
|
@@ -1,126 +1,126 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.GramCharacterExpansion
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rank Subrectangles -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module LinearMap Submodule Function Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J G : Type} [Fintype I] [Fintype J] [Fintype G] [DecidableEq I] [DecidableEq J]
|
| 12 |
-
|
| 13 |
-
omit [DecidableEq I] in
|
| 14 |
-
theorem basis_subcolumns (A : Mat I J) :
|
| 15 |
-
∃ f : Fin A.rank→J, Injective (A.submatrix _root_.id f).mulVec := by
|
| 16 |
-
classical
|
| 17 |
-
let M (S : Finset J) := Submodule.span F (A.col '' (S : Set J))
|
| 18 |
-
have hg (S : Finset J) : ∃ T⊆S,M T=M S ∧ T.card=dim (M T) := by
|
| 19 |
-
induction S using Finset.induction with
|
| 20 |
-
| empty =>
|
| 21 |
-
have he : M ∅ = ⊥ := by
|
| 22 |
-
unfold M
|
| 23 |
-
rw [show (A.col '' ((∅ : Finset J) : Set _))=∅ by ext; simp, Submodule.span_empty]
|
| 24 |
-
refine ⟨∅,by simp,rfl,?_⟩; rw [he]; exact (finrank_bot ..).symm
|
| 25 |
-
| insert x S hx ih =>
|
| 26 |
-
obtain ⟨T,hT,hM,hD⟩ := ih
|
| 27 |
-
have he (S : Finset J) :
|
| 28 |
-
M (insert x S)=M S⊔Submodule.span F ({A.col x}:Set _) := by
|
| 29 |
-
unfold M
|
| 30 |
-
rw [← span_union]
|
| 31 |
-
congr 1
|
| 32 |
-
ext; simp
|
| 33 |
-
rw [he,←hM]
|
| 34 |
-
by_cases h : A.col x∈M T
|
| 35 |
-
· exact ⟨T,hT.trans (Finset.subset_insert _ _),
|
| 36 |
-
(sup_eq_left.mpr (by rwa [Submodule.span_singleton_le_iff_mem])).symm,hD⟩
|
| 37 |
-
refine ⟨insert x T,Finset.insert_subset_insert x hT,he T,?_⟩
|
| 38 |
-
rw [Finset.card_insert_of_notMem (fun v => hx (hT v)), he,hD]
|
| 39 |
-
exact (Submodule.finrank_sup_span_singleton h).symm
|
| 40 |
-
obtain ⟨S,hS,hA,ht⟩ := hg Finset.univ
|
| 41 |
-
have hs : M S=colSp A := by
|
| 42 |
-
rw [hA,colSp, Matrix.range_mulVecLin]; unfold M
|
| 43 |
-
congr 1
|
| 44 |
-
ext x; simp
|
| 45 |
-
have he : S.card=A.rank := by rw [ht,hs,colSp_dim]
|
| 46 |
-
let e := Fintype.equivFinOfCardEq (Fintype.card_coe S |>.trans he)
|
| 47 |
-
let f (x : Fin A.rank) := (e.symm x).val
|
| 48 |
-
have hB : colSp (A.submatrix _root_.id f)=M S := by
|
| 49 |
-
rw [colSp,Matrix.range_mulVecLin]; unfold M
|
| 50 |
-
congr 1
|
| 51 |
-
ext x; constructor
|
| 52 |
-
· rintro ⟨k,rfl⟩; exact ⟨f k,(e.symm k).property,rfl⟩
|
| 53 |
-
· rintro ⟨k,h,rfl⟩
|
| 54 |
-
refine ⟨e ⟨k,h⟩,?_⟩
|
| 55 |
-
have heq : f (e ⟨k,h⟩) = k := by unfold f; rw [Equiv.symm_apply_apply]
|
| 56 |
-
ext; simp [Matrix.col_apply,heq]
|
| 57 |
-
rw [hs] at hB
|
| 58 |
-
refine ⟨f,mrk_inj.mpr ?_⟩
|
| 59 |
-
rw [← colSp_dim,hB,Fintype.card_fin,colSp_dim]
|
| 60 |
-
|
| 61 |
-
theorem minor_arc (A : Mat I J) :
|
| 62 |
-
∃ (f : Fin A.rank→ I) (g : Fin A.rank→ J), Injective (A.submatrix f g).mulVec := by
|
| 63 |
-
classical
|
| 64 |
-
let t := A.rank
|
| 65 |
-
obtain ⟨g,hg⟩ := basis_subcolumns A
|
| 66 |
-
let B := A.submatrix _root_.id g
|
| 67 |
-
have he : Bᵀ.rank=t := (Matrix.rank_transpose _).trans ((mrk_inj.mp hg).trans
|
| 68 |
-
(Fintype.card_fin _))
|
| 69 |
-
obtain ⟨f,hf⟩ : ∃ f : Fin t→I,Injective ((Bᵀ.submatrix _root_.id f)).mulVec := by
|
| 70 |
-
have hi := basis_subcolumns Bᵀ
|
| 71 |
-
rwa [he] at hi
|
| 72 |
-
have hh := mrk_inj.mp hf
|
| 73 |
-
refine ⟨f,g,mrk_inj.mpr ?_⟩
|
| 74 |
-
rw [← Matrix.rank_transpose]
|
| 75 |
-
exact hh
|
| 76 |
-
|
| 77 |
-
private theorem lastCol {t : ℕ} {I J : Type} [Fintype I] [Fintype J]
|
| 78 |
-
[DecidableEq I] [DecidableEq J] (A : Mat I J)
|
| 79 |
-
(f : Fin t→I) (g : Fin t→J) (x : I) (y : J)
|
| 80 |
-
(h : (A.submatrix (Sum.elim f (fun _ : Unit => x))
|
| 81 |
-
(Sum.elim g (fun _ : Unit => y))).rank ≤ t)
|
| 82 |
-
(hb : Injective (A.submatrix f g).mulVec) :
|
| 83 |
-
∃ z : Vec (Fin t),(A.submatrix f g)*ᵥ z=(fun i => A (f i) y) ∧
|
| 84 |
-
A x y=∑ i,A x (g i)*z i := by
|
| 85 |
-
classical
|
| 86 |
-
let C := A.submatrix (Sum.elim f (fun _ : Unit => x)) (Sum.elim g (fun _ : Unit => y))
|
| 87 |
-
let M := C.submatrix _root_.id (.inl ·)
|
| 88 |
-
have hm : Injective M.mulVec := by
|
| 89 |
-
intro X Y h
|
| 90 |
-
apply hb
|
| 91 |
-
funext i
|
| 92 |
-
exact congr_fun h (.inl i)
|
| 93 |
-
have hM : colSp M≤colSp C := by
|
| 94 |
-
rw [colSp,colSp, Matrix.range_mulVecLin,Matrix.range_mulVecLin]
|
| 95 |
-
apply Submodule.span_mono
|
| 96 |
-
rintro s ⟨i,rfl⟩; exact ⟨.inl i,rfl⟩
|
| 97 |
-
have he : colSp M=colSp C := Submodule.eq_of_le_of_finrank_le hM (by
|
| 98 |
-
have he : dim (colSp M)=t := (mrk_inj.mp hm).trans (Fintype.card_fin _)
|
| 99 |
-
change dim (colSp C) ≤ dim (colSp M)
|
| 100 |
-
rw [he]; exact h)
|
| 101 |
-
obtain ⟨v,hv⟩ := show C.col (.inr ()) ∈ colSp M from he.symm ▸ colSp_mem _
|
| 102 |
-
exact ⟨v,funext (fun i => congr_fun hv (.inl i)),(congr_fun hv (.inr ())).symm⟩
|
| 103 |
-
|
| 104 |
-
theorem border_same {t : ℕ} (A B : Mat I J) (f : Fin t→I) (g : Fin t→J)
|
| 105 |
-
(x : I) (y : J)
|
| 106 |
-
(h : Injective (A.submatrix f g).mulVec)
|
| 107 |
-
(hx : ∀ i j,A (f i) j=B (f i) j)
|
| 108 |
-
(hy : ∀ i j,A i (g j)=B i (g j))
|
| 109 |
-
(hA : (A.submatrix (Sum.elim f (fun _ : Unit => x))
|
| 110 |
-
(Sum.elim g (fun _ : Unit => y))).rank ≤ t)
|
| 111 |
-
(hB : (B.submatrix (Sum.elim f (fun _ : Unit => x))
|
| 112 |
-
(Sum.elim g (fun _ : Unit => y))).rank ≤ t) :
|
| 113 |
-
A x y=B x y := by
|
| 114 |
-
classical
|
| 115 |
-
have hh : A.submatrix f g=B.submatrix f g := Matrix.ext fun i j => hx i _
|
| 116 |
-
obtain ⟨s,hs,hL⟩ := lastCol A f g x y hA h
|
| 117 |
-
obtain ⟨s',hs',hR⟩ := lastCol B f g x y hB (hh ▸ h)
|
| 118 |
-
obtain rfl : s=s' := h ((show A.submatrix f g *ᵥ s=(fun i => A (f i) y) from hs).trans
|
| 119 |
-
((funext (fun i => hx i y)).trans (hh ▸ hs'.symm)))
|
| 120 |
-
rw [hL,hR]; simp_rw [hy]
|
| 121 |
-
|
| 122 |
-
end HadwigerCounterexample
|
| 123 |
-
|
| 124 |
-
end
|
| 125 |
-
|
| 126 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.GramCharacterExpansion
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rank Subrectangles -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module LinearMap Submodule Function Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J G : Type} [Fintype I] [Fintype J] [Fintype G] [DecidableEq I] [DecidableEq J]
|
| 12 |
+
|
| 13 |
+
omit [DecidableEq I] in
|
| 14 |
+
theorem basis_subcolumns (A : Mat I J) :
|
| 15 |
+
∃ f : Fin A.rank→J, Injective (A.submatrix _root_.id f).mulVec := by
|
| 16 |
+
classical
|
| 17 |
+
let M (S : Finset J) := Submodule.span F (A.col '' (S : Set J))
|
| 18 |
+
have hg (S : Finset J) : ∃ T⊆S,M T=M S ∧ T.card=dim (M T) := by
|
| 19 |
+
induction S using Finset.induction with
|
| 20 |
+
| empty =>
|
| 21 |
+
have he : M ∅ = ⊥ := by
|
| 22 |
+
unfold M
|
| 23 |
+
rw [show (A.col '' ((∅ : Finset J) : Set _))=∅ by ext; simp, Submodule.span_empty]
|
| 24 |
+
refine ⟨∅,by simp,rfl,?_⟩; rw [he]; exact (finrank_bot ..).symm
|
| 25 |
+
| insert x S hx ih =>
|
| 26 |
+
obtain ⟨T,hT,hM,hD⟩ := ih
|
| 27 |
+
have he (S : Finset J) :
|
| 28 |
+
M (insert x S)=M S⊔Submodule.span F ({A.col x}:Set _) := by
|
| 29 |
+
unfold M
|
| 30 |
+
rw [← span_union]
|
| 31 |
+
congr 1
|
| 32 |
+
ext; simp
|
| 33 |
+
rw [he,←hM]
|
| 34 |
+
by_cases h : A.col x∈M T
|
| 35 |
+
· exact ⟨T,hT.trans (Finset.subset_insert _ _),
|
| 36 |
+
(sup_eq_left.mpr (by rwa [Submodule.span_singleton_le_iff_mem])).symm,hD⟩
|
| 37 |
+
refine ⟨insert x T,Finset.insert_subset_insert x hT,he T,?_⟩
|
| 38 |
+
rw [Finset.card_insert_of_notMem (fun v => hx (hT v)), he,hD]
|
| 39 |
+
exact (Submodule.finrank_sup_span_singleton h).symm
|
| 40 |
+
obtain ⟨S,hS,hA,ht⟩ := hg Finset.univ
|
| 41 |
+
have hs : M S=colSp A := by
|
| 42 |
+
rw [hA,colSp, Matrix.range_mulVecLin]; unfold M
|
| 43 |
+
congr 1
|
| 44 |
+
ext x; simp
|
| 45 |
+
have he : S.card=A.rank := by rw [ht,hs,colSp_dim]
|
| 46 |
+
let e := Fintype.equivFinOfCardEq (Fintype.card_coe S |>.trans he)
|
| 47 |
+
let f (x : Fin A.rank) := (e.symm x).val
|
| 48 |
+
have hB : colSp (A.submatrix _root_.id f)=M S := by
|
| 49 |
+
rw [colSp,Matrix.range_mulVecLin]; unfold M
|
| 50 |
+
congr 1
|
| 51 |
+
ext x; constructor
|
| 52 |
+
· rintro ⟨k,rfl⟩; exact ⟨f k,(e.symm k).property,rfl⟩
|
| 53 |
+
· rintro ⟨k,h,rfl⟩
|
| 54 |
+
refine ⟨e ⟨k,h⟩,?_⟩
|
| 55 |
+
have heq : f (e ⟨k,h⟩) = k := by unfold f; rw [Equiv.symm_apply_apply]
|
| 56 |
+
ext; simp [Matrix.col_apply,heq]
|
| 57 |
+
rw [hs] at hB
|
| 58 |
+
refine ⟨f,mrk_inj.mpr ?_⟩
|
| 59 |
+
rw [← colSp_dim,hB,Fintype.card_fin,colSp_dim]
|
| 60 |
+
|
| 61 |
+
theorem minor_arc (A : Mat I J) :
|
| 62 |
+
∃ (f : Fin A.rank→ I) (g : Fin A.rank→ J), Injective (A.submatrix f g).mulVec := by
|
| 63 |
+
classical
|
| 64 |
+
let t := A.rank
|
| 65 |
+
obtain ⟨g,hg⟩ := basis_subcolumns A
|
| 66 |
+
let B := A.submatrix _root_.id g
|
| 67 |
+
have he : Bᵀ.rank=t := (Matrix.rank_transpose _).trans ((mrk_inj.mp hg).trans
|
| 68 |
+
(Fintype.card_fin _))
|
| 69 |
+
obtain ⟨f,hf⟩ : ∃ f : Fin t→I,Injective ((Bᵀ.submatrix _root_.id f)).mulVec := by
|
| 70 |
+
have hi := basis_subcolumns Bᵀ
|
| 71 |
+
rwa [he] at hi
|
| 72 |
+
have hh := mrk_inj.mp hf
|
| 73 |
+
refine ⟨f,g,mrk_inj.mpr ?_⟩
|
| 74 |
+
rw [← Matrix.rank_transpose]
|
| 75 |
+
exact hh
|
| 76 |
+
|
| 77 |
+
private theorem lastCol {t : ℕ} {I J : Type} [Fintype I] [Fintype J]
|
| 78 |
+
[DecidableEq I] [DecidableEq J] (A : Mat I J)
|
| 79 |
+
(f : Fin t→I) (g : Fin t→J) (x : I) (y : J)
|
| 80 |
+
(h : (A.submatrix (Sum.elim f (fun _ : Unit => x))
|
| 81 |
+
(Sum.elim g (fun _ : Unit => y))).rank ≤ t)
|
| 82 |
+
(hb : Injective (A.submatrix f g).mulVec) :
|
| 83 |
+
∃ z : Vec (Fin t),(A.submatrix f g)*ᵥ z=(fun i => A (f i) y) ∧
|
| 84 |
+
A x y=∑ i,A x (g i)*z i := by
|
| 85 |
+
classical
|
| 86 |
+
let C := A.submatrix (Sum.elim f (fun _ : Unit => x)) (Sum.elim g (fun _ : Unit => y))
|
| 87 |
+
let M := C.submatrix _root_.id (.inl ·)
|
| 88 |
+
have hm : Injective M.mulVec := by
|
| 89 |
+
intro X Y h
|
| 90 |
+
apply hb
|
| 91 |
+
funext i
|
| 92 |
+
exact congr_fun h (.inl i)
|
| 93 |
+
have hM : colSp M≤colSp C := by
|
| 94 |
+
rw [colSp,colSp, Matrix.range_mulVecLin,Matrix.range_mulVecLin]
|
| 95 |
+
apply Submodule.span_mono
|
| 96 |
+
rintro s ⟨i,rfl⟩; exact ⟨.inl i,rfl⟩
|
| 97 |
+
have he : colSp M=colSp C := Submodule.eq_of_le_of_finrank_le hM (by
|
| 98 |
+
have he : dim (colSp M)=t := (mrk_inj.mp hm).trans (Fintype.card_fin _)
|
| 99 |
+
change dim (colSp C) ≤ dim (colSp M)
|
| 100 |
+
rw [he]; exact h)
|
| 101 |
+
obtain ⟨v,hv⟩ := show C.col (.inr ()) ∈ colSp M from he.symm ▸ colSp_mem _
|
| 102 |
+
exact ⟨v,funext (fun i => congr_fun hv (.inl i)),(congr_fun hv (.inr ())).symm⟩
|
| 103 |
+
|
| 104 |
+
theorem border_same {t : ℕ} (A B : Mat I J) (f : Fin t→I) (g : Fin t→J)
|
| 105 |
+
(x : I) (y : J)
|
| 106 |
+
(h : Injective (A.submatrix f g).mulVec)
|
| 107 |
+
(hx : ∀ i j,A (f i) j=B (f i) j)
|
| 108 |
+
(hy : ∀ i j,A i (g j)=B i (g j))
|
| 109 |
+
(hA : (A.submatrix (Sum.elim f (fun _ : Unit => x))
|
| 110 |
+
(Sum.elim g (fun _ : Unit => y))).rank ≤ t)
|
| 111 |
+
(hB : (B.submatrix (Sum.elim f (fun _ : Unit => x))
|
| 112 |
+
(Sum.elim g (fun _ : Unit => y))).rank ≤ t) :
|
| 113 |
+
A x y=B x y := by
|
| 114 |
+
classical
|
| 115 |
+
have hh : A.submatrix f g=B.submatrix f g := Matrix.ext fun i j => hx i _
|
| 116 |
+
obtain ⟨s,hs,hL⟩ := lastCol A f g x y hA h
|
| 117 |
+
obtain ⟨s',hs',hR⟩ := lastCol B f g x y hB (hh ▸ h)
|
| 118 |
+
obtain rfl : s=s' := h ((show A.submatrix f g *ᵥ s=(fun i => A (f i) y) from hs).trans
|
| 119 |
+
((funext (fun i => hx i y)).trans (hh ▸ hs'.symm)))
|
| 120 |
+
rw [hL,hR]; simp_rw [hy]
|
| 121 |
+
|
| 122 |
+
end HadwigerCounterexample
|
| 123 |
+
|
| 124 |
+
end
|
| 125 |
+
|
| 126 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RareLeafEvents.lean
CHANGED
|
@@ -1,101 +1,101 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.SuperlevelBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rare Leaf Events -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
variable {p:Shape} {M n N K s0:ℕ}
|
| 13 |
-
namespace StatusAnalysis
|
| 14 |
-
variable {q:Format} {d e:Rates} {b:Bool}
|
| 15 |
-
|
| 16 |
-
namespace Quill
|
| 17 |
-
variable (w:Quill p q d b) (m:Mixer p n) (t : Tagging p (Messenger q))
|
| 18 |
-
(z : Messenger q→F)
|
| 19 |
-
def qualified (s:Charts p n d) (K :ℕ) (μ:Wgt (UnitType p n N)) (P : UnitType p n N→Prop) (a:ℝ) :=
|
| 20 |
-
2*a ≤ pr μ P ∧ ∀ i,P i →μ i ≠0→ w.steady t z m K s i
|
| 21 |
-
|
| 22 |
-
theorem qualify_hit (s : Charts p n d) (K:ℕ) (μ:Wgt (UnitType p n N))
|
| 23 |
-
(P: UnitType p n N→Prop) (H:Keys (p:=p) t N→Prop) {a α:ℝ} (hα:0<α)
|
| 24 |
-
(h:w.qualified m t z s K μ P a)
|
| 25 |
-
(hw : IsLaw μ) (hg:∀ i,IsLaw (w.policies t z n i))
|
| 26 |
-
(hp: pr μ (fun i=>¬w.sober t z K H m α i) ≤ a) :
|
| 27 |
-
a*α ≤ pr (w.sales t z μ P m s) H := by
|
| 28 |
-
classical
|
| 29 |
-
let Q:=w.sober t z K H m α
|
| 30 |
-
let V i:=w.prowl s t z m i (fun i=>ind (H i))
|
| 31 |
-
have he:a ≤ pr μ (fun x=>P x∧ Q x) :=
|
| 32 |
-
(le_trans (by linarith only [hp,h.1]) (pr_shield hw.nz _ _))
|
| 33 |
-
unfold pr; rw [sales_mean]
|
| 34 |
-
refine (mul_le_mul_of_nonneg_right he hα.le).trans ?_
|
| 35 |
-
unfold pr; rw [←avg_mul]
|
| 36 |
-
unfold avg
|
| 37 |
-
refine Finset.sum_le_sum fun i _=> ?_
|
| 38 |
-
dsimp only
|
| 39 |
-
by_cases hi:μ i=0
|
| 40 |
-
· simp only [hi,zero_mul]; rfl
|
| 41 |
-
refine mul_le_mul_of_nonneg_left ?_ (hw.nz i)
|
| 42 |
-
have hv : 0≤ V i := avg_nonneg (prodW_law hg).nz (fun j=> mul_nonneg (ind_nonneg _) (ind_nonneg _))
|
| 43 |
-
by_cases hP:P i∧ Q i
|
| 44 |
-
· change ind (_∧_) *_ ≤ _*V i; rw [ind_one hP,ind_one hP.1,one_mul,one_mul]
|
| 45 |
-
exact hP.2 s (h.2 i hP.1 hi)
|
| 46 |
-
rw [ind_zero hP,zero_mul]; exact mul_nonneg (ind_nonneg _) hv
|
| 47 |
-
end Quill
|
| 48 |
-
|
| 49 |
-
namespace Station
|
| 50 |
-
variable {w:LeafMixture p n N} (t:Station p n N K w) (x:Typus p q d e)
|
| 51 |
-
(m:Mixer p n) (k: Fin (2^deckMax p K)) (μ:Wgt (UnitType p n N))
|
| 52 |
-
|
| 53 |
-
def charter (a:ℝ) (i:w.T×w.T) :=
|
| 54 |
-
x.permission ∧
|
| 55 |
-
x.qA.qualified m x.t x.z (t.cAxes i.1 d) K (partW μ i.1.val) (t.frontPage x m i.1 i.2 k) a ∧
|
| 56 |
-
x.qB.qualified m x.t x.z (t.cAxes i.2 e) K (partW μ i.2.val) (t.backPage x m i.1 i.2 k) a
|
| 57 |
-
|
| 58 |
-
def berth (a:ℝ) :=
|
| 59 |
-
pr (pairW (portionW μ w.T) (portionW μ w.T)) (charter t x m k μ a)
|
| 60 |
-
|
| 61 |
-
theorem charterWeak {a b:ℝ} (hh:a≤b) (i:w.T×w.T) (hf:charter t x m k μ b i) :
|
| 62 |
-
charter t x m k μ a i :=
|
| 63 |
-
⟨hf.1,⟨(mul_le_mul_of_nonneg_left hh (by norm_num)).trans hf.2.1.1,hf.2.1.2⟩,
|
| 64 |
-
⟨(mul_le_mul_of_nonneg_left hh (by norm_num)).trans hf.2.2.1,hf.2.2.2⟩⟩
|
| 65 |
-
end Station
|
| 66 |
-
|
| 67 |
-
variable {A I J : Type} [Fintype A] [Fintype I] [Fintype J]
|
| 68 |
-
set_option maxHeartbeats 800000 in
|
| 69 |
-
theorem vacantBound (w : Wgt I) (v : I→ Wgt A) (K : I→ J → A→Prop) (P : A→Prop)
|
| 70 |
-
(hw:IsLaw w) (hv:∀ i,IsLaw (v i))
|
| 71 |
-
{b e ε:ℝ} (hb : 0<b)
|
| 72 |
-
(he : ∀ i j,pr (mixW w v) (K i j) ≤ e)
|
| 73 |
-
(hf : pr (mixW w v) P≤ε) :
|
| 74 |
-
let S (i:I×I) := (∃ j,b< pr (v i.1) (K i.2 j)) ∨ b< pr (v i.2) P
|
| 75 |
-
pr (pairW w w) S ≤ num J * (e/b)+ε/b := by
|
| 76 |
-
classical
|
| 77 |
-
intro S
|
| 78 |
-
have hg Q c (h: pr (mixW w v) Q≤c) : pr w (fun i=> b< pr (v i) Q)≤ c/b := by
|
| 79 |
-
refine (le_div_iff₀ hb).mpr ?_
|
| 80 |
-
rw [mul_comm]
|
| 81 |
-
unfold pr at h; rw [mixW_avg] at h
|
| 82 |
-
let f i:=pr (v i) Q
|
| 83 |
-
apply le_trans (b:=avg w f) ?_ h
|
| 84 |
-
exact le_trans (mul_le_mul_of_nonneg_left (pr_mono hw.nz
|
| 85 |
-
(q:=fun i=>b≤f i) (fun _ hh=>hh.le)) hb.le) (le_avg_markov hw.nz (fun i=> pr_nonneg (hv _).nz) b)
|
| 86 |
-
let Q i:= pr w (fun x=>∃ j,b<pr (v x) (K i j))
|
| 87 |
-
have hh i : Q i≤num J*(e/b) := ((pr_exists_le hw.nz _).trans
|
| 88 |
-
(Finset.sum_le_sum fun j _ => hg _ _ (he i j))).trans_eq (by simp [num])
|
| 89 |
-
let U (i:I×I):=∃ j,b<pr (v i.1) (K i.2 j)
|
| 90 |
-
let V (i:I×I):=b<pr (v i.2) P
|
| 91 |
-
apply (pr_or_le (p:=U) (q:=V) (pairW_law hw hw).nz).trans
|
| 92 |
-
refine add_le_add ?_ ?_
|
| 93 |
-
· unfold pr; rw [pairW_avg,avg_avg]; exact hw.avg_le hh
|
| 94 |
-
unfold pr; rw [pairW_avg ]; exact hw.avg_le fun _=>hg _ _ hf
|
| 95 |
-
|
| 96 |
-
end StatusAnalysis
|
| 97 |
-
end HadwigerCounterexample
|
| 98 |
-
|
| 99 |
-
end
|
| 100 |
-
|
| 101 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.SuperlevelBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rare Leaf Events -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
variable {p:Shape} {M n N K s0:ℕ}
|
| 13 |
+
namespace StatusAnalysis
|
| 14 |
+
variable {q:Format} {d e:Rates} {b:Bool}
|
| 15 |
+
|
| 16 |
+
namespace Quill
|
| 17 |
+
variable (w:Quill p q d b) (m:Mixer p n) (t : Tagging p (Messenger q))
|
| 18 |
+
(z : Messenger q→F)
|
| 19 |
+
def qualified (s:Charts p n d) (K :ℕ) (μ:Wgt (UnitType p n N)) (P : UnitType p n N→Prop) (a:ℝ) :=
|
| 20 |
+
2*a ≤ pr μ P ∧ ∀ i,P i →μ i ≠0→ w.steady t z m K s i
|
| 21 |
+
|
| 22 |
+
theorem qualify_hit (s : Charts p n d) (K:ℕ) (μ:Wgt (UnitType p n N))
|
| 23 |
+
(P: UnitType p n N→Prop) (H:Keys (p:=p) t N→Prop) {a α:ℝ} (hα:0<α)
|
| 24 |
+
(h:w.qualified m t z s K μ P a)
|
| 25 |
+
(hw : IsLaw μ) (hg:∀ i,IsLaw (w.policies t z n i))
|
| 26 |
+
(hp: pr μ (fun i=>¬w.sober t z K H m α i) ≤ a) :
|
| 27 |
+
a*α ≤ pr (w.sales t z μ P m s) H := by
|
| 28 |
+
classical
|
| 29 |
+
let Q:=w.sober t z K H m α
|
| 30 |
+
let V i:=w.prowl s t z m i (fun i=>ind (H i))
|
| 31 |
+
have he:a ≤ pr μ (fun x=>P x∧ Q x) :=
|
| 32 |
+
(le_trans (by linarith only [hp,h.1]) (pr_shield hw.nz _ _))
|
| 33 |
+
unfold pr; rw [sales_mean]
|
| 34 |
+
refine (mul_le_mul_of_nonneg_right he hα.le).trans ?_
|
| 35 |
+
unfold pr; rw [←avg_mul]
|
| 36 |
+
unfold avg
|
| 37 |
+
refine Finset.sum_le_sum fun i _=> ?_
|
| 38 |
+
dsimp only
|
| 39 |
+
by_cases hi:μ i=0
|
| 40 |
+
· simp only [hi,zero_mul]; rfl
|
| 41 |
+
refine mul_le_mul_of_nonneg_left ?_ (hw.nz i)
|
| 42 |
+
have hv : 0≤ V i := avg_nonneg (prodW_law hg).nz (fun j=> mul_nonneg (ind_nonneg _) (ind_nonneg _))
|
| 43 |
+
by_cases hP:P i∧ Q i
|
| 44 |
+
· change ind (_∧_) *_ ≤ _*V i; rw [ind_one hP,ind_one hP.1,one_mul,one_mul]
|
| 45 |
+
exact hP.2 s (h.2 i hP.1 hi)
|
| 46 |
+
rw [ind_zero hP,zero_mul]; exact mul_nonneg (ind_nonneg _) hv
|
| 47 |
+
end Quill
|
| 48 |
+
|
| 49 |
+
namespace Station
|
| 50 |
+
variable {w:LeafMixture p n N} (t:Station p n N K w) (x:Typus p q d e)
|
| 51 |
+
(m:Mixer p n) (k: Fin (2^deckMax p K)) (μ:Wgt (UnitType p n N))
|
| 52 |
+
|
| 53 |
+
def charter (a:ℝ) (i:w.T×w.T) :=
|
| 54 |
+
x.permission ∧
|
| 55 |
+
x.qA.qualified m x.t x.z (t.cAxes i.1 d) K (partW μ i.1.val) (t.frontPage x m i.1 i.2 k) a ∧
|
| 56 |
+
x.qB.qualified m x.t x.z (t.cAxes i.2 e) K (partW μ i.2.val) (t.backPage x m i.1 i.2 k) a
|
| 57 |
+
|
| 58 |
+
def berth (a:ℝ) :=
|
| 59 |
+
pr (pairW (portionW μ w.T) (portionW μ w.T)) (charter t x m k μ a)
|
| 60 |
+
|
| 61 |
+
theorem charterWeak {a b:ℝ} (hh:a≤b) (i:w.T×w.T) (hf:charter t x m k μ b i) :
|
| 62 |
+
charter t x m k μ a i :=
|
| 63 |
+
⟨hf.1,⟨(mul_le_mul_of_nonneg_left hh (by norm_num)).trans hf.2.1.1,hf.2.1.2⟩,
|
| 64 |
+
⟨(mul_le_mul_of_nonneg_left hh (by norm_num)).trans hf.2.2.1,hf.2.2.2⟩⟩
|
| 65 |
+
end Station
|
| 66 |
+
|
| 67 |
+
variable {A I J : Type} [Fintype A] [Fintype I] [Fintype J]
|
| 68 |
+
set_option maxHeartbeats 800000 in
|
| 69 |
+
theorem vacantBound (w : Wgt I) (v : I→ Wgt A) (K : I→ J → A→Prop) (P : A→Prop)
|
| 70 |
+
(hw:IsLaw w) (hv:∀ i,IsLaw (v i))
|
| 71 |
+
{b e ε:ℝ} (hb : 0<b)
|
| 72 |
+
(he : ∀ i j,pr (mixW w v) (K i j) ≤ e)
|
| 73 |
+
(hf : pr (mixW w v) P≤ε) :
|
| 74 |
+
let S (i:I×I) := (∃ j,b< pr (v i.1) (K i.2 j)) ∨ b< pr (v i.2) P
|
| 75 |
+
pr (pairW w w) S ≤ num J * (e/b)+ε/b := by
|
| 76 |
+
classical
|
| 77 |
+
intro S
|
| 78 |
+
have hg Q c (h: pr (mixW w v) Q≤c) : pr w (fun i=> b< pr (v i) Q)≤ c/b := by
|
| 79 |
+
refine (le_div_iff₀ hb).mpr ?_
|
| 80 |
+
rw [mul_comm]
|
| 81 |
+
unfold pr at h; rw [mixW_avg] at h
|
| 82 |
+
let f i:=pr (v i) Q
|
| 83 |
+
apply le_trans (b:=avg w f) ?_ h
|
| 84 |
+
exact le_trans (mul_le_mul_of_nonneg_left (pr_mono hw.nz
|
| 85 |
+
(q:=fun i=>b≤f i) (fun _ hh=>hh.le)) hb.le) (le_avg_markov hw.nz (fun i=> pr_nonneg (hv _).nz) b)
|
| 86 |
+
let Q i:= pr w (fun x=>∃ j,b<pr (v x) (K i j))
|
| 87 |
+
have hh i : Q i≤num J*(e/b) := ((pr_exists_le hw.nz _).trans
|
| 88 |
+
(Finset.sum_le_sum fun j _ => hg _ _ (he i j))).trans_eq (by simp [num])
|
| 89 |
+
let U (i:I×I):=∃ j,b<pr (v i.1) (K i.2 j)
|
| 90 |
+
let V (i:I×I):=b<pr (v i.2) P
|
| 91 |
+
apply (pr_or_le (p:=U) (q:=V) (pairW_law hw hw).nz).trans
|
| 92 |
+
refine add_le_add ?_ ?_
|
| 93 |
+
· unfold pr; rw [pairW_avg,avg_avg]; exact hw.avg_le hh
|
| 94 |
+
unfold pr; rw [pairW_avg ]; exact hw.avg_le fun _=>hg _ _ hf
|
| 95 |
+
|
| 96 |
+
end StatusAnalysis
|
| 97 |
+
end HadwigerCounterexample
|
| 98 |
+
|
| 99 |
+
end
|
| 100 |
+
|
| 101 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RareTestEvents.lean
CHANGED
|
@@ -1,132 +1,132 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.CompatibleOptionRealization
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rare Test Events -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix LinearMap Module Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
variable {p:Shape} {n N K M : ℕ}
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
|
| 14 |
-
def singles : Format:=fun _=>1
|
| 15 |
-
def volume1 : Volumes:=fun _=>1
|
| 16 |
-
theorem singles_vol : singles=toFormat volume1 := rfl
|
| 17 |
-
theorem singles_card : Fintype.card (Messenger singles)=4 := by
|
| 18 |
-
decide
|
| 19 |
-
theorem singles_short : ∀ i,1≤singles i ∧ singles i≤7 :=by simp [singles]
|
| 20 |
-
theorem funds_one {b : Bool} {d : Rates} (f: Fabric p singles d b) (i:Grid) :
|
| 21 |
-
funds f.amp i=(f.amp ⟨i,(0:Fin 1)⟩).2 := by
|
| 22 |
-
unfold funds
|
| 23 |
-
let : Unique (Fin (singles i)) := (show Unique (Fin 1) from inferInstance)
|
| 24 |
-
exact Fintype.sum_unique _
|
| 25 |
-
|
| 26 |
-
theorem fourPens (s:Plan p n) (K:ℕ) (H : Stalls p) (h:booths p K s H)
|
| 27 |
-
(ht : 2*frameBills p.g K+4 ≤Fintype.card (Label p.b)) :
|
| 28 |
-
∃ z:Messenger singles→Label p.b, Injective z ∧ ∀ i j, z i∉ H j := by
|
| 29 |
-
classical
|
| 30 |
-
let F:=H true ∪ H false; let T:=Fᶜ
|
| 31 |
-
have hp : F.card≤ 2* frameBills p.g K :=
|
| 32 |
-
(Finset.card_union_le _ _).trans ((add_le_add (h.1 _) (h.1 _)).trans_eq (two_mul _).symm)
|
| 33 |
-
have he : Fintype.card (Messenger singles) ≤ Fintype.card (↑T:Type) := by
|
| 34 |
-
rw [Fintype.card_coe,singles_card]; unfold T; rw [Finset.card_compl]; omega
|
| 35 |
-
obtain ⟨i,hi⟩: ∃ i : Messenger singles → ↑T,Injective i := by
|
| 36 |
-
|
| 37 |
-
obtain ⟨g⟩:=Function.Embedding.nonempty_of_card_le he
|
| 38 |
-
exact ⟨g,g.injective⟩
|
| 39 |
-
refine ⟨fun x=>(i x).val,Subtype.val_injective.comp hi,fun x b=>?_⟩
|
| 40 |
-
have hh:(i x).val∉F:=Finset.mem_compl.mp (i x).property
|
| 41 |
-
intro hx; cases b
|
| 42 |
-
· exact hh (Finset.mem_union_right _ hx)
|
| 43 |
-
exact hh (Finset.mem_union_left _ hx)
|
| 44 |
-
|
| 45 |
-
variable {d:Rates}
|
| 46 |
-
def coordSpec (m:BMark p n N) (o:UnitType p n N) (s:Charts p n d)
|
| 47 |
-
(w:∀ i:Nodes,Cell (d i)) := ∀ i,s i (w i)= m o i
|
| 48 |
-
|
| 49 |
-
def beacon (p:Shape) (s:Charts p n d) (w:∀ i:Nodes,Cell (d i)) (b:Bool)
|
| 50 |
-
(T: Cross p n) (z : Digest p.g) : Amounts p singles d b :=
|
| 51 |
-
fun k =>
|
| 52 |
-
let i:=parcel b k
|
| 53 |
-
let j:= parcel (!b) k
|
| 54 |
-
let x:=targetMark p s T i j
|
| 55 |
-
(z,(z.diagO,x), z.diagO+dotProduct x (w i))
|
| 56 |
-
|
| 57 |
-
set_option maxHeartbeats 800000 in
|
| 58 |
-
theorem stillBeacon (m:BMark p n N) (o:UnitType p n N) (s:Charts p n d)
|
| 59 |
-
(w:∀ i:Nodes,Cell (d i)) (b:Bool) (T:Cross p n) (z:Digest p.g)
|
| 60 |
-
(h:coordSpec m o s w) (hT:∀ i,cardTone m o T i= glint p (m o)) :
|
| 61 |
-
still b (beacon p s w b T z) s T := by
|
| 62 |
-
classical
|
| 63 |
-
let f:Amounts p singles d b:= beacon p s w b T z
|
| 64 |
-
have hf (i): funds f i=(f ⟨i,(0:Fin 1)⟩).2 := by
|
| 65 |
-
unfold funds; let : Unique (Fin (singles i)) := (show Unique (Fin 1) from inferInstance); exact Fintype.sum_unique _
|
| 66 |
-
change (∀ i, _ ) ∧ _
|
| 67 |
-
constructor
|
| 68 |
-
· intro i
|
| 69 |
-
change (funds f i).1.2=_
|
| 70 |
-
rw [hf]
|
| 71 |
-
rfl
|
| 72 |
-
intro i
|
| 73 |
-
have hh t q : couple _ (funds f (transit b (t,q))) =
|
| 74 |
-
contract p T t q (m o t)+role p n (m o t) := by
|
| 75 |
-
rw [hf]
|
| 76 |
-
let k : Messenger singles:=⟨transit b (t,q),(0:Fin 1)⟩
|
| 77 |
-
let a:= targetMark p s T (parcel b k) (parcel (!b) k)
|
| 78 |
-
change z.diagO+(z.diagO+dotProduct a (w _))=_
|
| 79 |
-
rw [← add_assoc,char_two,zero_add]; unfold a targetMark
|
| 80 |
-
rw [← roll_project]
|
| 81 |
-
have he (i t): (contract p T i t+role p n) (s i (w i))=contract p T i t (m o i)+role p n (m o i) :=
|
| 82 |
-
by rw [h]; rfl
|
| 83 |
-
rw [he]; cases b <;> rfl
|
| 84 |
-
change couple _ (funds f _) = couple _ (funds f _)
|
| 85 |
-
simp_rw [hh]
|
| 86 |
-
have ht:= hT i
|
| 87 |
-
unfold glint cardTone at ht; rw [Fintype.sum_bool,Fintype.sum_bool] at ht
|
| 88 |
-
apply sub_eq_zero.mp
|
| 89 |
-
rw [ZModModule.sub_eq_add]
|
| 90 |
-
rw [add_add_add_comm,ht,char_two]
|
| 91 |
-
|
| 92 |
-
set_option maxHeartbeats 700000 in
|
| 93 |
-
theorem steadyBeacon {plan : Plan p n} (m:BMark p n N) (o:UnitType p n N) (s:Charts p n d)
|
| 94 |
-
(w:∀ i:Nodes,Cell (d i)) (b:Bool) (T:Cross p n)
|
| 95 |
-
(q:Quill p singles d b) (t:Tagging p (Messenger singles))
|
| 96 |
-
(g: Mixer p n) (z:Digest p.g) (K:ℕ)
|
| 97 |
-
(hd:∀ i,d i≤K^2)
|
| 98 |
-
(ha:q.amp=beacon p s w b T z)
|
| 99 |
-
(hk:planRank plan≤K)
|
| 100 |
-
(hs:charted s plan)
|
| 101 |
-
(h:coordSpec m o s w)
|
| 102 |
-
(hF : PreparationParameters.frameSide p g o)
|
| 103 |
-
(hg : exactInk p g m o) :
|
| 104 |
-
q.steady t (fun _=>1) g K s o := by
|
| 105 |
-
classical
|
| 106 |
-
refine ⟨hF,fun i=> ⟨hd _,(hs _).2,fun y=>?_⟩,fun i=>by rw [ha];rfl, fun i v hv => ?_⟩
|
| 107 |
-
· refine (effective_rank (i:=parcel b i) ?_).trans hk
|
| 108 |
-
rw [← (hs _).1]; exact mem_range_self _ _
|
| 109 |
-
· let l:= q.allure t (fun _=>1) i; let j:=parcel b i
|
| 110 |
-
let V:= l.profile j o g (s j) v
|
| 111 |
-
have ht : V.1 = (q.amp i).1 ∧ V.2.1=(q.amp i).2.1 → V=q.amp i := by
|
| 112 |
-
rintro ⟨h1,h2⟩
|
| 113 |
-
apply Prod.ext h1 (Prod.ext h2 _)
|
| 114 |
-
rw [ha] at h2 ⊢
|
| 115 |
-
let a:= useAtom p l.l l.s l.f v
|
| 116 |
-
let k:=targetMark p s T j (parcel (!b) i)
|
| 117 |
-
have heq : V.2.2 = z.diagO + dotProduct k (w j) := by
|
| 118 |
-
have he := exactInner g m o hg j a
|
| 119 |
-
have hx : a∈Xspace p n:= mem_useAtom ..
|
| 120 |
-
have hg' : role p n a=z.diagO := congrArg Prod.fst h2
|
| 121 |
-
have hk : roll (s j) (Tsym g a)=k := congrArg Prod.snd h2
|
| 122 |
-
change innerP p o j a=_
|
| 123 |
-
rw [he hx, grad_val,hg',T_swap, ←h,roll_project,hk]
|
| 124 |
-
exact heq
|
| 125 |
-
exact (hv ht).elim
|
| 126 |
-
|
| 127 |
-
end StatusAnalysis
|
| 128 |
-
end HadwigerCounterexample
|
| 129 |
-
|
| 130 |
-
end
|
| 131 |
-
|
| 132 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.CompatibleOptionRealization
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rare Test Events -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix LinearMap Module Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
variable {p:Shape} {n N K M : ℕ}
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
|
| 14 |
+
def singles : Format:=fun _=>1
|
| 15 |
+
def volume1 : Volumes:=fun _=>1
|
| 16 |
+
theorem singles_vol : singles=toFormat volume1 := rfl
|
| 17 |
+
theorem singles_card : Fintype.card (Messenger singles)=4 := by
|
| 18 |
+
decide
|
| 19 |
+
theorem singles_short : ∀ i,1≤singles i ∧ singles i≤7 :=by simp [singles]
|
| 20 |
+
theorem funds_one {b : Bool} {d : Rates} (f: Fabric p singles d b) (i:Grid) :
|
| 21 |
+
funds f.amp i=(f.amp ⟨i,(0:Fin 1)⟩).2 := by
|
| 22 |
+
unfold funds
|
| 23 |
+
let : Unique (Fin (singles i)) := (show Unique (Fin 1) from inferInstance)
|
| 24 |
+
exact Fintype.sum_unique _
|
| 25 |
+
|
| 26 |
+
theorem fourPens (s:Plan p n) (K:ℕ) (H : Stalls p) (h:booths p K s H)
|
| 27 |
+
(ht : 2*frameBills p.g K+4 ≤Fintype.card (Label p.b)) :
|
| 28 |
+
∃ z:Messenger singles→Label p.b, Injective z ∧ ∀ i j, z i∉ H j := by
|
| 29 |
+
classical
|
| 30 |
+
let F:=H true ∪ H false; let T:=Fᶜ
|
| 31 |
+
have hp : F.card≤ 2* frameBills p.g K :=
|
| 32 |
+
(Finset.card_union_le _ _).trans ((add_le_add (h.1 _) (h.1 _)).trans_eq (two_mul _).symm)
|
| 33 |
+
have he : Fintype.card (Messenger singles) ≤ Fintype.card (↑T:Type) := by
|
| 34 |
+
rw [Fintype.card_coe,singles_card]; unfold T; rw [Finset.card_compl]; omega
|
| 35 |
+
obtain ⟨i,hi⟩: ∃ i : Messenger singles → ↑T,Injective i := by
|
| 36 |
+
|
| 37 |
+
obtain ⟨g⟩:=Function.Embedding.nonempty_of_card_le he
|
| 38 |
+
exact ⟨g,g.injective⟩
|
| 39 |
+
refine ⟨fun x=>(i x).val,Subtype.val_injective.comp hi,fun x b=>?_⟩
|
| 40 |
+
have hh:(i x).val∉F:=Finset.mem_compl.mp (i x).property
|
| 41 |
+
intro hx; cases b
|
| 42 |
+
· exact hh (Finset.mem_union_right _ hx)
|
| 43 |
+
exact hh (Finset.mem_union_left _ hx)
|
| 44 |
+
|
| 45 |
+
variable {d:Rates}
|
| 46 |
+
def coordSpec (m:BMark p n N) (o:UnitType p n N) (s:Charts p n d)
|
| 47 |
+
(w:∀ i:Nodes,Cell (d i)) := ∀ i,s i (w i)= m o i
|
| 48 |
+
|
| 49 |
+
def beacon (p:Shape) (s:Charts p n d) (w:∀ i:Nodes,Cell (d i)) (b:Bool)
|
| 50 |
+
(T: Cross p n) (z : Digest p.g) : Amounts p singles d b :=
|
| 51 |
+
fun k =>
|
| 52 |
+
let i:=parcel b k
|
| 53 |
+
let j:= parcel (!b) k
|
| 54 |
+
let x:=targetMark p s T i j
|
| 55 |
+
(z,(z.diagO,x), z.diagO+dotProduct x (w i))
|
| 56 |
+
|
| 57 |
+
set_option maxHeartbeats 800000 in
|
| 58 |
+
theorem stillBeacon (m:BMark p n N) (o:UnitType p n N) (s:Charts p n d)
|
| 59 |
+
(w:∀ i:Nodes,Cell (d i)) (b:Bool) (T:Cross p n) (z:Digest p.g)
|
| 60 |
+
(h:coordSpec m o s w) (hT:∀ i,cardTone m o T i= glint p (m o)) :
|
| 61 |
+
still b (beacon p s w b T z) s T := by
|
| 62 |
+
classical
|
| 63 |
+
let f:Amounts p singles d b:= beacon p s w b T z
|
| 64 |
+
have hf (i): funds f i=(f ⟨i,(0:Fin 1)⟩).2 := by
|
| 65 |
+
unfold funds; let : Unique (Fin (singles i)) := (show Unique (Fin 1) from inferInstance); exact Fintype.sum_unique _
|
| 66 |
+
change (∀ i, _ ) ∧ _
|
| 67 |
+
constructor
|
| 68 |
+
· intro i
|
| 69 |
+
change (funds f i).1.2=_
|
| 70 |
+
rw [hf]
|
| 71 |
+
rfl
|
| 72 |
+
intro i
|
| 73 |
+
have hh t q : couple _ (funds f (transit b (t,q))) =
|
| 74 |
+
contract p T t q (m o t)+role p n (m o t) := by
|
| 75 |
+
rw [hf]
|
| 76 |
+
let k : Messenger singles:=⟨transit b (t,q),(0:Fin 1)⟩
|
| 77 |
+
let a:= targetMark p s T (parcel b k) (parcel (!b) k)
|
| 78 |
+
change z.diagO+(z.diagO+dotProduct a (w _))=_
|
| 79 |
+
rw [← add_assoc,char_two,zero_add]; unfold a targetMark
|
| 80 |
+
rw [← roll_project]
|
| 81 |
+
have he (i t): (contract p T i t+role p n) (s i (w i))=contract p T i t (m o i)+role p n (m o i) :=
|
| 82 |
+
by rw [h]; rfl
|
| 83 |
+
rw [he]; cases b <;> rfl
|
| 84 |
+
change couple _ (funds f _) = couple _ (funds f _)
|
| 85 |
+
simp_rw [hh]
|
| 86 |
+
have ht:= hT i
|
| 87 |
+
unfold glint cardTone at ht; rw [Fintype.sum_bool,Fintype.sum_bool] at ht
|
| 88 |
+
apply sub_eq_zero.mp
|
| 89 |
+
rw [ZModModule.sub_eq_add]
|
| 90 |
+
rw [add_add_add_comm,ht,char_two]
|
| 91 |
+
|
| 92 |
+
set_option maxHeartbeats 700000 in
|
| 93 |
+
theorem steadyBeacon {plan : Plan p n} (m:BMark p n N) (o:UnitType p n N) (s:Charts p n d)
|
| 94 |
+
(w:∀ i:Nodes,Cell (d i)) (b:Bool) (T:Cross p n)
|
| 95 |
+
(q:Quill p singles d b) (t:Tagging p (Messenger singles))
|
| 96 |
+
(g: Mixer p n) (z:Digest p.g) (K:ℕ)
|
| 97 |
+
(hd:∀ i,d i≤K^2)
|
| 98 |
+
(ha:q.amp=beacon p s w b T z)
|
| 99 |
+
(hk:planRank plan≤K)
|
| 100 |
+
(hs:charted s plan)
|
| 101 |
+
(h:coordSpec m o s w)
|
| 102 |
+
(hF : PreparationParameters.frameSide p g o)
|
| 103 |
+
(hg : exactInk p g m o) :
|
| 104 |
+
q.steady t (fun _=>1) g K s o := by
|
| 105 |
+
classical
|
| 106 |
+
refine ⟨hF,fun i=> ⟨hd _,(hs _).2,fun y=>?_⟩,fun i=>by rw [ha];rfl, fun i v hv => ?_⟩
|
| 107 |
+
· refine (effective_rank (i:=parcel b i) ?_).trans hk
|
| 108 |
+
rw [← (hs _).1]; exact mem_range_self _ _
|
| 109 |
+
· let l:= q.allure t (fun _=>1) i; let j:=parcel b i
|
| 110 |
+
let V:= l.profile j o g (s j) v
|
| 111 |
+
have ht : V.1 = (q.amp i).1 ∧ V.2.1=(q.amp i).2.1 → V=q.amp i := by
|
| 112 |
+
rintro ⟨h1,h2⟩
|
| 113 |
+
apply Prod.ext h1 (Prod.ext h2 _)
|
| 114 |
+
rw [ha] at h2 ⊢
|
| 115 |
+
let a:= useAtom p l.l l.s l.f v
|
| 116 |
+
let k:=targetMark p s T j (parcel (!b) i)
|
| 117 |
+
have heq : V.2.2 = z.diagO + dotProduct k (w j) := by
|
| 118 |
+
have he := exactInner g m o hg j a
|
| 119 |
+
have hx : a∈Xspace p n:= mem_useAtom ..
|
| 120 |
+
have hg' : role p n a=z.diagO := congrArg Prod.fst h2
|
| 121 |
+
have hk : roll (s j) (Tsym g a)=k := congrArg Prod.snd h2
|
| 122 |
+
change innerP p o j a=_
|
| 123 |
+
rw [he hx, grad_val,hg',T_swap, ←h,roll_project,hk]
|
| 124 |
+
exact heq
|
| 125 |
+
exact (hv ht).elim
|
| 126 |
+
|
| 127 |
+
end StatusAnalysis
|
| 128 |
+
end HadwigerCounterexample
|
| 129 |
+
|
| 130 |
+
end
|
| 131 |
+
|
| 132 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RawFrameLaws.lean
CHANGED
|
@@ -1,185 +1,185 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.AffineFrames
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.MixedImageBounds
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Raw Frame Laws -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
|
| 13 |
-
variable {p : Shape} {n N : ℕ}
|
| 14 |
-
|
| 15 |
-
instance rowDecidableEq (p : Shape) (n : ℕ) : DecidableEq (Row p n) := inferInstance
|
| 16 |
-
instance fullDecidableEq (p : Shape) (n : ℕ) : DecidableEq (Full p n) := inferInstance
|
| 17 |
-
instance fullFintype (p : Shape) (n : ℕ) : Fintype (Full p n) := inferInstance
|
| 18 |
-
instance oframeFintype (p : Shape) (n N : ℕ) : Fintype (Oframe p n N) := inferInstance
|
| 19 |
-
instance orientFintype (p : Shape) (n N : ℕ) : Fintype (Orient p n N) := inferInstance
|
| 20 |
-
|
| 21 |
-
def gramCond (m : Mixer p n) (G : Mat (Full p n) (Full p n)) : Prop :=
|
| 22 |
-
G.toBlocks₁₁ = selfM p n m.mixM ∧ G.toBlocks₂₁ = 0 ∧ G.toBlocks₁₂ = 0
|
| 23 |
-
|
| 24 |
-
theorem gramCond_exists (m : Mixer p n) : ∃ G, gramCond m G := by
|
| 25 |
-
refine ⟨fromBlocks (selfM p n m.mixM) 0 0 0,?_,?_,?_⟩ <;> rfl
|
| 26 |
-
|
| 27 |
-
theorem valid_iff (m : Mixer p n) (X : Oframe p n N) :
|
| 28 |
-
valid (selfM p n m.mixM) X ↔ FramesAt (gramCond m) X := by
|
| 29 |
-
have he : (X.1ᵀ*X.2).toBlocks₁₁ = (primary X.1)ᵀ * primary X.2 := by ext; rfl
|
| 30 |
-
have hf : (X.1ᵀ*X.2).toBlocks₂₁ = (channel X.1)ᵀ * primary X.2 := by ext; rfl
|
| 31 |
-
have hg : (X.1ᵀ*X.2).toBlocks₁₂ = (primary X.1)ᵀ * channel X.2 := by ext; rfl
|
| 32 |
-
unfold valid FramesAt gramCond
|
| 33 |
-
rw [he,hf,hg]; tauto
|
| 34 |
-
|
| 35 |
-
def raw (m : Mixer p n) (N : ℕ) : Wgt (Orient p n N) :=
|
| 36 |
-
prodW (fun (_ : Comp p.g) => unifOn (FramesAt (U := Fin N) (gramCond m)))
|
| 37 |
-
|
| 38 |
-
theorem raw_law (m : Mixer p n) (hN : 2*num (Full p n)<N) : IsLaw (raw m N) :=
|
| 39 |
-
prodW_law (fun _ => unifOn_law (framesAt_exists (gramCond_exists m)
|
| 40 |
-
(show num (Full p n) + num (Full p n) < num (Fin N) by
|
| 41 |
-
rw [← two_mul]; simpa [num] using hN)))
|
| 42 |
-
|
| 43 |
-
theorem raw_nonneg (m : Mixer p n) (X : Orient p n N) : 0 ≤ raw m N X :=
|
| 44 |
-
prodW_nonneg (fun _ _ => (unifOn_sub _).nz _) _
|
| 45 |
-
|
| 46 |
-
theorem raw_carried (m : Mixer p n) (N : ℕ) : carried (raw m N) (frameLaw m) := by
|
| 47 |
-
intro X h
|
| 48 |
-
unfold frameLaw at h
|
| 49 |
-
push Not at h
|
| 50 |
-
obtain ⟨e,he⟩ := h
|
| 51 |
-
unfold raw prodW
|
| 52 |
-
apply Finset.prod_eq_zero (Finset.mem_univ e)
|
| 53 |
-
exact unifOn_carried _ _ ((valid_iff _ _).not.mp he)
|
| 54 |
-
|
| 55 |
-
abbrev UnitType (p : Shape) (n N : ℕ) := Orient p n N × Orient p n N
|
| 56 |
-
abbrev Place (p : Shape) := Comp p.g × Bool
|
| 57 |
-
abbrev JointIdx (p : Shape) (n : ℕ) := Full p n ⊕ Full p n
|
| 58 |
-
|
| 59 |
-
def takeSign (w : Oframe p n N) (b : Bool) := if b then w.1 else w.2
|
| 60 |
-
|
| 61 |
-
def images (x : UnitType p n N) (z : Place p) : Mat (Fin N) (JointIdx p n) :=
|
| 62 |
-
fromCols (takeSign (x.1 z.1) z.2) (takeSign (x.2 z.1) z.2)
|
| 63 |
-
|
| 64 |
-
abbrev Dir (p : Shape) (n : ℕ) := Vec (JointIdx p n)
|
| 65 |
-
abbrev Plan (p : Shape) (n : ℕ) := Place p → Submodule F (Dir p n)
|
| 66 |
-
def planRank (s : Plan p n) := ∑ i, dim (s i)
|
| 67 |
-
|
| 68 |
-
/-- Pin data: stored subspaces of directions with assigned images. We store a
|
| 69 |
-
full linear map for convenience; only its restriction to the pin directions
|
| 70 |
-
at each place is used. Counts charge only for the restrictions. -/
|
| 71 |
-
structure Pin (p : Shape) (n N : ℕ) where
|
| 72 |
-
sp : Plan p n
|
| 73 |
-
target : Place p → Mat (Fin N) (JointIdx p n)
|
| 74 |
-
|
| 75 |
-
def Pin.agree (a : Pin p n N) (x : UnitType p n N) :=
|
| 76 |
-
∀ i, ∀ v ∈ a.sp i, images x i *ᵥ v = a.target i *ᵥ v
|
| 77 |
-
|
| 78 |
-
theorem Pin.agree_pack {a : Pin p n N} {x : UnitType p n N} :
|
| 79 |
-
a.agree x ↔ ∀ i : Place p, images x i * pack (a.sp i) = a.target i * pack (a.sp i) := by
|
| 80 |
-
have heq {I J L : Type} [Fintype I] [Fintype J] [Fintype L] (P Q : Mat I J) (M : Mat J L) :
|
| 81 |
-
(∀ v ∈ colSp M, P *ᵥ v = Q *ᵥ v) ↔ P*M=Q*M := by
|
| 82 |
-
constructor
|
| 83 |
-
· intro h
|
| 84 |
-
apply coe_mv_inj
|
| 85 |
-
exact LinearMap.ext fun v => by
|
| 86 |
-
change (P*M) *ᵥ v=(Q*M) *ᵥ v
|
| 87 |
-
rw [← mulVec_mulVec,← mulVec_mulVec]
|
| 88 |
-
exact h _ ⟨v,rfl⟩
|
| 89 |
-
· rintro h x ⟨v,rfl⟩
|
| 90 |
-
change P *ᵥ (M *ᵥ v) = Q *ᵥ (M *ᵥ v)
|
| 91 |
-
rw [mulVec_mulVec,mulVec_mulVec,h]
|
| 92 |
-
unfold Pin.agree
|
| 93 |
-
apply forall_congr'; intro i
|
| 94 |
-
have hh := heq (images x i) (a.target i) (pack (a.sp i))
|
| 95 |
-
rw [colSp_pack] at hh
|
| 96 |
-
exact hh
|
| 97 |
-
|
| 98 |
-
theorem bp_sum {A : Type*} (s : Finset A) (f : A → ℝ) :
|
| 99 |
-
bp (∑ i ∈ s, f i) = ∏ i ∈ s, bp (f i) := by
|
| 100 |
-
classical
|
| 101 |
-
induction s using Finset.induction with
|
| 102 |
-
| empty => simp
|
| 103 |
-
| insert a s ha hi => rw [Finset.sum_insert ha, Finset.prod_insert ha,bp_add,hi]
|
| 104 |
-
|
| 105 |
-
/-- Image cap under two independent raw orientations. Uniform over all
|
| 106 |
-
simultaneous exact-image specifications. -/
|
| 107 |
-
theorem reference_cap (m : Mixer p n) (a : Pin p n N) {δ : ℝ} (hd : 0 < δ)
|
| 108 |
-
(hu : 2*num (Full p n) - N ≤ -1)
|
| 109 |
-
(hδ : 2*num (Full p n) ≤ δ/2 * N)
|
| 110 |
-
(hA : 4*num (Comp p.g) ≤ δ/2 * N) :
|
| 111 |
-
pr (pairW (raw m N) (raw m N)) a.agree ≤ bp (-(1-δ)*(planRank a.sp)*N) := by
|
| 112 |
-
let s := a.sp
|
| 113 |
-
let μ := raw m N
|
| 114 |
-
have hn : 2*num (Full p n)<N := by linarith only [hu]
|
| 115 |
-
have hh := raw_law m hn
|
| 116 |
-
by_cases he : planRank s = 0
|
| 117 |
-
· change _ ≤ bp (_ * (planRank s) * _)
|
| 118 |
-
rw [he]
|
| 119 |
-
simp only [Nat.cast_zero,mul_zero,zero_mul,bp_zero]
|
| 120 |
-
exact le_trans (pr_le_tot (pairW_law hh hh).nz) (pairW_law hh hh).total.le
|
| 121 |
-
let g (e : Comp p.g) := unifOn (FramesAt (U:=Fin N) (gramCond m))
|
| 122 |
-
let D (e : Place p) := pack (s e)
|
| 123 |
-
let rankval (e : Place p) := (dim (s e) : ℝ)
|
| 124 |
-
let f (e : Comp p.g) (w : Oframe p n N × Oframe p n N) :=
|
| 125 |
-
mixImage (D (e,true)) (w.1.1,w.2.1) = a.target (e,true) * D (e,true) ∧
|
| 126 |
-
mixImage (D (e,false)) (w.1.2,w.2.2) = a.target (e,false) * D (e,false)
|
| 127 |
-
have hf : pr (pairW μ μ) a.agree = ∏ e, pr (pairW (g e) (g e)) (f e) := by
|
| 128 |
-
have hfun : a.agree = (fun x => ∀ e, f e (x.1 e,x.2 e)) := by
|
| 129 |
-
funext x; apply propext
|
| 130 |
-
rw [Pin.agree_pack]
|
| 131 |
-
constructor
|
| 132 |
-
· intro hi e
|
| 133 |
-
exact ⟨hi (e,true),hi (e,false)⟩
|
| 134 |
-
· rintro h ⟨e,b⟩; cases b
|
| 135 |
-
· exact (h e).2
|
| 136 |
-
· exact (h e).1
|
| 137 |
-
rw [hfun]
|
| 138 |
-
exact prodW_pair_pr g g f
|
| 139 |
-
let y := fun e : Comp p.g => 4 - (1-δ/2) * (rankval (e,true)+rankval (e,false))*N
|
| 140 |
-
have hb (e) : pr (pairW (g e) (g e)) (f e) ≤ bp (y e) := by
|
| 141 |
-
have h1 := comp_image_cap (gramCond_exists m)
|
| 142 |
-
(show 2*num (Full p n)-num (Fin N) ≤ -1 by simpa [num] using hu)
|
| 143 |
-
_ _ (pack_inj (s (e,true))) (pack_inj (s (e,false))) (a.target (e,true)*D (e,true))
|
| 144 |
-
(a.target (e,false)*D (e,false))
|
| 145 |
-
have hnum (n : ℕ) : num (Fin n)=(n:ℝ) := by simp [num]
|
| 146 |
-
change pr _ _ ≤ _
|
| 147 |
-
apply le_trans h1
|
| 148 |
-
rw [show (16:ℝ)=bp 4 by
|
| 149 |
-
have hh := bp_nat 4; norm_num at hh ⊢; linarith,← bp_add,hnum,hnum,hnum]
|
| 150 |
-
apply bp_le
|
| 151 |
-
let rp := rankval (e,true)
|
| 152 |
-
let rm := rankval (e,false)
|
| 153 |
-
change 4+(-((N:ℝ))*rp-(_-2*num (Full p n))*rm) ≤ 4 - _ * (rp+rm)*_
|
| 154 |
-
have hp := mul_nonneg (show 0 ≤ rp from Nat.cast_nonneg _) (mul_nonneg hd.le
|
| 155 |
-
(show (0:ℝ) ≤ N from Nat.cast_nonneg _))
|
| 156 |
-
have hg := mul_le_mul_of_nonneg_right hδ (show 0 ≤ rm from Nat.cast_nonneg _)
|
| 157 |
-
linarith only [hp,hg]
|
| 158 |
-
have hg : pr (pairW μ μ) a.agree ≤ bp (∑ i, y i) := by
|
| 159 |
-
rw [hf,bp_sum]
|
| 160 |
-
apply Finset.prod_le_prod₀ _ fun i _ => hb i
|
| 161 |
-
exact fun i _ => pr_nonneg
|
| 162 |
-
(subLaw_pair (unifOn_sub _) (unifOn_sub _)).nz
|
| 163 |
-
apply hg.trans
|
| 164 |
-
apply bp_le
|
| 165 |
-
have ht : (planRank s : ℝ) = ∑ i : Comp p.g, (rankval (i,true) + rankval (i,false)) := by
|
| 166 |
-
rw [planRank,Fintype.sum_prod_type]
|
| 167 |
-
simp only [Fintype.sum_bool, Nat.cast_sum,Nat.cast_add,rankval]
|
| 168 |
-
have h1 : ∑ i, y i = 4*num (Comp p.g) - (1-δ/2)*(planRank s)*N := by
|
| 169 |
-
dsimp only [y]
|
| 170 |
-
rw [Finset.sum_sub_distrib,← Finset.sum_mul, ← Finset.mul_sum, ← ht]
|
| 171 |
-
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,num]
|
| 172 |
-
ring
|
| 173 |
-
have hk : 1 ≤ (planRank s : ℝ) := by
|
| 174 |
-
exact_mod_cast Nat.one_le_iff_ne_zero.mpr he
|
| 175 |
-
rw [h1]
|
| 176 |
-
change _ ≤ -(1-δ)*(planRank s)*N
|
| 177 |
-
have he := mul_le_mul_of_nonneg_right hk
|
| 178 |
-
(mul_nonneg hd.le (show (0:ℝ) ≤ N from Nat.cast_nonneg _))
|
| 179 |
-
linarith only [hA,he]
|
| 180 |
-
|
| 181 |
-
end HadwigerCounterexample
|
| 182 |
-
|
| 183 |
-
end
|
| 184 |
-
|
| 185 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.AffineFrames
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.MixedImageBounds
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Raw Frame Laws -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
|
| 13 |
+
variable {p : Shape} {n N : ℕ}
|
| 14 |
+
|
| 15 |
+
instance rowDecidableEq (p : Shape) (n : ℕ) : DecidableEq (Row p n) := inferInstance
|
| 16 |
+
instance fullDecidableEq (p : Shape) (n : ℕ) : DecidableEq (Full p n) := inferInstance
|
| 17 |
+
instance fullFintype (p : Shape) (n : ℕ) : Fintype (Full p n) := inferInstance
|
| 18 |
+
instance oframeFintype (p : Shape) (n N : ℕ) : Fintype (Oframe p n N) := inferInstance
|
| 19 |
+
instance orientFintype (p : Shape) (n N : ℕ) : Fintype (Orient p n N) := inferInstance
|
| 20 |
+
|
| 21 |
+
def gramCond (m : Mixer p n) (G : Mat (Full p n) (Full p n)) : Prop :=
|
| 22 |
+
G.toBlocks₁₁ = selfM p n m.mixM ∧ G.toBlocks₂₁ = 0 ∧ G.toBlocks₁₂ = 0
|
| 23 |
+
|
| 24 |
+
theorem gramCond_exists (m : Mixer p n) : ∃ G, gramCond m G := by
|
| 25 |
+
refine ⟨fromBlocks (selfM p n m.mixM) 0 0 0,?_,?_,?_⟩ <;> rfl
|
| 26 |
+
|
| 27 |
+
theorem valid_iff (m : Mixer p n) (X : Oframe p n N) :
|
| 28 |
+
valid (selfM p n m.mixM) X ↔ FramesAt (gramCond m) X := by
|
| 29 |
+
have he : (X.1ᵀ*X.2).toBlocks₁₁ = (primary X.1)ᵀ * primary X.2 := by ext; rfl
|
| 30 |
+
have hf : (X.1ᵀ*X.2).toBlocks₂₁ = (channel X.1)ᵀ * primary X.2 := by ext; rfl
|
| 31 |
+
have hg : (X.1ᵀ*X.2).toBlocks₁₂ = (primary X.1)ᵀ * channel X.2 := by ext; rfl
|
| 32 |
+
unfold valid FramesAt gramCond
|
| 33 |
+
rw [he,hf,hg]; tauto
|
| 34 |
+
|
| 35 |
+
def raw (m : Mixer p n) (N : ℕ) : Wgt (Orient p n N) :=
|
| 36 |
+
prodW (fun (_ : Comp p.g) => unifOn (FramesAt (U := Fin N) (gramCond m)))
|
| 37 |
+
|
| 38 |
+
theorem raw_law (m : Mixer p n) (hN : 2*num (Full p n)<N) : IsLaw (raw m N) :=
|
| 39 |
+
prodW_law (fun _ => unifOn_law (framesAt_exists (gramCond_exists m)
|
| 40 |
+
(show num (Full p n) + num (Full p n) < num (Fin N) by
|
| 41 |
+
rw [← two_mul]; simpa [num] using hN)))
|
| 42 |
+
|
| 43 |
+
theorem raw_nonneg (m : Mixer p n) (X : Orient p n N) : 0 ≤ raw m N X :=
|
| 44 |
+
prodW_nonneg (fun _ _ => (unifOn_sub _).nz _) _
|
| 45 |
+
|
| 46 |
+
theorem raw_carried (m : Mixer p n) (N : ℕ) : carried (raw m N) (frameLaw m) := by
|
| 47 |
+
intro X h
|
| 48 |
+
unfold frameLaw at h
|
| 49 |
+
push Not at h
|
| 50 |
+
obtain ⟨e,he⟩ := h
|
| 51 |
+
unfold raw prodW
|
| 52 |
+
apply Finset.prod_eq_zero (Finset.mem_univ e)
|
| 53 |
+
exact unifOn_carried _ _ ((valid_iff _ _).not.mp he)
|
| 54 |
+
|
| 55 |
+
abbrev UnitType (p : Shape) (n N : ℕ) := Orient p n N × Orient p n N
|
| 56 |
+
abbrev Place (p : Shape) := Comp p.g × Bool
|
| 57 |
+
abbrev JointIdx (p : Shape) (n : ℕ) := Full p n ⊕ Full p n
|
| 58 |
+
|
| 59 |
+
def takeSign (w : Oframe p n N) (b : Bool) := if b then w.1 else w.2
|
| 60 |
+
|
| 61 |
+
def images (x : UnitType p n N) (z : Place p) : Mat (Fin N) (JointIdx p n) :=
|
| 62 |
+
fromCols (takeSign (x.1 z.1) z.2) (takeSign (x.2 z.1) z.2)
|
| 63 |
+
|
| 64 |
+
abbrev Dir (p : Shape) (n : ℕ) := Vec (JointIdx p n)
|
| 65 |
+
abbrev Plan (p : Shape) (n : ℕ) := Place p → Submodule F (Dir p n)
|
| 66 |
+
def planRank (s : Plan p n) := ∑ i, dim (s i)
|
| 67 |
+
|
| 68 |
+
/-- Pin data: stored subspaces of directions with assigned images. We store a
|
| 69 |
+
full linear map for convenience; only its restriction to the pin directions
|
| 70 |
+
at each place is used. Counts charge only for the restrictions. -/
|
| 71 |
+
structure Pin (p : Shape) (n N : ℕ) where
|
| 72 |
+
sp : Plan p n
|
| 73 |
+
target : Place p → Mat (Fin N) (JointIdx p n)
|
| 74 |
+
|
| 75 |
+
def Pin.agree (a : Pin p n N) (x : UnitType p n N) :=
|
| 76 |
+
∀ i, ∀ v ∈ a.sp i, images x i *ᵥ v = a.target i *ᵥ v
|
| 77 |
+
|
| 78 |
+
theorem Pin.agree_pack {a : Pin p n N} {x : UnitType p n N} :
|
| 79 |
+
a.agree x ↔ ∀ i : Place p, images x i * pack (a.sp i) = a.target i * pack (a.sp i) := by
|
| 80 |
+
have heq {I J L : Type} [Fintype I] [Fintype J] [Fintype L] (P Q : Mat I J) (M : Mat J L) :
|
| 81 |
+
(∀ v ∈ colSp M, P *ᵥ v = Q *ᵥ v) ↔ P*M=Q*M := by
|
| 82 |
+
constructor
|
| 83 |
+
· intro h
|
| 84 |
+
apply coe_mv_inj
|
| 85 |
+
exact LinearMap.ext fun v => by
|
| 86 |
+
change (P*M) *ᵥ v=(Q*M) *ᵥ v
|
| 87 |
+
rw [← mulVec_mulVec,← mulVec_mulVec]
|
| 88 |
+
exact h _ ⟨v,rfl⟩
|
| 89 |
+
· rintro h x ⟨v,rfl⟩
|
| 90 |
+
change P *ᵥ (M *ᵥ v) = Q *ᵥ (M *ᵥ v)
|
| 91 |
+
rw [mulVec_mulVec,mulVec_mulVec,h]
|
| 92 |
+
unfold Pin.agree
|
| 93 |
+
apply forall_congr'; intro i
|
| 94 |
+
have hh := heq (images x i) (a.target i) (pack (a.sp i))
|
| 95 |
+
rw [colSp_pack] at hh
|
| 96 |
+
exact hh
|
| 97 |
+
|
| 98 |
+
theorem bp_sum {A : Type*} (s : Finset A) (f : A → ℝ) :
|
| 99 |
+
bp (∑ i ∈ s, f i) = ∏ i ∈ s, bp (f i) := by
|
| 100 |
+
classical
|
| 101 |
+
induction s using Finset.induction with
|
| 102 |
+
| empty => simp
|
| 103 |
+
| insert a s ha hi => rw [Finset.sum_insert ha, Finset.prod_insert ha,bp_add,hi]
|
| 104 |
+
|
| 105 |
+
/-- Image cap under two independent raw orientations. Uniform over all
|
| 106 |
+
simultaneous exact-image specifications. -/
|
| 107 |
+
theorem reference_cap (m : Mixer p n) (a : Pin p n N) {δ : ℝ} (hd : 0 < δ)
|
| 108 |
+
(hu : 2*num (Full p n) - N ≤ -1)
|
| 109 |
+
(hδ : 2*num (Full p n) ≤ δ/2 * N)
|
| 110 |
+
(hA : 4*num (Comp p.g) ≤ δ/2 * N) :
|
| 111 |
+
pr (pairW (raw m N) (raw m N)) a.agree ≤ bp (-(1-δ)*(planRank a.sp)*N) := by
|
| 112 |
+
let s := a.sp
|
| 113 |
+
let μ := raw m N
|
| 114 |
+
have hn : 2*num (Full p n)<N := by linarith only [hu]
|
| 115 |
+
have hh := raw_law m hn
|
| 116 |
+
by_cases he : planRank s = 0
|
| 117 |
+
· change _ ≤ bp (_ * (planRank s) * _)
|
| 118 |
+
rw [he]
|
| 119 |
+
simp only [Nat.cast_zero,mul_zero,zero_mul,bp_zero]
|
| 120 |
+
exact le_trans (pr_le_tot (pairW_law hh hh).nz) (pairW_law hh hh).total.le
|
| 121 |
+
let g (e : Comp p.g) := unifOn (FramesAt (U:=Fin N) (gramCond m))
|
| 122 |
+
let D (e : Place p) := pack (s e)
|
| 123 |
+
let rankval (e : Place p) := (dim (s e) : ℝ)
|
| 124 |
+
let f (e : Comp p.g) (w : Oframe p n N × Oframe p n N) :=
|
| 125 |
+
mixImage (D (e,true)) (w.1.1,w.2.1) = a.target (e,true) * D (e,true) ∧
|
| 126 |
+
mixImage (D (e,false)) (w.1.2,w.2.2) = a.target (e,false) * D (e,false)
|
| 127 |
+
have hf : pr (pairW μ μ) a.agree = ∏ e, pr (pairW (g e) (g e)) (f e) := by
|
| 128 |
+
have hfun : a.agree = (fun x => ∀ e, f e (x.1 e,x.2 e)) := by
|
| 129 |
+
funext x; apply propext
|
| 130 |
+
rw [Pin.agree_pack]
|
| 131 |
+
constructor
|
| 132 |
+
· intro hi e
|
| 133 |
+
exact ⟨hi (e,true),hi (e,false)⟩
|
| 134 |
+
· rintro h ⟨e,b⟩; cases b
|
| 135 |
+
· exact (h e).2
|
| 136 |
+
· exact (h e).1
|
| 137 |
+
rw [hfun]
|
| 138 |
+
exact prodW_pair_pr g g f
|
| 139 |
+
let y := fun e : Comp p.g => 4 - (1-δ/2) * (rankval (e,true)+rankval (e,false))*N
|
| 140 |
+
have hb (e) : pr (pairW (g e) (g e)) (f e) ≤ bp (y e) := by
|
| 141 |
+
have h1 := comp_image_cap (gramCond_exists m)
|
| 142 |
+
(show 2*num (Full p n)-num (Fin N) ≤ -1 by simpa [num] using hu)
|
| 143 |
+
_ _ (pack_inj (s (e,true))) (pack_inj (s (e,false))) (a.target (e,true)*D (e,true))
|
| 144 |
+
(a.target (e,false)*D (e,false))
|
| 145 |
+
have hnum (n : ℕ) : num (Fin n)=(n:ℝ) := by simp [num]
|
| 146 |
+
change pr _ _ ≤ _
|
| 147 |
+
apply le_trans h1
|
| 148 |
+
rw [show (16:ℝ)=bp 4 by
|
| 149 |
+
have hh := bp_nat 4; norm_num at hh ⊢; linarith,← bp_add,hnum,hnum,hnum]
|
| 150 |
+
apply bp_le
|
| 151 |
+
let rp := rankval (e,true)
|
| 152 |
+
let rm := rankval (e,false)
|
| 153 |
+
change 4+(-((N:ℝ))*rp-(_-2*num (Full p n))*rm) ≤ 4 - _ * (rp+rm)*_
|
| 154 |
+
have hp := mul_nonneg (show 0 ≤ rp from Nat.cast_nonneg _) (mul_nonneg hd.le
|
| 155 |
+
(show (0:ℝ) ≤ N from Nat.cast_nonneg _))
|
| 156 |
+
have hg := mul_le_mul_of_nonneg_right hδ (show 0 ≤ rm from Nat.cast_nonneg _)
|
| 157 |
+
linarith only [hp,hg]
|
| 158 |
+
have hg : pr (pairW μ μ) a.agree ≤ bp (∑ i, y i) := by
|
| 159 |
+
rw [hf,bp_sum]
|
| 160 |
+
apply Finset.prod_le_prod₀ _ fun i _ => hb i
|
| 161 |
+
exact fun i _ => pr_nonneg
|
| 162 |
+
(subLaw_pair (unifOn_sub _) (unifOn_sub _)).nz
|
| 163 |
+
apply hg.trans
|
| 164 |
+
apply bp_le
|
| 165 |
+
have ht : (planRank s : ℝ) = ∑ i : Comp p.g, (rankval (i,true) + rankval (i,false)) := by
|
| 166 |
+
rw [planRank,Fintype.sum_prod_type]
|
| 167 |
+
simp only [Fintype.sum_bool, Nat.cast_sum,Nat.cast_add,rankval]
|
| 168 |
+
have h1 : ∑ i, y i = 4*num (Comp p.g) - (1-δ/2)*(planRank s)*N := by
|
| 169 |
+
dsimp only [y]
|
| 170 |
+
rw [Finset.sum_sub_distrib,← Finset.sum_mul, ← Finset.mul_sum, ← ht]
|
| 171 |
+
simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,num]
|
| 172 |
+
ring
|
| 173 |
+
have hk : 1 ≤ (planRank s : ℝ) := by
|
| 174 |
+
exact_mod_cast Nat.one_le_iff_ne_zero.mpr he
|
| 175 |
+
rw [h1]
|
| 176 |
+
change _ ≤ -(1-δ)*(planRank s)*N
|
| 177 |
+
have he := mul_le_mul_of_nonneg_right hk
|
| 178 |
+
(mul_nonneg hd.le (show (0:ℝ) ≤ N from Nat.cast_nonneg _))
|
| 179 |
+
linarith only [hA,he]
|
| 180 |
+
|
| 181 |
+
end HadwigerCounterexample
|
| 182 |
+
|
| 183 |
+
end
|
| 184 |
+
|
| 185 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RealizationConditions.lean
CHANGED
|
@@ -1,93 +1,93 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.KeyDirections
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Realization Conditions -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]
|
| 12 |
-
|
| 13 |
-
namespace Volley
|
| 14 |
-
variable (v w : Volley p n I)
|
| 15 |
-
|
| 16 |
-
def legal (t : Tagging p I) := ∀ i : I, allows (t i) (v.par i)
|
| 17 |
-
def diagonalAt (i : I) := eta p n (mom p (v.sel i) (v.par i))
|
| 18 |
-
def bounded (w' : I→Bool) := ∀ (i j : Bool), 1≤ (v.shoots w' i j).card ∧
|
| 19 |
-
(v.shoots w' i j).card ≤7
|
| 20 |
-
|
| 21 |
-
/-- Conditions for one orientation of roles, §5 (scalar recipe). -/
|
| 22 |
-
structure scalarRecipe (t : Tagging p I) (m : Mixer p n) (x : UnitType p n N) (S : Plan p n)
|
| 23 |
-
(M : Cross p n) : Prop where
|
| 24 |
-
summ (i j : Bool) : ∑ a ∈ v.shoots w.obj i j,v.diagonalAt a=1
|
| 25 |
-
coupled (j : Bool) : ((innerP p x true)+role p n) (v.sumAt t w.obj true j) =
|
| 26 |
-
((innerP p x false)+role p n) (v.sumAt t w.obj false j)
|
| 27 |
-
gradient (i j : Bool) (y : Profile p n) : y∈effective S i →
|
| 28 |
-
grad m (v.sumAt t w.obj i j) y= contract p M i j y
|
| 29 |
-
|
| 30 |
-
def roleMatch (t : Tagging p I) :=
|
| 31 |
-
∀ i j, role p n (v.sumAt t w.obj i j)+ role p n (w.sumAt t v.obj j i)=1
|
| 32 |
-
|
| 33 |
-
def attackGrad (t : Tagging p I) (m : Mixer p n) (y : UnitType p n N) :=
|
| 34 |
-
∀ (a : I) (j : Bool),
|
| 35 |
-
grad m (v.sumAt t w.obj (v.obj a) j) (v.atomAt t a) =
|
| 36 |
-
if j=w.obj a then 0 else innerP p y (w.obj a) (w.atomAt t a)
|
| 37 |
-
|
| 38 |
-
def realized (t : Tagging p I) (m : Mixer p n) (M : Cross p n) :=
|
| 39 |
-
∀ i j, ∀ y ∈ Xspace p n, grad m (v.sumAt t w.obj i j) y=contract p M i j y
|
| 40 |
-
|
| 41 |
-
theorem shoots_swap (i j) : v.shoots w.obj i j=w.shoots v.obj j i := by
|
| 42 |
-
ext; simp [shoots,and_comm]
|
| 43 |
-
|
| 44 |
-
theorem sum_share {t : Tagging p I} {x y : UnitType p n N} (h : v.keys t x=w.keys t y)
|
| 45 |
-
(i j : Bool) : Uembed (onSide x i) (v.sumAt t w.obj i j)=
|
| 46 |
-
Uembed (onSide y j) (w.sumAt t v.obj j i) := by
|
| 47 |
-
classical
|
| 48 |
-
unfold sumAt
|
| 49 |
-
rw [map_sum,map_sum,← shoots_swap v w]
|
| 50 |
-
refine Finset.sum_congr rfl fun k hk => ?_
|
| 51 |
-
have hi := (Finset.mem_filter.mp hk).2
|
| 52 |
-
rw [← hi.1, ← hi.2]
|
| 53 |
-
exact v.atom_share _ _ _ _ h k
|
| 54 |
-
|
| 55 |
-
theorem sum_mem {t : Tagging p I} (h : v.legal t) (f : I → Bool) (i j : Bool) :
|
| 56 |
-
v.sumAt t f i j∈Xspace p n :=
|
| 57 |
-
Submodule.sum_mem _ fun k _ => atom_mem _ (h k)
|
| 58 |
-
|
| 59 |
-
theorem realized_conflicts {t : Tagging p I} (m : Mixer p n)
|
| 60 |
-
(x y : UnitType p n N) (hv : v.legal t) (hw : w.legal t)
|
| 61 |
-
(hL : ∀ i, frameLaw m (onSide x i)) (hR : ∀ i, frameLaw m (onSide y i))
|
| 62 |
-
(h : v.keys t x=w.keys t y) (hm : v.roleMatch w t)
|
| 63 |
-
(hA : v.realized w t m (actual p x y)) (hB : w.realized v t m (actual p y x)) :
|
| 64 |
-
(rawHoles m).conflict x y := by
|
| 65 |
-
have hh i j : hole m (onSide x i) (onSide y j) := by
|
| 66 |
-
refine ⟨hL i,hR j,v.sumAt t w.obj i j,w.sumAt t v.obj j i,
|
| 67 |
-
v.sum_mem hv .., w.sum_mem hw .., v.sum_share _ h i j,fun q hq => ?_,fun q hq => ?_,hm i j⟩
|
| 68 |
-
· rw [hA _ _ _ hq,contract_actual]; rfl
|
| 69 |
-
· rw [hB _ _ _ hq,contract_actual]; rfl
|
| 70 |
-
exact ⟨hh true true,hh true false,hh false true,hh false false⟩
|
| 71 |
-
|
| 72 |
-
end Volley
|
| 73 |
-
|
| 74 |
-
def scalarBlocks (p : Shape) {n} (M : Cross p n) (e : Place p) (i j : Bool) :=
|
| 75 |
-
channelOut p M j e * IP p n i
|
| 76 |
-
|
| 77 |
-
theorem contract_val (p : Shape) {n} (M : Cross p n) (i j : Bool) (x : Profile p n) :
|
| 78 |
-
contract p M i j x = ∑ e,mpair
|
| 79 |
-
((scalarBlocks p M (e,true) i j)ᵀ * scalarBlocks p M (e,false) i j) (x e) := by
|
| 80 |
-
change ∑ e : Comp p.g, _ = _
|
| 81 |
-
refine Finset.sum_congr rfl fun e _ => ?_
|
| 82 |
-
rw [mpair_liftM]
|
| 83 |
-
simp only [liftM_def,transpose_transpose,scalarBlocks,transpose_mul,Matrix.mul_assoc]
|
| 84 |
-
|
| 85 |
-
theorem contract_scalars (A M : Cross p n) (h : scalarBlocks p A=scalarBlocks p M) (i j) :
|
| 86 |
-
contract p A i j=contract p M i j := by
|
| 87 |
-
refine LinearMap.ext fun v => ?_
|
| 88 |
-
rw [contract_val,contract_val,h]
|
| 89 |
-
end HadwigerCounterexample
|
| 90 |
-
|
| 91 |
-
end
|
| 92 |
-
|
| 93 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.KeyDirections
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Realization Conditions -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]
|
| 12 |
+
|
| 13 |
+
namespace Volley
|
| 14 |
+
variable (v w : Volley p n I)
|
| 15 |
+
|
| 16 |
+
def legal (t : Tagging p I) := ∀ i : I, allows (t i) (v.par i)
|
| 17 |
+
def diagonalAt (i : I) := eta p n (mom p (v.sel i) (v.par i))
|
| 18 |
+
def bounded (w' : I→Bool) := ∀ (i j : Bool), 1≤ (v.shoots w' i j).card ∧
|
| 19 |
+
(v.shoots w' i j).card ≤7
|
| 20 |
+
|
| 21 |
+
/-- Conditions for one orientation of roles, §5 (scalar recipe). -/
|
| 22 |
+
structure scalarRecipe (t : Tagging p I) (m : Mixer p n) (x : UnitType p n N) (S : Plan p n)
|
| 23 |
+
(M : Cross p n) : Prop where
|
| 24 |
+
summ (i j : Bool) : ∑ a ∈ v.shoots w.obj i j,v.diagonalAt a=1
|
| 25 |
+
coupled (j : Bool) : ((innerP p x true)+role p n) (v.sumAt t w.obj true j) =
|
| 26 |
+
((innerP p x false)+role p n) (v.sumAt t w.obj false j)
|
| 27 |
+
gradient (i j : Bool) (y : Profile p n) : y∈effective S i →
|
| 28 |
+
grad m (v.sumAt t w.obj i j) y= contract p M i j y
|
| 29 |
+
|
| 30 |
+
def roleMatch (t : Tagging p I) :=
|
| 31 |
+
∀ i j, role p n (v.sumAt t w.obj i j)+ role p n (w.sumAt t v.obj j i)=1
|
| 32 |
+
|
| 33 |
+
def attackGrad (t : Tagging p I) (m : Mixer p n) (y : UnitType p n N) :=
|
| 34 |
+
∀ (a : I) (j : Bool),
|
| 35 |
+
grad m (v.sumAt t w.obj (v.obj a) j) (v.atomAt t a) =
|
| 36 |
+
if j=w.obj a then 0 else innerP p y (w.obj a) (w.atomAt t a)
|
| 37 |
+
|
| 38 |
+
def realized (t : Tagging p I) (m : Mixer p n) (M : Cross p n) :=
|
| 39 |
+
∀ i j, ∀ y ∈ Xspace p n, grad m (v.sumAt t w.obj i j) y=contract p M i j y
|
| 40 |
+
|
| 41 |
+
theorem shoots_swap (i j) : v.shoots w.obj i j=w.shoots v.obj j i := by
|
| 42 |
+
ext; simp [shoots,and_comm]
|
| 43 |
+
|
| 44 |
+
theorem sum_share {t : Tagging p I} {x y : UnitType p n N} (h : v.keys t x=w.keys t y)
|
| 45 |
+
(i j : Bool) : Uembed (onSide x i) (v.sumAt t w.obj i j)=
|
| 46 |
+
Uembed (onSide y j) (w.sumAt t v.obj j i) := by
|
| 47 |
+
classical
|
| 48 |
+
unfold sumAt
|
| 49 |
+
rw [map_sum,map_sum,← shoots_swap v w]
|
| 50 |
+
refine Finset.sum_congr rfl fun k hk => ?_
|
| 51 |
+
have hi := (Finset.mem_filter.mp hk).2
|
| 52 |
+
rw [← hi.1, ← hi.2]
|
| 53 |
+
exact v.atom_share _ _ _ _ h k
|
| 54 |
+
|
| 55 |
+
theorem sum_mem {t : Tagging p I} (h : v.legal t) (f : I → Bool) (i j : Bool) :
|
| 56 |
+
v.sumAt t f i j∈Xspace p n :=
|
| 57 |
+
Submodule.sum_mem _ fun k _ => atom_mem _ (h k)
|
| 58 |
+
|
| 59 |
+
theorem realized_conflicts {t : Tagging p I} (m : Mixer p n)
|
| 60 |
+
(x y : UnitType p n N) (hv : v.legal t) (hw : w.legal t)
|
| 61 |
+
(hL : ∀ i, frameLaw m (onSide x i)) (hR : ∀ i, frameLaw m (onSide y i))
|
| 62 |
+
(h : v.keys t x=w.keys t y) (hm : v.roleMatch w t)
|
| 63 |
+
(hA : v.realized w t m (actual p x y)) (hB : w.realized v t m (actual p y x)) :
|
| 64 |
+
(rawHoles m).conflict x y := by
|
| 65 |
+
have hh i j : hole m (onSide x i) (onSide y j) := by
|
| 66 |
+
refine ⟨hL i,hR j,v.sumAt t w.obj i j,w.sumAt t v.obj j i,
|
| 67 |
+
v.sum_mem hv .., w.sum_mem hw .., v.sum_share _ h i j,fun q hq => ?_,fun q hq => ?_,hm i j⟩
|
| 68 |
+
· rw [hA _ _ _ hq,contract_actual]; rfl
|
| 69 |
+
· rw [hB _ _ _ hq,contract_actual]; rfl
|
| 70 |
+
exact ⟨hh true true,hh true false,hh false true,hh false false⟩
|
| 71 |
+
|
| 72 |
+
end Volley
|
| 73 |
+
|
| 74 |
+
def scalarBlocks (p : Shape) {n} (M : Cross p n) (e : Place p) (i j : Bool) :=
|
| 75 |
+
channelOut p M j e * IP p n i
|
| 76 |
+
|
| 77 |
+
theorem contract_val (p : Shape) {n} (M : Cross p n) (i j : Bool) (x : Profile p n) :
|
| 78 |
+
contract p M i j x = ∑ e,mpair
|
| 79 |
+
((scalarBlocks p M (e,true) i j)ᵀ * scalarBlocks p M (e,false) i j) (x e) := by
|
| 80 |
+
change ∑ e : Comp p.g, _ = _
|
| 81 |
+
refine Finset.sum_congr rfl fun e _ => ?_
|
| 82 |
+
rw [mpair_liftM]
|
| 83 |
+
simp only [liftM_def,transpose_transpose,scalarBlocks,transpose_mul,Matrix.mul_assoc]
|
| 84 |
+
|
| 85 |
+
theorem contract_scalars (A M : Cross p n) (h : scalarBlocks p A=scalarBlocks p M) (i j) :
|
| 86 |
+
contract p A i j=contract p M i j := by
|
| 87 |
+
refine LinearMap.ext fun v => ?_
|
| 88 |
+
rw [contract_val,contract_val,h]
|
| 89 |
+
end HadwigerCounterexample
|
| 90 |
+
|
| 91 |
+
end
|
| 92 |
+
|
| 93 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RectangleComparisons.lean
CHANGED
|
@@ -1,146 +1,146 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.SurrogateProductBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rectangle Comparisons -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix Function
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
variable {p:Shape} {n N r : ℕ}
|
| 12 |
-
open Template
|
| 13 |
-
namespace StatusAnalysis
|
| 14 |
-
|
| 15 |
-
private theorem warm_bound {u v : ℝ} (h : |u|≤1) {r:ℝ}
|
| 16 |
-
(hv : |v|≤r) : |u*v|≤r := by
|
| 17 |
-
rw [abs_mul]; exact (mul_le_mul h hv (abs_nonneg _) zero_le_one).trans_eq (one_mul _)
|
| 18 |
-
|
| 19 |
-
namespace Quill
|
| 20 |
-
variable {q : Format} {d : Rates} {b : Bool}
|
| 21 |
-
(w : Quill p q d b) (t : Tagging p (Messenger q)) (z : Messenger q→F)
|
| 22 |
-
(m : Mixer p n)
|
| 23 |
-
|
| 24 |
-
structure mirrorSpan (s:ℕ) (ε : ℝ) (Y:Silhouette p N r) (o:UnitType p n N) : Prop where
|
| 25 |
-
law : ∀ i,IsLaw (w.policies t z n i)
|
| 26 |
-
frame : ∀ i,frameLaw m (onSide o i)
|
| 27 |
-
close : ∀ i,(w.allure t z i).close Y (onSide o (parcel b i)) ε
|
| 28 |
-
ready : ∀ u:Messenger q → Wgt (Knobs p.g n),(∀ i x, |u i x|≤1) →
|
| 29 |
-
let v:=w.pen t; let x:=w.policies t z n
|
| 30 |
-
|avg (prodW x) (fun y=>ind (v.performs w.script m o y)*prodW u y)-v.kappa*∏ i:Messenger q,
|
| 31 |
-
avg (x i) (u i)|≤ ε
|
| 32 |
-
reference : ∀ f:∀ i:Messenger q,Wgt (AtomKey (p:=p) (t i) N),(∀ i x,|f i x|≤1) →
|
| 33 |
-
|avg (lawNu p N t z) (prodW f) - ∏ i:Messenger q,avg (lawOmega p N (t i) (z i)) (f i)| ≤ ε
|
| 34 |
-
|
| 35 |
-
set_option maxHeartbeats 800000 in
|
| 36 |
-
theorem paint_agree (Y:Silhouette p N r) (o: UnitType p n N) (s : Charts p n d)
|
| 37 |
-
(f:Paint (w.pen t) N) (hF : pigments z Y f)
|
| 38 |
-
(hg : 2≤p.g) (hj : 1≤p.j) (hc : |f.coeff|≤1) {u ℓ}
|
| 39 |
-
(he : w.mirrorSpan t z m ℓ u Y o) :
|
| 40 |
-
|w.prowl s t z m o f.cost-w.sheen t z o m s Y f.cost|≤(2+num (Messenger q))*u := by
|
| 41 |
-
classical
|
| 42 |
-
let A:= w.suede t z o m s f; let x:= w.policies t z n
|
| 43 |
-
let V:= w.pen t
|
| 44 |
-
let B:= w.insidePaint t z o m s Y f
|
| 45 |
-
let Q:= avg (prodW x) (fun y=>ind (V.performs w.script m o y)*prodW A y)
|
| 46 |
-
let E:=avg (lawNu p N t z) (prodW B)
|
| 47 |
-
have hb i y := paintFloor w t z o m s Y f i y (he.law _)
|
| 48 |
-
have ha := suedeFloor w t z o m s f
|
| 49 |
-
let h := he.law
|
| 50 |
-
let P i := avg (x i) (A i); let R i:= avg (lawOmega p N (t i) (z i)) (B i)
|
| 51 |
-
have hm : |Q-V.kappa*(∏ i,P i)|≤u := he.ready A ha
|
| 52 |
-
have hf : |E-∏ i,R i|≤u := he.reference B hb
|
| 53 |
-
have hP i : |P i|≤1 := by
|
| 54 |
-
exact (abs_avg_le (h i).nz).trans ((avg_mono (h i).nz (ha i)).trans_eq ((h i).avg_const _))
|
| 55 |
-
have hR i : |R i|≤1 := by
|
| 56 |
-
have hv : SubLaw (lawOmega p N (t i) (z i)) := unifOn_sub _
|
| 57 |
-
exact (abs_avg_le hv.nz).trans (hv.avg_le zero_le_one (hb i))
|
| 58 |
-
have hh : |(∏ i, P i)-(∏ i, R i)|≤num (Messenger q)*u :=
|
| 59 |
-
cottonError _ _ _ _ hP hR (fun i =>(abs_sub_comm ..).trans_le
|
| 60 |
-
(surrogate_close w t z o m s Y f hF _ (h _) (he.close _)))
|
| 61 |
-
have hK : |V.kappa|≤1 := by rw [abs_of_pos V.kappa_pos]; exact w.kappaTop t
|
| 62 |
-
rw [score_prowl w t z o m s f he.frame hg hj,score_sheen w t z o m,←mul_sub]
|
| 63 |
-
apply warm_bound hc
|
| 64 |
-
have hh' : |V.kappa*(∏ i,P i)-V.kappa*E|≤num (Messenger q)*u+u := by
|
| 65 |
-
rw [←mul_sub]; exact warm_bound hK ((abs_sub_le (∏ i,P i) (∏ i,R i) E).trans (add_le_add hh
|
| 66 |
-
((abs_sub_comm ..).trans_le hf)))
|
| 67 |
-
exact ((abs_sub_le Q _ (V.kappa*E)).trans (add_le_add hm hh')).trans_eq (by ring)
|
| 68 |
-
|
| 69 |
-
set_option maxHeartbeats 800000 in
|
| 70 |
-
theorem paint_set (Y:Silhouette p N r) (o: UnitType p n N) (s : Charts p n d)
|
| 71 |
-
{r' : ℕ}
|
| 72 |
-
(f:Fin r' → Paint (w.pen t) N) (hF : ∀ i,pigments z Y (f i))
|
| 73 |
-
(hg : 2≤p.g) (hj : 1≤p.j) (hc : ∀ i,|(f i).coeff|≤1) {u ℓ}
|
| 74 |
-
(he : w.mirrorSpan t z m ℓ u Y o) :
|
| 75 |
-
|w.prowl s t z m o (mural (w.pen t) f)-w.sheen t z o m s Y (mural (w.pen t) f)|≤
|
| 76 |
-
r' * ((2+num (Messenger q))*u) := by
|
| 77 |
-
classical
|
| 78 |
-
let F i : Wgt (Keys (p:=p) t N) := (f i).cost
|
| 79 |
-
let R := show Wgt (Keys (p:=p) t N) from mural (w.pen t) f
|
| 80 |
-
have hf x : R x=∑ i:Fin r', F i x := rfl
|
| 81 |
-
change |w.prowl _ _ _ _ _ R-w.sheen _ _ _ _ _ _ R|≤_
|
| 82 |
-
have hh :
|
| 83 |
-
w.prowl s t z m o R=∑ i:Fin r',w.prowl s t z m o (F i) := by
|
| 84 |
-
let key : Inputs p n (Messenger q) → Keys (p:=p) t N := (w.pen t).resultKey o
|
| 85 |
-
change avg ((w.pen t).state z n) (fun x => ind (w.deposit t z m o s x) * R (key x)) =
|
| 86 |
-
∑ i : Fin r', avg ((w.pen t).state z n)
|
| 87 |
-
(fun x => ind (w.deposit t z m o s x) * F i (key x))
|
| 88 |
-
simp_rw [hf, Finset.mul_sum,avg_sum]
|
| 89 |
-
have ht :
|
| 90 |
-
w.sheen t z o m s Y R=∑ i:Fin r',w.sheen t z o m s Y (F i) := by
|
| 91 |
-
unfold sheen; simp_rw [hf,Finset.mul_sum,avg_sum]
|
| 92 |
-
rw [hh,ht,←Finset.sum_sub_distrib]
|
| 93 |
-
apply (abs_sum_le_sum_abs ..).trans
|
| 94 |
-
exact (Finset.sum_le_sum fun i _=> paint_agree w t z m Y o s (f i) (hF i) hg hj (hc i)
|
| 95 |
-
he).trans_eq (by simp)
|
| 96 |
-
|
| 97 |
-
structure witnessPaint (ε:ℝ) (W T : Wgt (Keys (p:=p) t N))
|
| 98 |
-
(o : UnitType p n N) : Prop where
|
| 99 |
-
shadow : ∀ f : (w.pen t).Localist N,(∀ i j, |f i j|≤1) →
|
| 100 |
-
|avg (lawNu p N t z) (fun x=>(W x-T x)*prodW f x)|≤ε
|
| 101 |
-
tested : ¬ exceeds (w.pen t) z (W-T) w.script m (w.policies t z n) ε o
|
| 102 |
-
|
| 103 |
-
set_option maxHeartbeats 800000 in
|
| 104 |
-
theorem bare_bridge (Y : Silhouette p N r) (o:UnitType p n N) (s:Charts p n d)
|
| 105 |
-
{r' : ℕ}
|
| 106 |
-
(f:Fin r' → Paint (w.pen t) N) (hF : ∀ i,pigments z Y (f i))
|
| 107 |
-
(hg : 2≤p.g) (hj : 1≤p.j) (hc : ∀ i,|(f i).coeff|≤1) {u ℓ ε}
|
| 108 |
-
(he : w.mirrorSpan t z m ℓ u Y o) (W : Wgt (Keys (p:=p) t N))
|
| 109 |
-
(hw : w.witnessPaint t z m ε W (mural (w.pen t) f) o) :
|
| 110 |
-
|w.prowl s t z m o W-w.sheen t z o m s Y W|≤ 2*ε +r'*((2+num (Messenger q))*u) := by
|
| 111 |
-
classical
|
| 112 |
-
let A:=w.pen t
|
| 113 |
-
let T:= show Wgt (Keys (p:=p) t N) from mural A f
|
| 114 |
-
let x:=w.prowl s t z m o; let y:= w.sheen t z o m s Y
|
| 115 |
-
have h1 : |x W-x T|≤ε := by
|
| 116 |
-
have hz : x W-x T=x (W-T) := by
|
| 117 |
-
let key : Inputs p n (Messenger q) → Keys (p:=p) t N := A.resultKey o
|
| 118 |
-
change avg (A.state z n) (fun x => ind (w.deposit t z m o s x) * W (key x)) -
|
| 119 |
-
avg (A.state z n) (fun x => ind (w.deposit t z m o s x) * T (key x)) =
|
| 120 |
-
avg (A.state z n) (fun x => ind (w.deposit t z m o s x) * (W-T) (key x))
|
| 121 |
-
rw [←avg_sub]
|
| 122 |
-
simp only [Pi.sub_apply,mul_sub]
|
| 123 |
-
rw [hz]
|
| 124 |
-
change |w.prowl _ _ _ _ _ _|≤_
|
| 125 |
-
rw [prowl_astonish]
|
| 126 |
-
exact le_of_not_gt (fun h=> hw.tested ⟨_, stencil_floor w t z o s m,h⟩)
|
| 127 |
-
have h2 : |y W-y T|≤ε := by
|
| 128 |
-
unfold y; rw [sheen_sun,sheen_sun,←mul_sub,←avg_sub]
|
| 129 |
-
let B:= w.seraph t z o m s Y
|
| 130 |
-
have hF (i j): |B i j|≤1 := by
|
| 131 |
-
have hh:= w.seraphFloor t z o m s Y i (he.law i) j; rw [abs_of_nonneg (show 0≤B i j
|
| 132 |
-
from hh.1)]; exact hh.2
|
| 133 |
-
simp_rw [←sub_mul]; exact warm_bound (show |A.kappa|≤1 from (abs_of_pos A.kappa_pos).trans_le
|
| 134 |
-
(w.kappaTop t)) (hw.shadow B hF)
|
| 135 |
-
have h3 := paint_set w t z m Y o s f hF hg hj hc he
|
| 136 |
-
exact (abs_sub_le (x W) (x T) (y W)).trans ((add_le_add h1
|
| 137 |
-
((abs_sub_le (x T) (y T) (y W)).trans (add_le_add h3 ((abs_sub_comm ..).trans_le h2)))).trans_eq
|
| 138 |
-
(by ring))
|
| 139 |
-
|
| 140 |
-
end Quill
|
| 141 |
-
end StatusAnalysis
|
| 142 |
-
end HadwigerCounterexample
|
| 143 |
-
|
| 144 |
-
end
|
| 145 |
-
|
| 146 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.SurrogateProductBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rectangle Comparisons -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix Function
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
variable {p:Shape} {n N r : ℕ}
|
| 12 |
+
open Template
|
| 13 |
+
namespace StatusAnalysis
|
| 14 |
+
|
| 15 |
+
private theorem warm_bound {u v : ℝ} (h : |u|≤1) {r:ℝ}
|
| 16 |
+
(hv : |v|≤r) : |u*v|≤r := by
|
| 17 |
+
rw [abs_mul]; exact (mul_le_mul h hv (abs_nonneg _) zero_le_one).trans_eq (one_mul _)
|
| 18 |
+
|
| 19 |
+
namespace Quill
|
| 20 |
+
variable {q : Format} {d : Rates} {b : Bool}
|
| 21 |
+
(w : Quill p q d b) (t : Tagging p (Messenger q)) (z : Messenger q→F)
|
| 22 |
+
(m : Mixer p n)
|
| 23 |
+
|
| 24 |
+
structure mirrorSpan (s:ℕ) (ε : ℝ) (Y:Silhouette p N r) (o:UnitType p n N) : Prop where
|
| 25 |
+
law : ∀ i,IsLaw (w.policies t z n i)
|
| 26 |
+
frame : ∀ i,frameLaw m (onSide o i)
|
| 27 |
+
close : ∀ i,(w.allure t z i).close Y (onSide o (parcel b i)) ε
|
| 28 |
+
ready : ∀ u:Messenger q → Wgt (Knobs p.g n),(∀ i x, |u i x|≤1) →
|
| 29 |
+
let v:=w.pen t; let x:=w.policies t z n
|
| 30 |
+
|avg (prodW x) (fun y=>ind (v.performs w.script m o y)*prodW u y)-v.kappa*∏ i:Messenger q,
|
| 31 |
+
avg (x i) (u i)|≤ ε
|
| 32 |
+
reference : ∀ f:∀ i:Messenger q,Wgt (AtomKey (p:=p) (t i) N),(∀ i x,|f i x|≤1) →
|
| 33 |
+
|avg (lawNu p N t z) (prodW f) - ∏ i:Messenger q,avg (lawOmega p N (t i) (z i)) (f i)| ≤ ε
|
| 34 |
+
|
| 35 |
+
set_option maxHeartbeats 800000 in
|
| 36 |
+
theorem paint_agree (Y:Silhouette p N r) (o: UnitType p n N) (s : Charts p n d)
|
| 37 |
+
(f:Paint (w.pen t) N) (hF : pigments z Y f)
|
| 38 |
+
(hg : 2≤p.g) (hj : 1≤p.j) (hc : |f.coeff|≤1) {u ℓ}
|
| 39 |
+
(he : w.mirrorSpan t z m ℓ u Y o) :
|
| 40 |
+
|w.prowl s t z m o f.cost-w.sheen t z o m s Y f.cost|≤(2+num (Messenger q))*u := by
|
| 41 |
+
classical
|
| 42 |
+
let A:= w.suede t z o m s f; let x:= w.policies t z n
|
| 43 |
+
let V:= w.pen t
|
| 44 |
+
let B:= w.insidePaint t z o m s Y f
|
| 45 |
+
let Q:= avg (prodW x) (fun y=>ind (V.performs w.script m o y)*prodW A y)
|
| 46 |
+
let E:=avg (lawNu p N t z) (prodW B)
|
| 47 |
+
have hb i y := paintFloor w t z o m s Y f i y (he.law _)
|
| 48 |
+
have ha := suedeFloor w t z o m s f
|
| 49 |
+
let h := he.law
|
| 50 |
+
let P i := avg (x i) (A i); let R i:= avg (lawOmega p N (t i) (z i)) (B i)
|
| 51 |
+
have hm : |Q-V.kappa*(∏ i,P i)|≤u := he.ready A ha
|
| 52 |
+
have hf : |E-∏ i,R i|≤u := he.reference B hb
|
| 53 |
+
have hP i : |P i|≤1 := by
|
| 54 |
+
exact (abs_avg_le (h i).nz).trans ((avg_mono (h i).nz (ha i)).trans_eq ((h i).avg_const _))
|
| 55 |
+
have hR i : |R i|≤1 := by
|
| 56 |
+
have hv : SubLaw (lawOmega p N (t i) (z i)) := unifOn_sub _
|
| 57 |
+
exact (abs_avg_le hv.nz).trans (hv.avg_le zero_le_one (hb i))
|
| 58 |
+
have hh : |(∏ i, P i)-(∏ i, R i)|≤num (Messenger q)*u :=
|
| 59 |
+
cottonError _ _ _ _ hP hR (fun i =>(abs_sub_comm ..).trans_le
|
| 60 |
+
(surrogate_close w t z o m s Y f hF _ (h _) (he.close _)))
|
| 61 |
+
have hK : |V.kappa|≤1 := by rw [abs_of_pos V.kappa_pos]; exact w.kappaTop t
|
| 62 |
+
rw [score_prowl w t z o m s f he.frame hg hj,score_sheen w t z o m,←mul_sub]
|
| 63 |
+
apply warm_bound hc
|
| 64 |
+
have hh' : |V.kappa*(∏ i,P i)-V.kappa*E|≤num (Messenger q)*u+u := by
|
| 65 |
+
rw [←mul_sub]; exact warm_bound hK ((abs_sub_le (∏ i,P i) (∏ i,R i) E).trans (add_le_add hh
|
| 66 |
+
((abs_sub_comm ..).trans_le hf)))
|
| 67 |
+
exact ((abs_sub_le Q _ (V.kappa*E)).trans (add_le_add hm hh')).trans_eq (by ring)
|
| 68 |
+
|
| 69 |
+
set_option maxHeartbeats 800000 in
|
| 70 |
+
theorem paint_set (Y:Silhouette p N r) (o: UnitType p n N) (s : Charts p n d)
|
| 71 |
+
{r' : ℕ}
|
| 72 |
+
(f:Fin r' → Paint (w.pen t) N) (hF : ∀ i,pigments z Y (f i))
|
| 73 |
+
(hg : 2≤p.g) (hj : 1≤p.j) (hc : ∀ i,|(f i).coeff|≤1) {u ℓ}
|
| 74 |
+
(he : w.mirrorSpan t z m ℓ u Y o) :
|
| 75 |
+
|w.prowl s t z m o (mural (w.pen t) f)-w.sheen t z o m s Y (mural (w.pen t) f)|≤
|
| 76 |
+
r' * ((2+num (Messenger q))*u) := by
|
| 77 |
+
classical
|
| 78 |
+
let F i : Wgt (Keys (p:=p) t N) := (f i).cost
|
| 79 |
+
let R := show Wgt (Keys (p:=p) t N) from mural (w.pen t) f
|
| 80 |
+
have hf x : R x=∑ i:Fin r', F i x := rfl
|
| 81 |
+
change |w.prowl _ _ _ _ _ R-w.sheen _ _ _ _ _ _ R|≤_
|
| 82 |
+
have hh :
|
| 83 |
+
w.prowl s t z m o R=∑ i:Fin r',w.prowl s t z m o (F i) := by
|
| 84 |
+
let key : Inputs p n (Messenger q) → Keys (p:=p) t N := (w.pen t).resultKey o
|
| 85 |
+
change avg ((w.pen t).state z n) (fun x => ind (w.deposit t z m o s x) * R (key x)) =
|
| 86 |
+
∑ i : Fin r', avg ((w.pen t).state z n)
|
| 87 |
+
(fun x => ind (w.deposit t z m o s x) * F i (key x))
|
| 88 |
+
simp_rw [hf, Finset.mul_sum,avg_sum]
|
| 89 |
+
have ht :
|
| 90 |
+
w.sheen t z o m s Y R=∑ i:Fin r',w.sheen t z o m s Y (F i) := by
|
| 91 |
+
unfold sheen; simp_rw [hf,Finset.mul_sum,avg_sum]
|
| 92 |
+
rw [hh,ht,←Finset.sum_sub_distrib]
|
| 93 |
+
apply (abs_sum_le_sum_abs ..).trans
|
| 94 |
+
exact (Finset.sum_le_sum fun i _=> paint_agree w t z m Y o s (f i) (hF i) hg hj (hc i)
|
| 95 |
+
he).trans_eq (by simp)
|
| 96 |
+
|
| 97 |
+
structure witnessPaint (ε:ℝ) (W T : Wgt (Keys (p:=p) t N))
|
| 98 |
+
(o : UnitType p n N) : Prop where
|
| 99 |
+
shadow : ∀ f : (w.pen t).Localist N,(∀ i j, |f i j|≤1) →
|
| 100 |
+
|avg (lawNu p N t z) (fun x=>(W x-T x)*prodW f x)|≤ε
|
| 101 |
+
tested : ¬ exceeds (w.pen t) z (W-T) w.script m (w.policies t z n) ε o
|
| 102 |
+
|
| 103 |
+
set_option maxHeartbeats 800000 in
|
| 104 |
+
theorem bare_bridge (Y : Silhouette p N r) (o:UnitType p n N) (s:Charts p n d)
|
| 105 |
+
{r' : ℕ}
|
| 106 |
+
(f:Fin r' → Paint (w.pen t) N) (hF : ∀ i,pigments z Y (f i))
|
| 107 |
+
(hg : 2≤p.g) (hj : 1≤p.j) (hc : ∀ i,|(f i).coeff|≤1) {u ℓ ε}
|
| 108 |
+
(he : w.mirrorSpan t z m ℓ u Y o) (W : Wgt (Keys (p:=p) t N))
|
| 109 |
+
(hw : w.witnessPaint t z m ε W (mural (w.pen t) f) o) :
|
| 110 |
+
|w.prowl s t z m o W-w.sheen t z o m s Y W|≤ 2*ε +r'*((2+num (Messenger q))*u) := by
|
| 111 |
+
classical
|
| 112 |
+
let A:=w.pen t
|
| 113 |
+
let T:= show Wgt (Keys (p:=p) t N) from mural A f
|
| 114 |
+
let x:=w.prowl s t z m o; let y:= w.sheen t z o m s Y
|
| 115 |
+
have h1 : |x W-x T|≤ε := by
|
| 116 |
+
have hz : x W-x T=x (W-T) := by
|
| 117 |
+
let key : Inputs p n (Messenger q) → Keys (p:=p) t N := A.resultKey o
|
| 118 |
+
change avg (A.state z n) (fun x => ind (w.deposit t z m o s x) * W (key x)) -
|
| 119 |
+
avg (A.state z n) (fun x => ind (w.deposit t z m o s x) * T (key x)) =
|
| 120 |
+
avg (A.state z n) (fun x => ind (w.deposit t z m o s x) * (W-T) (key x))
|
| 121 |
+
rw [←avg_sub]
|
| 122 |
+
simp only [Pi.sub_apply,mul_sub]
|
| 123 |
+
rw [hz]
|
| 124 |
+
change |w.prowl _ _ _ _ _ _|≤_
|
| 125 |
+
rw [prowl_astonish]
|
| 126 |
+
exact le_of_not_gt (fun h=> hw.tested ⟨_, stencil_floor w t z o s m,h⟩)
|
| 127 |
+
have h2 : |y W-y T|≤ε := by
|
| 128 |
+
unfold y; rw [sheen_sun,sheen_sun,←mul_sub,←avg_sub]
|
| 129 |
+
let B:= w.seraph t z o m s Y
|
| 130 |
+
have hF (i j): |B i j|≤1 := by
|
| 131 |
+
have hh:= w.seraphFloor t z o m s Y i (he.law i) j; rw [abs_of_nonneg (show 0≤B i j
|
| 132 |
+
from hh.1)]; exact hh.2
|
| 133 |
+
simp_rw [←sub_mul]; exact warm_bound (show |A.kappa|≤1 from (abs_of_pos A.kappa_pos).trans_le
|
| 134 |
+
(w.kappaTop t)) (hw.shadow B hF)
|
| 135 |
+
have h3 := paint_set w t z m Y o s f hF hg hj hc he
|
| 136 |
+
exact (abs_sub_le (x W) (x T) (y W)).trans ((add_le_add h1
|
| 137 |
+
((abs_sub_le (x T) (y T) (y W)).trans (add_le_add h3 ((abs_sub_comm ..).trans_le h2)))).trans_eq
|
| 138 |
+
(by ring))
|
| 139 |
+
|
| 140 |
+
end Quill
|
| 141 |
+
end StatusAnalysis
|
| 142 |
+
end HadwigerCounterexample
|
| 143 |
+
|
| 144 |
+
end
|
| 145 |
+
|
| 146 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RectangleRegularity.lean
CHANGED
|
@@ -1,115 +1,115 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ConditionalProjection
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rectangle Regularity -/
|
| 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 thinCut (μ f : Wgt A) (x : A→B) (y : A→C) (ε : ℝ) :=
|
| 14 |
-
∀ u : Wgt B,(∀ i,|u i|≤1) → ∀ v : Wgt C,(∀ i,|v i|≤1) →
|
| 15 |
-
|avg μ (fun i=> f i*(u (x i)*v (y i)))|≤ ε
|
| 16 |
-
def doubleBook {L R : Type} (x : A→B) (y : A→C) (a : B→L) (b : C→R) :=
|
| 17 |
-
fun i => (a (x i),b (y i))
|
| 18 |
-
def swab (x : Bool) : ℝ := if x then 1 else -1
|
| 19 |
-
theorem swab_abs (x) : |swab x|=1 := by cases x <;> simp [swab]
|
| 20 |
-
|
| 21 |
-
private theorem sign_mass (w : Wgt A) (f : A→B) (u : Wgt B) (h : ∀ i,|u i|≤1) :
|
| 22 |
-
∃ y : B→Bool,|avg w (u ∘ f)|≤|avg w (swab ∘ y ∘ f)| := by
|
| 23 |
-
classical
|
| 24 |
-
let p := mapW w f
|
| 25 |
-
let y (i) := decide (0≤p i)
|
| 26 |
-
have he i :
|
| 27 |
-
p i*swab (y i)=|p i| := by
|
| 28 |
-
by_cases hh : 0≤p i <;> simp [swab,y,hh,abs_of_nonneg,abs_of_neg,lt_of_not_ge]
|
| 29 |
-
have hu :
|
| 30 |
-
|avg p u| ≤ ∑ i,|p i| := by
|
| 31 |
-
unfold avg; refine (Finset.abs_sum_le_sum_abs ..).trans ?_
|
| 32 |
-
refine Finset.sum_le_sum fun i _ => ?_
|
| 33 |
-
rw [abs_mul]
|
| 34 |
-
exact (mul_le_mul_of_nonneg_left (h i) (abs_nonneg _)).trans_eq (mul_one _)
|
| 35 |
-
have hz : avg p (swab ∘ y) = ∑ i, |p i| := Finset.sum_congr rfl fun i _=> he i
|
| 36 |
-
refine ⟨y,?_⟩
|
| 37 |
-
rw [show avg w (u∘f)=avg p u from (mapW_avg w f u).symm,show avg w (swab∘y∘f)=
|
| 38 |
-
avg p (swab∘y) from (mapW_avg w f (swab ∘ y)).symm]
|
| 39 |
-
exact hu.trans (hz.symm.le.trans (le_abs_self _))
|
| 40 |
-
|
| 41 |
-
theorem cut_witness (μ f : Wgt A) {x : A→B} {y : A→C} {ε : ℝ} (h : ¬ thinCut μ f x y ε) :
|
| 42 |
-
∃ (i : B→Bool) (j : C→Bool), ε < |avg μ (fun z=>f z*(swab (i (x z))*swab (j (y z))))| := by
|
| 43 |
-
classical
|
| 44 |
-
unfold thinCut at h
|
| 45 |
-
push Not at h
|
| 46 |
-
obtain ⟨u,hu,v,hv,h⟩ := h
|
| 47 |
-
let Q (u : Wgt B) (v : Wgt C) := avg μ (fun z=>f z*(u (x z)*v (y z)))
|
| 48 |
-
let U z := μ z*f z*v (y z)
|
| 49 |
-
obtain ⟨i,hi⟩ := sign_mass U x u hu
|
| 50 |
-
have hx (u) : Q u v=avg U (u∘x) := Finset.sum_congr rfl (fun z _=>by unfold U Function.comp; ring)
|
| 51 |
-
let V z := μ z*f z*swab (i (x z))
|
| 52 |
-
obtain ⟨j,hj⟩ := sign_mass V y v hv
|
| 53 |
-
have hy (v) : Q (swab ∘ i) v=avg V (v∘y) := Finset.sum_congr rfl (fun z _=>by
|
| 54 |
-
unfold V Function.comp; ring)
|
| 55 |
-
rw [←hx u,show avg U (swab ∘ i ∘ x)=Q (swab ∘ i) v from (hx (swab ∘ i)).symm] at hi
|
| 56 |
-
rw [←hy v,show avg V (swab ∘ j ∘ y)=Q (swab ∘ i) (swab∘j) from (hy (swab ∘ j)).symm] at hj
|
| 57 |
-
exact ⟨i,j, lt_of_lt_of_le h (hi.trans hj)⟩
|
| 58 |
-
|
| 59 |
-
def weakRank (μ f : Wgt A) (x : A→B) (y : A→C) (δ : ℝ) (R : ℕ) :=
|
| 60 |
-
∃ l : ℕ,l≤R ∧ ∃ (a:B→Fin l) (b:C→ Fin l),
|
| 61 |
-
thinCut μ (fun i=> f i-banner μ (doubleBook x y a b) f i) x y δ
|
| 62 |
-
|
| 63 |
-
set_option maxHeartbeats 800000 in
|
| 64 |
-
theorem plenty_cuts (δ M : ℝ) (hδ : 0<δ) (hM : 0≤M) :
|
| 65 |
-
∃ r:ℕ,∀ (A B C : Type) [Fintype A] [Fintype B] [Fintype C]
|
| 66 |
-
(μ f : Wgt A) (x : A→B) (y : A→C),SubLaw μ → (∀ i,|f i| ≤ M) →
|
| 67 |
-
weakRank μ f x y δ r := by
|
| 68 |
-
classical
|
| 69 |
-
obtain ⟨l,hl⟩ := exists_nat_gt (M^2 / δ^2)
|
| 70 |
-
refine ⟨2^l,fun A B C _ _ _ μ f x y hw hf => ?_⟩
|
| 71 |
-
by_contra h
|
| 72 |
-
have hh (i : ℕ) (hi : i≤l) :
|
| 73 |
-
∃ (a:B→Fin (2^i)) (b:C→Fin (2^i)), i*δ^2 ≤ ode μ (banner μ (doubleBook x y a b) f) := by
|
| 74 |
-
induction i with
|
| 75 |
-
| zero => exact ⟨fun _=>0,fun _=>0, by simpa using ode_nonneg hw.nz _⟩
|
| 76 |
-
| succ i ih =>
|
| 77 |
-
obtain ⟨a,b,he⟩ := ih (by omega)
|
| 78 |
-
let T := doubleBook x y a b
|
| 79 |
-
let d := fun z => f z-banner μ T f z
|
| 80 |
-
obtain ⟨u,v,e⟩ := cut_witness μ d (x:=x) (y:=y) (ε:=δ) (fun p =>
|
| 81 |
-
h ⟨_,Nat.pow_le_pow_right (by decide) (by omega),a,b,p⟩)
|
| 82 |
-
let r := 2^i
|
| 83 |
-
let E : Fin r × Bool ≃ Fin (2^(i+1)) := Fintype.equivFinOfCardEq (by simp [r,pow_succ])
|
| 84 |
-
let a' z := E (a z,u z); let b' z := E (b z,v z)
|
| 85 |
-
let S := doubleBook x y a' b'
|
| 86 |
-
let U (z j : Fin (2^(i+1))) := ((E.symm z).1,(E.symm j).1)
|
| 87 |
-
let V (z j : Fin (2^(i+1))) := swab (E.symm z).2*swab (E.symm j).2
|
| 88 |
-
have hz : uncurry U ∘ S=T := by
|
| 89 |
-
funext i; simp only [doubleBook,a',b',Function.comp_apply,U,S,uncurry_apply_pair,
|
| 90 |
-
Equiv.symm_apply_apply]; rfl
|
| 91 |
-
have hH (i) : uncurry V (S i)=swab (u (x i))*swab (v (y i)) := by
|
| 92 |
-
simp only [S,doubleBook,a',b',V,uncurry_apply_pair,Equiv.symm_apply_apply]
|
| 93 |
-
have hh (i) : |uncurry V (S i)| ≤ 1 := by rw [hH,abs_mul,swab_abs,swab_abs,mul_one]
|
| 94 |
-
have hq := archive_gain hw f S (uncurry U) (uncurry V) hh
|
| 95 |
-
rw [hz] at hq
|
| 96 |
-
have ht : dip μ d (uncurry V ∘ S)=
|
| 97 |
-
avg μ (fun z => d z*(swab (u (x z))*swab (v (y z)))) :=
|
| 98 |
-
avg_congr (fun i _=> congrArg _ (hH i))
|
| 99 |
-
change (dip μ d _)^2≤_ at hq
|
| 100 |
-
rw [←ht] at e
|
| 101 |
-
refine ⟨a',b',?_⟩
|
| 102 |
-
change ↑(i+1)*δ^2≤ode μ (banner μ S f)
|
| 103 |
-
change ↑i*δ^2≤ode μ (banner μ T f) at he
|
| 104 |
-
push_cast
|
| 105 |
-
nlinarith only [he,hq,e,sq_abs (dip μ d (uncurry V ∘ S)),hδ]
|
| 106 |
-
obtain ⟨a,b,he⟩ := hh l le_rfl
|
| 107 |
-
let F := doubleBook x y a b
|
| 108 |
-
have hb := cashbook_bound μ hw.nz F f M hM hf
|
| 109 |
-
have ht := he.trans (ode_upper hw _ M (fun i : A=> hb (F i)))
|
| 110 |
-
exact not_lt_of_ge ht ((div_lt_iff₀ (by positivity)).mp hl)
|
| 111 |
-
end HadwigerCounterexample
|
| 112 |
-
|
| 113 |
-
end
|
| 114 |
-
|
| 115 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ConditionalProjection
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rectangle Regularity -/
|
| 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 thinCut (μ f : Wgt A) (x : A→B) (y : A→C) (ε : ℝ) :=
|
| 14 |
+
∀ u : Wgt B,(∀ i,|u i|≤1) → ∀ v : Wgt C,(∀ i,|v i|≤1) →
|
| 15 |
+
|avg μ (fun i=> f i*(u (x i)*v (y i)))|≤ ε
|
| 16 |
+
def doubleBook {L R : Type} (x : A→B) (y : A→C) (a : B→L) (b : C→R) :=
|
| 17 |
+
fun i => (a (x i),b (y i))
|
| 18 |
+
def swab (x : Bool) : ℝ := if x then 1 else -1
|
| 19 |
+
theorem swab_abs (x) : |swab x|=1 := by cases x <;> simp [swab]
|
| 20 |
+
|
| 21 |
+
private theorem sign_mass (w : Wgt A) (f : A→B) (u : Wgt B) (h : ∀ i,|u i|≤1) :
|
| 22 |
+
∃ y : B→Bool,|avg w (u ∘ f)|≤|avg w (swab ∘ y ∘ f)| := by
|
| 23 |
+
classical
|
| 24 |
+
let p := mapW w f
|
| 25 |
+
let y (i) := decide (0≤p i)
|
| 26 |
+
have he i :
|
| 27 |
+
p i*swab (y i)=|p i| := by
|
| 28 |
+
by_cases hh : 0≤p i <;> simp [swab,y,hh,abs_of_nonneg,abs_of_neg,lt_of_not_ge]
|
| 29 |
+
have hu :
|
| 30 |
+
|avg p u| ≤ ∑ i,|p i| := by
|
| 31 |
+
unfold avg; refine (Finset.abs_sum_le_sum_abs ..).trans ?_
|
| 32 |
+
refine Finset.sum_le_sum fun i _ => ?_
|
| 33 |
+
rw [abs_mul]
|
| 34 |
+
exact (mul_le_mul_of_nonneg_left (h i) (abs_nonneg _)).trans_eq (mul_one _)
|
| 35 |
+
have hz : avg p (swab ∘ y) = ∑ i, |p i| := Finset.sum_congr rfl fun i _=> he i
|
| 36 |
+
refine ⟨y,?_⟩
|
| 37 |
+
rw [show avg w (u∘f)=avg p u from (mapW_avg w f u).symm,show avg w (swab∘y∘f)=
|
| 38 |
+
avg p (swab∘y) from (mapW_avg w f (swab ∘ y)).symm]
|
| 39 |
+
exact hu.trans (hz.symm.le.trans (le_abs_self _))
|
| 40 |
+
|
| 41 |
+
theorem cut_witness (μ f : Wgt A) {x : A→B} {y : A→C} {ε : ℝ} (h : ¬ thinCut μ f x y ε) :
|
| 42 |
+
∃ (i : B→Bool) (j : C→Bool), ε < |avg μ (fun z=>f z*(swab (i (x z))*swab (j (y z))))| := by
|
| 43 |
+
classical
|
| 44 |
+
unfold thinCut at h
|
| 45 |
+
push Not at h
|
| 46 |
+
obtain ⟨u,hu,v,hv,h⟩ := h
|
| 47 |
+
let Q (u : Wgt B) (v : Wgt C) := avg μ (fun z=>f z*(u (x z)*v (y z)))
|
| 48 |
+
let U z := μ z*f z*v (y z)
|
| 49 |
+
obtain ⟨i,hi⟩ := sign_mass U x u hu
|
| 50 |
+
have hx (u) : Q u v=avg U (u∘x) := Finset.sum_congr rfl (fun z _=>by unfold U Function.comp; ring)
|
| 51 |
+
let V z := μ z*f z*swab (i (x z))
|
| 52 |
+
obtain ⟨j,hj⟩ := sign_mass V y v hv
|
| 53 |
+
have hy (v) : Q (swab ∘ i) v=avg V (v∘y) := Finset.sum_congr rfl (fun z _=>by
|
| 54 |
+
unfold V Function.comp; ring)
|
| 55 |
+
rw [←hx u,show avg U (swab ∘ i ∘ x)=Q (swab ∘ i) v from (hx (swab ∘ i)).symm] at hi
|
| 56 |
+
rw [←hy v,show avg V (swab ∘ j ∘ y)=Q (swab ∘ i) (swab∘j) from (hy (swab ∘ j)).symm] at hj
|
| 57 |
+
exact ⟨i,j, lt_of_lt_of_le h (hi.trans hj)⟩
|
| 58 |
+
|
| 59 |
+
def weakRank (μ f : Wgt A) (x : A→B) (y : A→C) (δ : ℝ) (R : ℕ) :=
|
| 60 |
+
∃ l : ℕ,l≤R ∧ ∃ (a:B→Fin l) (b:C→ Fin l),
|
| 61 |
+
thinCut μ (fun i=> f i-banner μ (doubleBook x y a b) f i) x y δ
|
| 62 |
+
|
| 63 |
+
set_option maxHeartbeats 800000 in
|
| 64 |
+
theorem plenty_cuts (δ M : ℝ) (hδ : 0<δ) (hM : 0≤M) :
|
| 65 |
+
∃ r:ℕ,∀ (A B C : Type) [Fintype A] [Fintype B] [Fintype C]
|
| 66 |
+
(μ f : Wgt A) (x : A→B) (y : A→C),SubLaw μ → (∀ i,|f i| ≤ M) →
|
| 67 |
+
weakRank μ f x y δ r := by
|
| 68 |
+
classical
|
| 69 |
+
obtain ⟨l,hl⟩ := exists_nat_gt (M^2 / δ^2)
|
| 70 |
+
refine ⟨2^l,fun A B C _ _ _ μ f x y hw hf => ?_⟩
|
| 71 |
+
by_contra h
|
| 72 |
+
have hh (i : ℕ) (hi : i≤l) :
|
| 73 |
+
∃ (a:B→Fin (2^i)) (b:C→Fin (2^i)), i*δ^2 ≤ ode μ (banner μ (doubleBook x y a b) f) := by
|
| 74 |
+
induction i with
|
| 75 |
+
| zero => exact ⟨fun _=>0,fun _=>0, by simpa using ode_nonneg hw.nz _⟩
|
| 76 |
+
| succ i ih =>
|
| 77 |
+
obtain ⟨a,b,he⟩ := ih (by omega)
|
| 78 |
+
let T := doubleBook x y a b
|
| 79 |
+
let d := fun z => f z-banner μ T f z
|
| 80 |
+
obtain ⟨u,v,e⟩ := cut_witness μ d (x:=x) (y:=y) (ε:=δ) (fun p =>
|
| 81 |
+
h ⟨_,Nat.pow_le_pow_right (by decide) (by omega),a,b,p⟩)
|
| 82 |
+
let r := 2^i
|
| 83 |
+
let E : Fin r × Bool ≃ Fin (2^(i+1)) := Fintype.equivFinOfCardEq (by simp [r,pow_succ])
|
| 84 |
+
let a' z := E (a z,u z); let b' z := E (b z,v z)
|
| 85 |
+
let S := doubleBook x y a' b'
|
| 86 |
+
let U (z j : Fin (2^(i+1))) := ((E.symm z).1,(E.symm j).1)
|
| 87 |
+
let V (z j : Fin (2^(i+1))) := swab (E.symm z).2*swab (E.symm j).2
|
| 88 |
+
have hz : uncurry U ∘ S=T := by
|
| 89 |
+
funext i; simp only [doubleBook,a',b',Function.comp_apply,U,S,uncurry_apply_pair,
|
| 90 |
+
Equiv.symm_apply_apply]; rfl
|
| 91 |
+
have hH (i) : uncurry V (S i)=swab (u (x i))*swab (v (y i)) := by
|
| 92 |
+
simp only [S,doubleBook,a',b',V,uncurry_apply_pair,Equiv.symm_apply_apply]
|
| 93 |
+
have hh (i) : |uncurry V (S i)| ≤ 1 := by rw [hH,abs_mul,swab_abs,swab_abs,mul_one]
|
| 94 |
+
have hq := archive_gain hw f S (uncurry U) (uncurry V) hh
|
| 95 |
+
rw [hz] at hq
|
| 96 |
+
have ht : dip μ d (uncurry V ∘ S)=
|
| 97 |
+
avg μ (fun z => d z*(swab (u (x z))*swab (v (y z)))) :=
|
| 98 |
+
avg_congr (fun i _=> congrArg _ (hH i))
|
| 99 |
+
change (dip μ d _)^2≤_ at hq
|
| 100 |
+
rw [←ht] at e
|
| 101 |
+
refine ⟨a',b',?_⟩
|
| 102 |
+
change ↑(i+1)*δ^2≤ode μ (banner μ S f)
|
| 103 |
+
change ↑i*δ^2≤ode μ (banner μ T f) at he
|
| 104 |
+
push_cast
|
| 105 |
+
nlinarith only [he,hq,e,sq_abs (dip μ d (uncurry V ∘ S)),hδ]
|
| 106 |
+
obtain ⟨a,b,he⟩ := hh l le_rfl
|
| 107 |
+
let F := doubleBook x y a b
|
| 108 |
+
have hb := cashbook_bound μ hw.nz F f M hM hf
|
| 109 |
+
have ht := he.trans (ode_upper hw _ M (fun i : A=> hb (F i)))
|
| 110 |
+
exact not_lt_of_ge ht ((div_lt_iff₀ (by positivity)).mp hl)
|
| 111 |
+
end HadwigerCounterexample
|
| 112 |
+
|
| 113 |
+
end
|
| 114 |
+
|
| 115 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RecursiveComparisonErrors.lean
CHANGED
|
@@ -1,93 +1,93 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.HeadPartitionComparison
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Recursive Comparison Errors -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Function Filter Matrix
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {I : Type} [Fintype I] [DecidableEq I] {n N : ℕ}
|
| 12 |
-
namespace Template
|
| 13 |
-
variable (v : Template p I)
|
| 14 |
-
|
| 15 |
-
theorem board_add (v : Template p I) (q : I→F) (U V : Wgt (Keys (p:=p) v.t N)) f :
|
| 16 |
-
board v q (U+V) f=board v q U f+board v q V f := by
|
| 17 |
-
unfold board curtain; simp only [Pi.add_apply,mul_add,add_mul,avg_add]
|
| 18 |
-
|
| 19 |
-
theorem shadow_add (v : Template p I) (q : I→F) (U V : Wgt (Keys (p:=p) v.t N))
|
| 20 |
-
(r s : ℝ) (h : shadowed v q U r) (h' : shadowed v q V s) :
|
| 21 |
-
shadowed v q (U+V) (r+s) := fun f hf => by
|
| 22 |
-
rw [board_add]
|
| 23 |
-
exact (abs_add_le _ _).trans (add_le_add (h f hf) (h' f hf))
|
| 24 |
-
|
| 25 |
-
theorem scene_join (v : Template p I) (q : I→ F) (U V : Wgt (Keys (p:=p) v.t N))
|
| 26 |
-
(s : Script p I) (m : Mixer p n) (w : I→Wgt (Knobs p.g n))
|
| 27 |
-
(x y : ℝ) (o : UnitType p n N)
|
| 28 |
-
(h : exceeds v q (U+V) s m w (x+y) o) :
|
| 29 |
-
exceeds v q U s m w x o ∨ exceeds v q V s m w y o := by
|
| 30 |
-
classical
|
| 31 |
-
obtain ⟨f,hf,h'⟩ := h
|
| 32 |
-
have he :
|
| 33 |
-
astonish v q (U+V) s m w f o=astonish v q U s m w f o+astonish v q V s m w f o := by
|
| 34 |
-
simp only [astonish_val,Pi.add_apply,mul_add,add_mul,avg_add]
|
| 35 |
-
change x+y < |astonish v q (U+V) s m w f o| at h'
|
| 36 |
-
rw [he] at h'
|
| 37 |
-
by_contra! hh
|
| 38 |
-
have ht : |astonish v q U s m w f o|≤x := le_of_not_gt (fun h=>hh.1 ⟨f,hf,h⟩)
|
| 39 |
-
have hv : |astonish v q V s m w f o|≤y := le_of_not_gt (fun h=>hh.2 ⟨f,hf,h⟩)
|
| 40 |
-
exact not_lt_of_ge ((abs_add_le _ _).trans (add_le_add ht hv)) h'
|
| 41 |
-
|
| 42 |
-
def drained (m : Mixer p n) (C : ℝ) (w : Wgt (UnitType p n N)) :=
|
| 43 |
-
let μ := raw m N; let H:=bp ((1/32:ℝ)*n)
|
| 44 |
-
IsLaw w ∧ (∀ x,mapW w Prod.fst x ≤ H*μ x) ∧ (∀ x,mapW w Prod.snd x≤H*μ x) ∧
|
| 45 |
-
∀ x,w x ≤ bp (C*N)*pairW μ μ x
|
| 46 |
-
|
| 47 |
-
def engaged (v : Template p I) (q : I→F) (U : Wgt (Keys (p:=p) v.t N))
|
| 48 |
-
(n : ℕ) (C e ε : ℝ) :=
|
| 49 |
-
∀ (m : Mixer p n),2*num (Full p n)<N →
|
| 50 |
-
∀ (w : Wgt (UnitType p n N)),drained m C w →
|
| 51 |
-
∀ (s : Script p I) (x : I→Wgt (Knobs p.g n)),(∀ i,IsLaw (x i)) →
|
| 52 |
-
(∀ i,mapW (x i) (freePart p)=unif) → pr w (exceeds v q U s m x ε) ≤ e
|
| 53 |
-
|
| 54 |
-
set_option maxHeartbeats 800000 in
|
| 55 |
-
theorem gild_play (v : Template p I) (j : I) (q : I→F) (n N r : ℕ)
|
| 56 |
-
(a : AtomKey (p:=p) (v.t j) N→Fin r) (B B' : Fin r→ Wgt (Keys (p:=p) (v.beyond j).t N))
|
| 57 |
-
(U : Wgt (Keys (p:=p) v.t N)) (C ε x y : ℝ)
|
| 58 |
-
(hs : shadowed v q (U-patched v j a B) ε)
|
| 59 |
-
(h : engaged v q (U-patched v j a B) n C x ε)
|
| 60 |
-
(hg : ∀ i,shadowed (v.beyond j) (v.boundTail j q) (B i-B' i) ε)
|
| 61 |
-
(hh : ∀ i,engaged (v.beyond j) (v.boundTail j q) (B i-B' i) n C y ε) :
|
| 62 |
-
let d:=U-patched v j a B'
|
| 63 |
-
shadowed v q d (ε+ε) ∧ engaged v q d n C (x+r*y) (ε+ε) := by
|
| 64 |
-
classical
|
| 65 |
-
intro d
|
| 66 |
-
let f:=U-patched v j a B
|
| 67 |
-
let V z := B z - B' z
|
| 68 |
-
let g:=patched v j a V
|
| 69 |
-
have hd : d=f+g := by
|
| 70 |
-
unfold d f g V; ext i; unfold patched; simp only [Pi.add_apply,Pi.sub_apply]
|
| 71 |
-
ring
|
| 72 |
-
rw [hd]
|
| 73 |
-
refine ⟨shadow_add v q f g ε ε hs (patched_board v j q a V ε hg),?_⟩
|
| 74 |
-
intro m hN w hw s u hu hz
|
| 75 |
-
let W (i) := exceeds (v.beyond j) (v.boundTail j q) (V i) (scriptTail s j) m
|
| 76 |
-
(fun i=>u i.val) ε
|
| 77 |
-
have he (o) (hf : exceeds v q g s m u ε o) : ∃ i,W i o := by
|
| 78 |
-
by_contra! hx
|
| 79 |
-
exact patched_exceed v j q a V ε u hu s m o hx hf
|
| 80 |
-
have hn := hw.1
|
| 81 |
-
have hi :
|
| 82 |
-
pr w (fun x => ∃ i:Fin r,W i x) ≤ (r:ℝ)*y := by
|
| 83 |
-
refine (pr_exists_le hn.nz W).trans ((Finset.sum_le_sum
|
| 84 |
-
(g:=fun _=>y) (fun i _=>?_)).trans_eq (by simp))
|
| 85 |
-
exact hh i m hN w hw (scriptTail s j) _ (fun i =>hu i.val) (fun i =>hz i.val)
|
| 86 |
-
apply (le_trans (pr_mono hn.nz (fun i => scene_join v q f g s m u _ _ i)) (pr_or_le hn.nz)).trans
|
| 87 |
-
exact add_le_add (h m hN w hw s u hu hz) ((pr_mono hn.nz he).trans hi)
|
| 88 |
-
end Template
|
| 89 |
-
end HadwigerCounterexample
|
| 90 |
-
|
| 91 |
-
end
|
| 92 |
-
|
| 93 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.HeadPartitionComparison
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Recursive Comparison Errors -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Function Filter Matrix
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {I : Type} [Fintype I] [DecidableEq I] {n N : ℕ}
|
| 12 |
+
namespace Template
|
| 13 |
+
variable (v : Template p I)
|
| 14 |
+
|
| 15 |
+
theorem board_add (v : Template p I) (q : I→F) (U V : Wgt (Keys (p:=p) v.t N)) f :
|
| 16 |
+
board v q (U+V) f=board v q U f+board v q V f := by
|
| 17 |
+
unfold board curtain; simp only [Pi.add_apply,mul_add,add_mul,avg_add]
|
| 18 |
+
|
| 19 |
+
theorem shadow_add (v : Template p I) (q : I→F) (U V : Wgt (Keys (p:=p) v.t N))
|
| 20 |
+
(r s : ℝ) (h : shadowed v q U r) (h' : shadowed v q V s) :
|
| 21 |
+
shadowed v q (U+V) (r+s) := fun f hf => by
|
| 22 |
+
rw [board_add]
|
| 23 |
+
exact (abs_add_le _ _).trans (add_le_add (h f hf) (h' f hf))
|
| 24 |
+
|
| 25 |
+
theorem scene_join (v : Template p I) (q : I→ F) (U V : Wgt (Keys (p:=p) v.t N))
|
| 26 |
+
(s : Script p I) (m : Mixer p n) (w : I→Wgt (Knobs p.g n))
|
| 27 |
+
(x y : ℝ) (o : UnitType p n N)
|
| 28 |
+
(h : exceeds v q (U+V) s m w (x+y) o) :
|
| 29 |
+
exceeds v q U s m w x o ∨ exceeds v q V s m w y o := by
|
| 30 |
+
classical
|
| 31 |
+
obtain ⟨f,hf,h'⟩ := h
|
| 32 |
+
have he :
|
| 33 |
+
astonish v q (U+V) s m w f o=astonish v q U s m w f o+astonish v q V s m w f o := by
|
| 34 |
+
simp only [astonish_val,Pi.add_apply,mul_add,add_mul,avg_add]
|
| 35 |
+
change x+y < |astonish v q (U+V) s m w f o| at h'
|
| 36 |
+
rw [he] at h'
|
| 37 |
+
by_contra! hh
|
| 38 |
+
have ht : |astonish v q U s m w f o|≤x := le_of_not_gt (fun h=>hh.1 ⟨f,hf,h⟩)
|
| 39 |
+
have hv : |astonish v q V s m w f o|≤y := le_of_not_gt (fun h=>hh.2 ⟨f,hf,h⟩)
|
| 40 |
+
exact not_lt_of_ge ((abs_add_le _ _).trans (add_le_add ht hv)) h'
|
| 41 |
+
|
| 42 |
+
def drained (m : Mixer p n) (C : ℝ) (w : Wgt (UnitType p n N)) :=
|
| 43 |
+
let μ := raw m N; let H:=bp ((1/32:ℝ)*n)
|
| 44 |
+
IsLaw w ∧ (∀ x,mapW w Prod.fst x ≤ H*μ x) ∧ (∀ x,mapW w Prod.snd x≤H*μ x) ∧
|
| 45 |
+
∀ x,w x ≤ bp (C*N)*pairW μ μ x
|
| 46 |
+
|
| 47 |
+
def engaged (v : Template p I) (q : I→F) (U : Wgt (Keys (p:=p) v.t N))
|
| 48 |
+
(n : ℕ) (C e ε : ℝ) :=
|
| 49 |
+
∀ (m : Mixer p n),2*num (Full p n)<N →
|
| 50 |
+
∀ (w : Wgt (UnitType p n N)),drained m C w →
|
| 51 |
+
∀ (s : Script p I) (x : I→Wgt (Knobs p.g n)),(∀ i,IsLaw (x i)) →
|
| 52 |
+
(∀ i,mapW (x i) (freePart p)=unif) → pr w (exceeds v q U s m x ε) ≤ e
|
| 53 |
+
|
| 54 |
+
set_option maxHeartbeats 800000 in
|
| 55 |
+
theorem gild_play (v : Template p I) (j : I) (q : I→F) (n N r : ℕ)
|
| 56 |
+
(a : AtomKey (p:=p) (v.t j) N→Fin r) (B B' : Fin r→ Wgt (Keys (p:=p) (v.beyond j).t N))
|
| 57 |
+
(U : Wgt (Keys (p:=p) v.t N)) (C ε x y : ℝ)
|
| 58 |
+
(hs : shadowed v q (U-patched v j a B) ε)
|
| 59 |
+
(h : engaged v q (U-patched v j a B) n C x ε)
|
| 60 |
+
(hg : ∀ i,shadowed (v.beyond j) (v.boundTail j q) (B i-B' i) ε)
|
| 61 |
+
(hh : ∀ i,engaged (v.beyond j) (v.boundTail j q) (B i-B' i) n C y ε) :
|
| 62 |
+
let d:=U-patched v j a B'
|
| 63 |
+
shadowed v q d (ε+ε) ∧ engaged v q d n C (x+r*y) (ε+ε) := by
|
| 64 |
+
classical
|
| 65 |
+
intro d
|
| 66 |
+
let f:=U-patched v j a B
|
| 67 |
+
let V z := B z - B' z
|
| 68 |
+
let g:=patched v j a V
|
| 69 |
+
have hd : d=f+g := by
|
| 70 |
+
unfold d f g V; ext i; unfold patched; simp only [Pi.add_apply,Pi.sub_apply]
|
| 71 |
+
ring
|
| 72 |
+
rw [hd]
|
| 73 |
+
refine ⟨shadow_add v q f g ε ε hs (patched_board v j q a V ε hg),?_⟩
|
| 74 |
+
intro m hN w hw s u hu hz
|
| 75 |
+
let W (i) := exceeds (v.beyond j) (v.boundTail j q) (V i) (scriptTail s j) m
|
| 76 |
+
(fun i=>u i.val) ε
|
| 77 |
+
have he (o) (hf : exceeds v q g s m u ε o) : ∃ i,W i o := by
|
| 78 |
+
by_contra! hx
|
| 79 |
+
exact patched_exceed v j q a V ε u hu s m o hx hf
|
| 80 |
+
have hn := hw.1
|
| 81 |
+
have hi :
|
| 82 |
+
pr w (fun x => ∃ i:Fin r,W i x) ≤ (r:ℝ)*y := by
|
| 83 |
+
refine (pr_exists_le hn.nz W).trans ((Finset.sum_le_sum
|
| 84 |
+
(g:=fun _=>y) (fun i _=>?_)).trans_eq (by simp))
|
| 85 |
+
exact hh i m hN w hw (scriptTail s j) _ (fun i =>hu i.val) (fun i =>hz i.val)
|
| 86 |
+
apply (le_trans (pr_mono hn.nz (fun i => scene_join v q f g s m u _ _ i)) (pr_or_le hn.nz)).trans
|
| 87 |
+
exact add_le_add (h m hN w hw s u hu hz) ((pr_mono hn.nz he).trans hi)
|
| 88 |
+
end Template
|
| 89 |
+
end HadwigerCounterexample
|
| 90 |
+
|
| 91 |
+
end
|
| 92 |
+
|
| 93 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ReferenceProductTests.lean
CHANGED
|
@@ -1,85 +1,85 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.KeyReferenceLaws
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.EndpointTemplateConcentration
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Reference Product Tests -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
open Matrix Module Function Finset Filter
|
| 12 |
-
variable {p : Shape} {I : Type} [Fintype I] [DecidableEq I] {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
set_option maxHeartbeats 600000 in
|
| 15 |
-
theorem reference_product (t : Tagging p I) (q : I → F)
|
| 16 |
-
(f : ∀ i,Wgt (AtomKey (p:=p) (t i) N))
|
| 17 |
-
(hf : ∀ i x,|f i x|≤1) (hN : 2*num (I×Toast p)-(N:ℝ)≤ -1) :
|
| 18 |
-
|avg (lawNu p N t q) (prodW f)- ∏ i,avg (lawOmega p N (t i) (q i)) (f i)|≤
|
| 19 |
-
2*netFact (trayPort p t)*bp (-(N:ℝ)/2) := by
|
| 20 |
-
classical
|
| 21 |
-
let F (i : I) := (f i)∘(mug p (t i) N).symm
|
| 22 |
-
let g := trayPort p t
|
| 23 |
-
let A := trayMap p t q
|
| 24 |
-
have hpL i := show 2*num (Port g i)-(N:ℝ)≤ -1 by linarith only [hN,port_limit g i]
|
| 25 |
-
have he :
|
| 26 |
-
avg (rackWave A N) (brightProd F) =avg (lawNu p N t q) (prodW f) := by
|
| 27 |
-
unfold A; rw [←lawtray,mapW_avg]
|
| 28 |
-
have hh x : brightProd F (tray p t N x)=prodW f x := by
|
| 29 |
-
simp_rw [brightProd,tray_sips,F,Function.comp_apply,Equiv.symm_apply_apply]
|
| 30 |
-
rfl
|
| 31 |
-
simp_rw [hh]
|
| 32 |
-
have hw i : avg (rackWave (laneM A i) N) (F i)=avg (lawOmega p N (t i) (q i)) (f i) := by
|
| 33 |
-
unfold A; rw [←lawmug,mapW_avg]
|
| 34 |
-
simp_rw [F,Function.comp_apply, Equiv.symm_apply_apply]
|
| 35 |
-
have h := compare_waves A F (fun i x => hf _ _) hpL
|
| 36 |
-
simp_rw [he,hw] at h; exact h
|
| 37 |
-
|
| 38 |
-
theorem priceNu (t : Tagging p I) (q : I→F) (hN : 2*num (I×Toast p)-(N:ℝ) ≤ -1) :
|
| 39 |
-
(netFact (trayPort p t))⁻¹ ≤ pr unif (ownPart (p:=p) t q (N:=N)) := by
|
| 40 |
-
classical
|
| 41 |
-
let g := trayPort p t; let A := trayMap p t q
|
| 42 |
-
have hpL i := show 2*num (Port g i)-(N:ℝ)≤ -1 by linarith only [hN,port_limit g i]
|
| 43 |
-
have he : pr unif (gramPart A (N:=N))=pr unif (ownPart (p:=p) t q (N:=N)) := by
|
| 44 |
-
rw [← unif_equiv (tray p t N),mapW_pr]
|
| 45 |
-
unfold A
|
| 46 |
-
congr 1; ext i
|
| 47 |
-
exact (tray_wave ..).symm
|
| 48 |
-
rw [←he]
|
| 49 |
-
exact wave_norm A N hpL
|
| 50 |
-
theorem nuLaw (t : Tagging p I) (q : I → F) (hN : 2*num (I×Toast p)-(N:ℝ) ≤ -1) :
|
| 51 |
-
IsLaw (lawNu p N t q) := by
|
| 52 |
-
classical
|
| 53 |
-
rw [lawNu,←on_unif]
|
| 54 |
-
exact on_law unif_law.nz ((inv_pos_of_pos netFact_pos).trans_le (priceNu t q hN))
|
| 55 |
-
|
| 56 |
-
theorem priceOmega (t : Tagging p I) (q : I→F) (i : I) (hN : 2*num (I×Toast p)-(N:ℝ) ≤ -1) :
|
| 57 |
-
(netFact (street (trayPort p t) i))⁻¹ ≤ pr unif (ownOne p (t i) (q i) (N:=N)) := by
|
| 58 |
-
classical
|
| 59 |
-
let g := street (trayPort p t) i; let A := laneM (trayMap p t q) i
|
| 60 |
-
have hh j : num (Port g j)≤num (I×Toast p) := by
|
| 61 |
-
apply le_trans (port_limit g j)
|
| 62 |
-
exact_mod_cast Fintype.card_le_of_injective (fun j : Toast p => (i,j)) (fun i j h =>
|
| 63 |
-
congrArg Prod.snd h)
|
| 64 |
-
have hpL j := show 2*num (Port g j)-(N:ℝ)≤ -1 by linarith only [hN,hh j]
|
| 65 |
-
have he : pr unif (gramPart A (N:=N))=pr unif (ownOne p (t i) (q i) (N:=N)) := by
|
| 66 |
-
rw [← unif_equiv (mug p (t i) N),mapW_pr]
|
| 67 |
-
unfold A
|
| 68 |
-
congr 1; ext x
|
| 69 |
-
exact (mug_wave ..).symm
|
| 70 |
-
rw [←he]
|
| 71 |
-
exact wave_norm A N hpL
|
| 72 |
-
|
| 73 |
-
theorem omegaLaw (p : Shape) (l : Tag p.g) (q : F) (hN : 2*num (Toast p)-(N:ℝ)≤ -1) :
|
| 74 |
-
IsLaw (lawOmega p N l q) := by
|
| 75 |
-
classical
|
| 76 |
-
let t := fun (_ : Unit) => l
|
| 77 |
-
have hh : 2*num (Unit×Toast p)-(N:ℝ)≤ -1 := by simpa [num] using hN
|
| 78 |
-
rw [lawOmega,←on_unif]
|
| 79 |
-
exact on_law unif_law.nz ((inv_pos_of_pos netFact_pos).trans_le
|
| 80 |
-
(priceOmega t (fun _ : Unit => q) () hh))
|
| 81 |
-
end HadwigerCounterexample
|
| 82 |
-
|
| 83 |
-
end
|
| 84 |
-
|
| 85 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.KeyReferenceLaws
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.EndpointTemplateConcentration
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Reference Product Tests -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
open Matrix Module Function Finset Filter
|
| 12 |
+
variable {p : Shape} {I : Type} [Fintype I] [DecidableEq I] {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
set_option maxHeartbeats 600000 in
|
| 15 |
+
theorem reference_product (t : Tagging p I) (q : I → F)
|
| 16 |
+
(f : ∀ i,Wgt (AtomKey (p:=p) (t i) N))
|
| 17 |
+
(hf : ∀ i x,|f i x|≤1) (hN : 2*num (I×Toast p)-(N:ℝ)≤ -1) :
|
| 18 |
+
|avg (lawNu p N t q) (prodW f)- ∏ i,avg (lawOmega p N (t i) (q i)) (f i)|≤
|
| 19 |
+
2*netFact (trayPort p t)*bp (-(N:ℝ)/2) := by
|
| 20 |
+
classical
|
| 21 |
+
let F (i : I) := (f i)∘(mug p (t i) N).symm
|
| 22 |
+
let g := trayPort p t
|
| 23 |
+
let A := trayMap p t q
|
| 24 |
+
have hpL i := show 2*num (Port g i)-(N:ℝ)≤ -1 by linarith only [hN,port_limit g i]
|
| 25 |
+
have he :
|
| 26 |
+
avg (rackWave A N) (brightProd F) =avg (lawNu p N t q) (prodW f) := by
|
| 27 |
+
unfold A; rw [←lawtray,mapW_avg]
|
| 28 |
+
have hh x : brightProd F (tray p t N x)=prodW f x := by
|
| 29 |
+
simp_rw [brightProd,tray_sips,F,Function.comp_apply,Equiv.symm_apply_apply]
|
| 30 |
+
rfl
|
| 31 |
+
simp_rw [hh]
|
| 32 |
+
have hw i : avg (rackWave (laneM A i) N) (F i)=avg (lawOmega p N (t i) (q i)) (f i) := by
|
| 33 |
+
unfold A; rw [←lawmug,mapW_avg]
|
| 34 |
+
simp_rw [F,Function.comp_apply, Equiv.symm_apply_apply]
|
| 35 |
+
have h := compare_waves A F (fun i x => hf _ _) hpL
|
| 36 |
+
simp_rw [he,hw] at h; exact h
|
| 37 |
+
|
| 38 |
+
theorem priceNu (t : Tagging p I) (q : I→F) (hN : 2*num (I×Toast p)-(N:ℝ) ≤ -1) :
|
| 39 |
+
(netFact (trayPort p t))⁻¹ ≤ pr unif (ownPart (p:=p) t q (N:=N)) := by
|
| 40 |
+
classical
|
| 41 |
+
let g := trayPort p t; let A := trayMap p t q
|
| 42 |
+
have hpL i := show 2*num (Port g i)-(N:ℝ)≤ -1 by linarith only [hN,port_limit g i]
|
| 43 |
+
have he : pr unif (gramPart A (N:=N))=pr unif (ownPart (p:=p) t q (N:=N)) := by
|
| 44 |
+
rw [← unif_equiv (tray p t N),mapW_pr]
|
| 45 |
+
unfold A
|
| 46 |
+
congr 1; ext i
|
| 47 |
+
exact (tray_wave ..).symm
|
| 48 |
+
rw [←he]
|
| 49 |
+
exact wave_norm A N hpL
|
| 50 |
+
theorem nuLaw (t : Tagging p I) (q : I → F) (hN : 2*num (I×Toast p)-(N:ℝ) ≤ -1) :
|
| 51 |
+
IsLaw (lawNu p N t q) := by
|
| 52 |
+
classical
|
| 53 |
+
rw [lawNu,←on_unif]
|
| 54 |
+
exact on_law unif_law.nz ((inv_pos_of_pos netFact_pos).trans_le (priceNu t q hN))
|
| 55 |
+
|
| 56 |
+
theorem priceOmega (t : Tagging p I) (q : I→F) (i : I) (hN : 2*num (I×Toast p)-(N:ℝ) ≤ -1) :
|
| 57 |
+
(netFact (street (trayPort p t) i))⁻¹ ≤ pr unif (ownOne p (t i) (q i) (N:=N)) := by
|
| 58 |
+
classical
|
| 59 |
+
let g := street (trayPort p t) i; let A := laneM (trayMap p t q) i
|
| 60 |
+
have hh j : num (Port g j)≤num (I×Toast p) := by
|
| 61 |
+
apply le_trans (port_limit g j)
|
| 62 |
+
exact_mod_cast Fintype.card_le_of_injective (fun j : Toast p => (i,j)) (fun i j h =>
|
| 63 |
+
congrArg Prod.snd h)
|
| 64 |
+
have hpL j := show 2*num (Port g j)-(N:ℝ)≤ -1 by linarith only [hN,hh j]
|
| 65 |
+
have he : pr unif (gramPart A (N:=N))=pr unif (ownOne p (t i) (q i) (N:=N)) := by
|
| 66 |
+
rw [← unif_equiv (mug p (t i) N),mapW_pr]
|
| 67 |
+
unfold A
|
| 68 |
+
congr 1; ext x
|
| 69 |
+
exact (mug_wave ..).symm
|
| 70 |
+
rw [←he]
|
| 71 |
+
exact wave_norm A N hpL
|
| 72 |
+
|
| 73 |
+
theorem omegaLaw (p : Shape) (l : Tag p.g) (q : F) (hN : 2*num (Toast p)-(N:ℝ)≤ -1) :
|
| 74 |
+
IsLaw (lawOmega p N l q) := by
|
| 75 |
+
classical
|
| 76 |
+
let t := fun (_ : Unit) => l
|
| 77 |
+
have hh : 2*num (Unit×Toast p)-(N:ℝ)≤ -1 := by simpa [num] using hN
|
| 78 |
+
rw [lawOmega,←on_unif]
|
| 79 |
+
exact on_law unif_law.nz ((inv_pos_of_pos netFact_pos).trans_le
|
| 80 |
+
(priceOmega t (fun _ : Unit => q) () hh))
|
| 81 |
+
end HadwigerCounterexample
|
| 82 |
+
|
| 83 |
+
end
|
| 84 |
+
|
| 85 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RefinedPinImages.lean
CHANGED
|
@@ -1,240 +1,240 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.PartitionSelection
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.FourPhaseBits
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Refined Pin Images -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Matrix LinearMap Module Submodule Function Finset
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {p : Shape} {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
def front (s : Plan p n) : Plan p n := prSmall s
|
| 15 |
-
|
| 16 |
-
theorem front_rank (s : Plan p n) : planRank (front s) ≤2*planRank s := by
|
| 17 |
-
classical
|
| 18 |
-
unfold planRank
|
| 19 |
-
rw [Finset.mul_sum]
|
| 20 |
-
refine Finset.sum_le_sum fun i _ => ?_
|
| 21 |
-
have hh (j) :
|
| 22 |
-
dim ((sPin s i j).map (IP p n j).mulVecLin)≤dim (s i) :=
|
| 23 |
-
(Submodule.finrank_map_le ..).trans (sPin_dim ..)
|
| 24 |
-
exact ((Submodule.finrank_add_le_finrank_add_finrank ..).trans (add_le_add (hh _) (hh _))).trans_eq
|
| 25 |
-
(two_mul _).symm
|
| 26 |
-
|
| 27 |
-
theorem combined_rank (s t : Plan p n) : planRank (s⊔t)≤planRank s+planRank t := by
|
| 28 |
-
unfold planRank; rw [←Finset.sum_add_distrib]
|
| 29 |
-
exact Finset.sum_le_sum fun i _ => finrank_add_le_finrank_add_finrank ..
|
| 30 |
-
|
| 31 |
-
abbrev Signal (p : Shape) (N : ℕ) {n} (s : Plan p n) := DTuple (p:=p) (fun z => dim (s z)) N
|
| 32 |
-
|
| 33 |
-
def readPin (x : UnitType p n N) (a : Plan p n) : Signal p N a :=
|
| 34 |
-
fun z => images x z * pack (a z)
|
| 35 |
-
|
| 36 |
-
abbrev EffSeq {p : Shape} {n} (s : Plan p n) := ∀ i : Bool,effective s i
|
| 37 |
-
|
| 38 |
-
def entrySeq {p : Shape} {n} (s : Plan p n) (m : Bool → Profile p n) : EffSeq s :=
|
| 39 |
-
open scoped Classical in
|
| 40 |
-
fun i => if h : m i ∈ effective s i then ⟨_,h⟩ else 0
|
| 41 |
-
|
| 42 |
-
abbrev Story {p : Shape} {n N} (T : Cov p N) (s : Plan p n) :=
|
| 43 |
-
Daypair p T × Signal p N (front s) × EffSeq s
|
| 44 |
-
|
| 45 |
-
instance fintypeStory {s : Plan p n} {T : Cov p N} : Fintype (Story T s) := by
|
| 46 |
-
classical
|
| 47 |
-
let A := (coverX p T)
|
| 48 |
-
letI : Finite (Module.Dual F A) := Finite.of_injective _ DFunLike.coe_injective
|
| 49 |
-
letI : Fintype (Module.Dual F A) := Fintype.ofFinite _
|
| 50 |
-
letI : Fintype (Daypair p T) := inferInstanceAs (Fintype (Daypair p T))
|
| 51 |
-
letI : ∀ i,Fintype (effective s i) := fun i => Fintype.ofFinite _
|
| 52 |
-
letI : Fintype (EffSeq s) := inferInstanceAs (Fintype (EffSeq s))
|
| 53 |
-
letI : Fintype (Signal p N (front s)) := inferInstanceAs (Fintype (Signal p N (front s)))
|
| 54 |
-
exact inferInstanceAs (Fintype (Story T s))
|
| 55 |
-
|
| 56 |
-
def story (T : Cov p N) (s : Plan p n) (m : BMark p n N) (x : UnitType p n N) : Story T s :=
|
| 57 |
-
(daypair p T (delta m) (fun _ => 1) x,readPin x (front s),entrySeq s (m x))
|
| 58 |
-
|
| 59 |
-
def specialLeaf (T : Cov p N) (m : BMark p n N) (a : Pin p n N)
|
| 60 |
-
(G : CTile p n N) (b : Pin p n N) :=
|
| 61 |
-
a.sp ≤ b.sp ∧ front a.sp ≤ b.sp ∧
|
| 62 |
-
∀ x∈G,∀ y∈G, m x=m y ∧ delta m x=delta m y ∧
|
| 63 |
-
∀ i,juris p T x (unary i) = juris p T y (unary i)
|
| 64 |
-
|
| 65 |
-
private theorem storyOk (T : Cov p N) (m : BMark p n N)
|
| 66 |
-
(a : Pin p n N) (S : CTile p n N) (K : ℕ) (hk : planRank a.sp≤K)
|
| 67 |
-
(h : ∀ x∈S, a.agree x ∧ covered p T (delta m x) ∧
|
| 68 |
-
∀ i,m x i∈effective a.sp i) :
|
| 69 |
-
∀ i : Story T a.sp,∃ b : Pin p n N,
|
| 70 |
-
(∀ x∈ S,story T a.sp m x=i → b.agree x) ∧ planRank b.sp ≤ 3*K ∧
|
| 71 |
-
∀ c (G : CTile p n N), G.Nonempty →
|
| 72 |
-
(∀ x∈G,x∈S ∧ story T a.sp m x=i) → b.sp ≤ c.sp → specialLeaf T m a G c := by
|
| 73 |
-
classical
|
| 74 |
-
intro i
|
| 75 |
-
let A := a.sp ⊔ front a.sp
|
| 76 |
-
have hK : planRank A≤3*K := by
|
| 77 |
-
apply (combined_rank ..).trans
|
| 78 |
-
have hh := front_rank a.sp
|
| 79 |
-
omega
|
| 80 |
-
have h1 : ∃ x : UnitType p n N, ∀ y∈ S,story T a.sp m y=i → (Pin.make A x).agree y := by
|
| 81 |
-
by_cases hg : ∃ x∈S,story T a.sp m x=i
|
| 82 |
-
· obtain ⟨x,hx,he⟩ := hg
|
| 83 |
-
refine ⟨x,fun y hy ht => ?_⟩
|
| 84 |
-
let b := Pin.make (front a.sp) x
|
| 85 |
-
have hf : b.agree y := by
|
| 86 |
-
rw [Pin.agree_pack]; intro z
|
| 87 |
-
have hh : readPin y (front a.sp)=readPin x (front a.sp) :=
|
| 88 |
-
congrArg (fun x : Story T a.sp => x.2.1) (ht.trans he.symm)
|
| 89 |
-
exact congr_fun hh z
|
| 90 |
-
exact (Pin.combine (b:=b) (h x hx).1 (show b.agree x from fun _ _ _ => rfl)).mpr
|
| 91 |
-
⟨(h y hy).1,hf⟩
|
| 92 |
-
exact ⟨0,fun x hx he => (hg ⟨x,hx,he⟩).elim⟩
|
| 93 |
-
obtain ⟨x,hx⟩ := h1
|
| 94 |
-
refine ⟨Pin.make A x,hx,hK,fun c G hm hC hA => ⟨le_trans le_sup_left hA,
|
| 95 |
-
le_trans le_sup_right hA, fun x hx y hy => ?_⟩⟩
|
| 96 |
-
have he := (hC x hx).2.trans (hC y hy).2.symm
|
| 97 |
-
have hD := congrArg Prod.fst he
|
| 98 |
-
have hr z (hz : z∈G) : (story T a.sp m z).1.1.val=delta m z := by
|
| 99 |
-
unfold story daypair; change (cutDown p T (delta m) (fun _ => 1) z).val=_
|
| 100 |
-
unfold cutDown; rw [dite_eq_left ⟨(by norm_num),(h z (hC z hz).1).2.1⟩]
|
| 101 |
-
have ht z (hz : z∈G) (i) : ((story T a.sp m z).2.2 i).val=m z i := by
|
| 102 |
-
unfold story entrySeq; dsimp only
|
| 103 |
-
rw [dite_eq_left ((h z (hC z hz).1).2.2 i)]
|
| 104 |
-
refine ⟨funext (fun i => ?_),?_,fun i => ?_⟩
|
| 105 |
-
· rw [←ht x hx i,←ht y hy i,he]
|
| 106 |
-
· rw [←hr x hx, ←hr y hy,he]
|
| 107 |
-
exact congr_fun (congrArg Prod.snd hD) i
|
| 108 |
-
|
| 109 |
-
theorem story_size (T : Cov p N) (s : Plan p n) (K d : ℕ)
|
| 110 |
-
(hK : planRank s≤K) (hd : cdim p T≤d) :
|
| 111 |
-
num (Story T s) ≤ bp ((3*d+2*K : ℝ)*N + 2*K^2) := by
|
| 112 |
-
classical
|
| 113 |
-
have h1 : dim (coverX p T)≤ N*d := (cover_dim p T).trans (Nat.mul_le_mul_left N hd)
|
| 114 |
-
have h2 : dim (Daypair p T) ≤ 3*d*N := by
|
| 115 |
-
unfold dim Daypair
|
| 116 |
-
rw [finrank_prod,finrank_pi_fintype, Fintype.sum_bool,Subspace.dual_finrank_eq]
|
| 117 |
-
change dim _+(dim _+dim _) ≤ _
|
| 118 |
-
nlinarith
|
| 119 |
-
have h3 : dim (Signal p N (front s)) ≤ (2*K)*N := tuple_dim.trans_le (by
|
| 120 |
-
rw [mul_comm]; apply Nat.mul_le_mul_right
|
| 121 |
-
exact (front_rank s).trans (Nat.mul_le_mul_left _ hK))
|
| 122 |
-
have h4 : dim (EffSeq s)≤ 2*K^2 := by
|
| 123 |
-
unfold EffSeq dim
|
| 124 |
-
rw [finrank_pi_fintype,Fintype.sum_bool,two_mul]
|
| 125 |
-
have hh i : dim (effective s i) ≤ K^2 := (effective_dim ..).trans (by gcongr)
|
| 126 |
-
exact add_le_add (hh _) (hh _)
|
| 127 |
-
unfold num
|
| 128 |
-
rw [card_space]
|
| 129 |
-
apply bp_le
|
| 130 |
-
have hh : dim (Story T s)≤ (3*d+2*K)*N+2*K^2 := by
|
| 131 |
-
unfold Story dim; rw [finrank_prod, finrank_prod (M:=Signal p N (front s))]
|
| 132 |
-
change dim (Daypair p T)+(dim (Signal p N (front s))+dim (EffSeq s)) ≤ _
|
| 133 |
-
rw [Nat.add_mul,add_assoc]
|
| 134 |
-
exact add_le_add h2 (add_le_add h3 h4)
|
| 135 |
-
exact_mod_cast hh
|
| 136 |
-
|
| 137 |
-
theorem plan_inc_eff (s t : Plan p n) (h : s ≤ t) (i : Bool) :
|
| 138 |
-
effective s i≤effective t i := by
|
| 139 |
-
intro x hx
|
| 140 |
-
obtain ⟨h1,h2⟩ := effective_mem.mp hx
|
| 141 |
-
have he z : sPin s z i ≤ sPin t z i := Submodule.map_mono (h z)
|
| 142 |
-
exact effective_mem.mpr ⟨h1,fun z => box_le (he _) (he _) (h2 _)⟩
|
| 143 |
-
|
| 144 |
-
/-- Old contractions on admissible tables evaluate correctly when
|
| 145 |
-
the enlarged leaf has pinned the entire front. -/
|
| 146 |
-
theorem front_table (x y : UnitType p n N)
|
| 147 |
-
{a b : Pin p n N} (s : Plan p n)
|
| 148 |
-
(hf : front s≤a.sp)
|
| 149 |
-
{M : Cross p n} (hx : a.agree x) (hB : tableFlag b a (reciprocal p M) y)
|
| 150 |
-
(i j : Bool) (w : Profile p n) (h : w∈effective s i) :
|
| 151 |
-
contract p (actual p x y) i j w=contract p M i j w := by
|
| 152 |
-
have hz (z) (u : Dir p n) (hu : u∈a.sp z) :
|
| 153 |
-
channelOut p M j z *ᵥ u=channelOut p (actual p x y) j z *ᵥ u := by
|
| 154 |
-
refine channel_same j z u (fun v => ?_)
|
| 155 |
-
have h1 : IH p n j *ᵥ v∈tabSpace b.sp (flipZ p z) :=
|
| 156 |
-
channel_le_table b.sp _ _ ⟨_,rfl⟩
|
| 157 |
-
have h2 : u∈a.sp (flipZ p (flipZ p z)) := by rwa [flipZ_flip]
|
| 158 |
-
have he := hB (flipZ p z) _ h1 _ h2
|
| 159 |
-
have hg := flag_actual (a:=b) y x hx (flipZ p z) _ h1 _ h2
|
| 160 |
-
rw [← reciprocal_actual x y] at hg
|
| 161 |
-
simp only [reciprocal,flipZ_flip,evmat_transpose] at he hg
|
| 162 |
-
exact he.trans hg.symm
|
| 163 |
-
have he z : (sPin s z i).map (IP p n i).mulVecLin ≤ a.sp z := by
|
| 164 |
-
apply le_trans _ (hf z)
|
| 165 |
-
cases i; exact le_sup_right; exact le_sup_left
|
| 166 |
-
change ∑ e, _=_
|
| 167 |
-
refine Finset.sum_congr rfl fun e _ => ?_
|
| 168 |
-
refine (box_eval_iff (a.sp (e,true)) (a.sp (e,false)) _ _).mp ?_ _
|
| 169 |
-
(box_le (he _) (he _) (lift_mem_box _ _ ((effective_mem.mp h).2 e)))
|
| 170 |
-
intro x hx y hy
|
| 171 |
-
rw [ev_duom,ev_duom,hz _ _ hx,hz _ _ hy]
|
| 172 |
-
|
| 173 |
-
set_option maxHeartbeats 900000 in
|
| 174 |
-
theorem weave (P : UnitType p n N→Prop)
|
| 175 |
-
{w μ : Wgt (UnitType p n N)}
|
| 176 |
-
(m : BMark p n N) (T : Cov p N)
|
| 177 |
-
(hw : ∀ x,0≤w x) {D ζ u : ℝ} (hz : 0 < ζ) (hz' : ζ<1) {K K' d : ℕ}
|
| 178 |
-
(hn : 0<N)
|
| 179 |
-
(hμ : ∀ a : Pin p n N,pr μ a.agree ≤ fee N (ζ/4) (planRank a.sp))
|
| 180 |
-
(hd : cdim p T≤d)
|
| 181 |
-
{F : Canopy p n N} (hT : apart F) (g : CTile p n N → Pin p n N)
|
| 182 |
-
(h : ∀ i∈F,Ripe p w μ i (g i) D ζ K)
|
| 183 |
-
(hg : ∀ i∈ F,∀ x∈i,P x→covered p T (delta m x) ∧ ∀ j,m x j∈effective (g i).sp j)
|
| 184 |
-
(hk : D+u+ζ≤(ζ-ζ/4)*K')
|
| 185 |
-
(hu : (3*d+2*K:ℝ)*N+2*K^2 ≤ (u-1)*N) :
|
| 186 |
-
∃ V : Canopy p n N,apart V ∧
|
| 187 |
-
(∀ S∈V,∃ i∈F,S⊆i ∧ (∀ x∈ S,P x) ∧
|
| 188 |
-
∃ b : Pin p n N,Ripe p w μ S b (D+u+K'+1) ζ (3*K+K') ∧ specialLeaf T m (g i) S b) ∧
|
| 189 |
-
pr w (fun x => inTiles F x ∧ P x ∧ ¬inTiles V x) ≤
|
| 190 |
-
allMass w F*(bp (-(N:ℝ))+bp (-ζ*N)) := by
|
| 191 |
-
classical
|
| 192 |
-
refine improve F w hw P
|
| 193 |
-
(fun i S => (∀ x∈ S,P x) ∧ ∃ b : Pin p n N,Ripe p w μ S b (D+u+K'+1) ζ (3*K+K') ∧
|
| 194 |
-
specialLeaf T m (g i) S b)
|
| 195 |
-
hT (fun i hi => ?_)
|
| 196 |
-
let A := CTile p n N
|
| 197 |
-
let S := i.filter P
|
| 198 |
-
let Q := specialLeaf T m (g i)
|
| 199 |
-
have hs (x : UnitType p n N) : x∈S↔ x∈i∧ P x := Finset.mem_filter
|
| 200 |
-
have hq := h i hi
|
| 201 |
-
let w' := partW w i
|
| 202 |
-
have hw' : IsLaw w' := on_law hw hq.pos
|
| 203 |
-
have hg : ∀ x∈ S,(g i).agree x∧ covered p T (delta m x)∧∀ j,m x j∈effective (g i).sp j :=
|
| 204 |
-
fun x h => ⟨hq.fixpin _ ((hs ..).mp h).1,hg i hi x ((hs ..).mp h).1 ((hs ..).mp h).2⟩
|
| 205 |
-
obtain ⟨V,hV,hX,hZ⟩ := reparts w' μ hw' S D ζ u hn hz hz' hμ hq.density
|
| 206 |
-
(story T (g i).sp m) (3*K) K' Q
|
| 207 |
-
(storyOk T m (g i) S K hq.bound hg) hk
|
| 208 |
-
refine ⟨V,hV,fun x hx => ?_,?_⟩
|
| 209 |
-
· obtain ⟨hS,b,hB,hL⟩ := hX x hx
|
| 210 |
-
have hx' : x⊆i := hS.trans (Finset.filter_subset ..)
|
| 211 |
-
obtain ⟨he,hLaw⟩ := issued_law w hw hq.pos hx' hB.pos
|
| 212 |
-
refine ⟨hx', (fun z hz => ((hs ..).mp (hS hz)).2),b,⟨he,hB.fixpin,hB.bound,?_,?_⟩,hL⟩
|
| 213 |
-
· rw [hLaw]; exact hB.clear
|
| 214 |
-
rw [hLaw]; exact hB.density
|
| 215 |
-
simp_rw [hs,and_assoc] at hZ
|
| 216 |
-
refine hZ.trans (add_le_add_left ?_ _)
|
| 217 |
-
refine (mul_le_mul_of_nonneg_right (story_size T _ K d hq.bound hd) (bp_pos _).le).trans ?_
|
| 218 |
-
rw [←bp_add]; apply bp_le
|
| 219 |
-
linarith only [hu]
|
| 220 |
-
|
| 221 |
-
theorem phase_fixed (m : BMark p n N) (T : Cov p N)
|
| 222 |
-
(A A' B B' : Pin p n N) {S R : CTile p n N}
|
| 223 |
-
{x x' y y' : UnitType p n N}
|
| 224 |
-
(h : specialLeaf T m A S A') (hg : specialLeaf T m B R B')
|
| 225 |
-
(hx : x∈S) (hx' : x'∈S) (hy : y∈R) (hy' : y'∈R)
|
| 226 |
-
(hC : covered p T (delta m x)) (hC' : covered p T (delta m y)) :
|
| 227 |
-
quench p (delta m) (x,y)=quench p (delta m) (x',y') := by
|
| 228 |
-
obtain ⟨_,h1,h2⟩ := h.2.2 x hx x' hx'
|
| 229 |
-
obtain ⟨_,h3,h4⟩ := hg.2.2 y hy y' hy'
|
| 230 |
-
unfold quench; dsimp only
|
| 231 |
-
rw [← h1, ← h3]
|
| 232 |
-
exact Prod.ext
|
| 233 |
-
(funext fun i => LinearMap.congr_fun (h4 i) (⟨_,hC⟩ : coverX p T))
|
| 234 |
-
(funext fun i => LinearMap.congr_fun (h2 i) (⟨_,hC'⟩ : coverX p T))
|
| 235 |
-
|
| 236 |
-
end HadwigerCounterexample
|
| 237 |
-
|
| 238 |
-
end
|
| 239 |
-
|
| 240 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.PartitionSelection
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.FourPhaseBits
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Refined Pin Images -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Matrix LinearMap Module Submodule Function Finset
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {p : Shape} {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
def front (s : Plan p n) : Plan p n := prSmall s
|
| 15 |
+
|
| 16 |
+
theorem front_rank (s : Plan p n) : planRank (front s) ≤2*planRank s := by
|
| 17 |
+
classical
|
| 18 |
+
unfold planRank
|
| 19 |
+
rw [Finset.mul_sum]
|
| 20 |
+
refine Finset.sum_le_sum fun i _ => ?_
|
| 21 |
+
have hh (j) :
|
| 22 |
+
dim ((sPin s i j).map (IP p n j).mulVecLin)≤dim (s i) :=
|
| 23 |
+
(Submodule.finrank_map_le ..).trans (sPin_dim ..)
|
| 24 |
+
exact ((Submodule.finrank_add_le_finrank_add_finrank ..).trans (add_le_add (hh _) (hh _))).trans_eq
|
| 25 |
+
(two_mul _).symm
|
| 26 |
+
|
| 27 |
+
theorem combined_rank (s t : Plan p n) : planRank (s⊔t)≤planRank s+planRank t := by
|
| 28 |
+
unfold planRank; rw [←Finset.sum_add_distrib]
|
| 29 |
+
exact Finset.sum_le_sum fun i _ => finrank_add_le_finrank_add_finrank ..
|
| 30 |
+
|
| 31 |
+
abbrev Signal (p : Shape) (N : ℕ) {n} (s : Plan p n) := DTuple (p:=p) (fun z => dim (s z)) N
|
| 32 |
+
|
| 33 |
+
def readPin (x : UnitType p n N) (a : Plan p n) : Signal p N a :=
|
| 34 |
+
fun z => images x z * pack (a z)
|
| 35 |
+
|
| 36 |
+
abbrev EffSeq {p : Shape} {n} (s : Plan p n) := ∀ i : Bool,effective s i
|
| 37 |
+
|
| 38 |
+
def entrySeq {p : Shape} {n} (s : Plan p n) (m : Bool → Profile p n) : EffSeq s :=
|
| 39 |
+
open scoped Classical in
|
| 40 |
+
fun i => if h : m i ∈ effective s i then ⟨_,h⟩ else 0
|
| 41 |
+
|
| 42 |
+
abbrev Story {p : Shape} {n N} (T : Cov p N) (s : Plan p n) :=
|
| 43 |
+
Daypair p T × Signal p N (front s) × EffSeq s
|
| 44 |
+
|
| 45 |
+
instance fintypeStory {s : Plan p n} {T : Cov p N} : Fintype (Story T s) := by
|
| 46 |
+
classical
|
| 47 |
+
let A := (coverX p T)
|
| 48 |
+
letI : Finite (Module.Dual F A) := Finite.of_injective _ DFunLike.coe_injective
|
| 49 |
+
letI : Fintype (Module.Dual F A) := Fintype.ofFinite _
|
| 50 |
+
letI : Fintype (Daypair p T) := inferInstanceAs (Fintype (Daypair p T))
|
| 51 |
+
letI : ∀ i,Fintype (effective s i) := fun i => Fintype.ofFinite _
|
| 52 |
+
letI : Fintype (EffSeq s) := inferInstanceAs (Fintype (EffSeq s))
|
| 53 |
+
letI : Fintype (Signal p N (front s)) := inferInstanceAs (Fintype (Signal p N (front s)))
|
| 54 |
+
exact inferInstanceAs (Fintype (Story T s))
|
| 55 |
+
|
| 56 |
+
def story (T : Cov p N) (s : Plan p n) (m : BMark p n N) (x : UnitType p n N) : Story T s :=
|
| 57 |
+
(daypair p T (delta m) (fun _ => 1) x,readPin x (front s),entrySeq s (m x))
|
| 58 |
+
|
| 59 |
+
def specialLeaf (T : Cov p N) (m : BMark p n N) (a : Pin p n N)
|
| 60 |
+
(G : CTile p n N) (b : Pin p n N) :=
|
| 61 |
+
a.sp ≤ b.sp ∧ front a.sp ≤ b.sp ∧
|
| 62 |
+
∀ x∈G,∀ y∈G, m x=m y ∧ delta m x=delta m y ∧
|
| 63 |
+
∀ i,juris p T x (unary i) = juris p T y (unary i)
|
| 64 |
+
|
| 65 |
+
private theorem storyOk (T : Cov p N) (m : BMark p n N)
|
| 66 |
+
(a : Pin p n N) (S : CTile p n N) (K : ℕ) (hk : planRank a.sp≤K)
|
| 67 |
+
(h : ∀ x∈S, a.agree x ∧ covered p T (delta m x) ∧
|
| 68 |
+
∀ i,m x i∈effective a.sp i) :
|
| 69 |
+
∀ i : Story T a.sp,∃ b : Pin p n N,
|
| 70 |
+
(∀ x∈ S,story T a.sp m x=i → b.agree x) ∧ planRank b.sp ≤ 3*K ∧
|
| 71 |
+
∀ c (G : CTile p n N), G.Nonempty →
|
| 72 |
+
(∀ x∈G,x∈S ∧ story T a.sp m x=i) → b.sp ≤ c.sp → specialLeaf T m a G c := by
|
| 73 |
+
classical
|
| 74 |
+
intro i
|
| 75 |
+
let A := a.sp ⊔ front a.sp
|
| 76 |
+
have hK : planRank A≤3*K := by
|
| 77 |
+
apply (combined_rank ..).trans
|
| 78 |
+
have hh := front_rank a.sp
|
| 79 |
+
omega
|
| 80 |
+
have h1 : ∃ x : UnitType p n N, ∀ y∈ S,story T a.sp m y=i → (Pin.make A x).agree y := by
|
| 81 |
+
by_cases hg : ∃ x∈S,story T a.sp m x=i
|
| 82 |
+
· obtain ⟨x,hx,he⟩ := hg
|
| 83 |
+
refine ⟨x,fun y hy ht => ?_⟩
|
| 84 |
+
let b := Pin.make (front a.sp) x
|
| 85 |
+
have hf : b.agree y := by
|
| 86 |
+
rw [Pin.agree_pack]; intro z
|
| 87 |
+
have hh : readPin y (front a.sp)=readPin x (front a.sp) :=
|
| 88 |
+
congrArg (fun x : Story T a.sp => x.2.1) (ht.trans he.symm)
|
| 89 |
+
exact congr_fun hh z
|
| 90 |
+
exact (Pin.combine (b:=b) (h x hx).1 (show b.agree x from fun _ _ _ => rfl)).mpr
|
| 91 |
+
⟨(h y hy).1,hf⟩
|
| 92 |
+
exact ⟨0,fun x hx he => (hg ⟨x,hx,he⟩).elim⟩
|
| 93 |
+
obtain ⟨x,hx⟩ := h1
|
| 94 |
+
refine ⟨Pin.make A x,hx,hK,fun c G hm hC hA => ⟨le_trans le_sup_left hA,
|
| 95 |
+
le_trans le_sup_right hA, fun x hx y hy => ?_⟩⟩
|
| 96 |
+
have he := (hC x hx).2.trans (hC y hy).2.symm
|
| 97 |
+
have hD := congrArg Prod.fst he
|
| 98 |
+
have hr z (hz : z∈G) : (story T a.sp m z).1.1.val=delta m z := by
|
| 99 |
+
unfold story daypair; change (cutDown p T (delta m) (fun _ => 1) z).val=_
|
| 100 |
+
unfold cutDown; rw [dite_eq_left ⟨(by norm_num),(h z (hC z hz).1).2.1⟩]
|
| 101 |
+
have ht z (hz : z∈G) (i) : ((story T a.sp m z).2.2 i).val=m z i := by
|
| 102 |
+
unfold story entrySeq; dsimp only
|
| 103 |
+
rw [dite_eq_left ((h z (hC z hz).1).2.2 i)]
|
| 104 |
+
refine ⟨funext (fun i => ?_),?_,fun i => ?_⟩
|
| 105 |
+
· rw [←ht x hx i,←ht y hy i,he]
|
| 106 |
+
· rw [←hr x hx, ←hr y hy,he]
|
| 107 |
+
exact congr_fun (congrArg Prod.snd hD) i
|
| 108 |
+
|
| 109 |
+
theorem story_size (T : Cov p N) (s : Plan p n) (K d : ℕ)
|
| 110 |
+
(hK : planRank s≤K) (hd : cdim p T≤d) :
|
| 111 |
+
num (Story T s) ≤ bp ((3*d+2*K : ℝ)*N + 2*K^2) := by
|
| 112 |
+
classical
|
| 113 |
+
have h1 : dim (coverX p T)≤ N*d := (cover_dim p T).trans (Nat.mul_le_mul_left N hd)
|
| 114 |
+
have h2 : dim (Daypair p T) ≤ 3*d*N := by
|
| 115 |
+
unfold dim Daypair
|
| 116 |
+
rw [finrank_prod,finrank_pi_fintype, Fintype.sum_bool,Subspace.dual_finrank_eq]
|
| 117 |
+
change dim _+(dim _+dim _) ≤ _
|
| 118 |
+
nlinarith
|
| 119 |
+
have h3 : dim (Signal p N (front s)) ≤ (2*K)*N := tuple_dim.trans_le (by
|
| 120 |
+
rw [mul_comm]; apply Nat.mul_le_mul_right
|
| 121 |
+
exact (front_rank s).trans (Nat.mul_le_mul_left _ hK))
|
| 122 |
+
have h4 : dim (EffSeq s)≤ 2*K^2 := by
|
| 123 |
+
unfold EffSeq dim
|
| 124 |
+
rw [finrank_pi_fintype,Fintype.sum_bool,two_mul]
|
| 125 |
+
have hh i : dim (effective s i) ≤ K^2 := (effective_dim ..).trans (by gcongr)
|
| 126 |
+
exact add_le_add (hh _) (hh _)
|
| 127 |
+
unfold num
|
| 128 |
+
rw [card_space]
|
| 129 |
+
apply bp_le
|
| 130 |
+
have hh : dim (Story T s)≤ (3*d+2*K)*N+2*K^2 := by
|
| 131 |
+
unfold Story dim; rw [finrank_prod, finrank_prod (M:=Signal p N (front s))]
|
| 132 |
+
change dim (Daypair p T)+(dim (Signal p N (front s))+dim (EffSeq s)) ≤ _
|
| 133 |
+
rw [Nat.add_mul,add_assoc]
|
| 134 |
+
exact add_le_add h2 (add_le_add h3 h4)
|
| 135 |
+
exact_mod_cast hh
|
| 136 |
+
|
| 137 |
+
theorem plan_inc_eff (s t : Plan p n) (h : s ≤ t) (i : Bool) :
|
| 138 |
+
effective s i≤effective t i := by
|
| 139 |
+
intro x hx
|
| 140 |
+
obtain ⟨h1,h2⟩ := effective_mem.mp hx
|
| 141 |
+
have he z : sPin s z i ≤ sPin t z i := Submodule.map_mono (h z)
|
| 142 |
+
exact effective_mem.mpr ⟨h1,fun z => box_le (he _) (he _) (h2 _)⟩
|
| 143 |
+
|
| 144 |
+
/-- Old contractions on admissible tables evaluate correctly when
|
| 145 |
+
the enlarged leaf has pinned the entire front. -/
|
| 146 |
+
theorem front_table (x y : UnitType p n N)
|
| 147 |
+
{a b : Pin p n N} (s : Plan p n)
|
| 148 |
+
(hf : front s≤a.sp)
|
| 149 |
+
{M : Cross p n} (hx : a.agree x) (hB : tableFlag b a (reciprocal p M) y)
|
| 150 |
+
(i j : Bool) (w : Profile p n) (h : w∈effective s i) :
|
| 151 |
+
contract p (actual p x y) i j w=contract p M i j w := by
|
| 152 |
+
have hz (z) (u : Dir p n) (hu : u∈a.sp z) :
|
| 153 |
+
channelOut p M j z *ᵥ u=channelOut p (actual p x y) j z *ᵥ u := by
|
| 154 |
+
refine channel_same j z u (fun v => ?_)
|
| 155 |
+
have h1 : IH p n j *ᵥ v∈tabSpace b.sp (flipZ p z) :=
|
| 156 |
+
channel_le_table b.sp _ _ ⟨_,rfl⟩
|
| 157 |
+
have h2 : u∈a.sp (flipZ p (flipZ p z)) := by rwa [flipZ_flip]
|
| 158 |
+
have he := hB (flipZ p z) _ h1 _ h2
|
| 159 |
+
have hg := flag_actual (a:=b) y x hx (flipZ p z) _ h1 _ h2
|
| 160 |
+
rw [← reciprocal_actual x y] at hg
|
| 161 |
+
simp only [reciprocal,flipZ_flip,evmat_transpose] at he hg
|
| 162 |
+
exact he.trans hg.symm
|
| 163 |
+
have he z : (sPin s z i).map (IP p n i).mulVecLin ≤ a.sp z := by
|
| 164 |
+
apply le_trans _ (hf z)
|
| 165 |
+
cases i; exact le_sup_right; exact le_sup_left
|
| 166 |
+
change ∑ e, _=_
|
| 167 |
+
refine Finset.sum_congr rfl fun e _ => ?_
|
| 168 |
+
refine (box_eval_iff (a.sp (e,true)) (a.sp (e,false)) _ _).mp ?_ _
|
| 169 |
+
(box_le (he _) (he _) (lift_mem_box _ _ ((effective_mem.mp h).2 e)))
|
| 170 |
+
intro x hx y hy
|
| 171 |
+
rw [ev_duom,ev_duom,hz _ _ hx,hz _ _ hy]
|
| 172 |
+
|
| 173 |
+
set_option maxHeartbeats 900000 in
|
| 174 |
+
theorem weave (P : UnitType p n N→Prop)
|
| 175 |
+
{w μ : Wgt (UnitType p n N)}
|
| 176 |
+
(m : BMark p n N) (T : Cov p N)
|
| 177 |
+
(hw : ∀ x,0≤w x) {D ζ u : ℝ} (hz : 0 < ζ) (hz' : ζ<1) {K K' d : ℕ}
|
| 178 |
+
(hn : 0<N)
|
| 179 |
+
(hμ : ∀ a : Pin p n N,pr μ a.agree ≤ fee N (ζ/4) (planRank a.sp))
|
| 180 |
+
(hd : cdim p T≤d)
|
| 181 |
+
{F : Canopy p n N} (hT : apart F) (g : CTile p n N → Pin p n N)
|
| 182 |
+
(h : ∀ i∈F,Ripe p w μ i (g i) D ζ K)
|
| 183 |
+
(hg : ∀ i∈ F,∀ x∈i,P x→covered p T (delta m x) ∧ ∀ j,m x j∈effective (g i).sp j)
|
| 184 |
+
(hk : D+u+ζ≤(ζ-ζ/4)*K')
|
| 185 |
+
(hu : (3*d+2*K:ℝ)*N+2*K^2 ≤ (u-1)*N) :
|
| 186 |
+
∃ V : Canopy p n N,apart V ∧
|
| 187 |
+
(∀ S∈V,∃ i∈F,S⊆i ∧ (∀ x∈ S,P x) ∧
|
| 188 |
+
∃ b : Pin p n N,Ripe p w μ S b (D+u+K'+1) ζ (3*K+K') ∧ specialLeaf T m (g i) S b) ∧
|
| 189 |
+
pr w (fun x => inTiles F x ∧ P x ∧ ¬inTiles V x) ≤
|
| 190 |
+
allMass w F*(bp (-(N:ℝ))+bp (-ζ*N)) := by
|
| 191 |
+
classical
|
| 192 |
+
refine improve F w hw P
|
| 193 |
+
(fun i S => (∀ x∈ S,P x) ∧ ∃ b : Pin p n N,Ripe p w μ S b (D+u+K'+1) ζ (3*K+K') ∧
|
| 194 |
+
specialLeaf T m (g i) S b)
|
| 195 |
+
hT (fun i hi => ?_)
|
| 196 |
+
let A := CTile p n N
|
| 197 |
+
let S := i.filter P
|
| 198 |
+
let Q := specialLeaf T m (g i)
|
| 199 |
+
have hs (x : UnitType p n N) : x∈S↔ x∈i∧ P x := Finset.mem_filter
|
| 200 |
+
have hq := h i hi
|
| 201 |
+
let w' := partW w i
|
| 202 |
+
have hw' : IsLaw w' := on_law hw hq.pos
|
| 203 |
+
have hg : ∀ x∈ S,(g i).agree x∧ covered p T (delta m x)∧∀ j,m x j∈effective (g i).sp j :=
|
| 204 |
+
fun x h => ⟨hq.fixpin _ ((hs ..).mp h).1,hg i hi x ((hs ..).mp h).1 ((hs ..).mp h).2⟩
|
| 205 |
+
obtain ⟨V,hV,hX,hZ⟩ := reparts w' μ hw' S D ζ u hn hz hz' hμ hq.density
|
| 206 |
+
(story T (g i).sp m) (3*K) K' Q
|
| 207 |
+
(storyOk T m (g i) S K hq.bound hg) hk
|
| 208 |
+
refine ⟨V,hV,fun x hx => ?_,?_⟩
|
| 209 |
+
· obtain ⟨hS,b,hB,hL⟩ := hX x hx
|
| 210 |
+
have hx' : x⊆i := hS.trans (Finset.filter_subset ..)
|
| 211 |
+
obtain ⟨he,hLaw⟩ := issued_law w hw hq.pos hx' hB.pos
|
| 212 |
+
refine ⟨hx', (fun z hz => ((hs ..).mp (hS hz)).2),b,⟨he,hB.fixpin,hB.bound,?_,?_⟩,hL⟩
|
| 213 |
+
· rw [hLaw]; exact hB.clear
|
| 214 |
+
rw [hLaw]; exact hB.density
|
| 215 |
+
simp_rw [hs,and_assoc] at hZ
|
| 216 |
+
refine hZ.trans (add_le_add_left ?_ _)
|
| 217 |
+
refine (mul_le_mul_of_nonneg_right (story_size T _ K d hq.bound hd) (bp_pos _).le).trans ?_
|
| 218 |
+
rw [←bp_add]; apply bp_le
|
| 219 |
+
linarith only [hu]
|
| 220 |
+
|
| 221 |
+
theorem phase_fixed (m : BMark p n N) (T : Cov p N)
|
| 222 |
+
(A A' B B' : Pin p n N) {S R : CTile p n N}
|
| 223 |
+
{x x' y y' : UnitType p n N}
|
| 224 |
+
(h : specialLeaf T m A S A') (hg : specialLeaf T m B R B')
|
| 225 |
+
(hx : x∈S) (hx' : x'∈S) (hy : y∈R) (hy' : y'∈R)
|
| 226 |
+
(hC : covered p T (delta m x)) (hC' : covered p T (delta m y)) :
|
| 227 |
+
quench p (delta m) (x,y)=quench p (delta m) (x',y') := by
|
| 228 |
+
obtain ⟨_,h1,h2⟩ := h.2.2 x hx x' hx'
|
| 229 |
+
obtain ⟨_,h3,h4⟩ := hg.2.2 y hy y' hy'
|
| 230 |
+
unfold quench; dsimp only
|
| 231 |
+
rw [← h1, ← h3]
|
| 232 |
+
exact Prod.ext
|
| 233 |
+
(funext fun i => LinearMap.congr_fun (h4 i) (⟨_,hC⟩ : coverX p T))
|
| 234 |
+
(funext fun i => LinearMap.congr_fun (h2 i) (⟨_,hC'⟩ : coverX p T))
|
| 235 |
+
|
| 236 |
+
end HadwigerCounterexample
|
| 237 |
+
|
| 238 |
+
end
|
| 239 |
+
|
| 240 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RefinementEnergy.lean
CHANGED
|
@@ -1,105 +1,105 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.InformationSmallSetBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Refinement Energy -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Filter Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C D : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype D]
|
| 12 |
-
|
| 13 |
-
theorem var_nonneg (p q : Wgt A) : 0≤ varOne p q := Finset.sum_nonneg fun _ _ => abs_nonneg _
|
| 14 |
-
theorem var_tri (p q r : Wgt A) :
|
| 15 |
-
varOne p q≤varOne p r+varOne r q := by
|
| 16 |
-
unfold varOne; rw [← Finset.sum_add_distrib]; exact sum_le_sum fun i _ => abs_sub_le _ _ _
|
| 17 |
-
|
| 18 |
-
theorem var_pr (p q : Wgt A) (P : A→Prop) :
|
| 19 |
-
pr p P-pr q P ≤ varOne p q := by
|
| 20 |
-
unfold pr avg varOne
|
| 21 |
-
rw [← Finset.sum_sub_distrib]
|
| 22 |
-
refine sum_le_sum fun i _ => ?_
|
| 23 |
-
by_cases h : P i
|
| 24 |
-
· simp only [ind_one h,mul_one]; exact le_abs_self _
|
| 25 |
-
simp only [ind_zero h,mul_zero,sub_zero]; exact abs_nonneg _
|
| 26 |
-
|
| 27 |
-
theorem var_event (p q : Wgt A) (h : tot p=tot q) :
|
| 28 |
-
let P := fun i => q i<p i
|
| 29 |
-
varOne p q=2*(pr p P-pr q P) := by
|
| 30 |
-
intro P
|
| 31 |
-
have hi (i:A) : |p i-q i|=
|
| 32 |
-
2*(p i*ind (P i)-q i*ind (P i))+q i-p i := by
|
| 33 |
-
by_cases h : P i
|
| 34 |
-
· rw [ind_one h,abs_of_pos (sub_pos.mpr h)]; ring
|
| 35 |
-
rw [ind_zero h,abs_of_nonpos (sub_nonpos.mpr (le_of_not_gt h))]; ring
|
| 36 |
-
unfold varOne pr avg
|
| 37 |
-
simp_rw [hi,Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum,
|
| 38 |
-
Finset.sum_sub_distrib]
|
| 39 |
-
rw [show ∑ i,q i=∑ i,p i from h.symm]; ring
|
| 40 |
-
|
| 41 |
-
theorem var_mix {μ : Wgt A} (p q : A→Wgt B) (hμ : ∀ i,0≤μ i) :
|
| 42 |
-
varOne (mixW μ p) (mixW μ q) ≤ avg μ (fun i => varOne (p i) (q i)) := by
|
| 43 |
-
unfold varOne mixW
|
| 44 |
-
rw [avg_sum]
|
| 45 |
-
simp_rw [←avg_sub]; exact sum_le_sum fun i _ => abs_avg_le hμ
|
| 46 |
-
|
| 47 |
-
omit [Fintype D] in
|
| 48 |
-
theorem bucket_m (μ : Wgt A) (p : A → Wgt B) (f : B→C) (g : C→D) :
|
| 49 |
-
mapW (bucket unif (g∘f) (mixW μ p)) f =
|
| 50 |
-
mixW μ (fun x => bucket (mapW unif f) g (mapW (p x) f)) := by
|
| 51 |
-
rw [bucket_mix,map_mix]
|
| 52 |
-
simp only [bucket_nested]
|
| 53 |
-
|
| 54 |
-
variable {μ : Wgt A} {p : A→Wgt B}
|
| 55 |
-
|
| 56 |
-
theorem tariffs_monotone {r s : ℕ} {a b V : ℝ} (h : tariffs μ p r a V)
|
| 57 |
-
(hrs : s≤r) (hb : a ≤ b) : tariffs μ p s b V :=
|
| 58 |
-
fun C _ hC f hf => h C (hC.trans hrs) f (fun _ hi => hb.trans (hf _ hi))
|
| 59 |
-
|
| 60 |
-
theorem budget_nonneg [Nonempty B] (h : Ultra μ p) (f : B→ C) :
|
| 61 |
-
0≤budget μ p f := by
|
| 62 |
-
have h0 {p : Wgt B} : lsupp p unif := fun i _ => by rw [unif_apply]; positivity
|
| 63 |
-
have hv : IsLaw (mapW unif f) := mapW_law unif_law f
|
| 64 |
-
exact avg_nonneg h.law.nz (fun i => tension_nonneg (mapW_law (h.labs i) f) hv
|
| 65 |
-
(lsupp.map h0 unif_law.nz f))
|
| 66 |
-
|
| 67 |
-
set_option maxHeartbeats 800000 in
|
| 68 |
-
theorem budget_progress [Nonempty B] (h : Ultra μ p) (w : Wgt B)
|
| 69 |
-
(hw : catalog μ p w) (f : B→C) (g : C→D) :
|
| 70 |
-
varOne (mapW w f) (mapW (bucket unif (g∘f) w) f) ^ 2 ≤
|
| 71 |
-
(budget μ p f-budget μ p (g∘f))*4 := by
|
| 72 |
-
classical
|
| 73 |
-
let q := mapW unif f
|
| 74 |
-
let Q (i : A) := mapW (p i) f
|
| 75 |
-
let R (i : A) := bucket q g (Q i)
|
| 76 |
-
have hu : IsLaw q := mapW_law unif_law f
|
| 77 |
-
have hQ (i) : IsLaw (Q i) := mapW_law (h.labs i) f
|
| 78 |
-
have he (i) : lsupp (Q i) q := lsupp.map
|
| 79 |
-
(p:=p i) (q:=unif) (fun i _ => by rw [unif_apply]; positivity) unif_law.nz f
|
| 80 |
-
have hp (i : A) :
|
| 81 |
-
varOne (Q i) (R i) ^ 2 ≤ tension (Q i) (R i) *4 :=
|
| 82 |
-
var_tension _ _ (hQ i) (bucket_law (hQ i) g hu.nz (he i))
|
| 83 |
-
(lsupp_bucket g (hQ i).nz hu.nz (he i))
|
| 84 |
-
have hn :
|
| 85 |
-
budget μ p f=avg μ (fun i => tension (Q i) (R i))+budget μ p (g∘f) := by
|
| 86 |
-
unfold budget
|
| 87 |
-
have hi := fun i : A => tension_stage (Q i) q (hQ i).nz hu.nz (he i) g
|
| 88 |
-
unfold Q q at hi
|
| 89 |
-
simp_rw [map_nested] at hi
|
| 90 |
-
rw [← avg_add]; exact avg_congr fun i _ => hi i
|
| 91 |
-
let Z (i : A) := varOne (Q i) (R i)
|
| 92 |
-
have hs : avg μ Z ^ 2 ≤ avg μ (fun i => Z i ^ 2) := by
|
| 93 |
-
have hh := avg_CS h.law.nz Z (fun _ => 1)
|
| 94 |
-
simp only [mul_one,one_pow,h.law.avg_const] at hh; exact hh
|
| 95 |
-
obtain ⟨s,hs',ht,rfl⟩ := hw
|
| 96 |
-
rw [bucket_m,map_mix]
|
| 97 |
-
have h' := (var_mix Q R hs').trans (avg_mono_left (fun i => var_nonneg ..) ht)
|
| 98 |
-
refine (pow_le_pow_left₀ (var_nonneg ..) h' 2).trans (hs.trans ?_)
|
| 99 |
-
have hz := avg_mono h.law.nz hp; rw [avg_mul] at hz
|
| 100 |
-
rw [hn]; exact hz.trans_eq (by ring)
|
| 101 |
-
end HadwigerCounterexample
|
| 102 |
-
|
| 103 |
-
end
|
| 104 |
-
|
| 105 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.InformationSmallSetBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Refinement Energy -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Filter Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C D : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype D]
|
| 12 |
+
|
| 13 |
+
theorem var_nonneg (p q : Wgt A) : 0≤ varOne p q := Finset.sum_nonneg fun _ _ => abs_nonneg _
|
| 14 |
+
theorem var_tri (p q r : Wgt A) :
|
| 15 |
+
varOne p q≤varOne p r+varOne r q := by
|
| 16 |
+
unfold varOne; rw [← Finset.sum_add_distrib]; exact sum_le_sum fun i _ => abs_sub_le _ _ _
|
| 17 |
+
|
| 18 |
+
theorem var_pr (p q : Wgt A) (P : A→Prop) :
|
| 19 |
+
pr p P-pr q P ≤ varOne p q := by
|
| 20 |
+
unfold pr avg varOne
|
| 21 |
+
rw [← Finset.sum_sub_distrib]
|
| 22 |
+
refine sum_le_sum fun i _ => ?_
|
| 23 |
+
by_cases h : P i
|
| 24 |
+
· simp only [ind_one h,mul_one]; exact le_abs_self _
|
| 25 |
+
simp only [ind_zero h,mul_zero,sub_zero]; exact abs_nonneg _
|
| 26 |
+
|
| 27 |
+
theorem var_event (p q : Wgt A) (h : tot p=tot q) :
|
| 28 |
+
let P := fun i => q i<p i
|
| 29 |
+
varOne p q=2*(pr p P-pr q P) := by
|
| 30 |
+
intro P
|
| 31 |
+
have hi (i:A) : |p i-q i|=
|
| 32 |
+
2*(p i*ind (P i)-q i*ind (P i))+q i-p i := by
|
| 33 |
+
by_cases h : P i
|
| 34 |
+
· rw [ind_one h,abs_of_pos (sub_pos.mpr h)]; ring
|
| 35 |
+
rw [ind_zero h,abs_of_nonpos (sub_nonpos.mpr (le_of_not_gt h))]; ring
|
| 36 |
+
unfold varOne pr avg
|
| 37 |
+
simp_rw [hi,Finset.sum_sub_distrib,Finset.sum_add_distrib,← Finset.mul_sum,
|
| 38 |
+
Finset.sum_sub_distrib]
|
| 39 |
+
rw [show ∑ i,q i=∑ i,p i from h.symm]; ring
|
| 40 |
+
|
| 41 |
+
theorem var_mix {μ : Wgt A} (p q : A→Wgt B) (hμ : ∀ i,0≤μ i) :
|
| 42 |
+
varOne (mixW μ p) (mixW μ q) ≤ avg μ (fun i => varOne (p i) (q i)) := by
|
| 43 |
+
unfold varOne mixW
|
| 44 |
+
rw [avg_sum]
|
| 45 |
+
simp_rw [←avg_sub]; exact sum_le_sum fun i _ => abs_avg_le hμ
|
| 46 |
+
|
| 47 |
+
omit [Fintype D] in
|
| 48 |
+
theorem bucket_m (μ : Wgt A) (p : A → Wgt B) (f : B→C) (g : C→D) :
|
| 49 |
+
mapW (bucket unif (g∘f) (mixW μ p)) f =
|
| 50 |
+
mixW μ (fun x => bucket (mapW unif f) g (mapW (p x) f)) := by
|
| 51 |
+
rw [bucket_mix,map_mix]
|
| 52 |
+
simp only [bucket_nested]
|
| 53 |
+
|
| 54 |
+
variable {μ : Wgt A} {p : A→Wgt B}
|
| 55 |
+
|
| 56 |
+
theorem tariffs_monotone {r s : ℕ} {a b V : ℝ} (h : tariffs μ p r a V)
|
| 57 |
+
(hrs : s≤r) (hb : a ≤ b) : tariffs μ p s b V :=
|
| 58 |
+
fun C _ hC f hf => h C (hC.trans hrs) f (fun _ hi => hb.trans (hf _ hi))
|
| 59 |
+
|
| 60 |
+
theorem budget_nonneg [Nonempty B] (h : Ultra μ p) (f : B→ C) :
|
| 61 |
+
0≤budget μ p f := by
|
| 62 |
+
have h0 {p : Wgt B} : lsupp p unif := fun i _ => by rw [unif_apply]; positivity
|
| 63 |
+
have hv : IsLaw (mapW unif f) := mapW_law unif_law f
|
| 64 |
+
exact avg_nonneg h.law.nz (fun i => tension_nonneg (mapW_law (h.labs i) f) hv
|
| 65 |
+
(lsupp.map h0 unif_law.nz f))
|
| 66 |
+
|
| 67 |
+
set_option maxHeartbeats 800000 in
|
| 68 |
+
theorem budget_progress [Nonempty B] (h : Ultra μ p) (w : Wgt B)
|
| 69 |
+
(hw : catalog μ p w) (f : B→C) (g : C→D) :
|
| 70 |
+
varOne (mapW w f) (mapW (bucket unif (g∘f) w) f) ^ 2 ≤
|
| 71 |
+
(budget μ p f-budget μ p (g∘f))*4 := by
|
| 72 |
+
classical
|
| 73 |
+
let q := mapW unif f
|
| 74 |
+
let Q (i : A) := mapW (p i) f
|
| 75 |
+
let R (i : A) := bucket q g (Q i)
|
| 76 |
+
have hu : IsLaw q := mapW_law unif_law f
|
| 77 |
+
have hQ (i) : IsLaw (Q i) := mapW_law (h.labs i) f
|
| 78 |
+
have he (i) : lsupp (Q i) q := lsupp.map
|
| 79 |
+
(p:=p i) (q:=unif) (fun i _ => by rw [unif_apply]; positivity) unif_law.nz f
|
| 80 |
+
have hp (i : A) :
|
| 81 |
+
varOne (Q i) (R i) ^ 2 ≤ tension (Q i) (R i) *4 :=
|
| 82 |
+
var_tension _ _ (hQ i) (bucket_law (hQ i) g hu.nz (he i))
|
| 83 |
+
(lsupp_bucket g (hQ i).nz hu.nz (he i))
|
| 84 |
+
have hn :
|
| 85 |
+
budget μ p f=avg μ (fun i => tension (Q i) (R i))+budget μ p (g∘f) := by
|
| 86 |
+
unfold budget
|
| 87 |
+
have hi := fun i : A => tension_stage (Q i) q (hQ i).nz hu.nz (he i) g
|
| 88 |
+
unfold Q q at hi
|
| 89 |
+
simp_rw [map_nested] at hi
|
| 90 |
+
rw [← avg_add]; exact avg_congr fun i _ => hi i
|
| 91 |
+
let Z (i : A) := varOne (Q i) (R i)
|
| 92 |
+
have hs : avg μ Z ^ 2 ≤ avg μ (fun i => Z i ^ 2) := by
|
| 93 |
+
have hh := avg_CS h.law.nz Z (fun _ => 1)
|
| 94 |
+
simp only [mul_one,one_pow,h.law.avg_const] at hh; exact hh
|
| 95 |
+
obtain ⟨s,hs',ht,rfl⟩ := hw
|
| 96 |
+
rw [bucket_m,map_mix]
|
| 97 |
+
have h' := (var_mix Q R hs').trans (avg_mono_left (fun i => var_nonneg ..) ht)
|
| 98 |
+
refine (pow_le_pow_left₀ (var_nonneg ..) h' 2).trans (hs.trans ?_)
|
| 99 |
+
have hz := avg_mono h.law.nz hp; rw [avg_mul] at hz
|
| 100 |
+
rw [hn]; exact hz.trans_eq (by ring)
|
| 101 |
+
end HadwigerCounterexample
|
| 102 |
+
|
| 103 |
+
end
|
| 104 |
+
|
| 105 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ReindexedFourierSupport.lean
CHANGED
|
@@ -1,73 +1,73 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.TesterFourierSupport
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Reindexed Fourier Support -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix Module LinearMap Submodule Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ} {I : Type} [Fintype I]
|
| 12 |
-
|
| 13 |
-
namespace Move
|
| 14 |
-
variable (c : Flit n) {j k : Vec (Fin n)}
|
| 15 |
-
def jumpV : Vec (Fin n) ≃ Vec (Fin n) where
|
| 16 |
-
toFun := c.L.mulVec
|
| 17 |
-
invFun := c.R.mulVec
|
| 18 |
-
left_inv x := by change c.R*ᵥ(c.L *ᵥ x) = x; rw [mulVec_mulVec,c.RL,Matrix.one_mulVec]
|
| 19 |
-
right_inv x := by change c.L*ᵥ(c.R *ᵥ x) = x; rw [mulVec_mulVec,c.LR,Matrix.one_mulVec]
|
| 20 |
-
def zreroute (p : Shape) (c : Flit n) (f : Wgt (Knobs p.g n)) :=
|
| 21 |
-
fun y => f ((vault p c).symm y)
|
| 22 |
-
|
| 23 |
-
theorem zhat_jump (p : Shape) (c : Flit n) (f : Wgt (Knobs p.g n)) (y : Knobs p.g n)
|
| 24 |
-
(x : Vec (Fin n)) :
|
| 25 |
-
zhat p (zreroute p c f) y (c.dual.jumpV x)=zhat p f y x := by
|
| 26 |
-
classical
|
| 27 |
-
unfold zhat
|
| 28 |
-
rw [← avg_bij c.jumpV]
|
| 29 |
-
have he (z : Vec (Fin n)) : unif (c.jumpV z)=unif z := rfl
|
| 30 |
-
have hh (z) :
|
| 31 |
-
vectorPhase (c.dual.jumpV x) (c.jumpV z)= vectorPhase x z := by
|
| 32 |
-
unfold vectorPhase
|
| 33 |
-
change wsign (dotProduct (c.Rᵀ *ᵥ x) (c.L *ᵥ z))=_
|
| 34 |
-
rw [dotProduct_comm, dotProduct_transpose_mulVec,mulVec_mulVec,c.RL, Matrix.one_mulVec]
|
| 35 |
-
have ht (z) :
|
| 36 |
-
zreroute p c f (update y Block.Z (c.jumpV z))=f (update y Block.Z z) := by
|
| 37 |
-
unfold zreroute vault; simp only [doZ,Equiv.coe_fn_symm_mk,update_self]
|
| 38 |
-
change f (update (update y Block.Z _) _ (c.jumpV.symm (c.jumpV z)))=_
|
| 39 |
-
rw [Equiv.symm_apply_apply]; simp
|
| 40 |
-
simp_rw [he,hh,ht]
|
| 41 |
-
|
| 42 |
-
theorem jump_in (c : Flit n) (S : Space (Vec (Fin n))) {z} (h : z ∈ S) :
|
| 43 |
-
c.dual.jumpV z∈c.plume S := by
|
| 44 |
-
rw [←colSp_pack S] at h
|
| 45 |
-
obtain ⟨u,h⟩ := h
|
| 46 |
-
refine ⟨u,?_⟩
|
| 47 |
-
change (c.Rᵀ*pack S)*ᵥu=c.dual.jumpV z
|
| 48 |
-
rw [← mulVec_mulVec,show pack S *ᵥ u=z from h]
|
| 49 |
-
rfl
|
| 50 |
-
end Move
|
| 51 |
-
|
| 52 |
-
namespace Template
|
| 53 |
-
variable (v : Solo p)
|
| 54 |
-
|
| 55 |
-
def rotor (v : Solo p) (c : Flit n) (m : Mixer p n) (x : Profile p n) :=
|
| 56 |
-
Move.zreroute p c (v.shanty m x)
|
| 57 |
-
theorem rotor_budget (v : Solo p) (c : Flit n) (m : Mixer p n) (x : Profile p n)
|
| 58 |
-
(K s : ℕ) (hg : Odd p.g) (hm : unaryGood m K s) (hK : totalRank x≤K) (hx : 0<totalRank x)
|
| 59 |
-
(u : Knobs p.g n) (i : Vec (Fin n)) :
|
| 60 |
-
|zchar p (v.rotor c m x) i u|≤bp (-((p.J-s:ℕ):ℝ)) ∧
|
| 61 |
-
(i ∉ c.plume (v.scroll m x) → zchar p (v.rotor c m x) i u=0) := by
|
| 62 |
-
classical
|
| 63 |
-
obtain ⟨i,rfl⟩ := c.dual.jumpV.surjective i
|
| 64 |
-
unfold zchar rotor
|
| 65 |
-
rw [Move.zhat_jump,abs_mul,vectorPhase,wsign_abs,mul_one]
|
| 66 |
-
exact ⟨shanty_cap v m x K s hg hm hK hx u i,fun h =>
|
| 67 |
-
mul_eq_zero_of_left (shanty_outer v m x u hg i (fun he => h (Move.jump_in c _ he))) _⟩
|
| 68 |
-
end Template
|
| 69 |
-
end HadwigerCounterexample
|
| 70 |
-
|
| 71 |
-
end
|
| 72 |
-
|
| 73 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.TesterFourierSupport
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Reindexed Fourier Support -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix Module LinearMap Submodule Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ} {I : Type} [Fintype I]
|
| 12 |
+
|
| 13 |
+
namespace Move
|
| 14 |
+
variable (c : Flit n) {j k : Vec (Fin n)}
|
| 15 |
+
def jumpV : Vec (Fin n) ≃ Vec (Fin n) where
|
| 16 |
+
toFun := c.L.mulVec
|
| 17 |
+
invFun := c.R.mulVec
|
| 18 |
+
left_inv x := by change c.R*ᵥ(c.L *ᵥ x) = x; rw [mulVec_mulVec,c.RL,Matrix.one_mulVec]
|
| 19 |
+
right_inv x := by change c.L*ᵥ(c.R *ᵥ x) = x; rw [mulVec_mulVec,c.LR,Matrix.one_mulVec]
|
| 20 |
+
def zreroute (p : Shape) (c : Flit n) (f : Wgt (Knobs p.g n)) :=
|
| 21 |
+
fun y => f ((vault p c).symm y)
|
| 22 |
+
|
| 23 |
+
theorem zhat_jump (p : Shape) (c : Flit n) (f : Wgt (Knobs p.g n)) (y : Knobs p.g n)
|
| 24 |
+
(x : Vec (Fin n)) :
|
| 25 |
+
zhat p (zreroute p c f) y (c.dual.jumpV x)=zhat p f y x := by
|
| 26 |
+
classical
|
| 27 |
+
unfold zhat
|
| 28 |
+
rw [← avg_bij c.jumpV]
|
| 29 |
+
have he (z : Vec (Fin n)) : unif (c.jumpV z)=unif z := rfl
|
| 30 |
+
have hh (z) :
|
| 31 |
+
vectorPhase (c.dual.jumpV x) (c.jumpV z)= vectorPhase x z := by
|
| 32 |
+
unfold vectorPhase
|
| 33 |
+
change wsign (dotProduct (c.Rᵀ *ᵥ x) (c.L *ᵥ z))=_
|
| 34 |
+
rw [dotProduct_comm, dotProduct_transpose_mulVec,mulVec_mulVec,c.RL, Matrix.one_mulVec]
|
| 35 |
+
have ht (z) :
|
| 36 |
+
zreroute p c f (update y Block.Z (c.jumpV z))=f (update y Block.Z z) := by
|
| 37 |
+
unfold zreroute vault; simp only [doZ,Equiv.coe_fn_symm_mk,update_self]
|
| 38 |
+
change f (update (update y Block.Z _) _ (c.jumpV.symm (c.jumpV z)))=_
|
| 39 |
+
rw [Equiv.symm_apply_apply]; simp
|
| 40 |
+
simp_rw [he,hh,ht]
|
| 41 |
+
|
| 42 |
+
theorem jump_in (c : Flit n) (S : Space (Vec (Fin n))) {z} (h : z ∈ S) :
|
| 43 |
+
c.dual.jumpV z∈c.plume S := by
|
| 44 |
+
rw [←colSp_pack S] at h
|
| 45 |
+
obtain ⟨u,h⟩ := h
|
| 46 |
+
refine ⟨u,?_⟩
|
| 47 |
+
change (c.Rᵀ*pack S)*ᵥu=c.dual.jumpV z
|
| 48 |
+
rw [← mulVec_mulVec,show pack S *ᵥ u=z from h]
|
| 49 |
+
rfl
|
| 50 |
+
end Move
|
| 51 |
+
|
| 52 |
+
namespace Template
|
| 53 |
+
variable (v : Solo p)
|
| 54 |
+
|
| 55 |
+
def rotor (v : Solo p) (c : Flit n) (m : Mixer p n) (x : Profile p n) :=
|
| 56 |
+
Move.zreroute p c (v.shanty m x)
|
| 57 |
+
theorem rotor_budget (v : Solo p) (c : Flit n) (m : Mixer p n) (x : Profile p n)
|
| 58 |
+
(K s : ℕ) (hg : Odd p.g) (hm : unaryGood m K s) (hK : totalRank x≤K) (hx : 0<totalRank x)
|
| 59 |
+
(u : Knobs p.g n) (i : Vec (Fin n)) :
|
| 60 |
+
|zchar p (v.rotor c m x) i u|≤bp (-((p.J-s:ℕ):ℝ)) ∧
|
| 61 |
+
(i ∉ c.plume (v.scroll m x) → zchar p (v.rotor c m x) i u=0) := by
|
| 62 |
+
classical
|
| 63 |
+
obtain ⟨i,rfl⟩ := c.dual.jumpV.surjective i
|
| 64 |
+
unfold zchar rotor
|
| 65 |
+
rw [Move.zhat_jump,abs_mul,vectorPhase,wsign_abs,mul_one]
|
| 66 |
+
exact ⟨shanty_cap v m x K s hg hm hK hx u i,fun h =>
|
| 67 |
+
mul_eq_zero_of_left (shanty_outer v m x u hg i (fun he => h (Move.jump_in c _ he))) _⟩
|
| 68 |
+
end Template
|
| 69 |
+
end HadwigerCounterexample
|
| 70 |
+
|
| 71 |
+
end
|
| 72 |
+
|
| 73 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RelationMismatchBounds.lean
CHANGED
|
@@ -1,129 +1,129 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteDualSystems
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Relation Mismatch Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Matrix Finset Function Submodule LinearMap
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
open Template
|
| 12 |
-
variable {p:Shape} {N n r K : ℕ}
|
| 13 |
-
namespace StatusAnalysis
|
| 14 |
-
namespace DualAnalysis
|
| 15 |
-
open Club Guild
|
| 16 |
-
variable {d e : Rates}
|
| 17 |
-
{u:Terrain p r} {s:Gazette p r d} {t:Gazette p r e}
|
| 18 |
-
{β η δ:ℝ}
|
| 19 |
-
|
| 20 |
-
def seeking (p : Shape) (A : Stalls p) :=
|
| 21 |
-
∀ i, (A i).card+902 < Fintype.card (Label p.b)
|
| 22 |
-
theorem any_label (A : Finset (Label p.b)) (h : A.card<Fintype.card (Label p.b)) :
|
| 23 |
-
∃ x,x∉A := by
|
| 24 |
-
by_contra! hh
|
| 25 |
-
have hf := card_le_card (show univ ⊆ A from fun _ _=>hh _)
|
| 26 |
-
rw [card_univ] at hf; exact h.not_ge hf
|
| 27 |
-
|
| 28 |
-
theorem generic_apt (p:Shape) (hg:3≤p.g) (x:Appearance p) (hx:x.f=Flavor.full) :
|
| 29 |
-
x.apt := by obtain ⟨s,h1,h2,h3⟩:=generic_summary p hg x.l x.q 0; exact ⟨s,hx ▸ h1,h2⟩
|
| 30 |
-
|
| 31 |
-
set_option maxHeartbeats 900000 in
|
| 32 |
-
theorem plenitude (h:origami p r u δ) (hs:reports p r u s β δ) (ht:reports p r u t β δ)
|
| 33 |
-
(hg:3 ≤ p.g) (A B:Stalls p) (hk:seeking p A) (hl:seeking p B)
|
| 34 |
-
(hβ:0<β) (hz:0<η) (hη : playbook p K*η<1/2*β^2)
|
| 35 |
-
(hd:∀ i,d i≤K^2) (he:∀ i,e i≤K^2):
|
| 36 |
-
Guild.rich (stellar u s t η A B) := by
|
| 37 |
-
classical
|
| 38 |
-
intro i S hu y
|
| 39 |
-
have hh a (b:Finset (Label p.b)) (h : b.card+902<Fintype.card (Label p.b)):
|
| 40 |
-
∃ z,z∉b∧z∉S a := by
|
| 41 |
-
obtain ⟨z,hz⟩:=any_label (b∪S a) ((card_union_le ..).trans_lt ((Nat.add_le_add_left
|
| 42 |
-
(hu a) _).trans_lt h))
|
| 43 |
-
exact ⟨z,fun ht=>hz (mem_union_left _ ht),fun ht=>hz (mem_union_right _ ht)⟩
|
| 44 |
-
obtain ⟨v,h1,h2⟩:= hh true (A i.1) (hk _)
|
| 45 |
-
obtain ⟨w,h3,h4⟩:= hh false (B i.2) (hl _)
|
| 46 |
-
let x : Zodiac p:= ⟨⟨0,by omega⟩,y.1,fun i=>if i then v else w,fun _=>Flavor.full⟩
|
| 47 |
-
have hh : x.common:= fun i=> generic_apt p hg _ rfl
|
| 48 |
-
obtain ⟨W,hA,hB,hC⟩:= sturdy_contact u s t h hs ht hβ x hh (fun _=>rfl) i y.2.1 y.2.2 hz
|
| 49 |
-
((mul_le_mul_of_nonneg_right (booklet_cap p K _ _ (hd _) (he _)) hz.le).trans_lt hη)
|
| 50 |
-
refine ⟨(x,W),⟨⟨h1,h3,hA⟩,fun i=>?_⟩,?_⟩
|
| 51 |
-
· cases i; exact h4; exact h2
|
| 52 |
-
exact Prod.ext rfl (Prod.ext hB hC)
|
| 53 |
-
|
| 54 |
-
structure RhymeSet (d : ℕ) where
|
| 55 |
-
bit : F
|
| 56 |
-
coal : Cell d
|
| 57 |
-
headBit : F
|
| 58 |
-
gamma : F
|
| 59 |
-
|
| 60 |
-
def RhymeSet.read {k : ℕ} (s:RhymeSet k) (q:F) (x: Whole k) :=
|
| 61 |
-
s.bit*x.2+ dotProduct s.coal x.1.2+ (s.bit+s.headBit)*x.1.1+s.gamma*q
|
| 62 |
-
|
| 63 |
-
def RhymeSet.soot {k : ℕ} (s:RhymeSet k) {p:Shape} (x:Appearance p) (y:Magazine p k) :=
|
| 64 |
-
s.read x.q y.2
|
| 65 |
-
|
| 66 |
-
def leftChime (q:DualCoefficients d e) (i:Grid) : RhymeSet (d i.1) :=
|
| 67 |
-
⟨q.left i.2,q.north i,q.hed i,0⟩
|
| 68 |
-
def rightChime (q:DualCoefficients d e) (i:Grid) : RhymeSet (e i.2) :=
|
| 69 |
-
⟨q.right i.1,q.south i,q.hed i,q.gam i⟩
|
| 70 |
-
set_option maxHeartbeats 900000 in
|
| 71 |
-
theorem dual_eq (q:DualCoefficients d e) (V : StatusSp d e) (hq:q.law V)
|
| 72 |
-
(i:Grid) (x:Suite d e i) (hx:x∈V i) :
|
| 73 |
-
(leftChime q i).read x.1 x.2.1=(rightChime q i).read x.1 x.2.2 := by
|
| 74 |
-
classical
|
| 75 |
-
specialize hq i x hx
|
| 76 |
-
rcases x with ⟨a,⟨⟨b,u⟩,s⟩,⟨c,v⟩,t⟩
|
| 77 |
-
let f:= q.hed i; let W:= dotProduct (q.north i) u
|
| 78 |
-
let Z:= dotProduct (q.south i) v
|
| 79 |
-
let g:=q.left i.2; let h:=q.right i.1; let G:=q.gam i*a
|
| 80 |
-
change G+f*(b+c)+(W+Z)=g*(b+s)+h*(c+t) at hq
|
| 81 |
-
change g*s+W+(g+f)*b+0*_ = h*t+Z+(h+f)*c+G
|
| 82 |
-
apply sub_eq_zero.mp
|
| 83 |
-
rw [ZModModule.sub_eq_add]
|
| 84 |
-
calc _
|
| 85 |
-
_=(G+f*(b+c)+(W+Z))+(g*(b+s)+h*(c+t)):=by ring
|
| 86 |
-
_=0:= by rw [hq,char_two]
|
| 87 |
-
|
| 88 |
-
def charge (u:Terrain p r) (x: Zodiac p) (X:Gazette p r d) (Y:Gazette p r e)
|
| 89 |
-
(i:Grid) (a:RhymeSet (d i.1)) (b:RhymeSet (e i.2)) :=
|
| 90 |
-
pr (circlet u X Y x i) (fun y=>a.soot (x.aspect true) y.1≠ b.soot (x.aspect false) y.2)
|
| 91 |
-
|
| 92 |
-
def outstraps (a:Stalls p) (s:Straps (Label p.b)) (b:Bool):Stalls p:=
|
| 93 |
-
fun i=>a i∪s b
|
| 94 |
-
|
| 95 |
-
set_option maxHeartbeats 900000 in
|
| 96 |
-
theorem charge_counter (h:origami p r u δ) (hs:reports p r u s β δ) (ht:reports p r u t β δ)
|
| 97 |
-
(A B:Stalls p) (S : Straps (Label p.b)) (q:DualCoefficients d e)
|
| 98 |
-
(he:q.law (chapter (stellar u s t η A B) S)) (hη:0≤η)
|
| 99 |
-
(x: Zodiac p) (i:Grid) (hx:x.common) (hk:x.s true∉outstraps A S true i.1)
|
| 100 |
-
(hl:x.s false∉outstraps B S false i.2) :
|
| 101 |
-
charge u x s t i (leftChime q i) (rightChime q i)≤ num (Touch p d e i)*η := by
|
| 102 |
-
classical
|
| 103 |
-
let W:=circlet u s t x i
|
| 104 |
-
obtain ⟨hm,hn⟩:=circlet_state u s t h hs ht x hx i
|
| 105 |
-
let P:=fun y : Touch p d e i=> (leftChime q i).soot (x.aspect true) y.1≠
|
| 106 |
-
(rightChime q i).soot (x.aspect false) y.2
|
| 107 |
-
have hh (y): W y*ind (P y)≤η := by
|
| 108 |
-
by_cases hp : P y
|
| 109 |
-
· rw [ind_one hp,mul_one]
|
| 110 |
-
by_contra! hy
|
| 111 |
-
let C:=stellar u s t η A B
|
| 112 |
-
let v : Scriptum p d e i := (x,y)
|
| 113 |
-
have heq : (x.aspect true).fitsink y.1∧ (x.aspect false).fitsink y.2 := not_not.mp
|
| 114 |
-
(fun h=> (hη.trans_lt hy).ne' (hn y h))
|
| 115 |
-
have ht : (C i).zone S v :=
|
| 116 |
-
⟨⟨fun h=>hk (mem_union_left _ h),fun h=>hl (mem_union_left _ h),hx,heq.1,heq.2,hy.le⟩,
|
| 117 |
-
fun i=>by cases i; exact fun h=>hl (mem_union_right _ h); exact fun h=>hk (mem_union_right _ h)⟩
|
| 118 |
-
exact hp (dual_eq q (chapter C S) he i ((C i).writes v) ((C i).band_write S ht))
|
| 119 |
-
rw [ind_zero hp,mul_zero]; exact hη
|
| 120 |
-
change pr W P≤ _
|
| 121 |
-
exact (Finset.sum_le_sum fun i _=> hh i).trans_eq (by simp [num])
|
| 122 |
-
|
| 123 |
-
end DualAnalysis
|
| 124 |
-
end StatusAnalysis
|
| 125 |
-
end HadwigerCounterexample
|
| 126 |
-
|
| 127 |
-
end
|
| 128 |
-
|
| 129 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteDualSystems
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Relation Mismatch Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Matrix Finset Function Submodule LinearMap
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
open Template
|
| 12 |
+
variable {p:Shape} {N n r K : ℕ}
|
| 13 |
+
namespace StatusAnalysis
|
| 14 |
+
namespace DualAnalysis
|
| 15 |
+
open Club Guild
|
| 16 |
+
variable {d e : Rates}
|
| 17 |
+
{u:Terrain p r} {s:Gazette p r d} {t:Gazette p r e}
|
| 18 |
+
{β η δ:ℝ}
|
| 19 |
+
|
| 20 |
+
def seeking (p : Shape) (A : Stalls p) :=
|
| 21 |
+
∀ i, (A i).card+902 < Fintype.card (Label p.b)
|
| 22 |
+
theorem any_label (A : Finset (Label p.b)) (h : A.card<Fintype.card (Label p.b)) :
|
| 23 |
+
∃ x,x∉A := by
|
| 24 |
+
by_contra! hh
|
| 25 |
+
have hf := card_le_card (show univ ⊆ A from fun _ _=>hh _)
|
| 26 |
+
rw [card_univ] at hf; exact h.not_ge hf
|
| 27 |
+
|
| 28 |
+
theorem generic_apt (p:Shape) (hg:3≤p.g) (x:Appearance p) (hx:x.f=Flavor.full) :
|
| 29 |
+
x.apt := by obtain ⟨s,h1,h2,h3⟩:=generic_summary p hg x.l x.q 0; exact ⟨s,hx ▸ h1,h2⟩
|
| 30 |
+
|
| 31 |
+
set_option maxHeartbeats 900000 in
|
| 32 |
+
theorem plenitude (h:origami p r u δ) (hs:reports p r u s β δ) (ht:reports p r u t β δ)
|
| 33 |
+
(hg:3 ≤ p.g) (A B:Stalls p) (hk:seeking p A) (hl:seeking p B)
|
| 34 |
+
(hβ:0<β) (hz:0<η) (hη : playbook p K*η<1/2*β^2)
|
| 35 |
+
(hd:∀ i,d i≤K^2) (he:∀ i,e i≤K^2):
|
| 36 |
+
Guild.rich (stellar u s t η A B) := by
|
| 37 |
+
classical
|
| 38 |
+
intro i S hu y
|
| 39 |
+
have hh a (b:Finset (Label p.b)) (h : b.card+902<Fintype.card (Label p.b)):
|
| 40 |
+
∃ z,z∉b∧z∉S a := by
|
| 41 |
+
obtain ⟨z,hz⟩:=any_label (b∪S a) ((card_union_le ..).trans_lt ((Nat.add_le_add_left
|
| 42 |
+
(hu a) _).trans_lt h))
|
| 43 |
+
exact ⟨z,fun ht=>hz (mem_union_left _ ht),fun ht=>hz (mem_union_right _ ht)⟩
|
| 44 |
+
obtain ⟨v,h1,h2⟩:= hh true (A i.1) (hk _)
|
| 45 |
+
obtain ⟨w,h3,h4⟩:= hh false (B i.2) (hl _)
|
| 46 |
+
let x : Zodiac p:= ⟨⟨0,by omega⟩,y.1,fun i=>if i then v else w,fun _=>Flavor.full⟩
|
| 47 |
+
have hh : x.common:= fun i=> generic_apt p hg _ rfl
|
| 48 |
+
obtain ⟨W,hA,hB,hC⟩:= sturdy_contact u s t h hs ht hβ x hh (fun _=>rfl) i y.2.1 y.2.2 hz
|
| 49 |
+
((mul_le_mul_of_nonneg_right (booklet_cap p K _ _ (hd _) (he _)) hz.le).trans_lt hη)
|
| 50 |
+
refine ⟨(x,W),⟨⟨h1,h3,hA⟩,fun i=>?_⟩,?_⟩
|
| 51 |
+
· cases i; exact h4; exact h2
|
| 52 |
+
exact Prod.ext rfl (Prod.ext hB hC)
|
| 53 |
+
|
| 54 |
+
structure RhymeSet (d : ℕ) where
|
| 55 |
+
bit : F
|
| 56 |
+
coal : Cell d
|
| 57 |
+
headBit : F
|
| 58 |
+
gamma : F
|
| 59 |
+
|
| 60 |
+
def RhymeSet.read {k : ℕ} (s:RhymeSet k) (q:F) (x: Whole k) :=
|
| 61 |
+
s.bit*x.2+ dotProduct s.coal x.1.2+ (s.bit+s.headBit)*x.1.1+s.gamma*q
|
| 62 |
+
|
| 63 |
+
def RhymeSet.soot {k : ℕ} (s:RhymeSet k) {p:Shape} (x:Appearance p) (y:Magazine p k) :=
|
| 64 |
+
s.read x.q y.2
|
| 65 |
+
|
| 66 |
+
def leftChime (q:DualCoefficients d e) (i:Grid) : RhymeSet (d i.1) :=
|
| 67 |
+
⟨q.left i.2,q.north i,q.hed i,0⟩
|
| 68 |
+
def rightChime (q:DualCoefficients d e) (i:Grid) : RhymeSet (e i.2) :=
|
| 69 |
+
⟨q.right i.1,q.south i,q.hed i,q.gam i⟩
|
| 70 |
+
set_option maxHeartbeats 900000 in
|
| 71 |
+
theorem dual_eq (q:DualCoefficients d e) (V : StatusSp d e) (hq:q.law V)
|
| 72 |
+
(i:Grid) (x:Suite d e i) (hx:x∈V i) :
|
| 73 |
+
(leftChime q i).read x.1 x.2.1=(rightChime q i).read x.1 x.2.2 := by
|
| 74 |
+
classical
|
| 75 |
+
specialize hq i x hx
|
| 76 |
+
rcases x with ⟨a,⟨⟨b,u⟩,s⟩,⟨c,v⟩,t⟩
|
| 77 |
+
let f:= q.hed i; let W:= dotProduct (q.north i) u
|
| 78 |
+
let Z:= dotProduct (q.south i) v
|
| 79 |
+
let g:=q.left i.2; let h:=q.right i.1; let G:=q.gam i*a
|
| 80 |
+
change G+f*(b+c)+(W+Z)=g*(b+s)+h*(c+t) at hq
|
| 81 |
+
change g*s+W+(g+f)*b+0*_ = h*t+Z+(h+f)*c+G
|
| 82 |
+
apply sub_eq_zero.mp
|
| 83 |
+
rw [ZModModule.sub_eq_add]
|
| 84 |
+
calc _
|
| 85 |
+
_=(G+f*(b+c)+(W+Z))+(g*(b+s)+h*(c+t)):=by ring
|
| 86 |
+
_=0:= by rw [hq,char_two]
|
| 87 |
+
|
| 88 |
+
def charge (u:Terrain p r) (x: Zodiac p) (X:Gazette p r d) (Y:Gazette p r e)
|
| 89 |
+
(i:Grid) (a:RhymeSet (d i.1)) (b:RhymeSet (e i.2)) :=
|
| 90 |
+
pr (circlet u X Y x i) (fun y=>a.soot (x.aspect true) y.1≠ b.soot (x.aspect false) y.2)
|
| 91 |
+
|
| 92 |
+
def outstraps (a:Stalls p) (s:Straps (Label p.b)) (b:Bool):Stalls p:=
|
| 93 |
+
fun i=>a i∪s b
|
| 94 |
+
|
| 95 |
+
set_option maxHeartbeats 900000 in
|
| 96 |
+
theorem charge_counter (h:origami p r u δ) (hs:reports p r u s β δ) (ht:reports p r u t β δ)
|
| 97 |
+
(A B:Stalls p) (S : Straps (Label p.b)) (q:DualCoefficients d e)
|
| 98 |
+
(he:q.law (chapter (stellar u s t η A B) S)) (hη:0≤η)
|
| 99 |
+
(x: Zodiac p) (i:Grid) (hx:x.common) (hk:x.s true∉outstraps A S true i.1)
|
| 100 |
+
(hl:x.s false∉outstraps B S false i.2) :
|
| 101 |
+
charge u x s t i (leftChime q i) (rightChime q i)≤ num (Touch p d e i)*η := by
|
| 102 |
+
classical
|
| 103 |
+
let W:=circlet u s t x i
|
| 104 |
+
obtain ⟨hm,hn⟩:=circlet_state u s t h hs ht x hx i
|
| 105 |
+
let P:=fun y : Touch p d e i=> (leftChime q i).soot (x.aspect true) y.1≠
|
| 106 |
+
(rightChime q i).soot (x.aspect false) y.2
|
| 107 |
+
have hh (y): W y*ind (P y)≤η := by
|
| 108 |
+
by_cases hp : P y
|
| 109 |
+
· rw [ind_one hp,mul_one]
|
| 110 |
+
by_contra! hy
|
| 111 |
+
let C:=stellar u s t η A B
|
| 112 |
+
let v : Scriptum p d e i := (x,y)
|
| 113 |
+
have heq : (x.aspect true).fitsink y.1∧ (x.aspect false).fitsink y.2 := not_not.mp
|
| 114 |
+
(fun h=> (hη.trans_lt hy).ne' (hn y h))
|
| 115 |
+
have ht : (C i).zone S v :=
|
| 116 |
+
⟨⟨fun h=>hk (mem_union_left _ h),fun h=>hl (mem_union_left _ h),hx,heq.1,heq.2,hy.le⟩,
|
| 117 |
+
fun i=>by cases i; exact fun h=>hl (mem_union_right _ h); exact fun h=>hk (mem_union_right _ h)⟩
|
| 118 |
+
exact hp (dual_eq q (chapter C S) he i ((C i).writes v) ((C i).band_write S ht))
|
| 119 |
+
rw [ind_zero hp,mul_zero]; exact hη
|
| 120 |
+
change pr W P≤ _
|
| 121 |
+
exact (Finset.sum_le_sum fun i _=> hh i).trans_eq (by simp [num])
|
| 122 |
+
|
| 123 |
+
end DualAnalysis
|
| 124 |
+
end StatusAnalysis
|
| 125 |
+
end HadwigerCounterexample
|
| 126 |
+
|
| 127 |
+
end
|
| 128 |
+
|
| 129 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RelativeEntropy.lean
CHANGED
|
@@ -1,108 +1,108 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FiniteEntropy
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.WalshBounds
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Relative Entropy -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Finset Real
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {A B C : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 13 |
-
|
| 14 |
-
def lsupp (p q : Wgt A) := ∀ x,p x ≠ 0 → q x≠0
|
| 15 |
-
|
| 16 |
-
def tension (p q : Wgt A) := avg p (fun x => log (p x)-log (q x))
|
| 17 |
-
def varOne (p q : Wgt A) := ∑ x, |p x-q x|
|
| 18 |
-
|
| 19 |
-
theorem tension_of_ratio {p q : Wgt A} (h : lsupp p q) :
|
| 20 |
-
tension p q=avg p (fun x => log (p x/q x)) :=
|
| 21 |
-
avg_congr (fun i hi => (Real.log_div hi (h i hi)).symm)
|
| 22 |
-
|
| 23 |
-
theorem tension_as_diff (p q : Wgt A) :
|
| 24 |
-
tension p q= negEnt p-avg p (fun x => log (q x)) := avg_sub p _ _
|
| 25 |
-
|
| 26 |
-
theorem tension_mix {μ : Wgt A} {f : A→Wgt B} (q : Wgt B) :
|
| 27 |
-
avg μ (fun x => tension (f x) q) =
|
| 28 |
-
avg μ (fun x => tension (f x) (mixW μ f))+tension (mixW μ f) q := by
|
| 29 |
-
let u := mixW μ f
|
| 30 |
-
have h (x : A) : tension (f x) q=tension (f x) u+
|
| 31 |
-
avg (f x) (fun i => log (u i)-log (q i)) := by
|
| 32 |
-
simp only [tension_as_diff,avg_sub]
|
| 33 |
-
ring
|
| 34 |
-
simp_rw [h,avg_add,← mixW_avg]; rfl
|
| 35 |
-
|
| 36 |
-
theorem tension_le_cap {p q : Wgt A} (hp : ∀ i,0 ≤ p i) (hq : ∀ i,0 ≤ q i)
|
| 37 |
-
(C : ℝ) (hc : 0<C) (h : ∀ i,p i≤ C*q i) :
|
| 38 |
-
tension p q≤tot p*log C := by
|
| 39 |
-
rw [←avg_const]
|
| 40 |
-
unfold tension avg
|
| 41 |
-
refine sum_le_sum fun i _ => ?_
|
| 42 |
-
rcases eq_or_lt_of_le (hp i) with h'|h'
|
| 43 |
-
· rw [←h']; simp
|
| 44 |
-
have hqi : q i ≠ 0 :=
|
| 45 |
-
(pos_of_mul_pos_right (h'.trans_le (h i)) hc.le).ne'
|
| 46 |
-
have hg : 0 < q i := lt_of_le_of_ne (hq i) (Ne.symm hqi)
|
| 47 |
-
refine mul_le_mul_of_nonneg_left ?_ h'.le
|
| 48 |
-
change log (p i) - log (q i) ≤ log C
|
| 49 |
-
rw [← Real.log_div h'.ne' hg.ne']
|
| 50 |
-
exact Real.log_le_log (by positivity) ((div_le_iff₀ hg).mpr (h i))
|
| 51 |
-
|
| 52 |
-
private theorem tension_cell (a b : ℝ) (ha : 0≤a) (hb : 0 ≤ b) (h : a≠0→b≠0) :
|
| 53 |
-
(√a-√b)^2 ≤ a*(log a - log b)+ b - a := by
|
| 54 |
-
rcases eq_or_lt_of_le ha with h'|h'
|
| 55 |
-
· rw [← h']; simp only [sqrt_zero,zero_sub,neg_sq,zero_mul,zero_add,sub_zero]; rw [sq_sqrt hb]
|
| 56 |
-
have hb' := lt_of_le_of_ne hb (Ne.symm (h h'.ne'))
|
| 57 |
-
have hc : 0<√a := by positivity
|
| 58 |
-
have ht := Real.log_le_sub_one_of_pos (x:=√b/√a) (by positivity)
|
| 59 |
-
rw [Real.log_div (by positivity) (by positivity), Real.log_sqrt hb,Real.log_sqrt ha] at ht
|
| 60 |
-
have hh := mul_le_mul_of_nonneg_right ht ha
|
| 61 |
-
have he : √b/√a*a = √b*√a := by
|
| 62 |
-
field_simp; rw [sq_sqrt ha]
|
| 63 |
-
rw [sub_mul,sub_mul,he] at hh
|
| 64 |
-
nlinarith only [hh,sq_sqrt ha,sq_sqrt hb]
|
| 65 |
-
|
| 66 |
-
set_option maxHeartbeats 600000 in
|
| 67 |
-
theorem var_tension (p q : Wgt A) (hp : IsLaw p) (hq : IsLaw q) (h : lsupp p q) :
|
| 68 |
-
varOne p q ^ 2 ≤ tension p q * 4 := by
|
| 69 |
-
let a (i : A) := |√(p i)-√(q i)|
|
| 70 |
-
let b (i : A) := √(p i)+√(q i)
|
| 71 |
-
have ha : ∑ i, a i ^ 2 ≤ tension p q := by
|
| 72 |
-
have ht (x : A) :
|
| 73 |
-
a x ^2 ≤ p x * (log (p x)-log (q x))+q x-p x := by
|
| 74 |
-
unfold a; rw [sq_abs]; exact tension_cell _ _ (hp.nz _) (hq.nz _) (h _)
|
| 75 |
-
refine (sum_le_sum (fun i (_: i∈univ) => ht i)).trans_eq ?_
|
| 76 |
-
simp only [Finset.sum_sub_distrib,Finset.sum_add_distrib]
|
| 77 |
-
change _ +tot q-tot p=tension p q
|
| 78 |
-
rw [hp.total,hq.total,add_sub_cancel_right]
|
| 79 |
-
rfl
|
| 80 |
-
have hb : ∑ i,b i^2 ≤ 4 := by
|
| 81 |
-
have ht (x : A) :
|
| 82 |
-
b x ^ 2 ≤ 2*p x+2*q x := by
|
| 83 |
-
unfold b; nlinarith only [sq_sqrt (hp.nz x),sq_sqrt (hq.nz x),
|
| 84 |
-
sq_nonneg (√(p x)-√(q x))]
|
| 85 |
-
refine (sum_le_sum (fun i (_: i∈univ) => ht i)).trans_eq ?_
|
| 86 |
-
simp only [Finset.sum_add_distrib,← Finset.mul_sum]
|
| 87 |
-
change 2*tot p + 2*tot q = 4
|
| 88 |
-
rw [hp.total,hq.total]
|
| 89 |
-
norm_num
|
| 90 |
-
have h0 : 0≤tension p q := le_trans (sum_nonneg (fun i _ => sq_nonneg _)) ha
|
| 91 |
-
have he : varOne p q = ∑ i, a i * b i := by
|
| 92 |
-
unfold varOne
|
| 93 |
-
refine sum_congr rfl (fun i _ => ?_)
|
| 94 |
-
have hy :
|
| 95 |
-
(√(p i)-√(q i))*b i=p i-q i := by
|
| 96 |
-
unfold b; nlinarith only [sq_sqrt (hp.nz i),sq_sqrt (hq.nz i)]
|
| 97 |
-
rw [← hy,abs_mul,abs_of_nonneg (show 0≤b i from by unfold b; positivity)]
|
| 98 |
-
rw [he]
|
| 99 |
-
exact (Finset.sum_mul_sq_le_sq_mul_sq ..).trans
|
| 100 |
-
(mul_le_mul ha hb (sum_nonneg (fun i _ => sq_nonneg _)) h0)
|
| 101 |
-
|
| 102 |
-
theorem tension_nonneg {p q : Wgt A} (hp : IsLaw p) (hq : IsLaw q) (h : lsupp p q) :
|
| 103 |
-
0 ≤ tension p q := by nlinarith only [var_tension p q hp hq h,sq_nonneg (varOne p q)]
|
| 104 |
-
end HadwigerCounterexample
|
| 105 |
-
|
| 106 |
-
end
|
| 107 |
-
|
| 108 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FiniteEntropy
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.WalshBounds
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Relative Entropy -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Finset Real
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {A B C : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 13 |
+
|
| 14 |
+
def lsupp (p q : Wgt A) := ∀ x,p x ≠ 0 → q x≠0
|
| 15 |
+
|
| 16 |
+
def tension (p q : Wgt A) := avg p (fun x => log (p x)-log (q x))
|
| 17 |
+
def varOne (p q : Wgt A) := ∑ x, |p x-q x|
|
| 18 |
+
|
| 19 |
+
theorem tension_of_ratio {p q : Wgt A} (h : lsupp p q) :
|
| 20 |
+
tension p q=avg p (fun x => log (p x/q x)) :=
|
| 21 |
+
avg_congr (fun i hi => (Real.log_div hi (h i hi)).symm)
|
| 22 |
+
|
| 23 |
+
theorem tension_as_diff (p q : Wgt A) :
|
| 24 |
+
tension p q= negEnt p-avg p (fun x => log (q x)) := avg_sub p _ _
|
| 25 |
+
|
| 26 |
+
theorem tension_mix {μ : Wgt A} {f : A→Wgt B} (q : Wgt B) :
|
| 27 |
+
avg μ (fun x => tension (f x) q) =
|
| 28 |
+
avg μ (fun x => tension (f x) (mixW μ f))+tension (mixW μ f) q := by
|
| 29 |
+
let u := mixW μ f
|
| 30 |
+
have h (x : A) : tension (f x) q=tension (f x) u+
|
| 31 |
+
avg (f x) (fun i => log (u i)-log (q i)) := by
|
| 32 |
+
simp only [tension_as_diff,avg_sub]
|
| 33 |
+
ring
|
| 34 |
+
simp_rw [h,avg_add,← mixW_avg]; rfl
|
| 35 |
+
|
| 36 |
+
theorem tension_le_cap {p q : Wgt A} (hp : ∀ i,0 ≤ p i) (hq : ∀ i,0 ≤ q i)
|
| 37 |
+
(C : ℝ) (hc : 0<C) (h : ∀ i,p i≤ C*q i) :
|
| 38 |
+
tension p q≤tot p*log C := by
|
| 39 |
+
rw [←avg_const]
|
| 40 |
+
unfold tension avg
|
| 41 |
+
refine sum_le_sum fun i _ => ?_
|
| 42 |
+
rcases eq_or_lt_of_le (hp i) with h'|h'
|
| 43 |
+
· rw [←h']; simp
|
| 44 |
+
have hqi : q i ≠ 0 :=
|
| 45 |
+
(pos_of_mul_pos_right (h'.trans_le (h i)) hc.le).ne'
|
| 46 |
+
have hg : 0 < q i := lt_of_le_of_ne (hq i) (Ne.symm hqi)
|
| 47 |
+
refine mul_le_mul_of_nonneg_left ?_ h'.le
|
| 48 |
+
change log (p i) - log (q i) ≤ log C
|
| 49 |
+
rw [← Real.log_div h'.ne' hg.ne']
|
| 50 |
+
exact Real.log_le_log (by positivity) ((div_le_iff₀ hg).mpr (h i))
|
| 51 |
+
|
| 52 |
+
private theorem tension_cell (a b : ℝ) (ha : 0≤a) (hb : 0 ≤ b) (h : a≠0→b≠0) :
|
| 53 |
+
(√a-√b)^2 ≤ a*(log a - log b)+ b - a := by
|
| 54 |
+
rcases eq_or_lt_of_le ha with h'|h'
|
| 55 |
+
· rw [← h']; simp only [sqrt_zero,zero_sub,neg_sq,zero_mul,zero_add,sub_zero]; rw [sq_sqrt hb]
|
| 56 |
+
have hb' := lt_of_le_of_ne hb (Ne.symm (h h'.ne'))
|
| 57 |
+
have hc : 0<√a := by positivity
|
| 58 |
+
have ht := Real.log_le_sub_one_of_pos (x:=√b/√a) (by positivity)
|
| 59 |
+
rw [Real.log_div (by positivity) (by positivity), Real.log_sqrt hb,Real.log_sqrt ha] at ht
|
| 60 |
+
have hh := mul_le_mul_of_nonneg_right ht ha
|
| 61 |
+
have he : √b/√a*a = √b*√a := by
|
| 62 |
+
field_simp; rw [sq_sqrt ha]
|
| 63 |
+
rw [sub_mul,sub_mul,he] at hh
|
| 64 |
+
nlinarith only [hh,sq_sqrt ha,sq_sqrt hb]
|
| 65 |
+
|
| 66 |
+
set_option maxHeartbeats 600000 in
|
| 67 |
+
theorem var_tension (p q : Wgt A) (hp : IsLaw p) (hq : IsLaw q) (h : lsupp p q) :
|
| 68 |
+
varOne p q ^ 2 ≤ tension p q * 4 := by
|
| 69 |
+
let a (i : A) := |√(p i)-√(q i)|
|
| 70 |
+
let b (i : A) := √(p i)+√(q i)
|
| 71 |
+
have ha : ∑ i, a i ^ 2 ≤ tension p q := by
|
| 72 |
+
have ht (x : A) :
|
| 73 |
+
a x ^2 ≤ p x * (log (p x)-log (q x))+q x-p x := by
|
| 74 |
+
unfold a; rw [sq_abs]; exact tension_cell _ _ (hp.nz _) (hq.nz _) (h _)
|
| 75 |
+
refine (sum_le_sum (fun i (_: i∈univ) => ht i)).trans_eq ?_
|
| 76 |
+
simp only [Finset.sum_sub_distrib,Finset.sum_add_distrib]
|
| 77 |
+
change _ +tot q-tot p=tension p q
|
| 78 |
+
rw [hp.total,hq.total,add_sub_cancel_right]
|
| 79 |
+
rfl
|
| 80 |
+
have hb : ∑ i,b i^2 ≤ 4 := by
|
| 81 |
+
have ht (x : A) :
|
| 82 |
+
b x ^ 2 ≤ 2*p x+2*q x := by
|
| 83 |
+
unfold b; nlinarith only [sq_sqrt (hp.nz x),sq_sqrt (hq.nz x),
|
| 84 |
+
sq_nonneg (√(p x)-√(q x))]
|
| 85 |
+
refine (sum_le_sum (fun i (_: i∈univ) => ht i)).trans_eq ?_
|
| 86 |
+
simp only [Finset.sum_add_distrib,← Finset.mul_sum]
|
| 87 |
+
change 2*tot p + 2*tot q = 4
|
| 88 |
+
rw [hp.total,hq.total]
|
| 89 |
+
norm_num
|
| 90 |
+
have h0 : 0≤tension p q := le_trans (sum_nonneg (fun i _ => sq_nonneg _)) ha
|
| 91 |
+
have he : varOne p q = ∑ i, a i * b i := by
|
| 92 |
+
unfold varOne
|
| 93 |
+
refine sum_congr rfl (fun i _ => ?_)
|
| 94 |
+
have hy :
|
| 95 |
+
(√(p i)-√(q i))*b i=p i-q i := by
|
| 96 |
+
unfold b; nlinarith only [sq_sqrt (hp.nz i),sq_sqrt (hq.nz i)]
|
| 97 |
+
rw [← hy,abs_mul,abs_of_nonneg (show 0≤b i from by unfold b; positivity)]
|
| 98 |
+
rw [he]
|
| 99 |
+
exact (Finset.sum_mul_sq_le_sq_mul_sq ..).trans
|
| 100 |
+
(mul_le_mul ha hb (sum_nonneg (fun i _ => sq_nonneg _)) h0)
|
| 101 |
+
|
| 102 |
+
theorem tension_nonneg {p q : Wgt A} (hp : IsLaw p) (hq : IsLaw q) (h : lsupp p q) :
|
| 103 |
+
0 ≤ tension p q := by nlinarith only [var_tension p q hp hq h,sq_nonneg (varOne p q)]
|
| 104 |
+
end HadwigerCounterexample
|
| 105 |
+
|
| 106 |
+
end
|
| 107 |
+
|
| 108 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RelativeInjectionBounds.lean
CHANGED
|
@@ -1,110 +1,110 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.TableInjectionTransfer
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Relative Injection Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
|
| 10 |
-
open Matrix LinearMap Module Submodule Function Finset Filter
|
| 11 |
-
open scoped BigOperators Topology
|
| 12 |
-
variable {p : Shape} {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
def fringe (N : ℕ) := bp (-0.01*N)
|
| 15 |
-
def shine (N : ℕ) := bp (0.01*N)
|
| 16 |
-
def edgeError (N : ℕ) := bp (-0.005*N)
|
| 17 |
-
|
| 18 |
-
private theorem fire_budget (K : ℕ) (p : Shape) {l D : ℝ}
|
| 19 |
-
(hd : 0 ≤D) (hh : 2*K+l+200*(D+2 : ℝ) ≤ p.h) :
|
| 20 |
-
∀ᶠ N : ℕ in atTop,
|
| 21 |
-
bp (D*N)*(fireBill p (N/100) K (shine N)/(pushCost (bp (-l)) K)^(N/100)) ≤ fringe N := by
|
| 22 |
-
have he := (tendsto_natCast_atTop_atTop (R:=ℝ)).eventually
|
| 23 |
-
(eventually_ge_atTop (1+p.h*(K:ℝ)))
|
| 24 |
-
filter_upwards [he,eventually_ge_atTop 100] with N hN hk
|
| 25 |
-
change (1+p.h*(K:ℝ))≤(N:ℝ) at hN
|
| 26 |
-
let k := N/100
|
| 27 |
-
have ht : N ≤ 200*k := by
|
| 28 |
-
have h1 : 1 ≤ N/100 := (Nat.le_div_iff_mul_le (by omega)).mpr (by simpa using hk)
|
| 29 |
-
have h := Nat.div_add_mod' N 100
|
| 30 |
-
unfold k; omega
|
| 31 |
-
have ht' : (N:ℝ)≤200*k := by exact_mod_cast ht
|
| 32 |
-
have h1 : (D+2)*N≤ (p.h-(2*K+(l:ℝ)))*k := by
|
| 33 |
-
have h := mul_le_mul_of_nonneg_left ht' (show 0≤D+2 by linarith)
|
| 34 |
-
have h' := mul_le_mul_of_nonneg_right hh (Nat.cast_nonneg k : 0≤(k:ℝ))
|
| 35 |
-
linarith only [h,h']
|
| 36 |
-
change bp _*(fireBill p k K (shine N)/_ ^ k)≤_
|
| 37 |
-
unfold fireBill pushCost shine fringe
|
| 38 |
-
rw [←bp_sub, ← bp_mul_nat, ← bp_one,←bp_add,←bp_add,←bp_sub,←bp_add]
|
| 39 |
-
apply bp_le
|
| 40 |
-
linarith only [h1,hN,(Nat.cast_nonneg N : 0≤(N:ℝ))]
|
| 41 |
-
|
| 42 |
-
set_option maxHeartbeats 1000000 in
|
| 43 |
-
theorem guard_grid (g K : ℕ) (D ε : ℝ) (hd : 0≤D) (he : 0<ε) :
|
| 44 |
-
∀ᶠ h : ℕ in atTop,∀ p : Shape,p.g=g → p.h=h →
|
| 45 |
-
∀ᶠ M : ℕ in atTop,∀ᶠ n : ℕ in atTop,let N:=M*n;
|
| 46 |
-
∀ (P : UnitType p n N×UnitType p n N→Prop),
|
| 47 |
-
named P (bp (D*N)) → named (P ∘ Prod.swap) (bp (D*N)) →
|
| 48 |
-
∀ w (b : Fpins p n N) (m : Mixer p n), (∀ x,planRank (b x)≤ K) →
|
| 49 |
-
IsLaw w → bySide p w m (shine N) → (∀ x,w x≠0 → ∀ i,frameLaw m (onSide x i)) →
|
| 50 |
-
pr (pairW w w) (fun x => P x ∧ ¬ secureAt p b x) ≤
|
| 51 |
-
ε*pr (pairW w w) P+edgeError N := by
|
| 52 |
-
let W := 8*num (Comp g×Bool)
|
| 53 |
-
obtain ⟨k,hk⟩ : ∃ k : ℕ,W*(3*bp (-(k:ℝ)))≤ ε := by
|
| 54 |
-
have hh : Tendsto (fun n : ℕ => W*(3*bp (-(n:ℝ)))) atTop (𝓝 0) := by
|
| 55 |
-
have hi := ((bp_nat_vanish (by norm_num : 0<(1:ℝ))).const_mul 3).const_mul W
|
| 56 |
-
simpa using hi
|
| 57 |
-
obtain ⟨n,hn⟩ := (hh.eventually (gt_mem_nhds he)).exists
|
| 58 |
-
exact ⟨n,hn.le⟩
|
| 59 |
-
let l := bp (-(k:ℝ))
|
| 60 |
-
filter_upwards [tendsto_natCast_atTop_atTop.eventually
|
| 61 |
-
(eventually_ge_atTop (2*K+(k:ℝ)+200*(D+2)))] with h hH p hg hp
|
| 62 |
-
|
| 63 |
-
have heq : (8*num (Place p):ℝ)*(3*l) ≤ ε := by
|
| 64 |
-
change (8*num (Comp p.g×Bool):ℝ)*(3*l) ≤ _
|
| 65 |
-
rwa [hg]
|
| 66 |
-
have hFire : ∀ᶠ N : ℕ in atTop,
|
| 67 |
-
bp (D*N)*(fireBill p (N/100) K (shine N)/(pushCost l K)^(N/100)) ≤ fringe N :=
|
| 68 |
-
fire_budget K p hd (hp.symm ▸ hH)
|
| 69 |
-
have hsmall : ∀ᶠ N : ℕ in atTop,
|
| 70 |
-
8*num (Place p)*(fringe N +fringe N)≤edgeError N := by
|
| 71 |
-
filter_upwards [bp_poly_dom_nat (by norm_num : 0<(0.005:ℝ)) (8*num (Place p)*2) 0] with N hN
|
| 72 |
-
unfold fringe edgeError
|
| 73 |
-
rw [←two_mul,←mul_assoc]
|
| 74 |
-
refine (mul_le_mul_of_nonneg_right (show _≤bp (0.005*N) from by simpa using hN.le)
|
| 75 |
-
(bp_pos _).le).trans_eq ?_
|
| 76 |
-
rw [←bp_add]; congr 1; ring
|
| 77 |
-
filter_upwards [eventually_grid hFire,eventually_grid hsmall,
|
| 78 |
-
columns_budget p (δ:=1) zero_lt_one 2 1 (by norm_num) zero_le_one,
|
| 79 |
-
eventually_grid (tendsto_natCast_atTop_atTop.eventually
|
| 80 |
-
(eventually_ge_atTop (10*((k:ℝ)+1))))] with M hM hT hS hY
|
| 81 |
-
filter_upwards [hM,hT,eventually_ge_atTop 1,hY] with n hM hT hn hY
|
| 82 |
-
dsimp only
|
| 83 |
-
intro P hP hQ w b m hb hw hW hx
|
| 84 |
-
let N := M*n
|
| 85 |
-
have hN : 2*num (Full p n)+1≤N := (hS n hn).trans_eq (one_mul _)
|
| 86 |
-
have hρ : rhUp (shine N) (2*fringe N)*2 * bp (num (Row p n)+(N/100:ℕ)-N)≤l := by
|
| 87 |
-
change 10*((k:ℝ)+1) ≤ N at hY
|
| 88 |
-
have hh : 100*((N/100:ℕ):ℝ)≤N := by exact_mod_cast (show 100*(N/100) ≤ N from Nat.mul_div_le _ _)
|
| 89 |
-
unfold rhUp shine fringe
|
| 90 |
-
rw [show 2*bp (-0.01*N)/2=bp (-0.01*N) from (by ring), ← bp_neg, ←bp_one,
|
| 91 |
-
←bp_add,←bp_add,←bp_add]
|
| 92 |
-
apply bp_le
|
| 93 |
-
linarith only [hY,hN,hh,row_le p n]
|
| 94 |
-
have hl : 0<l:=bp_pos _
|
| 95 |
-
have hX := secure_bound hP hQ (bp_pos _ : 0<fringe N) (bp_pos _).le hl w b K (N/100) hb
|
| 96 |
-
hw m hW hx (by linarith only [hN]) hρ
|
| 97 |
-
let V := pr (pairW w w) P
|
| 98 |
-
have hv : 0≤V := pr_nonneg (pairW_law hw hw).nz
|
| 99 |
-
have hi := mul_le_mul_of_nonneg_right heq hv
|
| 100 |
-
refine hX.trans ?_
|
| 101 |
-
change (8*num (Place p))*(3*l*V+_ + bp (D*N)* _)≤ε*V+_
|
| 102 |
-
calc _ ≤ (8*num (Place p))*(3*l*V+fringe N + fringe N) :=
|
| 103 |
-
mul_le_mul_of_nonneg_left (add_le_add (show 3*l*V+fringe N ≤ _ from le_rfl) (show _ ≤ fringe N from hM)) (by unfold num; positivity)
|
| 104 |
-
_ ≤ _ := by linarith only [hi,hT]
|
| 105 |
-
|
| 106 |
-
end HadwigerCounterexample
|
| 107 |
-
|
| 108 |
-
end
|
| 109 |
-
|
| 110 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.TableInjectionTransfer
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Relative Injection Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
|
| 10 |
+
open Matrix LinearMap Module Submodule Function Finset Filter
|
| 11 |
+
open scoped BigOperators Topology
|
| 12 |
+
variable {p : Shape} {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
def fringe (N : ℕ) := bp (-0.01*N)
|
| 15 |
+
def shine (N : ℕ) := bp (0.01*N)
|
| 16 |
+
def edgeError (N : ℕ) := bp (-0.005*N)
|
| 17 |
+
|
| 18 |
+
private theorem fire_budget (K : ℕ) (p : Shape) {l D : ℝ}
|
| 19 |
+
(hd : 0 ≤D) (hh : 2*K+l+200*(D+2 : ℝ) ≤ p.h) :
|
| 20 |
+
∀ᶠ N : ℕ in atTop,
|
| 21 |
+
bp (D*N)*(fireBill p (N/100) K (shine N)/(pushCost (bp (-l)) K)^(N/100)) ≤ fringe N := by
|
| 22 |
+
have he := (tendsto_natCast_atTop_atTop (R:=ℝ)).eventually
|
| 23 |
+
(eventually_ge_atTop (1+p.h*(K:ℝ)))
|
| 24 |
+
filter_upwards [he,eventually_ge_atTop 100] with N hN hk
|
| 25 |
+
change (1+p.h*(K:ℝ))≤(N:ℝ) at hN
|
| 26 |
+
let k := N/100
|
| 27 |
+
have ht : N ≤ 200*k := by
|
| 28 |
+
have h1 : 1 ≤ N/100 := (Nat.le_div_iff_mul_le (by omega)).mpr (by simpa using hk)
|
| 29 |
+
have h := Nat.div_add_mod' N 100
|
| 30 |
+
unfold k; omega
|
| 31 |
+
have ht' : (N:ℝ)≤200*k := by exact_mod_cast ht
|
| 32 |
+
have h1 : (D+2)*N≤ (p.h-(2*K+(l:ℝ)))*k := by
|
| 33 |
+
have h := mul_le_mul_of_nonneg_left ht' (show 0≤D+2 by linarith)
|
| 34 |
+
have h' := mul_le_mul_of_nonneg_right hh (Nat.cast_nonneg k : 0≤(k:ℝ))
|
| 35 |
+
linarith only [h,h']
|
| 36 |
+
change bp _*(fireBill p k K (shine N)/_ ^ k)≤_
|
| 37 |
+
unfold fireBill pushCost shine fringe
|
| 38 |
+
rw [←bp_sub, ← bp_mul_nat, ← bp_one,←bp_add,←bp_add,←bp_sub,←bp_add]
|
| 39 |
+
apply bp_le
|
| 40 |
+
linarith only [h1,hN,(Nat.cast_nonneg N : 0≤(N:ℝ))]
|
| 41 |
+
|
| 42 |
+
set_option maxHeartbeats 1000000 in
|
| 43 |
+
theorem guard_grid (g K : ℕ) (D ε : ℝ) (hd : 0≤D) (he : 0<ε) :
|
| 44 |
+
∀ᶠ h : ℕ in atTop,∀ p : Shape,p.g=g → p.h=h →
|
| 45 |
+
∀ᶠ M : ℕ in atTop,∀ᶠ n : ℕ in atTop,let N:=M*n;
|
| 46 |
+
∀ (P : UnitType p n N×UnitType p n N→Prop),
|
| 47 |
+
named P (bp (D*N)) → named (P ∘ Prod.swap) (bp (D*N)) →
|
| 48 |
+
∀ w (b : Fpins p n N) (m : Mixer p n), (∀ x,planRank (b x)≤ K) →
|
| 49 |
+
IsLaw w → bySide p w m (shine N) → (∀ x,w x≠0 → ∀ i,frameLaw m (onSide x i)) →
|
| 50 |
+
pr (pairW w w) (fun x => P x ∧ ¬ secureAt p b x) ≤
|
| 51 |
+
ε*pr (pairW w w) P+edgeError N := by
|
| 52 |
+
let W := 8*num (Comp g×Bool)
|
| 53 |
+
obtain ⟨k,hk⟩ : ∃ k : ℕ,W*(3*bp (-(k:ℝ)))≤ ε := by
|
| 54 |
+
have hh : Tendsto (fun n : ℕ => W*(3*bp (-(n:ℝ)))) atTop (𝓝 0) := by
|
| 55 |
+
have hi := ((bp_nat_vanish (by norm_num : 0<(1:ℝ))).const_mul 3).const_mul W
|
| 56 |
+
simpa using hi
|
| 57 |
+
obtain ⟨n,hn⟩ := (hh.eventually (gt_mem_nhds he)).exists
|
| 58 |
+
exact ⟨n,hn.le⟩
|
| 59 |
+
let l := bp (-(k:ℝ))
|
| 60 |
+
filter_upwards [tendsto_natCast_atTop_atTop.eventually
|
| 61 |
+
(eventually_ge_atTop (2*K+(k:ℝ)+200*(D+2)))] with h hH p hg hp
|
| 62 |
+
|
| 63 |
+
have heq : (8*num (Place p):ℝ)*(3*l) ≤ ε := by
|
| 64 |
+
change (8*num (Comp p.g×Bool):ℝ)*(3*l) ≤ _
|
| 65 |
+
rwa [hg]
|
| 66 |
+
have hFire : ∀ᶠ N : ℕ in atTop,
|
| 67 |
+
bp (D*N)*(fireBill p (N/100) K (shine N)/(pushCost l K)^(N/100)) ≤ fringe N :=
|
| 68 |
+
fire_budget K p hd (hp.symm ▸ hH)
|
| 69 |
+
have hsmall : ∀ᶠ N : ℕ in atTop,
|
| 70 |
+
8*num (Place p)*(fringe N +fringe N)≤edgeError N := by
|
| 71 |
+
filter_upwards [bp_poly_dom_nat (by norm_num : 0<(0.005:ℝ)) (8*num (Place p)*2) 0] with N hN
|
| 72 |
+
unfold fringe edgeError
|
| 73 |
+
rw [←two_mul,←mul_assoc]
|
| 74 |
+
refine (mul_le_mul_of_nonneg_right (show _≤bp (0.005*N) from by simpa using hN.le)
|
| 75 |
+
(bp_pos _).le).trans_eq ?_
|
| 76 |
+
rw [←bp_add]; congr 1; ring
|
| 77 |
+
filter_upwards [eventually_grid hFire,eventually_grid hsmall,
|
| 78 |
+
columns_budget p (δ:=1) zero_lt_one 2 1 (by norm_num) zero_le_one,
|
| 79 |
+
eventually_grid (tendsto_natCast_atTop_atTop.eventually
|
| 80 |
+
(eventually_ge_atTop (10*((k:ℝ)+1))))] with M hM hT hS hY
|
| 81 |
+
filter_upwards [hM,hT,eventually_ge_atTop 1,hY] with n hM hT hn hY
|
| 82 |
+
dsimp only
|
| 83 |
+
intro P hP hQ w b m hb hw hW hx
|
| 84 |
+
let N := M*n
|
| 85 |
+
have hN : 2*num (Full p n)+1≤N := (hS n hn).trans_eq (one_mul _)
|
| 86 |
+
have hρ : rhUp (shine N) (2*fringe N)*2 * bp (num (Row p n)+(N/100:ℕ)-N)≤l := by
|
| 87 |
+
change 10*((k:ℝ)+1) ≤ N at hY
|
| 88 |
+
have hh : 100*((N/100:ℕ):ℝ)≤N := by exact_mod_cast (show 100*(N/100) ≤ N from Nat.mul_div_le _ _)
|
| 89 |
+
unfold rhUp shine fringe
|
| 90 |
+
rw [show 2*bp (-0.01*N)/2=bp (-0.01*N) from (by ring), ← bp_neg, ←bp_one,
|
| 91 |
+
←bp_add,←bp_add,←bp_add]
|
| 92 |
+
apply bp_le
|
| 93 |
+
linarith only [hY,hN,hh,row_le p n]
|
| 94 |
+
have hl : 0<l:=bp_pos _
|
| 95 |
+
have hX := secure_bound hP hQ (bp_pos _ : 0<fringe N) (bp_pos _).le hl w b K (N/100) hb
|
| 96 |
+
hw m hW hx (by linarith only [hN]) hρ
|
| 97 |
+
let V := pr (pairW w w) P
|
| 98 |
+
have hv : 0≤V := pr_nonneg (pairW_law hw hw).nz
|
| 99 |
+
have hi := mul_le_mul_of_nonneg_right heq hv
|
| 100 |
+
refine hX.trans ?_
|
| 101 |
+
change (8*num (Place p))*(3*l*V+_ + bp (D*N)* _)≤ε*V+_
|
| 102 |
+
calc _ ≤ (8*num (Place p))*(3*l*V+fringe N + fringe N) :=
|
| 103 |
+
mul_le_mul_of_nonneg_left (add_le_add (show 3*l*V+fringe N ≤ _ from le_rfl) (show _ ≤ fringe N from hM)) (by unfold num; positivity)
|
| 104 |
+
_ ≤ _ := by linarith only [hi,hT]
|
| 105 |
+
|
| 106 |
+
end HadwigerCounterexample
|
| 107 |
+
|
| 108 |
+
end
|
| 109 |
+
|
| 110 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RepeatedBatchLaws.lean
CHANGED
|
@@ -1,131 +1,131 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ConditionedBatchLaws
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Repeated Batch Laws -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module LinearMap Submodule Finset Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J G : Type} [Fintype I] [Fintype J] [Fintype G] [DecidableEq I]
|
| 12 |
-
variable [DecidableEq J] [DecidableEq G] {p : Shape} {n N : ℕ}
|
| 13 |
-
|
| 14 |
-
def tied (f : Route I G) (J : Type) : Route (J×I) G := f ∘ Prod.snd
|
| 15 |
-
variable {f : Route I G}
|
| 16 |
-
|
| 17 |
-
def pooled (A : J → NomQuery p n f) : NomQuery p n (tied f J) :=
|
| 18 |
-
fun g => Matrix.of (fun i j => A j.val.1 g i (⟨j.val.2,j.property⟩))
|
| 19 |
-
|
| 20 |
-
omit [Fintype I] [Fintype J] [Fintype G] [DecidableEq I] [DecidableEq J] [DecidableEq G] in
|
| 21 |
-
theorem peek_pooled (A B : J→NomQuery p n f) (x : Forum p n N G) (i : J) :
|
| 22 |
-
led i (peekR p (tied f J) (pooled A) (pooled B) x)=peekR p f (A i) (B i) x := by
|
| 23 |
-
apply Prod.ext <;> ext <;> rfl
|
| 24 |
-
|
| 25 |
-
omit [Fintype I] [Fintype J] [Fintype G] [DecidableEq I] [DecidableEq J] [DecidableEq G] in
|
| 26 |
-
theorem lane_pooled (A B : J→NomQuery p n f) (m : Mixer p n) (i : J) :
|
| 27 |
-
laneM (database m (pooled A) (pooled B)) i=database m (A i) (B i) := by
|
| 28 |
-
funext z; ext x y; rfl
|
| 29 |
-
|
| 30 |
-
omit [Fintype G] in
|
| 31 |
-
theorem pool_injective {A : J → NomQuery p n f} (h : ∀ i, Injective (pooled A i).mulVec) :
|
| 32 |
-
∀ z i,Injective (A z i).mulVec := by
|
| 33 |
-
classical
|
| 34 |
-
intro z i
|
| 35 |
-
let e := condLane (tied f J) z i
|
| 36 |
-
have he : Injective e := by
|
| 37 |
-
intro a b h; exact Subtype.ext (congrArg (fun x : Port (tied f J) i => x.val.2) h)
|
| 38 |
-
have ho : A z i=pooled A i*embedMat e := by rw [mul_embedMat]; rfl
|
| 39 |
-
rw [ho]; exact inj_comp_mat _ _ (h i) (embedMat_inj he)
|
| 40 |
-
|
| 41 |
-
theorem poUse (A B : J→NomQuery p n f) (m : Mixer p n)
|
| 42 |
-
(hN : 2*num (Full p n)<N)
|
| 43 |
-
(ha : ∀ i,Injective (pooled A i).mulVec) (hb : ∀ i, Injective (pooled B i).mulVec)
|
| 44 |
-
(F : Wgt (Rack (J×I) N)) :
|
| 45 |
-
avg (forumLaw m N) (fun x => F (peekR p (tied f J) (pooled A) (pooled B) x))=
|
| 46 |
-
avg (rackStation (database m (pooled A) (pooled B)) N) F := by
|
| 47 |
-
rw [← mapW_avg,law_peekR m hN ha hb]
|
| 48 |
-
|
| 49 |
-
set_option maxHeartbeats 800000 in
|
| 50 |
-
theorem pooled_batch (A B : J → NomQuery p n f) (m : Mixer p n)
|
| 51 |
-
(hN : 2*num (Full p n)<N)
|
| 52 |
-
(k : ℝ) (hk : ∀ i,num (Port (tied f J) i)≤k)
|
| 53 |
-
(hL : 2*k-N≤-1)
|
| 54 |
-
(ha : ∀ i, Injective (pooled A i).mulVec)
|
| 55 |
-
(hb : ∀ i, Injective (pooled B i).mulVec)
|
| 56 |
-
(F : J→ Wgt (Rack I N)) (hf : ∀ i x,|F i x|≤1) :
|
| 57 |
-
let w := forumLaw (G:=G) m N
|
| 58 |
-
|avg w (fun x => ∏ i, F i (peekR p f (A i) (B i) x)) -
|
| 59 |
-
∏ i, avg w (fun x => F i (peekR p f (A i) (B i) x))|≤
|
| 60 |
-
2*netFact (tied f J)*twinkle (tied f J) k N := by
|
| 61 |
-
classical
|
| 62 |
-
let w := forumLaw m N (G:=G)
|
| 63 |
-
let Z := database m (pooled A) (pooled B)
|
| 64 |
-
have he i :
|
| 65 |
-
avg w (fun x => F i (peekR p f (A i) (B i) x))=
|
| 66 |
-
avg (rackStation (database m (A i) (B i)) N) (F i) := by
|
| 67 |
-
unfold w; rw [←mapW_avg,law_peekR m hN (pool_injective ha i) (pool_injective hb i)]
|
| 68 |
-
have hx :
|
| 69 |
-
avg w (fun x => ∏ i, F i (peekR p f (A i) (B i) x)) =
|
| 70 |
-
avg (rackStation Z N) (brightProd F) := by
|
| 71 |
-
rw [show avg (rackStation Z N) _ =_ from (poUse A B m hN ha hb (brightProd F)).symm]
|
| 72 |
-
refine avg_congr fun x _ => ?_
|
| 73 |
-
simp_rw [brightProd, peek_pooled]
|
| 74 |
-
dsimp only
|
| 75 |
-
change |avg w _ - ∏ i, avg w _| ≤ _
|
| 76 |
-
simp_rw [he]; rw [hx]
|
| 77 |
-
have hi := compare_lanes Z F hf k hk (fun i => by linarith only [hk i,hL])
|
| 78 |
-
simp_rw [Z,lane_pooled] at *
|
| 79 |
-
exact hi
|
| 80 |
-
|
| 81 |
-
set_option maxHeartbeats 600000 in
|
| 82 |
-
theorem pool_upper (A B : J → NomQuery p n f) (m : Mixer p n)
|
| 83 |
-
(hN : 2*num (Full p n)<N)
|
| 84 |
-
(ha : ∀ i, Injective (pooled A i).mulVec)
|
| 85 |
-
(hb : ∀ i, Injective (pooled B i).mulVec)
|
| 86 |
-
(hL : ∀ i,2*num (Port (tied f J) i)-N ≤ -1) (P : J→Rack I N → Prop) :
|
| 87 |
-
let w := forumLaw (G:=G) m N
|
| 88 |
-
pr w (fun x => ∀ i,P i (peekR p f (A i) (B i) x))≤
|
| 89 |
-
netFact (tied f J)* ∏ i, pr w (fun x => P i (peekR p f (A i) (B i) x)) := by
|
| 90 |
-
classical
|
| 91 |
-
let w := forumLaw (G:=G) m N
|
| 92 |
-
let S := database m (pooled A) (pooled B)
|
| 93 |
-
let q (x : Rack (J×I) N) := ∀ i,P i (led i x)
|
| 94 |
-
have h1 i :
|
| 95 |
-
pr w (fun x => P i (peekR p f (A i) (B i) x)) =
|
| 96 |
-
pr (rackStation (database m (A i) (B i)) N) (P i) := by
|
| 97 |
-
unfold w; rw [←mapW_pr,law_peekR m hN (pool_injective ha i) (pool_injective hb i)]
|
| 98 |
-
have ht :
|
| 99 |
-
pr w (fun x => ∀ i,P i (peekR p f (A i) (B i) x)) =
|
| 100 |
-
pr (rackStation S N) q := by
|
| 101 |
-
rw [show pr (rackStation S N) q= _ from
|
| 102 |
-
(poUse A B m hN ha hb (fun x => ind (q x))).symm]
|
| 103 |
-
refine avg_congr fun x _ => ?_
|
| 104 |
-
simp_rw [q,peek_pooled]
|
| 105 |
-
let M := netFact (tied f J)
|
| 106 |
-
let g (i : J) := bothPart (laneM S i) (N:=N)
|
| 107 |
-
have hg x (hh : bothPart S x ∧ q x) :
|
| 108 |
-
∀ i,g i (led i x)∧ P i (led i x) := fun i => ⟨laneGram S _ hh.1 _,hh.2 i⟩
|
| 109 |
-
change pr w _ ≤ _
|
| 110 |
-
rw [ht, rackStation,← on_unif,pr_on]
|
| 111 |
-
have hx : pr unif (fun x : Rack (J×I) N => ∀ i,g i (led i x)∧ P i (led i x)) =
|
| 112 |
-
∏ i,pr unif (fun x => g i x∧P i x) := by
|
| 113 |
-
change avg unif _=_
|
| 114 |
-
simp_rw [ind_all]
|
| 115 |
-
exact led_piece Finset.univ (fun i x => g i x∧P i x)
|
| 116 |
-
have hh0 := net_norm S N hL
|
| 117 |
-
refine (div_le_div₀ (pr_nonneg unif_law.nz)
|
| 118 |
-
(pr_mono unif_law.nz hg) (inv_pos_of_pos netFact_pos) hh0.1).trans ?_
|
| 119 |
-
rw [hx,div_eq_mul_inv,inv_inv,mul_comm]
|
| 120 |
-
apply mul_le_mul_of_nonneg_left _ netFact_pos.le
|
| 121 |
-
refine Finset.prod_le_prod₀ (fun i _ => pr_nonneg unif_law.nz) (fun i _ => ?_)
|
| 122 |
-
rw [pr_of_on unif_law.nz (g _),on_unif,h1]
|
| 123 |
-
have h0 (i) : pr unif (g i)≤1 := (pr_le_tot unif_law.nz).trans unif_law.total.le
|
| 124 |
-
apply le_trans (mul_le_mul_of_nonneg_right (h0 _) (pr_nonneg (unifOn_sub _).nz))
|
| 125 |
-
unfold g S; rw [lane_pooled,one_mul]; exact le_rfl
|
| 126 |
-
|
| 127 |
-
end HadwigerCounterexample
|
| 128 |
-
|
| 129 |
-
end
|
| 130 |
-
|
| 131 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ConditionedBatchLaws
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Repeated Batch Laws -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module LinearMap Submodule Finset Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J G : Type} [Fintype I] [Fintype J] [Fintype G] [DecidableEq I]
|
| 12 |
+
variable [DecidableEq J] [DecidableEq G] {p : Shape} {n N : ℕ}
|
| 13 |
+
|
| 14 |
+
def tied (f : Route I G) (J : Type) : Route (J×I) G := f ∘ Prod.snd
|
| 15 |
+
variable {f : Route I G}
|
| 16 |
+
|
| 17 |
+
def pooled (A : J → NomQuery p n f) : NomQuery p n (tied f J) :=
|
| 18 |
+
fun g => Matrix.of (fun i j => A j.val.1 g i (⟨j.val.2,j.property⟩))
|
| 19 |
+
|
| 20 |
+
omit [Fintype I] [Fintype J] [Fintype G] [DecidableEq I] [DecidableEq J] [DecidableEq G] in
|
| 21 |
+
theorem peek_pooled (A B : J→NomQuery p n f) (x : Forum p n N G) (i : J) :
|
| 22 |
+
led i (peekR p (tied f J) (pooled A) (pooled B) x)=peekR p f (A i) (B i) x := by
|
| 23 |
+
apply Prod.ext <;> ext <;> rfl
|
| 24 |
+
|
| 25 |
+
omit [Fintype I] [Fintype J] [Fintype G] [DecidableEq I] [DecidableEq J] [DecidableEq G] in
|
| 26 |
+
theorem lane_pooled (A B : J→NomQuery p n f) (m : Mixer p n) (i : J) :
|
| 27 |
+
laneM (database m (pooled A) (pooled B)) i=database m (A i) (B i) := by
|
| 28 |
+
funext z; ext x y; rfl
|
| 29 |
+
|
| 30 |
+
omit [Fintype G] in
|
| 31 |
+
theorem pool_injective {A : J → NomQuery p n f} (h : ∀ i, Injective (pooled A i).mulVec) :
|
| 32 |
+
∀ z i,Injective (A z i).mulVec := by
|
| 33 |
+
classical
|
| 34 |
+
intro z i
|
| 35 |
+
let e := condLane (tied f J) z i
|
| 36 |
+
have he : Injective e := by
|
| 37 |
+
intro a b h; exact Subtype.ext (congrArg (fun x : Port (tied f J) i => x.val.2) h)
|
| 38 |
+
have ho : A z i=pooled A i*embedMat e := by rw [mul_embedMat]; rfl
|
| 39 |
+
rw [ho]; exact inj_comp_mat _ _ (h i) (embedMat_inj he)
|
| 40 |
+
|
| 41 |
+
theorem poUse (A B : J→NomQuery p n f) (m : Mixer p n)
|
| 42 |
+
(hN : 2*num (Full p n)<N)
|
| 43 |
+
(ha : ∀ i,Injective (pooled A i).mulVec) (hb : ∀ i, Injective (pooled B i).mulVec)
|
| 44 |
+
(F : Wgt (Rack (J×I) N)) :
|
| 45 |
+
avg (forumLaw m N) (fun x => F (peekR p (tied f J) (pooled A) (pooled B) x))=
|
| 46 |
+
avg (rackStation (database m (pooled A) (pooled B)) N) F := by
|
| 47 |
+
rw [← mapW_avg,law_peekR m hN ha hb]
|
| 48 |
+
|
| 49 |
+
set_option maxHeartbeats 800000 in
|
| 50 |
+
theorem pooled_batch (A B : J → NomQuery p n f) (m : Mixer p n)
|
| 51 |
+
(hN : 2*num (Full p n)<N)
|
| 52 |
+
(k : ℝ) (hk : ∀ i,num (Port (tied f J) i)≤k)
|
| 53 |
+
(hL : 2*k-N≤-1)
|
| 54 |
+
(ha : ∀ i, Injective (pooled A i).mulVec)
|
| 55 |
+
(hb : ∀ i, Injective (pooled B i).mulVec)
|
| 56 |
+
(F : J→ Wgt (Rack I N)) (hf : ∀ i x,|F i x|≤1) :
|
| 57 |
+
let w := forumLaw (G:=G) m N
|
| 58 |
+
|avg w (fun x => ∏ i, F i (peekR p f (A i) (B i) x)) -
|
| 59 |
+
∏ i, avg w (fun x => F i (peekR p f (A i) (B i) x))|≤
|
| 60 |
+
2*netFact (tied f J)*twinkle (tied f J) k N := by
|
| 61 |
+
classical
|
| 62 |
+
let w := forumLaw m N (G:=G)
|
| 63 |
+
let Z := database m (pooled A) (pooled B)
|
| 64 |
+
have he i :
|
| 65 |
+
avg w (fun x => F i (peekR p f (A i) (B i) x))=
|
| 66 |
+
avg (rackStation (database m (A i) (B i)) N) (F i) := by
|
| 67 |
+
unfold w; rw [←mapW_avg,law_peekR m hN (pool_injective ha i) (pool_injective hb i)]
|
| 68 |
+
have hx :
|
| 69 |
+
avg w (fun x => ∏ i, F i (peekR p f (A i) (B i) x)) =
|
| 70 |
+
avg (rackStation Z N) (brightProd F) := by
|
| 71 |
+
rw [show avg (rackStation Z N) _ =_ from (poUse A B m hN ha hb (brightProd F)).symm]
|
| 72 |
+
refine avg_congr fun x _ => ?_
|
| 73 |
+
simp_rw [brightProd, peek_pooled]
|
| 74 |
+
dsimp only
|
| 75 |
+
change |avg w _ - ∏ i, avg w _| ≤ _
|
| 76 |
+
simp_rw [he]; rw [hx]
|
| 77 |
+
have hi := compare_lanes Z F hf k hk (fun i => by linarith only [hk i,hL])
|
| 78 |
+
simp_rw [Z,lane_pooled] at *
|
| 79 |
+
exact hi
|
| 80 |
+
|
| 81 |
+
set_option maxHeartbeats 600000 in
|
| 82 |
+
theorem pool_upper (A B : J → NomQuery p n f) (m : Mixer p n)
|
| 83 |
+
(hN : 2*num (Full p n)<N)
|
| 84 |
+
(ha : ∀ i, Injective (pooled A i).mulVec)
|
| 85 |
+
(hb : ∀ i, Injective (pooled B i).mulVec)
|
| 86 |
+
(hL : ∀ i,2*num (Port (tied f J) i)-N ≤ -1) (P : J→Rack I N → Prop) :
|
| 87 |
+
let w := forumLaw (G:=G) m N
|
| 88 |
+
pr w (fun x => ∀ i,P i (peekR p f (A i) (B i) x))≤
|
| 89 |
+
netFact (tied f J)* ∏ i, pr w (fun x => P i (peekR p f (A i) (B i) x)) := by
|
| 90 |
+
classical
|
| 91 |
+
let w := forumLaw (G:=G) m N
|
| 92 |
+
let S := database m (pooled A) (pooled B)
|
| 93 |
+
let q (x : Rack (J×I) N) := ∀ i,P i (led i x)
|
| 94 |
+
have h1 i :
|
| 95 |
+
pr w (fun x => P i (peekR p f (A i) (B i) x)) =
|
| 96 |
+
pr (rackStation (database m (A i) (B i)) N) (P i) := by
|
| 97 |
+
unfold w; rw [←mapW_pr,law_peekR m hN (pool_injective ha i) (pool_injective hb i)]
|
| 98 |
+
have ht :
|
| 99 |
+
pr w (fun x => ∀ i,P i (peekR p f (A i) (B i) x)) =
|
| 100 |
+
pr (rackStation S N) q := by
|
| 101 |
+
rw [show pr (rackStation S N) q= _ from
|
| 102 |
+
(poUse A B m hN ha hb (fun x => ind (q x))).symm]
|
| 103 |
+
refine avg_congr fun x _ => ?_
|
| 104 |
+
simp_rw [q,peek_pooled]
|
| 105 |
+
let M := netFact (tied f J)
|
| 106 |
+
let g (i : J) := bothPart (laneM S i) (N:=N)
|
| 107 |
+
have hg x (hh : bothPart S x ∧ q x) :
|
| 108 |
+
∀ i,g i (led i x)∧ P i (led i x) := fun i => ⟨laneGram S _ hh.1 _,hh.2 i⟩
|
| 109 |
+
change pr w _ ≤ _
|
| 110 |
+
rw [ht, rackStation,← on_unif,pr_on]
|
| 111 |
+
have hx : pr unif (fun x : Rack (J×I) N => ∀ i,g i (led i x)∧ P i (led i x)) =
|
| 112 |
+
∏ i,pr unif (fun x => g i x∧P i x) := by
|
| 113 |
+
change avg unif _=_
|
| 114 |
+
simp_rw [ind_all]
|
| 115 |
+
exact led_piece Finset.univ (fun i x => g i x∧P i x)
|
| 116 |
+
have hh0 := net_norm S N hL
|
| 117 |
+
refine (div_le_div₀ (pr_nonneg unif_law.nz)
|
| 118 |
+
(pr_mono unif_law.nz hg) (inv_pos_of_pos netFact_pos) hh0.1).trans ?_
|
| 119 |
+
rw [hx,div_eq_mul_inv,inv_inv,mul_comm]
|
| 120 |
+
apply mul_le_mul_of_nonneg_left _ netFact_pos.le
|
| 121 |
+
refine Finset.prod_le_prod₀ (fun i _ => pr_nonneg unif_law.nz) (fun i _ => ?_)
|
| 122 |
+
rw [pr_of_on unif_law.nz (g _),on_unif,h1]
|
| 123 |
+
have h0 (i) : pr unif (g i)≤1 := (pr_le_tot unif_law.nz).trans unif_law.total.le
|
| 124 |
+
apply le_trans (mul_le_mul_of_nonneg_right (h0 _) (pr_nonneg (unifOn_sub _).nz))
|
| 125 |
+
unfold g S; rw [lane_pooled,one_mul]; exact le_rfl
|
| 126 |
+
|
| 127 |
+
end HadwigerCounterexample
|
| 128 |
+
|
| 129 |
+
end
|
| 130 |
+
|
| 131 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RepeatedQueryBounds.lean
CHANGED
|
@@ -1,161 +1,161 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BatchCharacters
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Repeated Query Bounds -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module LinearMap Submodule Function Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {I J G : Type} [Fintype I] [Fintype J] [Fintype G]
|
| 12 |
-
variable [DecidableEq I] [DecidableEq J] [DecidableEq G]
|
| 13 |
-
variable {N : ℕ}
|
| 14 |
-
|
| 15 |
-
private theorem num_cross_peak (E : Rail (I×J))
|
| 16 |
-
(he : ∀ i∈E,i.1.1≠i.2.1) (t : ℕ) :
|
| 17 |
-
nbr (fun v : Vec E=> peak (ledgerM E v)=t) ≤ bp (peakExpense I J t) := by
|
| 18 |
-
classical
|
| 19 |
-
let Γ := fun M : Avenue I J => interDraw M ∧ peak M=t
|
| 20 |
-
have hh (v) : interDraw (ledgerM E v) := fun i j k => within_recorded E v _ _
|
| 21 |
-
(fun h => he _ h rfl)
|
| 22 |
-
rw [nbr_eq_card]
|
| 23 |
-
apply le_trans _ (price_peak (I:=I) (J:=J) t)
|
| 24 |
-
rw [nbr_eq_card]
|
| 25 |
-
let f (v : {v : Vec E//peak (ledgerM E v)=t}) : { M//Γ M} :=
|
| 26 |
-
⟨ledgerM E v.val, hh _,v.property⟩
|
| 27 |
-
have h : Injective f := by
|
| 28 |
-
intro v w he
|
| 29 |
-
apply Subtype.ext
|
| 30 |
-
have h : ledgerM E v.val=ledgerM E w.val := congrArg Subtype.val he
|
| 31 |
-
rw [←inLedger E v.val,h,inLedger]
|
| 32 |
-
exact_mod_cast Fintype.card_le_of_injective f h
|
| 33 |
-
|
| 34 |
-
private theorem peak_sum (E : Rail (I×J))
|
| 35 |
-
(he : ∀ i∈E,i.1.1≠ i.2.1) (u : ℝ)
|
| 36 |
-
(h : peakExpense I J 1+u≤0) :
|
| 37 |
-
∑ v : Vec E,bp (u*peak (ledgerM E v))≤num (I×J)+1 := by
|
| 38 |
-
classical
|
| 39 |
-
let T := Fintype.card (I×J)
|
| 40 |
-
let f (v : Vec E) : Fin (T+1) :=
|
| 41 |
-
⟨peak (ledgerM E v), Nat.lt_succ_of_le (peak_le _)⟩
|
| 42 |
-
have hg : ∑ v : Vec E,bp (u*peak (ledgerM E v))=
|
| 43 |
-
∑ i : Fin (T+1),bp (u*i.val) * nbr (fun v : Vec E => peak (ledgerM E v)=i.val) := by
|
| 44 |
-
unfold nbr tot; simp only [Finset.mul_sum]; rw [Finset.sum_comm]
|
| 45 |
-
refine Finset.sum_congr rfl fun v _ => ?_
|
| 46 |
-
rw [Finset.sum_eq_single (f v)]
|
| 47 |
-
· simp only [f,ind_true,mul_one]
|
| 48 |
-
· intro i _ hi; rw [ind_zero (show peak _≠i.val from
|
| 49 |
-
fun h => hi (Fin.ext h.symm)),mul_zero]
|
| 50 |
-
simp
|
| 51 |
-
have hi (i : Fin (T+1)) :
|
| 52 |
-
bp (u*i.val)*nbr (fun v : Vec E=>peak (ledgerM E v)=i.val) ≤ 1 := by
|
| 53 |
-
refine (mul_le_mul_of_nonneg_left (num_cross_peak E he i.val) (bp_pos _).le).trans ?_
|
| 54 |
-
rw [←bp_add,←bp_zero]
|
| 55 |
-
apply bp_le
|
| 56 |
-
unfold peakExpense at *
|
| 57 |
-
have h1 := mul_nonpos_of_nonpos_of_nonneg h (Nat.cast_nonneg i.val : 0≤(i.val:ℝ))
|
| 58 |
-
norm_num at h1
|
| 59 |
-
linarith only [h1]
|
| 60 |
-
rw [hg]
|
| 61 |
-
exact (Finset.sum_le_sum fun i _ => hi i).trans_eq (by simp [num,T])
|
| 62 |
-
|
| 63 |
-
set_option maxHeartbeats 800000 in
|
| 64 |
-
theorem cross_flood (E : Rail (I×J)) (Z : Vec E)
|
| 65 |
-
(he : ∀ i∈E,i.1.1≠ i.2.1) (u : ℝ) (hu : 0≤u)
|
| 66 |
-
(P : I → Rack J N → Prop) (hp : ∀ i,bp (-u)≤pr unif (P i))
|
| 67 |
-
(hδ : peakExpense I J 1+(-(N:ℝ)/2+2*u) ≤0) :
|
| 68 |
-
pr unif (fun x => traced x E Z ∧ ∀ i,P i (led i x))≤
|
| 69 |
-
bp (-(E.card:ℝ)) * (num (I×J)+1) *∏ i,pr unif (P i) := by
|
| 70 |
-
classical
|
| 71 |
-
let H := ∏ i,pr unif (P i)
|
| 72 |
-
have hg : 0≤H := Finset.prod_nonneg fun _ _ => pr_nonneg unif_law.nz
|
| 73 |
-
let C : ℝ := -(N:ℝ)/2+2*u
|
| 74 |
-
let F (v : Vec E) :=
|
| 75 |
-
vectorPhase v Z*avg unif (fun x => phasedBy (ledgerM E v) x*phot P x)
|
| 76 |
-
have hh v : F v ≤ bp (C*peak (ledgerM E v))*H := by
|
| 77 |
-
refine (le_abs_self _).trans ?_
|
| 78 |
-
unfold F; rw [abs_mul,vectorPhase,wsign_abs,one_mul]
|
| 79 |
-
exact light_bound _ P u hu hp
|
| 80 |
-
have heq : pr unif (fun x => traced x E Z ∧ ∀ i,P i (led i x))=
|
| 81 |
-
avg unif F := by
|
| 82 |
-
unfold pr F
|
| 83 |
-
simp_rw [ind_and,ind_all,rail_expand,← avg_mul,← avg_mul']
|
| 84 |
-
rw [avg_avg]
|
| 85 |
-
refine avg_congr fun v _ => avg_congr fun x _ => ?_
|
| 86 |
-
unfold phot; ring
|
| 87 |
-
rw [heq]
|
| 88 |
-
refine (avg_mono unif_law.nz hh).trans ?_
|
| 89 |
-
let lamh := bp (-(E.card:ℝ))
|
| 90 |
-
have he' (x : Vec E) :
|
| 91 |
-
unif x=lamh := by rw [unif_apply,card_space,dim_vec,Fintype.card_coe, ← bp_neg]
|
| 92 |
-
simp only [avg,he',← Finset.mul_sum]
|
| 93 |
-
rw [← Finset.sum_mul,mul_assoc]
|
| 94 |
-
exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (peak_sum E he _ hδ) hg)
|
| 95 |
-
(bp_pos _).le
|
| 96 |
-
|
| 97 |
-
def cInside (g : Route (I×J) G) :=
|
| 98 |
-
(crowded g).filter (fun i => i.1.1=i.2.1)
|
| 99 |
-
|
| 100 |
-
omit [Fintype G] in
|
| 101 |
-
theorem inside_count (g : Route (I×J) G) :
|
| 102 |
-
(cInside g).card≤ Fintype.card I*Fintype.card J*Fintype.card J := by
|
| 103 |
-
classical
|
| 104 |
-
let f : I×J×J → (I×J)×(I×J) := fun x => ((x.1,x.2.1),(x.1,x.2.2))
|
| 105 |
-
have h : cInside g ⊆ Finset.univ.image f := by
|
| 106 |
-
rintro ⟨⟨x,i⟩,y,j⟩ hv
|
| 107 |
-
obtain rfl : x=y := (mem_filter.mp hv).2
|
| 108 |
-
exact mem_image.mpr ⟨(x,i,j),mem_univ _,rfl⟩
|
| 109 |
-
exact (card_le_card h).trans (card_image_le.trans_eq (by simp [mul_assoc]))
|
| 110 |
-
|
| 111 |
-
set_option maxHeartbeats 800000 in
|
| 112 |
-
theorem many_frames (g : Route (I×J) G) (Z : GeoM g) (hN : ∀ i,2*num (Port g i)-N≤ -1)
|
| 113 |
-
(u : ℝ) (hu : 0≤u) (P : I→Rack J N→Prop) (hp : ∀ i,bp (-u) ≤ pr unif (P i))
|
| 114 |
-
(hd : peakExpense I J 1+ (-(N:ℝ)/2+2*u) ≤0) :
|
| 115 |
-
pr (rackStation Z N) (fun x => ∀ i,P i (led i x))≤
|
| 116 |
-
(4:ℝ)^Fintype.card G * bp (num I * num J * num J) * (num (I×J)+1) *
|
| 117 |
-
∏ i:I,pr unif (P i) := by
|
| 118 |
-
classical
|
| 119 |
-
let E := crowded g
|
| 120 |
-
let Y := cInside g
|
| 121 |
-
let R := E\Y
|
| 122 |
-
have hn := (net_norm Z N hN).1
|
| 123 |
-
let Z' := directions g Z
|
| 124 |
-
let w (x : R) := Z' ⟨x.val,sdiff_subset x.property⟩
|
| 125 |
-
have hl (x : Rack (I×J) N) (h : gramPart Z x) :
|
| 126 |
-
traced x R w := by
|
| 127 |
-
have he := (match_crowd x g Z).mpr h
|
| 128 |
-
funext i
|
| 129 |
-
exact congr_fun he (⟨i.val,sdiff_subset i.property⟩ : ↑E)
|
| 130 |
-
have he i (h : i∈R) : i.1.1≠ i.2.1 := by
|
| 131 |
-
intro hx
|
| 132 |
-
obtain ⟨h1,h2⟩ := Finset.mem_sdiff.mp h
|
| 133 |
-
exact h2 (Finset.mem_filter.mpr ⟨h1,hx⟩)
|
| 134 |
-
let Q := fun x => ∀ i, P i (led i x)
|
| 135 |
-
let H := ∏ i,pr unif (P i)
|
| 136 |
-
have h0 := netFact_pos (f:=g)
|
| 137 |
-
unfold rackStation
|
| 138 |
-
rw [← on_unif, pr_on]
|
| 139 |
-
have hh : pr unif (fun x => bothPart (N:=N) Z x ∧ Q x) ≤
|
| 140 |
-
pr unif (fun x => traced x R w ∧ Q x) :=
|
| 141 |
-
pr_mono unif_law.nz (fun x h => ⟨hl x ((both_test ..).mp h.1).1,h.2⟩)
|
| 142 |
-
have hf := cross_flood R w he u hu P hp hd
|
| 143 |
-
refine le_trans (div_le_div₀ ((pr_nonneg unif_law.nz).trans hf)
|
| 144 |
-
(hh.trans hf) (inv_pos_of_pos h0) hn) ?_
|
| 145 |
-
let K : ℝ := num (I×J)+1
|
| 146 |
-
have hk : 0 ≤ K := by unfold K num; positivity
|
| 147 |
-
change bp (- (R.card:ℝ)) * K * H / (netFact g)⁻¹ ≤ (4:ℝ)^_ * _ * K * H
|
| 148 |
-
have hY : Y ⊆ E := Finset.filter_subset ..
|
| 149 |
-
have hy : (R.card:ℝ)+(Y.card:ℝ) = netSize g := by
|
| 150 |
-
rw [← rail_count]; exact_mod_cast Finset.card_sdiff_add_card_eq_card hY
|
| 151 |
-
have hY' : (Y.card:ℝ) ≤ num I * num J * num J := by exact_mod_cast inside_count g
|
| 152 |
-
unfold netFact
|
| 153 |
-
have hg : 0 ≤ H := Finset.prod_nonneg fun i _ => pr_nonneg unif_law.nz
|
| 154 |
-
calc _ = (4:ℝ)^Fintype.card G * bp (netSize g- (R.card:ℝ))*K*H := by
|
| 155 |
-
rw [div_eq_mul_inv,inv_inv,bp_sub,bp_neg]; ring
|
| 156 |
-
_ ≤ _ := by gcongr; linarith
|
| 157 |
-
end HadwigerCounterexample
|
| 158 |
-
|
| 159 |
-
end
|
| 160 |
-
|
| 161 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BatchCharacters
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Repeated Query Bounds -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module LinearMap Submodule Function Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {I J G : Type} [Fintype I] [Fintype J] [Fintype G]
|
| 12 |
+
variable [DecidableEq I] [DecidableEq J] [DecidableEq G]
|
| 13 |
+
variable {N : ℕ}
|
| 14 |
+
|
| 15 |
+
private theorem num_cross_peak (E : Rail (I×J))
|
| 16 |
+
(he : ∀ i∈E,i.1.1≠i.2.1) (t : ℕ) :
|
| 17 |
+
nbr (fun v : Vec E=> peak (ledgerM E v)=t) ≤ bp (peakExpense I J t) := by
|
| 18 |
+
classical
|
| 19 |
+
let Γ := fun M : Avenue I J => interDraw M ∧ peak M=t
|
| 20 |
+
have hh (v) : interDraw (ledgerM E v) := fun i j k => within_recorded E v _ _
|
| 21 |
+
(fun h => he _ h rfl)
|
| 22 |
+
rw [nbr_eq_card]
|
| 23 |
+
apply le_trans _ (price_peak (I:=I) (J:=J) t)
|
| 24 |
+
rw [nbr_eq_card]
|
| 25 |
+
let f (v : {v : Vec E//peak (ledgerM E v)=t}) : { M//Γ M} :=
|
| 26 |
+
⟨ledgerM E v.val, hh _,v.property⟩
|
| 27 |
+
have h : Injective f := by
|
| 28 |
+
intro v w he
|
| 29 |
+
apply Subtype.ext
|
| 30 |
+
have h : ledgerM E v.val=ledgerM E w.val := congrArg Subtype.val he
|
| 31 |
+
rw [←inLedger E v.val,h,inLedger]
|
| 32 |
+
exact_mod_cast Fintype.card_le_of_injective f h
|
| 33 |
+
|
| 34 |
+
private theorem peak_sum (E : Rail (I×J))
|
| 35 |
+
(he : ∀ i∈E,i.1.1≠ i.2.1) (u : ℝ)
|
| 36 |
+
(h : peakExpense I J 1+u≤0) :
|
| 37 |
+
∑ v : Vec E,bp (u*peak (ledgerM E v))≤num (I×J)+1 := by
|
| 38 |
+
classical
|
| 39 |
+
let T := Fintype.card (I×J)
|
| 40 |
+
let f (v : Vec E) : Fin (T+1) :=
|
| 41 |
+
⟨peak (ledgerM E v), Nat.lt_succ_of_le (peak_le _)⟩
|
| 42 |
+
have hg : ∑ v : Vec E,bp (u*peak (ledgerM E v))=
|
| 43 |
+
∑ i : Fin (T+1),bp (u*i.val) * nbr (fun v : Vec E => peak (ledgerM E v)=i.val) := by
|
| 44 |
+
unfold nbr tot; simp only [Finset.mul_sum]; rw [Finset.sum_comm]
|
| 45 |
+
refine Finset.sum_congr rfl fun v _ => ?_
|
| 46 |
+
rw [Finset.sum_eq_single (f v)]
|
| 47 |
+
· simp only [f,ind_true,mul_one]
|
| 48 |
+
· intro i _ hi; rw [ind_zero (show peak _≠i.val from
|
| 49 |
+
fun h => hi (Fin.ext h.symm)),mul_zero]
|
| 50 |
+
simp
|
| 51 |
+
have hi (i : Fin (T+1)) :
|
| 52 |
+
bp (u*i.val)*nbr (fun v : Vec E=>peak (ledgerM E v)=i.val) ≤ 1 := by
|
| 53 |
+
refine (mul_le_mul_of_nonneg_left (num_cross_peak E he i.val) (bp_pos _).le).trans ?_
|
| 54 |
+
rw [←bp_add,←bp_zero]
|
| 55 |
+
apply bp_le
|
| 56 |
+
unfold peakExpense at *
|
| 57 |
+
have h1 := mul_nonpos_of_nonpos_of_nonneg h (Nat.cast_nonneg i.val : 0≤(i.val:ℝ))
|
| 58 |
+
norm_num at h1
|
| 59 |
+
linarith only [h1]
|
| 60 |
+
rw [hg]
|
| 61 |
+
exact (Finset.sum_le_sum fun i _ => hi i).trans_eq (by simp [num,T])
|
| 62 |
+
|
| 63 |
+
set_option maxHeartbeats 800000 in
|
| 64 |
+
theorem cross_flood (E : Rail (I×J)) (Z : Vec E)
|
| 65 |
+
(he : ∀ i∈E,i.1.1≠ i.2.1) (u : ℝ) (hu : 0≤u)
|
| 66 |
+
(P : I → Rack J N → Prop) (hp : ∀ i,bp (-u)≤pr unif (P i))
|
| 67 |
+
(hδ : peakExpense I J 1+(-(N:ℝ)/2+2*u) ≤0) :
|
| 68 |
+
pr unif (fun x => traced x E Z ∧ ∀ i,P i (led i x))≤
|
| 69 |
+
bp (-(E.card:ℝ)) * (num (I×J)+1) *∏ i,pr unif (P i) := by
|
| 70 |
+
classical
|
| 71 |
+
let H := ∏ i,pr unif (P i)
|
| 72 |
+
have hg : 0≤H := Finset.prod_nonneg fun _ _ => pr_nonneg unif_law.nz
|
| 73 |
+
let C : ℝ := -(N:ℝ)/2+2*u
|
| 74 |
+
let F (v : Vec E) :=
|
| 75 |
+
vectorPhase v Z*avg unif (fun x => phasedBy (ledgerM E v) x*phot P x)
|
| 76 |
+
have hh v : F v ≤ bp (C*peak (ledgerM E v))*H := by
|
| 77 |
+
refine (le_abs_self _).trans ?_
|
| 78 |
+
unfold F; rw [abs_mul,vectorPhase,wsign_abs,one_mul]
|
| 79 |
+
exact light_bound _ P u hu hp
|
| 80 |
+
have heq : pr unif (fun x => traced x E Z ∧ ∀ i,P i (led i x))=
|
| 81 |
+
avg unif F := by
|
| 82 |
+
unfold pr F
|
| 83 |
+
simp_rw [ind_and,ind_all,rail_expand,← avg_mul,← avg_mul']
|
| 84 |
+
rw [avg_avg]
|
| 85 |
+
refine avg_congr fun v _ => avg_congr fun x _ => ?_
|
| 86 |
+
unfold phot; ring
|
| 87 |
+
rw [heq]
|
| 88 |
+
refine (avg_mono unif_law.nz hh).trans ?_
|
| 89 |
+
let lamh := bp (-(E.card:ℝ))
|
| 90 |
+
have he' (x : Vec E) :
|
| 91 |
+
unif x=lamh := by rw [unif_apply,card_space,dim_vec,Fintype.card_coe, ← bp_neg]
|
| 92 |
+
simp only [avg,he',← Finset.mul_sum]
|
| 93 |
+
rw [← Finset.sum_mul,mul_assoc]
|
| 94 |
+
exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (peak_sum E he _ hδ) hg)
|
| 95 |
+
(bp_pos _).le
|
| 96 |
+
|
| 97 |
+
def cInside (g : Route (I×J) G) :=
|
| 98 |
+
(crowded g).filter (fun i => i.1.1=i.2.1)
|
| 99 |
+
|
| 100 |
+
omit [Fintype G] in
|
| 101 |
+
theorem inside_count (g : Route (I×J) G) :
|
| 102 |
+
(cInside g).card≤ Fintype.card I*Fintype.card J*Fintype.card J := by
|
| 103 |
+
classical
|
| 104 |
+
let f : I×J×J → (I×J)×(I×J) := fun x => ((x.1,x.2.1),(x.1,x.2.2))
|
| 105 |
+
have h : cInside g ⊆ Finset.univ.image f := by
|
| 106 |
+
rintro ⟨⟨x,i⟩,y,j⟩ hv
|
| 107 |
+
obtain rfl : x=y := (mem_filter.mp hv).2
|
| 108 |
+
exact mem_image.mpr ⟨(x,i,j),mem_univ _,rfl⟩
|
| 109 |
+
exact (card_le_card h).trans (card_image_le.trans_eq (by simp [mul_assoc]))
|
| 110 |
+
|
| 111 |
+
set_option maxHeartbeats 800000 in
|
| 112 |
+
theorem many_frames (g : Route (I×J) G) (Z : GeoM g) (hN : ∀ i,2*num (Port g i)-N≤ -1)
|
| 113 |
+
(u : ℝ) (hu : 0≤u) (P : I→Rack J N→Prop) (hp : ∀ i,bp (-u) ≤ pr unif (P i))
|
| 114 |
+
(hd : peakExpense I J 1+ (-(N:ℝ)/2+2*u) ≤0) :
|
| 115 |
+
pr (rackStation Z N) (fun x => ∀ i,P i (led i x))≤
|
| 116 |
+
(4:ℝ)^Fintype.card G * bp (num I * num J * num J) * (num (I×J)+1) *
|
| 117 |
+
∏ i:I,pr unif (P i) := by
|
| 118 |
+
classical
|
| 119 |
+
let E := crowded g
|
| 120 |
+
let Y := cInside g
|
| 121 |
+
let R := E\Y
|
| 122 |
+
have hn := (net_norm Z N hN).1
|
| 123 |
+
let Z' := directions g Z
|
| 124 |
+
let w (x : R) := Z' ⟨x.val,sdiff_subset x.property⟩
|
| 125 |
+
have hl (x : Rack (I×J) N) (h : gramPart Z x) :
|
| 126 |
+
traced x R w := by
|
| 127 |
+
have he := (match_crowd x g Z).mpr h
|
| 128 |
+
funext i
|
| 129 |
+
exact congr_fun he (⟨i.val,sdiff_subset i.property⟩ : ↑E)
|
| 130 |
+
have he i (h : i∈R) : i.1.1≠ i.2.1 := by
|
| 131 |
+
intro hx
|
| 132 |
+
obtain ⟨h1,h2⟩ := Finset.mem_sdiff.mp h
|
| 133 |
+
exact h2 (Finset.mem_filter.mpr ⟨h1,hx⟩)
|
| 134 |
+
let Q := fun x => ∀ i, P i (led i x)
|
| 135 |
+
let H := ∏ i,pr unif (P i)
|
| 136 |
+
have h0 := netFact_pos (f:=g)
|
| 137 |
+
unfold rackStation
|
| 138 |
+
rw [← on_unif, pr_on]
|
| 139 |
+
have hh : pr unif (fun x => bothPart (N:=N) Z x ∧ Q x) ≤
|
| 140 |
+
pr unif (fun x => traced x R w ∧ Q x) :=
|
| 141 |
+
pr_mono unif_law.nz (fun x h => ⟨hl x ((both_test ..).mp h.1).1,h.2⟩)
|
| 142 |
+
have hf := cross_flood R w he u hu P hp hd
|
| 143 |
+
refine le_trans (div_le_div₀ ((pr_nonneg unif_law.nz).trans hf)
|
| 144 |
+
(hh.trans hf) (inv_pos_of_pos h0) hn) ?_
|
| 145 |
+
let K : ℝ := num (I×J)+1
|
| 146 |
+
have hk : 0 ≤ K := by unfold K num; positivity
|
| 147 |
+
change bp (- (R.card:ℝ)) * K * H / (netFact g)⁻¹ ≤ (4:ℝ)^_ * _ * K * H
|
| 148 |
+
have hY : Y ⊆ E := Finset.filter_subset ..
|
| 149 |
+
have hy : (R.card:ℝ)+(Y.card:ℝ) = netSize g := by
|
| 150 |
+
rw [← rail_count]; exact_mod_cast Finset.card_sdiff_add_card_eq_card hY
|
| 151 |
+
have hY' : (Y.card:ℝ) ≤ num I * num J * num J := by exact_mod_cast inside_count g
|
| 152 |
+
unfold netFact
|
| 153 |
+
have hg : 0 ≤ H := Finset.prod_nonneg fun i _ => pr_nonneg unif_law.nz
|
| 154 |
+
calc _ = (4:ℝ)^Fintype.card G * bp (netSize g- (R.card:ℝ))*K*H := by
|
| 155 |
+
rw [div_eq_mul_inv,inv_inv,bp_sub,bp_neg]; ring
|
| 156 |
+
_ ≤ _ := by gcongr; linarith
|
| 157 |
+
end HadwigerCounterexample
|
| 158 |
+
|
| 159 |
+
end
|
| 160 |
+
|
| 161 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RepeatedQueryEnergy.lean
CHANGED
|
@@ -1,117 +1,117 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.EmpiricalInformation
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Repeated Query Energy -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C X J : Type} [Fintype A] [Fintype B] [Fintype X] [Fintype J]
|
| 12 |
-
variable [DecidableEq J]
|
| 13 |
-
|
| 14 |
-
omit [Fintype B] in
|
| 15 |
-
theorem path_repeat {μ : Wgt A} {w : Wgt X} (f : A→ X→B) :
|
| 16 |
-
mixW μ (fun i => draws J (mapW w (f i))) =
|
| 17 |
-
mixW (draws J w) (fun x => mapW μ (fun i => f i ∘ x)) := by
|
| 18 |
-
classical
|
| 19 |
-
funext i
|
| 20 |
-
have h (j : A) :
|
| 21 |
-
draws J (mapW w (f j)) i=pr (draws J w) (fun x => f j ∘ x=i) := by
|
| 22 |
-
simp_rw [funext_iff]
|
| 23 |
-
exact Eq.symm (prodW_pr _ (fun l y => f j y=i l))
|
| 24 |
-
simp_rw [mixW,h]
|
| 25 |
-
exact avg_avg ..
|
| 26 |
-
|
| 27 |
-
theorem path_sub (w : Wgt X) (p : X→Prop) (f : X → Wgt A)
|
| 28 |
-
(hw : SubLaw w) (hf : ∀ i,IsLaw (f i)) :
|
| 29 |
-
SubLaw (mixW (subW w p) f) ∧ tot (mixW (subW w p) f)=pr w p := by
|
| 30 |
-
have hh : tot (mixW (subW w p) f)=pr w p := by
|
| 31 |
-
rw [mixW_tot]; simp_rw [(hf _).total,avg_const,mul_one,subW_tot]
|
| 32 |
-
exact ⟨⟨fun i => avg_nonneg (subLaw_sub hw p).nz (fun j => (hf j).nz i),
|
| 33 |
-
hh ▸ (pr_le_tot hw.nz).trans hw.total⟩,hh⟩
|
| 34 |
-
|
| 35 |
-
omit [Fintype A] in
|
| 36 |
-
theorem path_patch (w : Wgt X) (p : X→Prop) (f : X → Wgt A) :
|
| 37 |
-
∀ i,mixW w f i=mixW (subW w p) f i+mixW (subW w (fun x=>¬ p x)) f i := by
|
| 38 |
-
intro i
|
| 39 |
-
unfold mixW subW avg
|
| 40 |
-
rw [←Finset.sum_add_distrib]; simp_rw [ind_not]
|
| 41 |
-
exact sum_congr rfl fun j _ => by ring
|
| 42 |
-
|
| 43 |
-
set_option maxHeartbeats 1000000 in
|
| 44 |
-
theorem path_energy (μ : Wgt A) (w : Wgt X) (q : Wgt B)
|
| 45 |
-
(f : A → X→B) (hμ : IsLaw μ) (hw : IsLaw w) (hq : IsLaw q)
|
| 46 |
-
(h : ∀ i j,q (f i j)≠0)
|
| 47 |
-
(u : ℝ) (hu : 0≤u) (hp : ∀ i,q i ≠0 → bp (-u)≤q i)
|
| 48 |
-
(l : ℕ) (P : (Fin l→X)→ Prop) (r : ℝ)
|
| 49 |
-
(hr : pr (draws (Fin l) w) (fun x => ¬ P x)≤r)
|
| 50 |
-
(C : ℝ) (hc : 0≤C)
|
| 51 |
-
(hP : ∀ x,P x→ ∀ y,mapW μ (fun i => f i ∘ x) y ≤ bp C * draws (Fin l) q y) :
|
| 52 |
-
(l:ℝ)* avg μ (fun i => tension (mapW w (f i)) q) ≤
|
| 53 |
-
num B*log (↑l+1)+(C+r*u*l+1)*log 2 := by
|
| 54 |
-
classical
|
| 55 |
-
let F (i : A) := mapW w (f i)
|
| 56 |
-
let W := draws (Fin l) w
|
| 57 |
-
let Q := draws (Fin l) q
|
| 58 |
-
let k (x : Fin l → X) := mapW μ (fun i => f i ∘ x)
|
| 59 |
-
let g := mixW (subW W P) k
|
| 60 |
-
let b := mixW (subW W (fun x => ¬ P x)) k
|
| 61 |
-
let V := mixW μ (fun i => draws (Fin l) (F i))
|
| 62 |
-
have h0 : ∀ i, lsupp (F i) q := by
|
| 63 |
-
intro i j hj; obtain ⟨t,ht,rfl⟩ := lsupp_witness hj
|
| 64 |
-
exact h _ _
|
| 65 |
-
have hF : ∀ i,IsLaw (F i) := fun i => mapW_law hw (f i)
|
| 66 |
-
have hV : IsLaw V := mixW_law hμ (fun i => draws_law (hF i))
|
| 67 |
-
have hQ : IsLaw Q := draws_law hq
|
| 68 |
-
have hW : IsLaw W := draws_law hw
|
| 69 |
-
have hk : ∀ i,IsLaw (k i) := fun i => mapW_law hμ _
|
| 70 |
-
have h1 := traj_charge (l:=l) μ F q hμ hF h0
|
| 71 |
-
have h2 : ∀ i,V i=g i+b i := by unfold V F; rw [path_repeat]; exact path_patch W P k
|
| 72 |
-
have hg := path_sub W P k hW.sub hk
|
| 73 |
-
have hb := path_sub W (fun x => ¬ P x) k hW.sub hk
|
| 74 |
-
have h2L : 0 ≤ log (2:ℝ) := (Real.log_pos (by norm_num)).le
|
| 75 |
-
have h3 : tension g Q ≤ C*log 2 := by
|
| 76 |
-
have hz i : g i ≤ bp C*Q i := by
|
| 77 |
-
let c := bp C*Q i
|
| 78 |
-
have hc : 0≤c := mul_nonneg (bp_pos _).le (hQ.nz _)
|
| 79 |
-
have he (j) : ind (P j)*k j i ≤ c := by
|
| 80 |
-
by_cases h : P j
|
| 81 |
-
· rw [ind_one h,one_mul]; exact hP j h i
|
| 82 |
-
rw [ind_zero h,zero_mul]; exact hc
|
| 83 |
-
refine le_trans ?_ (hW.avg_le he)
|
| 84 |
-
simp only [g,mixW,subW,avg,mul_assoc]; rfl
|
| 85 |
-
refine (tension_le_cap hg.1.nz hQ.nz _ (bp_pos _) hz).trans ?_
|
| 86 |
-
rw [log_bp]
|
| 87 |
-
exact (mul_le_mul_of_nonneg_right hg.1.total
|
| 88 |
-
(mul_nonneg hc h2L)).trans_eq (one_mul _)
|
| 89 |
-
have h4 : tension b Q ≤ r*(u*l*log 2) := by
|
| 90 |
-
have hz (i : Fin l → B) : b i ≤ bp (u*l)*Q i := by
|
| 91 |
-
by_cases he : Q i=0
|
| 92 |
-
· have ht (j) : k j i=0 := by
|
| 93 |
-
by_contra h
|
| 94 |
-
obtain ⟨z,hz,rfl⟩ := lsupp_witness h
|
| 95 |
-
have ht : Q (f z ∘ j) ≠ 0 := by
|
| 96 |
-
change ∏ i:Fin l,q (f z (j i)) ≠0
|
| 97 |
-
rw [Finset.prod_ne_zero_iff]; exact fun i _ => ‹∀ i j,q (f i j)≠0› _ _
|
| 98 |
-
exact ht he
|
| 99 |
-
unfold b mixW; simp_rw [ht]; rw [he,avg_zero,mul_zero]
|
| 100 |
-
have hq := traj_cap q hq u hp i he
|
| 101 |
-
refine (hb.1.weight_le_one i).trans ?_
|
| 102 |
-
exact (le_of_eq (by rw [←bp_add,show u*l+ -u*l = 0 by ring,bp_zero])).trans
|
| 103 |
-
(mul_le_mul_of_nonneg_left hq (bp_pos _).le)
|
| 104 |
-
refine (tension_le_cap hb.1.nz hQ.nz _ (bp_pos _) hz).trans ?_
|
| 105 |
-
rw [log_bp]
|
| 106 |
-
exact mul_le_mul_of_nonneg_right (hb.2.le.trans hr)
|
| 107 |
-
(by apply mul_nonneg (by positivity) h2L)
|
| 108 |
-
apply h1.trans
|
| 109 |
-
refine add_le_add_right ?_ _
|
| 110 |
-
have h5 := tension_add_le V g b Q h2 hg.1.nz hb.1.nz
|
| 111 |
-
rw [hV.total] at h5
|
| 112 |
-
linarith only [h5,h4,h3]
|
| 113 |
-
end HadwigerCounterexample
|
| 114 |
-
|
| 115 |
-
end
|
| 116 |
-
|
| 117 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.EmpiricalInformation
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Repeated Query Energy -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C X J : Type} [Fintype A] [Fintype B] [Fintype X] [Fintype J]
|
| 12 |
+
variable [DecidableEq J]
|
| 13 |
+
|
| 14 |
+
omit [Fintype B] in
|
| 15 |
+
theorem path_repeat {μ : Wgt A} {w : Wgt X} (f : A→ X→B) :
|
| 16 |
+
mixW μ (fun i => draws J (mapW w (f i))) =
|
| 17 |
+
mixW (draws J w) (fun x => mapW μ (fun i => f i ∘ x)) := by
|
| 18 |
+
classical
|
| 19 |
+
funext i
|
| 20 |
+
have h (j : A) :
|
| 21 |
+
draws J (mapW w (f j)) i=pr (draws J w) (fun x => f j ∘ x=i) := by
|
| 22 |
+
simp_rw [funext_iff]
|
| 23 |
+
exact Eq.symm (prodW_pr _ (fun l y => f j y=i l))
|
| 24 |
+
simp_rw [mixW,h]
|
| 25 |
+
exact avg_avg ..
|
| 26 |
+
|
| 27 |
+
theorem path_sub (w : Wgt X) (p : X→Prop) (f : X → Wgt A)
|
| 28 |
+
(hw : SubLaw w) (hf : ∀ i,IsLaw (f i)) :
|
| 29 |
+
SubLaw (mixW (subW w p) f) ∧ tot (mixW (subW w p) f)=pr w p := by
|
| 30 |
+
have hh : tot (mixW (subW w p) f)=pr w p := by
|
| 31 |
+
rw [mixW_tot]; simp_rw [(hf _).total,avg_const,mul_one,subW_tot]
|
| 32 |
+
exact ⟨⟨fun i => avg_nonneg (subLaw_sub hw p).nz (fun j => (hf j).nz i),
|
| 33 |
+
hh ▸ (pr_le_tot hw.nz).trans hw.total⟩,hh⟩
|
| 34 |
+
|
| 35 |
+
omit [Fintype A] in
|
| 36 |
+
theorem path_patch (w : Wgt X) (p : X→Prop) (f : X → Wgt A) :
|
| 37 |
+
∀ i,mixW w f i=mixW (subW w p) f i+mixW (subW w (fun x=>¬ p x)) f i := by
|
| 38 |
+
intro i
|
| 39 |
+
unfold mixW subW avg
|
| 40 |
+
rw [←Finset.sum_add_distrib]; simp_rw [ind_not]
|
| 41 |
+
exact sum_congr rfl fun j _ => by ring
|
| 42 |
+
|
| 43 |
+
set_option maxHeartbeats 1000000 in
|
| 44 |
+
theorem path_energy (μ : Wgt A) (w : Wgt X) (q : Wgt B)
|
| 45 |
+
(f : A → X→B) (hμ : IsLaw μ) (hw : IsLaw w) (hq : IsLaw q)
|
| 46 |
+
(h : ∀ i j,q (f i j)≠0)
|
| 47 |
+
(u : ℝ) (hu : 0≤u) (hp : ∀ i,q i ≠0 → bp (-u)≤q i)
|
| 48 |
+
(l : ℕ) (P : (Fin l→X)→ Prop) (r : ℝ)
|
| 49 |
+
(hr : pr (draws (Fin l) w) (fun x => ¬ P x)≤r)
|
| 50 |
+
(C : ℝ) (hc : 0≤C)
|
| 51 |
+
(hP : ∀ x,P x→ ∀ y,mapW μ (fun i => f i ∘ x) y ≤ bp C * draws (Fin l) q y) :
|
| 52 |
+
(l:ℝ)* avg μ (fun i => tension (mapW w (f i)) q) ≤
|
| 53 |
+
num B*log (↑l+1)+(C+r*u*l+1)*log 2 := by
|
| 54 |
+
classical
|
| 55 |
+
let F (i : A) := mapW w (f i)
|
| 56 |
+
let W := draws (Fin l) w
|
| 57 |
+
let Q := draws (Fin l) q
|
| 58 |
+
let k (x : Fin l → X) := mapW μ (fun i => f i ∘ x)
|
| 59 |
+
let g := mixW (subW W P) k
|
| 60 |
+
let b := mixW (subW W (fun x => ¬ P x)) k
|
| 61 |
+
let V := mixW μ (fun i => draws (Fin l) (F i))
|
| 62 |
+
have h0 : ∀ i, lsupp (F i) q := by
|
| 63 |
+
intro i j hj; obtain ⟨t,ht,rfl⟩ := lsupp_witness hj
|
| 64 |
+
exact h _ _
|
| 65 |
+
have hF : ∀ i,IsLaw (F i) := fun i => mapW_law hw (f i)
|
| 66 |
+
have hV : IsLaw V := mixW_law hμ (fun i => draws_law (hF i))
|
| 67 |
+
have hQ : IsLaw Q := draws_law hq
|
| 68 |
+
have hW : IsLaw W := draws_law hw
|
| 69 |
+
have hk : ∀ i,IsLaw (k i) := fun i => mapW_law hμ _
|
| 70 |
+
have h1 := traj_charge (l:=l) μ F q hμ hF h0
|
| 71 |
+
have h2 : ∀ i,V i=g i+b i := by unfold V F; rw [path_repeat]; exact path_patch W P k
|
| 72 |
+
have hg := path_sub W P k hW.sub hk
|
| 73 |
+
have hb := path_sub W (fun x => ¬ P x) k hW.sub hk
|
| 74 |
+
have h2L : 0 ≤ log (2:ℝ) := (Real.log_pos (by norm_num)).le
|
| 75 |
+
have h3 : tension g Q ≤ C*log 2 := by
|
| 76 |
+
have hz i : g i ≤ bp C*Q i := by
|
| 77 |
+
let c := bp C*Q i
|
| 78 |
+
have hc : 0≤c := mul_nonneg (bp_pos _).le (hQ.nz _)
|
| 79 |
+
have he (j) : ind (P j)*k j i ≤ c := by
|
| 80 |
+
by_cases h : P j
|
| 81 |
+
· rw [ind_one h,one_mul]; exact hP j h i
|
| 82 |
+
rw [ind_zero h,zero_mul]; exact hc
|
| 83 |
+
refine le_trans ?_ (hW.avg_le he)
|
| 84 |
+
simp only [g,mixW,subW,avg,mul_assoc]; rfl
|
| 85 |
+
refine (tension_le_cap hg.1.nz hQ.nz _ (bp_pos _) hz).trans ?_
|
| 86 |
+
rw [log_bp]
|
| 87 |
+
exact (mul_le_mul_of_nonneg_right hg.1.total
|
| 88 |
+
(mul_nonneg hc h2L)).trans_eq (one_mul _)
|
| 89 |
+
have h4 : tension b Q ≤ r*(u*l*log 2) := by
|
| 90 |
+
have hz (i : Fin l → B) : b i ≤ bp (u*l)*Q i := by
|
| 91 |
+
by_cases he : Q i=0
|
| 92 |
+
· have ht (j) : k j i=0 := by
|
| 93 |
+
by_contra h
|
| 94 |
+
obtain ⟨z,hz,rfl⟩ := lsupp_witness h
|
| 95 |
+
have ht : Q (f z ∘ j) ≠ 0 := by
|
| 96 |
+
change ∏ i:Fin l,q (f z (j i)) ≠0
|
| 97 |
+
rw [Finset.prod_ne_zero_iff]; exact fun i _ => ‹∀ i j,q (f i j)≠0› _ _
|
| 98 |
+
exact ht he
|
| 99 |
+
unfold b mixW; simp_rw [ht]; rw [he,avg_zero,mul_zero]
|
| 100 |
+
have hq := traj_cap q hq u hp i he
|
| 101 |
+
refine (hb.1.weight_le_one i).trans ?_
|
| 102 |
+
exact (le_of_eq (by rw [←bp_add,show u*l+ -u*l = 0 by ring,bp_zero])).trans
|
| 103 |
+
(mul_le_mul_of_nonneg_left hq (bp_pos _).le)
|
| 104 |
+
refine (tension_le_cap hb.1.nz hQ.nz _ (bp_pos _) hz).trans ?_
|
| 105 |
+
rw [log_bp]
|
| 106 |
+
exact mul_le_mul_of_nonneg_right (hb.2.le.trans hr)
|
| 107 |
+
(by apply mul_nonneg (by positivity) h2L)
|
| 108 |
+
apply h1.trans
|
| 109 |
+
refine add_le_add_right ?_ _
|
| 110 |
+
have h5 := tension_add_le V g b Q h2 hg.1.nz hb.1.nz
|
| 111 |
+
rw [hV.total] at h5
|
| 112 |
+
linarith only [h5,h4,h3]
|
| 113 |
+
end HadwigerCounterexample
|
| 114 |
+
|
| 115 |
+
end
|
| 116 |
+
|
| 117 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ReservedLabels.lean
CHANGED
|
@@ -1,122 +1,122 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FreshGeneratorCorrection
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Reserved Labels -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Module LinearMap Submodule Function Finset
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
namespace StatusAnalysis
|
| 12 |
-
variable {I L : Type} [DecidableEq L] [DecidableEq I] {d e : ℕ}
|
| 13 |
-
open Club
|
| 14 |
-
set_option maxHeartbeats 600000 in
|
| 15 |
-
theorem fresh_single (C : Club I (Signal d e) L) {s : Straps L} {V}
|
| 16 |
-
(h : C.travels s 4 (view d e) V) (x : Signal d e) (hx : x∈V) :
|
| 17 |
-
∃ p:Finset I,C.bundle p s∧ C.contents p=x∧1≤p.card∧p.card≤7 := by
|
| 18 |
-
classical
|
| 19 |
-
obtain ⟨hh,hC⟩:= C.travel_now h
|
| 20 |
-
let Q:= view d e
|
| 21 |
-
obtain ⟨i,hi,hI,_⟩:= C.yield_after s Q hC ∅ (by simp) (Q x)
|
| 22 |
-
let p : Finset I:= {i}
|
| 23 |
-
have hp := C.bundle_one s hi
|
| 24 |
-
have hr : C.travels (s⊔ C.addrs p) 3 Q V := C.travel_more h (C.addrs p)
|
| 25 |
-
(fun i=>card_image_le.trans (by unfold p; simp : p.card≤1)) (by norm_num)
|
| 26 |
-
obtain ⟨q,hq,hQ,hT⟩ := jump_two C hr (ker_two _) (x-C.writes i) (by
|
| 27 |
-
constructor
|
| 28 |
-
· exact Submodule.sub_mem _ hx (hh ▸ C.band_write s hi)
|
| 29 |
-
change Q (x-C.writes i)=0
|
| 30 |
-
rw [map_sub,hI,sub_self])
|
| 31 |
-
obtain ⟨ha,hb⟩:= C.bundle_combine hp hq
|
| 32 |
-
refine ⟨p∪q,ha,?_,?_,(card_union_le ..).trans ?_⟩
|
| 33 |
-
· change ∑ j∈p∪q,_=_
|
| 34 |
-
rw [sum_union hb, ←show C.contents q=(∑ j∈q,_) from rfl, hT]
|
| 35 |
-
simp only [sum_singleton,add_sub_cancel]
|
| 36 |
-
· exact card_pos.mpr ⟨i, mem_union_left _ (by simp [p])⟩
|
| 37 |
-
simp only [p,card_singleton]
|
| 38 |
-
omega
|
| 39 |
-
|
| 40 |
-
variable {I : Grid → Type} [∀ i,DecidableEq (I i)] {A B : Rates}
|
| 41 |
-
abbrev Congress (I : Grid→Type) (A B : Rates) (L : Type) := ∀ i,Club (I i) (Suite A B i) L
|
| 42 |
-
namespace Guild
|
| 43 |
-
variable (C : Congress I A B L)
|
| 44 |
-
def chapter (s : Straps L) : StatusSp A B := fun i=> (C i).band s
|
| 45 |
-
def excess (s : Straps L) := ∑ i:Grid,overage (chapter C s i)
|
| 46 |
-
|
| 47 |
-
omit [DecidableEq L] [∀ i,DecidableEq (I i)] in
|
| 48 |
-
theorem excess_bound (s : Straps L) : excess C s ≤8 := by
|
| 49 |
-
unfold excess
|
| 50 |
-
exact (Finset.sum_le_sum (g:=fun _=>2) (fun i _=>overage_two
|
| 51 |
-
(chapter C s i))).trans_eq (by norm_num [Grid,Nodes])
|
| 52 |
-
|
| 53 |
-
omit [DecidableEq L] [∀ i,DecidableEq (I i)] in
|
| 54 |
-
theorem chapter_mono {s t : Straps L} (h : s≤t) (i) :
|
| 55 |
-
chapter C t i ≤ chapter C s i := span_mono (fun _ ⟨a,ht,hx⟩=>
|
| 56 |
-
⟨a,(C i).zone_smaller h a ht,hx⟩)
|
| 57 |
-
|
| 58 |
-
def rich (C : Congress I A B L) :=
|
| 59 |
-
∀ i:Grid,∀ s:Straps L,sizeB s 902 → ∀ y:View (A i.1) (B i.2),∃ j,
|
| 60 |
-
(C i).zone s j ∧ view _ _ ((C i).writes j)=y
|
| 61 |
-
|
| 62 |
-
omit [DecidableEq L] [∀ i,DecidableEq (I i)] in
|
| 63 |
-
theorem rich_covers (h : rich C) (s : Straps L) (hs : sizeB s 902) (i) :
|
| 64 |
-
coverBase (chapter C s i) := by
|
| 65 |
-
intro y
|
| 66 |
-
obtain ⟨j,hj,hy⟩:=h i s hs y
|
| 67 |
-
exact ⟨⟨_, (C i).band_write s hj⟩,hy⟩
|
| 68 |
-
|
| 69 |
-
set_option maxHeartbeats 800000 in
|
| 70 |
-
omit [∀ i,DecidableEq (I i)] in
|
| 71 |
-
theorem stable (h : rich C) :
|
| 72 |
-
∃ s:Straps L,sizeB s 800 ∧
|
| 73 |
-
∀ i:Grid,(C i).travels s 100 (view _ _) (chapter C s i) := by
|
| 74 |
-
classical
|
| 75 |
-
have hh (k : ℕ) (hk : k≤ 8) (t : Straps L)
|
| 76 |
-
(ht : sizeB t ((8-k)*100)) (hb : excess C t≤ k) :
|
| 77 |
-
∃ s:Straps L,sizeB s 800 ∧
|
| 78 |
-
∀ i:Grid,(C i).travels s 100 (view _ _) (chapter C s i) := by
|
| 79 |
-
induction k generalizing t with
|
| 80 |
-
| zero =>
|
| 81 |
-
refine ⟨t,ht,fun i u hu=>?_⟩
|
| 82 |
-
let v:=t⊔u
|
| 83 |
-
have he : sizeB v 900:= fun i=> (card_union_le ..).trans (Nat.add_le_add (ht i) (hu i))
|
| 84 |
-
constructor
|
| 85 |
-
· change chapter C v i=chapter C t i
|
| 86 |
-
have hm (i:Grid) : overage (chapter C t i)=0 := by
|
| 87 |
-
have hy : overage (chapter C t i) ≤ 0 := le_trans (Finset.single_le_sum (s:=Finset.univ)
|
| 88 |
-
(fun i _=>Nat.zero_le (overage (chapter C t i))) (Finset.mem_univ i)) hb
|
| 89 |
-
exact Nat.eq_zero_of_le_zero hy
|
| 90 |
-
exact eq_of_le_of_not_lt (chapter_mono C le_sup_left i) (fun hx=> Nat.not_lt_zero _
|
| 91 |
-
((overage_lt hx (rich_covers C h v (fun i=> (he i).trans (by decide)) i)).trans_eq (hm i)))
|
| 92 |
-
intro w hw y
|
| 93 |
-
exact h i (v⊔w) (fun i=> (card_union_le ..).trans (Nat.add_le_add (he i) (hw i))) y
|
| 94 |
-
| succ k ih =>
|
| 95 |
-
have hT : sizeB t 800 := fun i=> (ht i).trans (by omega)
|
| 96 |
-
by_cases hE : ∃ (s:Straps L), sizeB s 100∧∃ i:Grid, chapter C (t⊔s) i < chapter C t i
|
| 97 |
-
· obtain ⟨u,hu,i,hU⟩:=hE
|
| 98 |
-
let s:=t⊔u
|
| 99 |
-
have he : sizeB s ((8-k)*100):= fun i=> (card_union_le ..).trans
|
| 100 |
-
((Nat.add_le_add (ht i) (hu i)).trans (by omega))
|
| 101 |
-
refine ih (by omega) s he ?_
|
| 102 |
-
have hS : excess C s < excess C t := by
|
| 103 |
-
unfold excess
|
| 104 |
-
have h1 := overage_lt hU (rich_covers C h s (fun i=> (he i).trans (by omega)) i)
|
| 105 |
-
exact Finset.sum_lt_sum (fun i _=> overage_mono (chapter_mono C le_sup_left i))
|
| 106 |
-
⟨i,mem_univ _,h1⟩
|
| 107 |
-
omega
|
| 108 |
-
refine ⟨t,hT,fun i u hu=>?_⟩
|
| 109 |
-
constructor
|
| 110 |
-
· exact eq_of_le_of_not_lt (chapter_mono C (s:=t) (t:=t⊔u) le_sup_left i) (fun hx =>
|
| 111 |
-
hE ⟨u,hu,i,hx⟩)
|
| 112 |
-
intro w hw y
|
| 113 |
-
have he : sizeB (t⊔u) 900:= fun i=> (card_union_le ..).trans (Nat.add_le_add (hT i) (hu i))
|
| 114 |
-
exact h i ((t⊔u)⊔w) (fun i=> (card_union_le ..).trans (Nat.add_le_add (he i) (hw i))) y
|
| 115 |
-
exact hh 8 (Nat.le_refl _) ⊥ (by intro i; change (∅:Finset L).card ≤_; simp) (excess_bound C _)
|
| 116 |
-
end Guild
|
| 117 |
-
end StatusAnalysis
|
| 118 |
-
end HadwigerCounterexample
|
| 119 |
-
|
| 120 |
-
end
|
| 121 |
-
|
| 122 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FreshGeneratorCorrection
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Reserved Labels -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Module LinearMap Submodule Function Finset
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
namespace StatusAnalysis
|
| 12 |
+
variable {I L : Type} [DecidableEq L] [DecidableEq I] {d e : ℕ}
|
| 13 |
+
open Club
|
| 14 |
+
set_option maxHeartbeats 600000 in
|
| 15 |
+
theorem fresh_single (C : Club I (Signal d e) L) {s : Straps L} {V}
|
| 16 |
+
(h : C.travels s 4 (view d e) V) (x : Signal d e) (hx : x∈V) :
|
| 17 |
+
∃ p:Finset I,C.bundle p s∧ C.contents p=x∧1≤p.card∧p.card≤7 := by
|
| 18 |
+
classical
|
| 19 |
+
obtain ⟨hh,hC⟩:= C.travel_now h
|
| 20 |
+
let Q:= view d e
|
| 21 |
+
obtain ⟨i,hi,hI,_⟩:= C.yield_after s Q hC ∅ (by simp) (Q x)
|
| 22 |
+
let p : Finset I:= {i}
|
| 23 |
+
have hp := C.bundle_one s hi
|
| 24 |
+
have hr : C.travels (s⊔ C.addrs p) 3 Q V := C.travel_more h (C.addrs p)
|
| 25 |
+
(fun i=>card_image_le.trans (by unfold p; simp : p.card≤1)) (by norm_num)
|
| 26 |
+
obtain ⟨q,hq,hQ,hT⟩ := jump_two C hr (ker_two _) (x-C.writes i) (by
|
| 27 |
+
constructor
|
| 28 |
+
· exact Submodule.sub_mem _ hx (hh ▸ C.band_write s hi)
|
| 29 |
+
change Q (x-C.writes i)=0
|
| 30 |
+
rw [map_sub,hI,sub_self])
|
| 31 |
+
obtain ⟨ha,hb⟩:= C.bundle_combine hp hq
|
| 32 |
+
refine ⟨p∪q,ha,?_,?_,(card_union_le ..).trans ?_⟩
|
| 33 |
+
· change ∑ j∈p∪q,_=_
|
| 34 |
+
rw [sum_union hb, ←show C.contents q=(∑ j∈q,_) from rfl, hT]
|
| 35 |
+
simp only [sum_singleton,add_sub_cancel]
|
| 36 |
+
· exact card_pos.mpr ⟨i, mem_union_left _ (by simp [p])⟩
|
| 37 |
+
simp only [p,card_singleton]
|
| 38 |
+
omega
|
| 39 |
+
|
| 40 |
+
variable {I : Grid → Type} [∀ i,DecidableEq (I i)] {A B : Rates}
|
| 41 |
+
abbrev Congress (I : Grid→Type) (A B : Rates) (L : Type) := ∀ i,Club (I i) (Suite A B i) L
|
| 42 |
+
namespace Guild
|
| 43 |
+
variable (C : Congress I A B L)
|
| 44 |
+
def chapter (s : Straps L) : StatusSp A B := fun i=> (C i).band s
|
| 45 |
+
def excess (s : Straps L) := ∑ i:Grid,overage (chapter C s i)
|
| 46 |
+
|
| 47 |
+
omit [DecidableEq L] [∀ i,DecidableEq (I i)] in
|
| 48 |
+
theorem excess_bound (s : Straps L) : excess C s ≤8 := by
|
| 49 |
+
unfold excess
|
| 50 |
+
exact (Finset.sum_le_sum (g:=fun _=>2) (fun i _=>overage_two
|
| 51 |
+
(chapter C s i))).trans_eq (by norm_num [Grid,Nodes])
|
| 52 |
+
|
| 53 |
+
omit [DecidableEq L] [∀ i,DecidableEq (I i)] in
|
| 54 |
+
theorem chapter_mono {s t : Straps L} (h : s≤t) (i) :
|
| 55 |
+
chapter C t i ≤ chapter C s i := span_mono (fun _ ⟨a,ht,hx⟩=>
|
| 56 |
+
⟨a,(C i).zone_smaller h a ht,hx⟩)
|
| 57 |
+
|
| 58 |
+
def rich (C : Congress I A B L) :=
|
| 59 |
+
∀ i:Grid,∀ s:Straps L,sizeB s 902 → ∀ y:View (A i.1) (B i.2),∃ j,
|
| 60 |
+
(C i).zone s j ∧ view _ _ ((C i).writes j)=y
|
| 61 |
+
|
| 62 |
+
omit [DecidableEq L] [∀ i,DecidableEq (I i)] in
|
| 63 |
+
theorem rich_covers (h : rich C) (s : Straps L) (hs : sizeB s 902) (i) :
|
| 64 |
+
coverBase (chapter C s i) := by
|
| 65 |
+
intro y
|
| 66 |
+
obtain ⟨j,hj,hy⟩:=h i s hs y
|
| 67 |
+
exact ⟨⟨_, (C i).band_write s hj⟩,hy⟩
|
| 68 |
+
|
| 69 |
+
set_option maxHeartbeats 800000 in
|
| 70 |
+
omit [∀ i,DecidableEq (I i)] in
|
| 71 |
+
theorem stable (h : rich C) :
|
| 72 |
+
∃ s:Straps L,sizeB s 800 ∧
|
| 73 |
+
∀ i:Grid,(C i).travels s 100 (view _ _) (chapter C s i) := by
|
| 74 |
+
classical
|
| 75 |
+
have hh (k : ℕ) (hk : k≤ 8) (t : Straps L)
|
| 76 |
+
(ht : sizeB t ((8-k)*100)) (hb : excess C t≤ k) :
|
| 77 |
+
∃ s:Straps L,sizeB s 800 ∧
|
| 78 |
+
∀ i:Grid,(C i).travels s 100 (view _ _) (chapter C s i) := by
|
| 79 |
+
induction k generalizing t with
|
| 80 |
+
| zero =>
|
| 81 |
+
refine ⟨t,ht,fun i u hu=>?_⟩
|
| 82 |
+
let v:=t⊔u
|
| 83 |
+
have he : sizeB v 900:= fun i=> (card_union_le ..).trans (Nat.add_le_add (ht i) (hu i))
|
| 84 |
+
constructor
|
| 85 |
+
· change chapter C v i=chapter C t i
|
| 86 |
+
have hm (i:Grid) : overage (chapter C t i)=0 := by
|
| 87 |
+
have hy : overage (chapter C t i) ≤ 0 := le_trans (Finset.single_le_sum (s:=Finset.univ)
|
| 88 |
+
(fun i _=>Nat.zero_le (overage (chapter C t i))) (Finset.mem_univ i)) hb
|
| 89 |
+
exact Nat.eq_zero_of_le_zero hy
|
| 90 |
+
exact eq_of_le_of_not_lt (chapter_mono C le_sup_left i) (fun hx=> Nat.not_lt_zero _
|
| 91 |
+
((overage_lt hx (rich_covers C h v (fun i=> (he i).trans (by decide)) i)).trans_eq (hm i)))
|
| 92 |
+
intro w hw y
|
| 93 |
+
exact h i (v⊔w) (fun i=> (card_union_le ..).trans (Nat.add_le_add (he i) (hw i))) y
|
| 94 |
+
| succ k ih =>
|
| 95 |
+
have hT : sizeB t 800 := fun i=> (ht i).trans (by omega)
|
| 96 |
+
by_cases hE : ∃ (s:Straps L), sizeB s 100∧∃ i:Grid, chapter C (t⊔s) i < chapter C t i
|
| 97 |
+
· obtain ⟨u,hu,i,hU⟩:=hE
|
| 98 |
+
let s:=t⊔u
|
| 99 |
+
have he : sizeB s ((8-k)*100):= fun i=> (card_union_le ..).trans
|
| 100 |
+
((Nat.add_le_add (ht i) (hu i)).trans (by omega))
|
| 101 |
+
refine ih (by omega) s he ?_
|
| 102 |
+
have hS : excess C s < excess C t := by
|
| 103 |
+
unfold excess
|
| 104 |
+
have h1 := overage_lt hU (rich_covers C h s (fun i=> (he i).trans (by omega)) i)
|
| 105 |
+
exact Finset.sum_lt_sum (fun i _=> overage_mono (chapter_mono C le_sup_left i))
|
| 106 |
+
⟨i,mem_univ _,h1⟩
|
| 107 |
+
omega
|
| 108 |
+
refine ⟨t,hT,fun i u hu=>?_⟩
|
| 109 |
+
constructor
|
| 110 |
+
· exact eq_of_le_of_not_lt (chapter_mono C (s:=t) (t:=t⊔u) le_sup_left i) (fun hx =>
|
| 111 |
+
hE ⟨u,hu,i,hx⟩)
|
| 112 |
+
intro w hw y
|
| 113 |
+
have he : sizeB (t⊔u) 900:= fun i=> (card_union_le ..).trans (Nat.add_le_add (hT i) (hu i))
|
| 114 |
+
exact h i ((t⊔u)⊔w) (fun i=> (card_union_le ..).trans (Nat.add_le_add (he i) (hw i))) y
|
| 115 |
+
exact hh 8 (Nat.le_refl _) ⊥ (by intro i; change (∅:Finset L).card ≤_; simp) (excess_bound C _)
|
| 116 |
+
end Guild
|
| 117 |
+
end StatusAnalysis
|
| 118 |
+
end HadwigerCounterexample
|
| 119 |
+
|
| 120 |
+
end
|
| 121 |
+
|
| 122 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ResidualCutPairs.lean
CHANGED
|
@@ -1,202 +1,202 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.AttackCutDecomposition
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Residual Cut Pairs -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open scoped BigOperators
|
| 10 |
-
open Matrix LinearMap Submodule Module Finset
|
| 11 |
-
variable {p : Shape} {n : ℕ} {I : Type} [Fintype I]
|
| 12 |
-
namespace Volley
|
| 13 |
-
|
| 14 |
-
def CleanRay (v : Volley p n I) (i : Bool) (R : ℕ) (x : Ray p n) :=
|
| 15 |
-
∃ (L : Finset (Label p.b)) (u : LabVals p n), x=labcomb p n L u ∧ L.card≤R ∧
|
| 16 |
-
Disjoint L (v.marked i)
|
| 17 |
-
|
| 18 |
-
variable {v : Volley p n I}
|
| 19 |
-
private theorem clean_apply {i : Bool} {R : ℕ} {M : Moment p n} (h : v.clean i R M) (x : Ray p n) :
|
| 20 |
-
v.CleanRay i R (M *ᵥ x) := by
|
| 21 |
-
classical
|
| 22 |
-
obtain ⟨L,Z,rfl,hL,ht⟩ := h
|
| 23 |
-
refine ⟨L,(fun s => Z s *ᵥ ((labMat p n s)ᵀ *ᵥ x)),?_,hL,ht⟩
|
| 24 |
-
rw [labcomb_eval,labelSum,Matrix.sum_mulVec]
|
| 25 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 26 |
-
simp only [mput,liftM_def,←Matrix.mulVec_mulVec]
|
| 27 |
-
rw [labMat_act]
|
| 28 |
-
|
| 29 |
-
private theorem clean_zero (v : Volley p n I) (i : Bool) (R : ℕ) :
|
| 30 |
-
v.CleanRay i R 0 :=
|
| 31 |
-
⟨∅,0,(map_zero _).symm,by simp,by simp⟩
|
| 32 |
-
|
| 33 |
-
/-- Key coefficients cannot contribute to a short nonattack primal
|
| 34 |
-
combination even if only the primal projection is specified. -/
|
| 35 |
-
private theorem clean_proj {w : I → Bool} {a : Plan p n} (t : Tagging p I) {R q : ℕ}
|
| 36 |
-
(hb : v.bounded w) (hv : v.avoids a q) (hr : R+14 ≤ q)
|
| 37 |
-
(x : Ray p n) (z : Place p) (i : Bool) (hx : v.CleanRay i R x)
|
| 38 |
-
(b : Vec (visits p t z.1)) (he : x-(IP p n i)ᵀ *ᵥ (v.keyM t z.1 *ᵥ b) ∈ sPin a z i) :
|
| 39 |
-
∀ j∈v.visitH t i z.1,b j = 0 := by
|
| 40 |
-
classical
|
| 41 |
-
let K := v.visitH t i z.1
|
| 42 |
-
obtain ⟨B,hB,hE,hG,hsel⟩ := hv i
|
| 43 |
-
obtain ⟨L,u,hx,hL,hdis⟩ := hx
|
| 44 |
-
let s (j : visits p t z.1) := v.sel j.val
|
| 45 |
-
let T := K.image s
|
| 46 |
-
have hk (i' : visits p t z.1) (h : i'∈K) : i'.val∈v.here i :=
|
| 47 |
-
(v.visitH_here ..).mp h
|
| 48 |
-
have hs : Set.InjOn s (K : Set _) := by
|
| 49 |
-
intro x hx y hy h
|
| 50 |
-
exact Subtype.ext (hsel (hk _ hx) (hk _ hy) h)
|
| 51 |
-
obtain ⟨y,hy,hZ⟩ := point_comb K s (v.par ∘ Subtype.val) b hs
|
| 52 |
-
rw [key_proj] at he
|
| 53 |
-
let r : LabVals p n := withinL p L u - withinL p T y
|
| 54 |
-
have h : labcomb p n (L∪T) r∈sPin a z i := by
|
| 55 |
-
rw [show r =_ - _ from rfl,map_sub,← within_eq subset_union_left u,
|
| 56 |
-
← within_eq subset_union_right y,← hx, show labcomb p n T y =_ from hZ.symm]
|
| 57 |
-
exact he
|
| 58 |
-
have hh : (L∪T).card≤q :=
|
| 59 |
-
(Finset.card_union_le ..).trans ((Nat.add_le_add hL (Finset.card_image_le.trans
|
| 60 |
-
(v.visitH_card hb t i z.1))).trans hr)
|
| 61 |
-
intro j hj
|
| 62 |
-
have hj' : s j ∈ T := mem_image_of_mem s hj
|
| 63 |
-
have hj'' : s j ∉ L := fun hh => Finset.disjoint_left.mp hdis hh
|
| 64 |
-
(mem_image_of_mem _ (hk j hj))
|
| 65 |
-
have hy' := hB z (L∪T) r h hh _ (mem_union_right _ hj') (hE _ (hk _ hj))
|
| 66 |
-
unfold r withinL at hy'
|
| 67 |
-
simp only [Pi.sub_apply,ite_eq_right hj'',ite_eq_left hj',hy j hj,zero_sub,neg_eq_zero] at hy'
|
| 68 |
-
simpa only [Function.comp_apply,Pi.zero_apply,Pi.smul_apply,smul_eq_mul,baseV,
|
| 69 |
-
Option.elim',mul_one] using congr_fun hy' none
|
| 70 |
-
|
| 71 |
-
private theorem clean_sPin {w : I → Bool} {a : Plan p n} (t : Tagging p I) {R q : ℕ}
|
| 72 |
-
(hb : v.bounded w) (hv : v.avoids a q) (hr : R+14 ≤ q)
|
| 73 |
-
(x : Ray p n) (z : Place p) (i : Bool) (hx : v.CleanRay i R x)
|
| 74 |
-
(hg : x∈sPin (v.frozen a t) z i) :
|
| 75 |
-
x∈sPin a z i := by
|
| 76 |
-
classical
|
| 77 |
-
rw [sPin_frozen,Submodule.mem_sup] at hg
|
| 78 |
-
obtain ⟨y,hy,q',⟨q',⟨b,rfl⟩,rfl⟩,hX⟩ := hg
|
| 79 |
-
have he : x - ((IP p n i)ᵀ *ᵥ (v.keyM t z.1 *ᵥ b))=y := by
|
| 80 |
-
rw [← hX]; exact add_sub_cancel_right _ _
|
| 81 |
-
have h := clean_proj t hb hv hr x z i hx b (he ▸ hy)
|
| 82 |
-
rw [key_proj,Finset.sum_eq_zero (fun j hj => by rw [h j hj,zero_smul]),sub_zero] at he
|
| 83 |
-
rwa [he]
|
| 84 |
-
|
| 85 |
-
private theorem clean_Pin {w : I→Bool} {a : Plan p n} (t : Tagging p I)
|
| 86 |
-
{R q : ℕ} (hb : v.bounded w) (hv : v.avoids a q) (hr : R+14 ≤ q)
|
| 87 |
-
(x : Ray p n) (z : Place p) (i : Bool) (hx : v.CleanRay i R x)
|
| 88 |
-
(hg : IP p n i *ᵥ x ∈ v.frozen a t z) :
|
| 89 |
-
IP p n i *ᵥ x∈a z := by
|
| 90 |
-
classical
|
| 91 |
-
obtain ⟨d,hd,q',⟨b,rfl⟩,hX⟩ := Submodule.mem_sup.mp
|
| 92 |
-
(show IP p n i *ᵥ x∈a z ⊔ v.keyPlan t z from hg)
|
| 93 |
-
let f (k : Bool) := (IP p n k)ᵀ
|
| 94 |
-
have hzero : b=0 := by
|
| 95 |
-
funext j
|
| 96 |
-
let k := v.obj j.val
|
| 97 |
-
let x' := f k *ᵥ (IP p n i *ᵥ x)
|
| 98 |
-
have h : x' - ((IP p n k)ᵀ *ᵥ (v.keyM t z.1 *ᵥ b))∈sPin a z k := by
|
| 99 |
-
unfold x'
|
| 100 |
-
rw [← hX,Matrix.mulVec_add]
|
| 101 |
-
change f k *ᵥ d + _ - f k *ᵥ (_ *ᵥ _) ∈ _
|
| 102 |
-
rw [mulVecLin_apply,add_sub_cancel_right]
|
| 103 |
-
exact ⟨d,hd,rfl⟩
|
| 104 |
-
have h' : v.CleanRay k R x' := by
|
| 105 |
-
unfold x' f; rw [Matrix.mulVec_mulVec]
|
| 106 |
-
by_cases h : k=i
|
| 107 |
-
· rw [h,IP_self,Matrix.one_mulVec]
|
| 108 |
-
exact hx
|
| 109 |
-
rw [IP_cross h,Matrix.zero_mulVec]; exact clean_zero v k R
|
| 110 |
-
exact clean_proj t hb hv hr x' z k h' b h j (mem_filter.mpr ⟨mem_univ _,rfl⟩)
|
| 111 |
-
rw [hzero,map_zero,add_zero] at hX
|
| 112 |
-
rwa [← hX]
|
| 113 |
-
|
| 114 |
-
end Volley
|
| 115 |
-
|
| 116 |
-
theorem orth_delta_probe {f b : Plan p n} {x : Xpair p n} {C : ChanOut p n} {j}
|
| 117 |
-
(h : orth p C f b j x) (i : Bool) (z : Place p) (φ : Ray p n)
|
| 118 |
-
(hφ : φ∈annih (sPin f (flipZ p z) i)) :
|
| 119 |
-
C z *ᵥ (IP p n i *ᵥ ((x i).val z.1 *ᵥ φ)) ∈ hPin b z j := by
|
| 120 |
-
classical
|
| 121 |
-
rw [← annih_annih (hPin b z j), annih_mem]
|
| 122 |
-
intro y hy
|
| 123 |
-
rw [← pure_ip]
|
| 124 |
-
let Q := IP p n i *ᵥ φ
|
| 125 |
-
have hQ := (ip_annih ..).mpr hφ
|
| 126 |
-
let D : ChanOut p n := Pi.single (flipZ p z) (vecMulVec y Q)
|
| 127 |
-
have hD : D∈deltaSpace p f b j := by
|
| 128 |
-
refine (deltaSpace_mem _).mpr (fun z' => ?_)
|
| 129 |
-
by_cases hz : z'=flipZ p z
|
| 130 |
-
· subst z'
|
| 131 |
-
unfold D; rw [Pi.single_eq_same,flipZ_flip]
|
| 132 |
-
exact outer_in_box y Q hy hQ
|
| 133 |
-
simp [D,hz]
|
| 134 |
-
have hg := h D hD 0 (Submodule.zero_mem _)
|
| 135 |
-
change ∑ i, mpair ((chanDeriv p C D+0) i) (purePair p n x i) = _ at hg
|
| 136 |
-
rw [add_zero,Finset.sum_eq_single z.1] at hg
|
| 137 |
-
· let T := (C z)ᵀ * vecMulVec y Q
|
| 138 |
-
let X := purePair p n x z.1
|
| 139 |
-
have hh : mpair T X = dotProduct (C z *ᵥ (X *ᵥ Q)) y := by
|
| 140 |
-
unfold T; rw [mul_vecMulVec,mpair_comm,mpair_outer,evmat]
|
| 141 |
-
rw [dotProduct_comm, dotProduct_transpose_mulVec,dotProduct_comm]
|
| 142 |
-
change dotProduct (C z *ᵥ (X *ᵥ Q)) y = _
|
| 143 |
-
rw [← hh]
|
| 144 |
-
have hZ : z≠flipZ p z := by cases z with | mk e c => cases c <;> simp [flipZ]
|
| 145 |
-
have h1 : D z=0 := Pi.single_eq_of_ne hZ _
|
| 146 |
-
have h2 : D (flipZ p z)=vecMulVec y Q := Pi.single_eq_same _ _
|
| 147 |
-
rcases z with ⟨e,c|c⟩
|
| 148 |
-
· change mpair ((C (e,true))ᵀ * D (e,false)+(D (e,true))ᵀ * C (e,false)) X=0 at hg
|
| 149 |
-
change D (e,true)=_ at h2
|
| 150 |
-
rw [h1,h2,Matrix.mul_zero,zero_add,transpose_vecMulVec,vecMulVec_mul] at hg
|
| 151 |
-
unfold T; rw [mul_vecMulVec, Matrix.mulVec_transpose,mpair_comm,mpair_outer,
|
| 152 |
-
←evmat_transpose, show Xᵀ=X from purePair_sym x e]
|
| 153 |
-
rw [mpair_comm,mpair_outer] at hg
|
| 154 |
-
exact hg
|
| 155 |
-
change mpair ((C (e,true))ᵀ * D (e,false)+(D (e,true))ᵀ * C (e,false)) X=0 at hg
|
| 156 |
-
change D (e,false)=_ at h2
|
| 157 |
-
rw [h1,Matrix.transpose_zero,Matrix.zero_mul,add_zero,h2] at hg
|
| 158 |
-
exact hg
|
| 159 |
-
· intro k _ hk
|
| 160 |
-
have h1 (i : Bool) : D (k,i)=0 := Pi.single_eq_of_ne (show (_,_)≠flipZ p z from
|
| 161 |
-
fun hh => hk (congrArg Prod.fst hh)) _
|
| 162 |
-
simp only [chanDeriv,chanInner,Pi.add_apply,h1,Matrix.transpose_zero,Matrix.mul_zero,
|
| 163 |
-
Matrix.zero_mul,zero_add]
|
| 164 |
-
rw [mpair_comm,map_zero]
|
| 165 |
-
simp
|
| 166 |
-
|
| 167 |
-
namespace Volley
|
| 168 |
-
variable {v : Volley p n I}
|
| 169 |
-
theorem clean_effective {w : I→Bool} {a b : Plan p n} (t : Tagging p I)
|
| 170 |
-
{q R : ℕ} (hb : v.bounded w) (hv : v.avoids a q) (hr : R+14≤q)
|
| 171 |
-
{j : Bool} (M : Cross p n) (x : Xpair p n)
|
| 172 |
-
(hh : orth p (channelOut p M j) (v.frozen a t) b j x)
|
| 173 |
-
(hg : tableInj a b M) (i : Bool) (hx : ∀ e,v.clean i R ((x i).val e)) :
|
| 174 |
-
(x i).val∈effective a i := by
|
| 175 |
-
classical
|
| 176 |
-
refine effective_mem.mpr ⟨(x i).property,fun e => ?_⟩
|
| 177 |
-
let A := (x i).val e
|
| 178 |
-
let S (z) := sPin (v.frozen a t) (e,z) i
|
| 179 |
-
have hd (c : Bool) (φ : Ray p n) (hφ : φ∈annih (S (!c))) : A *ᵥ φ=0 := by
|
| 180 |
-
have hray := clean_apply (hx e) φ
|
| 181 |
-
have hm := orth_ip_frozen hh i (e,c) φ hφ
|
| 182 |
-
exact hg (e,c) i j (A *ᵥ φ) (clean_Pin t hb hv hr _ _ i hray hm)
|
| 183 |
-
(orth_delta_probe hh i (e,c) φ hφ)
|
| 184 |
-
have hsym : Aᵀ=A := orth_pair_sym x e i
|
| 185 |
-
have h (c : Bool) : colSp A ≤ sPin a (e,c) i := by
|
| 186 |
-
have hh' : colSp A ≤ S c := by
|
| 187 |
-
have hf : colSp A ≤ annih (annih (S c)) := (colSp_kill ..).mpr (fun φ hφ => by
|
| 188 |
-
rw [hsym]
|
| 189 |
-
exact hd (!c) φ (by simpa using hφ))
|
| 190 |
-
rwa [annih_annih] at hf
|
| 191 |
-
rintro x' ⟨y,rfl⟩
|
| 192 |
-
exact clean_sPin t hb hv hr _ _ i (clean_apply (hx e) y) (hh' ⟨y,rfl⟩)
|
| 193 |
-
change A∈box _ _
|
| 194 |
-
rw [box_mem,hsym]
|
| 195 |
-
exact ⟨h _,h _⟩
|
| 196 |
-
|
| 197 |
-
end Volley
|
| 198 |
-
end HadwigerCounterexample
|
| 199 |
-
|
| 200 |
-
end
|
| 201 |
-
|
| 202 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.AttackCutDecomposition
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Residual Cut Pairs -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open scoped BigOperators
|
| 10 |
+
open Matrix LinearMap Submodule Module Finset
|
| 11 |
+
variable {p : Shape} {n : ℕ} {I : Type} [Fintype I]
|
| 12 |
+
namespace Volley
|
| 13 |
+
|
| 14 |
+
def CleanRay (v : Volley p n I) (i : Bool) (R : ℕ) (x : Ray p n) :=
|
| 15 |
+
∃ (L : Finset (Label p.b)) (u : LabVals p n), x=labcomb p n L u ∧ L.card≤R ∧
|
| 16 |
+
Disjoint L (v.marked i)
|
| 17 |
+
|
| 18 |
+
variable {v : Volley p n I}
|
| 19 |
+
private theorem clean_apply {i : Bool} {R : ℕ} {M : Moment p n} (h : v.clean i R M) (x : Ray p n) :
|
| 20 |
+
v.CleanRay i R (M *ᵥ x) := by
|
| 21 |
+
classical
|
| 22 |
+
obtain ⟨L,Z,rfl,hL,ht⟩ := h
|
| 23 |
+
refine ⟨L,(fun s => Z s *ᵥ ((labMat p n s)ᵀ *ᵥ x)),?_,hL,ht⟩
|
| 24 |
+
rw [labcomb_eval,labelSum,Matrix.sum_mulVec]
|
| 25 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 26 |
+
simp only [mput,liftM_def,←Matrix.mulVec_mulVec]
|
| 27 |
+
rw [labMat_act]
|
| 28 |
+
|
| 29 |
+
private theorem clean_zero (v : Volley p n I) (i : Bool) (R : ℕ) :
|
| 30 |
+
v.CleanRay i R 0 :=
|
| 31 |
+
⟨∅,0,(map_zero _).symm,by simp,by simp⟩
|
| 32 |
+
|
| 33 |
+
/-- Key coefficients cannot contribute to a short nonattack primal
|
| 34 |
+
combination even if only the primal projection is specified. -/
|
| 35 |
+
private theorem clean_proj {w : I → Bool} {a : Plan p n} (t : Tagging p I) {R q : ℕ}
|
| 36 |
+
(hb : v.bounded w) (hv : v.avoids a q) (hr : R+14 ≤ q)
|
| 37 |
+
(x : Ray p n) (z : Place p) (i : Bool) (hx : v.CleanRay i R x)
|
| 38 |
+
(b : Vec (visits p t z.1)) (he : x-(IP p n i)ᵀ *ᵥ (v.keyM t z.1 *ᵥ b) ∈ sPin a z i) :
|
| 39 |
+
∀ j∈v.visitH t i z.1,b j = 0 := by
|
| 40 |
+
classical
|
| 41 |
+
let K := v.visitH t i z.1
|
| 42 |
+
obtain ⟨B,hB,hE,hG,hsel⟩ := hv i
|
| 43 |
+
obtain ⟨L,u,hx,hL,hdis⟩ := hx
|
| 44 |
+
let s (j : visits p t z.1) := v.sel j.val
|
| 45 |
+
let T := K.image s
|
| 46 |
+
have hk (i' : visits p t z.1) (h : i'∈K) : i'.val∈v.here i :=
|
| 47 |
+
(v.visitH_here ..).mp h
|
| 48 |
+
have hs : Set.InjOn s (K : Set _) := by
|
| 49 |
+
intro x hx y hy h
|
| 50 |
+
exact Subtype.ext (hsel (hk _ hx) (hk _ hy) h)
|
| 51 |
+
obtain ⟨y,hy,hZ⟩ := point_comb K s (v.par ∘ Subtype.val) b hs
|
| 52 |
+
rw [key_proj] at he
|
| 53 |
+
let r : LabVals p n := withinL p L u - withinL p T y
|
| 54 |
+
have h : labcomb p n (L∪T) r∈sPin a z i := by
|
| 55 |
+
rw [show r =_ - _ from rfl,map_sub,← within_eq subset_union_left u,
|
| 56 |
+
← within_eq subset_union_right y,← hx, show labcomb p n T y =_ from hZ.symm]
|
| 57 |
+
exact he
|
| 58 |
+
have hh : (L∪T).card≤q :=
|
| 59 |
+
(Finset.card_union_le ..).trans ((Nat.add_le_add hL (Finset.card_image_le.trans
|
| 60 |
+
(v.visitH_card hb t i z.1))).trans hr)
|
| 61 |
+
intro j hj
|
| 62 |
+
have hj' : s j ∈ T := mem_image_of_mem s hj
|
| 63 |
+
have hj'' : s j ∉ L := fun hh => Finset.disjoint_left.mp hdis hh
|
| 64 |
+
(mem_image_of_mem _ (hk j hj))
|
| 65 |
+
have hy' := hB z (L∪T) r h hh _ (mem_union_right _ hj') (hE _ (hk _ hj))
|
| 66 |
+
unfold r withinL at hy'
|
| 67 |
+
simp only [Pi.sub_apply,ite_eq_right hj'',ite_eq_left hj',hy j hj,zero_sub,neg_eq_zero] at hy'
|
| 68 |
+
simpa only [Function.comp_apply,Pi.zero_apply,Pi.smul_apply,smul_eq_mul,baseV,
|
| 69 |
+
Option.elim',mul_one] using congr_fun hy' none
|
| 70 |
+
|
| 71 |
+
private theorem clean_sPin {w : I → Bool} {a : Plan p n} (t : Tagging p I) {R q : ℕ}
|
| 72 |
+
(hb : v.bounded w) (hv : v.avoids a q) (hr : R+14 ≤ q)
|
| 73 |
+
(x : Ray p n) (z : Place p) (i : Bool) (hx : v.CleanRay i R x)
|
| 74 |
+
(hg : x∈sPin (v.frozen a t) z i) :
|
| 75 |
+
x∈sPin a z i := by
|
| 76 |
+
classical
|
| 77 |
+
rw [sPin_frozen,Submodule.mem_sup] at hg
|
| 78 |
+
obtain ⟨y,hy,q',⟨q',⟨b,rfl⟩,rfl⟩,hX⟩ := hg
|
| 79 |
+
have he : x - ((IP p n i)ᵀ *ᵥ (v.keyM t z.1 *ᵥ b))=y := by
|
| 80 |
+
rw [← hX]; exact add_sub_cancel_right _ _
|
| 81 |
+
have h := clean_proj t hb hv hr x z i hx b (he ▸ hy)
|
| 82 |
+
rw [key_proj,Finset.sum_eq_zero (fun j hj => by rw [h j hj,zero_smul]),sub_zero] at he
|
| 83 |
+
rwa [he]
|
| 84 |
+
|
| 85 |
+
private theorem clean_Pin {w : I→Bool} {a : Plan p n} (t : Tagging p I)
|
| 86 |
+
{R q : ℕ} (hb : v.bounded w) (hv : v.avoids a q) (hr : R+14 ≤ q)
|
| 87 |
+
(x : Ray p n) (z : Place p) (i : Bool) (hx : v.CleanRay i R x)
|
| 88 |
+
(hg : IP p n i *ᵥ x ∈ v.frozen a t z) :
|
| 89 |
+
IP p n i *ᵥ x∈a z := by
|
| 90 |
+
classical
|
| 91 |
+
obtain ⟨d,hd,q',⟨b,rfl⟩,hX⟩ := Submodule.mem_sup.mp
|
| 92 |
+
(show IP p n i *ᵥ x∈a z ⊔ v.keyPlan t z from hg)
|
| 93 |
+
let f (k : Bool) := (IP p n k)ᵀ
|
| 94 |
+
have hzero : b=0 := by
|
| 95 |
+
funext j
|
| 96 |
+
let k := v.obj j.val
|
| 97 |
+
let x' := f k *ᵥ (IP p n i *ᵥ x)
|
| 98 |
+
have h : x' - ((IP p n k)ᵀ *ᵥ (v.keyM t z.1 *ᵥ b))∈sPin a z k := by
|
| 99 |
+
unfold x'
|
| 100 |
+
rw [← hX,Matrix.mulVec_add]
|
| 101 |
+
change f k *ᵥ d + _ - f k *ᵥ (_ *ᵥ _) ∈ _
|
| 102 |
+
rw [mulVecLin_apply,add_sub_cancel_right]
|
| 103 |
+
exact ⟨d,hd,rfl⟩
|
| 104 |
+
have h' : v.CleanRay k R x' := by
|
| 105 |
+
unfold x' f; rw [Matrix.mulVec_mulVec]
|
| 106 |
+
by_cases h : k=i
|
| 107 |
+
· rw [h,IP_self,Matrix.one_mulVec]
|
| 108 |
+
exact hx
|
| 109 |
+
rw [IP_cross h,Matrix.zero_mulVec]; exact clean_zero v k R
|
| 110 |
+
exact clean_proj t hb hv hr x' z k h' b h j (mem_filter.mpr ⟨mem_univ _,rfl⟩)
|
| 111 |
+
rw [hzero,map_zero,add_zero] at hX
|
| 112 |
+
rwa [← hX]
|
| 113 |
+
|
| 114 |
+
end Volley
|
| 115 |
+
|
| 116 |
+
theorem orth_delta_probe {f b : Plan p n} {x : Xpair p n} {C : ChanOut p n} {j}
|
| 117 |
+
(h : orth p C f b j x) (i : Bool) (z : Place p) (φ : Ray p n)
|
| 118 |
+
(hφ : φ∈annih (sPin f (flipZ p z) i)) :
|
| 119 |
+
C z *ᵥ (IP p n i *ᵥ ((x i).val z.1 *ᵥ φ)) ∈ hPin b z j := by
|
| 120 |
+
classical
|
| 121 |
+
rw [← annih_annih (hPin b z j), annih_mem]
|
| 122 |
+
intro y hy
|
| 123 |
+
rw [← pure_ip]
|
| 124 |
+
let Q := IP p n i *ᵥ φ
|
| 125 |
+
have hQ := (ip_annih ..).mpr hφ
|
| 126 |
+
let D : ChanOut p n := Pi.single (flipZ p z) (vecMulVec y Q)
|
| 127 |
+
have hD : D∈deltaSpace p f b j := by
|
| 128 |
+
refine (deltaSpace_mem _).mpr (fun z' => ?_)
|
| 129 |
+
by_cases hz : z'=flipZ p z
|
| 130 |
+
· subst z'
|
| 131 |
+
unfold D; rw [Pi.single_eq_same,flipZ_flip]
|
| 132 |
+
exact outer_in_box y Q hy hQ
|
| 133 |
+
simp [D,hz]
|
| 134 |
+
have hg := h D hD 0 (Submodule.zero_mem _)
|
| 135 |
+
change ∑ i, mpair ((chanDeriv p C D+0) i) (purePair p n x i) = _ at hg
|
| 136 |
+
rw [add_zero,Finset.sum_eq_single z.1] at hg
|
| 137 |
+
· let T := (C z)ᵀ * vecMulVec y Q
|
| 138 |
+
let X := purePair p n x z.1
|
| 139 |
+
have hh : mpair T X = dotProduct (C z *ᵥ (X *ᵥ Q)) y := by
|
| 140 |
+
unfold T; rw [mul_vecMulVec,mpair_comm,mpair_outer,evmat]
|
| 141 |
+
rw [dotProduct_comm, dotProduct_transpose_mulVec,dotProduct_comm]
|
| 142 |
+
change dotProduct (C z *ᵥ (X *ᵥ Q)) y = _
|
| 143 |
+
rw [← hh]
|
| 144 |
+
have hZ : z≠flipZ p z := by cases z with | mk e c => cases c <;> simp [flipZ]
|
| 145 |
+
have h1 : D z=0 := Pi.single_eq_of_ne hZ _
|
| 146 |
+
have h2 : D (flipZ p z)=vecMulVec y Q := Pi.single_eq_same _ _
|
| 147 |
+
rcases z with ⟨e,c|c⟩
|
| 148 |
+
· change mpair ((C (e,true))ᵀ * D (e,false)+(D (e,true))ᵀ * C (e,false)) X=0 at hg
|
| 149 |
+
change D (e,true)=_ at h2
|
| 150 |
+
rw [h1,h2,Matrix.mul_zero,zero_add,transpose_vecMulVec,vecMulVec_mul] at hg
|
| 151 |
+
unfold T; rw [mul_vecMulVec, Matrix.mulVec_transpose,mpair_comm,mpair_outer,
|
| 152 |
+
←evmat_transpose, show Xᵀ=X from purePair_sym x e]
|
| 153 |
+
rw [mpair_comm,mpair_outer] at hg
|
| 154 |
+
exact hg
|
| 155 |
+
change mpair ((C (e,true))ᵀ * D (e,false)+(D (e,true))ᵀ * C (e,false)) X=0 at hg
|
| 156 |
+
change D (e,false)=_ at h2
|
| 157 |
+
rw [h1,Matrix.transpose_zero,Matrix.zero_mul,add_zero,h2] at hg
|
| 158 |
+
exact hg
|
| 159 |
+
· intro k _ hk
|
| 160 |
+
have h1 (i : Bool) : D (k,i)=0 := Pi.single_eq_of_ne (show (_,_)≠flipZ p z from
|
| 161 |
+
fun hh => hk (congrArg Prod.fst hh)) _
|
| 162 |
+
simp only [chanDeriv,chanInner,Pi.add_apply,h1,Matrix.transpose_zero,Matrix.mul_zero,
|
| 163 |
+
Matrix.zero_mul,zero_add]
|
| 164 |
+
rw [mpair_comm,map_zero]
|
| 165 |
+
simp
|
| 166 |
+
|
| 167 |
+
namespace Volley
|
| 168 |
+
variable {v : Volley p n I}
|
| 169 |
+
theorem clean_effective {w : I→Bool} {a b : Plan p n} (t : Tagging p I)
|
| 170 |
+
{q R : ℕ} (hb : v.bounded w) (hv : v.avoids a q) (hr : R+14≤q)
|
| 171 |
+
{j : Bool} (M : Cross p n) (x : Xpair p n)
|
| 172 |
+
(hh : orth p (channelOut p M j) (v.frozen a t) b j x)
|
| 173 |
+
(hg : tableInj a b M) (i : Bool) (hx : ∀ e,v.clean i R ((x i).val e)) :
|
| 174 |
+
(x i).val∈effective a i := by
|
| 175 |
+
classical
|
| 176 |
+
refine effective_mem.mpr ⟨(x i).property,fun e => ?_⟩
|
| 177 |
+
let A := (x i).val e
|
| 178 |
+
let S (z) := sPin (v.frozen a t) (e,z) i
|
| 179 |
+
have hd (c : Bool) (φ : Ray p n) (hφ : φ∈annih (S (!c))) : A *ᵥ φ=0 := by
|
| 180 |
+
have hray := clean_apply (hx e) φ
|
| 181 |
+
have hm := orth_ip_frozen hh i (e,c) φ hφ
|
| 182 |
+
exact hg (e,c) i j (A *ᵥ φ) (clean_Pin t hb hv hr _ _ i hray hm)
|
| 183 |
+
(orth_delta_probe hh i (e,c) φ hφ)
|
| 184 |
+
have hsym : Aᵀ=A := orth_pair_sym x e i
|
| 185 |
+
have h (c : Bool) : colSp A ≤ sPin a (e,c) i := by
|
| 186 |
+
have hh' : colSp A ≤ S c := by
|
| 187 |
+
have hf : colSp A ≤ annih (annih (S c)) := (colSp_kill ..).mpr (fun φ hφ => by
|
| 188 |
+
rw [hsym]
|
| 189 |
+
exact hd (!c) φ (by simpa using hφ))
|
| 190 |
+
rwa [annih_annih] at hf
|
| 191 |
+
rintro x' ⟨y,rfl⟩
|
| 192 |
+
exact clean_sPin t hb hv hr _ _ i (clean_apply (hx e) y) (hh' ⟨y,rfl⟩)
|
| 193 |
+
change A∈box _ _
|
| 194 |
+
rw [box_mem,hsym]
|
| 195 |
+
exact ⟨h _,h _⟩
|
| 196 |
+
|
| 197 |
+
end Volley
|
| 198 |
+
end HadwigerCounterexample
|
| 199 |
+
|
| 200 |
+
end
|
| 201 |
+
|
| 202 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ResidualRegularity.lean
CHANGED
|
@@ -1,107 +1,107 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RectangleRegularity
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Residual Regularity -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix LinearMap Function Filter Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B I : Type} [Fintype A] [Fintype B] [Fintype I]
|
| 12 |
-
|
| 13 |
-
def wanes (u : Wgt I) (w : Wgt A) (f : I→Wgt A) (p : A→B) (ε : ℝ) :=
|
| 14 |
-
∀ h : Wgt A,(∀ x,|h x| ≤ 1) →
|
| 15 |
-
avg u (fun i => |dip w (fun x=> f i x - banner w p (f i) x) h|) ≤ ε
|
| 16 |
-
def hits (u : Wgt I) (w : Wgt A) (f : I→ Wgt A) (p : A→ B) :=
|
| 17 |
-
avg u (fun i => ode w (banner w p (f i)))
|
| 18 |
-
|
| 19 |
-
private def twistSign (b : ℝ) := decide (0≤ b)
|
| 20 |
-
private theorem twistabs (b : ℝ) : b*swab (twistSign b)=|b| := by
|
| 21 |
-
classical by_cases h : 0≤b <;> simp [swab,twistSign,h,abs_of_nonneg,abs_of_neg,lt_of_not_ge]
|
| 22 |
-
|
| 23 |
-
set_option maxHeartbeats 600000 in
|
| 24 |
-
theorem tilt_test (w : Wgt A) (u : Wgt I) (hu : ∀ i,0 ≤ u i) (f : I → Wgt A) (h : Wgt A)
|
| 25 |
-
(hh : ∀ x,|h x|≤1) :
|
| 26 |
-
∃ p : A→Bool, avg u (fun i=>|dip w (f i) h|) ≤ avg u (fun i => |dip w (f i) (swab∘ p)|) := by
|
| 27 |
-
classical
|
| 28 |
-
let q (i:I) := swab (twistSign (dip w (f i) h))
|
| 29 |
-
let V (x) := avg u (fun i=> f i x * q i)
|
| 30 |
-
have hx (h : Wgt A) :
|
| 31 |
-
avg u (fun i=> dip w (f i) h * q i)=dip w V h := by
|
| 32 |
-
unfold V dip; simp_rw [← avg_mul]
|
| 33 |
-
rw [avg_avg]
|
| 34 |
-
refine avg_congr fun i _=> avg_congr fun j _=>by ring
|
| 35 |
-
let p (x:A) := twistSign (w x*V x)
|
| 36 |
-
refine ⟨p,?_⟩
|
| 37 |
-
have hV : dip w V h ≤ dip w V (swab ∘ p) := by
|
| 38 |
-
unfold dip avg; refine Finset.sum_le_sum fun i _=> ?_
|
| 39 |
-
dsimp only [Function.comp_apply,p]
|
| 40 |
-
set t := w i*V i with ht
|
| 41 |
-
rw [←mul_assoc,←mul_assoc,←ht,twistabs]
|
| 42 |
-
refine (le_abs_self _).trans ?_
|
| 43 |
-
rw [abs_mul]
|
| 44 |
-
exact (mul_le_mul_of_nonneg_left (hh _) (abs_nonneg _)).trans_eq (mul_one _)
|
| 45 |
-
have h0 i :
|
| 46 |
-
|dip w (f i) h|=dip w (f i) h*q i := (twistabs ..).symm
|
| 47 |
-
simp_rw [h0,hx]; rw [←hx (swab ∘ p)] at hV
|
| 48 |
-
apply le_trans hV
|
| 49 |
-
apply avg_mono hu
|
| 50 |
-
intro i
|
| 51 |
-
rw [← show |dip w (f i) (swab∘p)* q i|=|dip w (f i) (swab∘p)| by rw [abs_mul,swab_abs,mul_one]]
|
| 52 |
-
exact le_abs_self _
|
| 53 |
-
|
| 54 |
-
theorem mean_sq (u : Wgt I) (hu : IsLaw u) (f : Wgt I) :
|
| 55 |
-
avg u f ^ 2 ≤ avg u (fun i=> f i^2) := by
|
| 56 |
-
simpa only [mul_one,one_pow, hu.avg_const] using avg_CS hu.nz f (fun _=>1)
|
| 57 |
-
|
| 58 |
-
set_option maxHeartbeats 800000 in
|
| 59 |
-
theorem erosive (M ε : ℝ) (hM : 0≤M) (hε : 0<ε) :
|
| 60 |
-
∃ k:ℕ,∀ (A I : Type) [Fintype A] [Fintype I]
|
| 61 |
-
(u : Wgt I) (w : Wgt A) (f : I→Wgt A),
|
| 62 |
-
IsLaw u → IsLaw w → (∀ i j,|f i j|≤ M) →
|
| 63 |
-
∃ l:ℕ,l≤ k∧∃ p:A→Fin l,wanes u w f p ε := by
|
| 64 |
-
classical
|
| 65 |
-
obtain ⟨n,hn⟩:=exists_nat_gt (M^2/ε^2)
|
| 66 |
-
rw [div_lt_iff₀ (by positivity)] at hn
|
| 67 |
-
refine ⟨2^n,fun A I _ _ u w f hu hw hf =>?_⟩
|
| 68 |
-
by_contra! h
|
| 69 |
-
have hh (i:ℕ) (hi : i≤ n) :
|
| 70 |
-
∃ p : A→ Fin (2^i),i*ε^2 ≤ hits u w f p := by
|
| 71 |
-
induction i with
|
| 72 |
-
| zero => exact ⟨fun _=>0,(by simp only [Nat.cast_zero,zero_mul,hits]; exact avg_nonneg hu.nz (fun i=>ode_nonneg hw.nz _))⟩
|
| 73 |
-
| succ i ih =>
|
| 74 |
-
obtain ⟨p,hp⟩:=ih (by omega)
|
| 75 |
-
obtain h := h (2^i) (Nat.pow_le_pow_right (by decide) (by omega)) p
|
| 76 |
-
let T (i:I) (x:A) := f i x-banner w p (f i) x
|
| 77 |
-
unfold wanes at h; push Not at h; obtain ⟨a,ha,h⟩:=h
|
| 78 |
-
obtain ⟨s,hs⟩:=tilt_test w u hu.nz T a ha
|
| 79 |
-
let q:= swab∘s
|
| 80 |
-
let e : (Fin (2^i) × Bool)≃ Fin (2^(i+1)) := Fintype.equivFinOfCardEq (by simp [pow_succ])
|
| 81 |
-
let b x := e (p x,s x)
|
| 82 |
-
let P := Prod.fst ∘ e.symm; let Q:= swab ∘ Prod.snd ∘ e.symm
|
| 83 |
-
have hP : P∘b=p := by funext i; simp [P,b]
|
| 84 |
-
have hQ : Q∘b=q := by funext i; simp [q,Q,b]
|
| 85 |
-
have he x : ode w (banner w p (f x)) + dip w (T x) q ^2 ≤ ode w (banner w b (f x)) := by
|
| 86 |
-
have he := archive_gain hw.sub (f x) b P Q (fun i=>by unfold Q; simp [swab_abs])
|
| 87 |
-
rw [hP,hQ] at he
|
| 88 |
-
change ode _ _+dip w (fun i=> f x i-banner w p (f x) i) q ^2≤_
|
| 89 |
-
linarith only [he]
|
| 90 |
-
let V i:= |dip w (T i) q|
|
| 91 |
-
have hz : ε ≤ avg u V := h.le.trans hs
|
| 92 |
-
have hb := (pow_le_pow_left₀ hε.le hz 2).trans (mean_sq u hu V)
|
| 93 |
-
have hh := avg_mono hu.nz he
|
| 94 |
-
rw [avg_add] at hh
|
| 95 |
-
change hits u w f p + _ ≤ hits u w f b at hh
|
| 96 |
-
unfold V at hb; simp_rw [sq_abs] at hb
|
| 97 |
-
refine ⟨b,?_⟩
|
| 98 |
-
push_cast; linarith only [hp,hb,hh]
|
| 99 |
-
obtain ⟨p,hp⟩ := hh n le_rfl
|
| 100 |
-
have h (i:I) : ∀ x:A,|banner w p (f i) x|≤ M :=
|
| 101 |
-
fun i'=> cashbook_bound w hw.nz p _ _ hM (hf i) (p i')
|
| 102 |
-
exact not_lt_of_ge (hp.trans (hu.avg_le (fun i=> ode_upper hw.sub _ M (h i)))) hn
|
| 103 |
-
end HadwigerCounterexample
|
| 104 |
-
|
| 105 |
-
end
|
| 106 |
-
|
| 107 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RectangleRegularity
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Residual Regularity -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix LinearMap Function Filter Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B I : Type} [Fintype A] [Fintype B] [Fintype I]
|
| 12 |
+
|
| 13 |
+
def wanes (u : Wgt I) (w : Wgt A) (f : I→Wgt A) (p : A→B) (ε : ℝ) :=
|
| 14 |
+
∀ h : Wgt A,(∀ x,|h x| ≤ 1) →
|
| 15 |
+
avg u (fun i => |dip w (fun x=> f i x - banner w p (f i) x) h|) ≤ ε
|
| 16 |
+
def hits (u : Wgt I) (w : Wgt A) (f : I→ Wgt A) (p : A→ B) :=
|
| 17 |
+
avg u (fun i => ode w (banner w p (f i)))
|
| 18 |
+
|
| 19 |
+
private def twistSign (b : ℝ) := decide (0≤ b)
|
| 20 |
+
private theorem twistabs (b : ℝ) : b*swab (twistSign b)=|b| := by
|
| 21 |
+
classical by_cases h : 0≤b <;> simp [swab,twistSign,h,abs_of_nonneg,abs_of_neg,lt_of_not_ge]
|
| 22 |
+
|
| 23 |
+
set_option maxHeartbeats 600000 in
|
| 24 |
+
theorem tilt_test (w : Wgt A) (u : Wgt I) (hu : ∀ i,0 ≤ u i) (f : I → Wgt A) (h : Wgt A)
|
| 25 |
+
(hh : ∀ x,|h x|≤1) :
|
| 26 |
+
∃ p : A→Bool, avg u (fun i=>|dip w (f i) h|) ≤ avg u (fun i => |dip w (f i) (swab∘ p)|) := by
|
| 27 |
+
classical
|
| 28 |
+
let q (i:I) := swab (twistSign (dip w (f i) h))
|
| 29 |
+
let V (x) := avg u (fun i=> f i x * q i)
|
| 30 |
+
have hx (h : Wgt A) :
|
| 31 |
+
avg u (fun i=> dip w (f i) h * q i)=dip w V h := by
|
| 32 |
+
unfold V dip; simp_rw [← avg_mul]
|
| 33 |
+
rw [avg_avg]
|
| 34 |
+
refine avg_congr fun i _=> avg_congr fun j _=>by ring
|
| 35 |
+
let p (x:A) := twistSign (w x*V x)
|
| 36 |
+
refine ⟨p,?_⟩
|
| 37 |
+
have hV : dip w V h ≤ dip w V (swab ∘ p) := by
|
| 38 |
+
unfold dip avg; refine Finset.sum_le_sum fun i _=> ?_
|
| 39 |
+
dsimp only [Function.comp_apply,p]
|
| 40 |
+
set t := w i*V i with ht
|
| 41 |
+
rw [←mul_assoc,←mul_assoc,←ht,twistabs]
|
| 42 |
+
refine (le_abs_self _).trans ?_
|
| 43 |
+
rw [abs_mul]
|
| 44 |
+
exact (mul_le_mul_of_nonneg_left (hh _) (abs_nonneg _)).trans_eq (mul_one _)
|
| 45 |
+
have h0 i :
|
| 46 |
+
|dip w (f i) h|=dip w (f i) h*q i := (twistabs ..).symm
|
| 47 |
+
simp_rw [h0,hx]; rw [←hx (swab ∘ p)] at hV
|
| 48 |
+
apply le_trans hV
|
| 49 |
+
apply avg_mono hu
|
| 50 |
+
intro i
|
| 51 |
+
rw [← show |dip w (f i) (swab∘p)* q i|=|dip w (f i) (swab∘p)| by rw [abs_mul,swab_abs,mul_one]]
|
| 52 |
+
exact le_abs_self _
|
| 53 |
+
|
| 54 |
+
theorem mean_sq (u : Wgt I) (hu : IsLaw u) (f : Wgt I) :
|
| 55 |
+
avg u f ^ 2 ≤ avg u (fun i=> f i^2) := by
|
| 56 |
+
simpa only [mul_one,one_pow, hu.avg_const] using avg_CS hu.nz f (fun _=>1)
|
| 57 |
+
|
| 58 |
+
set_option maxHeartbeats 800000 in
|
| 59 |
+
theorem erosive (M ε : ℝ) (hM : 0≤M) (hε : 0<ε) :
|
| 60 |
+
∃ k:ℕ,∀ (A I : Type) [Fintype A] [Fintype I]
|
| 61 |
+
(u : Wgt I) (w : Wgt A) (f : I→Wgt A),
|
| 62 |
+
IsLaw u → IsLaw w → (∀ i j,|f i j|≤ M) →
|
| 63 |
+
∃ l:ℕ,l≤ k∧∃ p:A→Fin l,wanes u w f p ε := by
|
| 64 |
+
classical
|
| 65 |
+
obtain ⟨n,hn⟩:=exists_nat_gt (M^2/ε^2)
|
| 66 |
+
rw [div_lt_iff₀ (by positivity)] at hn
|
| 67 |
+
refine ⟨2^n,fun A I _ _ u w f hu hw hf =>?_⟩
|
| 68 |
+
by_contra! h
|
| 69 |
+
have hh (i:ℕ) (hi : i≤ n) :
|
| 70 |
+
∃ p : A→ Fin (2^i),i*ε^2 ≤ hits u w f p := by
|
| 71 |
+
induction i with
|
| 72 |
+
| zero => exact ⟨fun _=>0,(by simp only [Nat.cast_zero,zero_mul,hits]; exact avg_nonneg hu.nz (fun i=>ode_nonneg hw.nz _))⟩
|
| 73 |
+
| succ i ih =>
|
| 74 |
+
obtain ⟨p,hp⟩:=ih (by omega)
|
| 75 |
+
obtain h := h (2^i) (Nat.pow_le_pow_right (by decide) (by omega)) p
|
| 76 |
+
let T (i:I) (x:A) := f i x-banner w p (f i) x
|
| 77 |
+
unfold wanes at h; push Not at h; obtain ⟨a,ha,h⟩:=h
|
| 78 |
+
obtain ⟨s,hs⟩:=tilt_test w u hu.nz T a ha
|
| 79 |
+
let q:= swab∘s
|
| 80 |
+
let e : (Fin (2^i) × Bool)≃ Fin (2^(i+1)) := Fintype.equivFinOfCardEq (by simp [pow_succ])
|
| 81 |
+
let b x := e (p x,s x)
|
| 82 |
+
let P := Prod.fst ∘ e.symm; let Q:= swab ∘ Prod.snd ∘ e.symm
|
| 83 |
+
have hP : P∘b=p := by funext i; simp [P,b]
|
| 84 |
+
have hQ : Q∘b=q := by funext i; simp [q,Q,b]
|
| 85 |
+
have he x : ode w (banner w p (f x)) + dip w (T x) q ^2 ≤ ode w (banner w b (f x)) := by
|
| 86 |
+
have he := archive_gain hw.sub (f x) b P Q (fun i=>by unfold Q; simp [swab_abs])
|
| 87 |
+
rw [hP,hQ] at he
|
| 88 |
+
change ode _ _+dip w (fun i=> f x i-banner w p (f x) i) q ^2≤_
|
| 89 |
+
linarith only [he]
|
| 90 |
+
let V i:= |dip w (T i) q|
|
| 91 |
+
have hz : ε ≤ avg u V := h.le.trans hs
|
| 92 |
+
have hb := (pow_le_pow_left₀ hε.le hz 2).trans (mean_sq u hu V)
|
| 93 |
+
have hh := avg_mono hu.nz he
|
| 94 |
+
rw [avg_add] at hh
|
| 95 |
+
change hits u w f p + _ ≤ hits u w f b at hh
|
| 96 |
+
unfold V at hb; simp_rw [sq_abs] at hb
|
| 97 |
+
refine ⟨b,?_⟩
|
| 98 |
+
push_cast; linarith only [hp,hb,hh]
|
| 99 |
+
obtain ⟨p,hp⟩ := hh n le_rfl
|
| 100 |
+
have h (i:I) : ∀ x:A,|banner w p (f i) x|≤ M :=
|
| 101 |
+
fun i'=> cashbook_bound w hw.nz p _ _ hM (hf i) (p i')
|
| 102 |
+
exact not_lt_of_ge (hp.trans (hu.avg_le (fun i=> ode_upper hw.sub _ M (h i)))) hn
|
| 103 |
+
end HadwigerCounterexample
|
| 104 |
+
|
| 105 |
+
end
|
| 106 |
+
|
| 107 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ResponseAnnihilators.lean
CHANGED
|
@@ -1,206 +1,206 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FrozenProjections
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Response Annihilators -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix Finset LinearMap Submodule Module
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n : ℕ}
|
| 12 |
-
variable {I : Type} [Fintype I]
|
| 13 |
-
|
| 14 |
-
def dotL (x : Vec I) : Vec I →ₗ[F] F where
|
| 15 |
-
toFun y := dotProduct x y
|
| 16 |
-
map_add' u v := dotProduct_add x _ _
|
| 17 |
-
map_smul' b u := by
|
| 18 |
-
simp only [dotProduct,Pi.smul_apply,RingHom.id_apply,smul_eq_mul,mul_sum,mul_left_comm]
|
| 19 |
-
|
| 20 |
-
theorem dotL_surj (x : Vec I →ₗ[F] F) : ∃ y : Vec I,x=dotL y := by
|
| 21 |
-
classical
|
| 22 |
-
let y (i:I) := x (Pi.single i 1)
|
| 23 |
-
refine ⟨y,LinearMap.ext fun v => ?_⟩
|
| 24 |
-
have he : x v=x (∑ i, Pi.single i (v i)) := by rw [Finset.univ_sum_single]
|
| 25 |
-
rw [he,map_sum]
|
| 26 |
-
change (∑ i,x (Pi.single i (v i)))=∑ i,y i*v i
|
| 27 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 28 |
-
rw [show Pi.single i (v i)=v i • (Pi.single i 1 : Vec I) from (by
|
| 29 |
-
funext j
|
| 30 |
-
by_cases h : j = i
|
| 31 |
-
· simp [h]
|
| 32 |
-
simp [Pi.single_eq_of_ne h]),
|
| 33 |
-
map_smul]
|
| 34 |
-
exact mul_comm _ _
|
| 35 |
-
|
| 36 |
-
private theorem protection_test {S : Space (Ray p n)} {q} {E L : Finset (Label p.b)}
|
| 37 |
-
(h : protectedBy p S q E) {s} (hs : s∈L) (he : s∉E) (hl : L.card≤q)
|
| 38 |
-
(ψ : Vec (AIdx p.g n)) :
|
| 39 |
-
∃ x ∈ annih S,∀ j∈L,(labMat p n j)ᵀ *ᵥ x= if j=s then ψ else 0 := by
|
| 40 |
-
classical
|
| 41 |
-
let P := S.subtype.coprod (labcomb p n L)
|
| 42 |
-
let Q := dotL ψ ∘ₗ LinearMap.proj s ∘ₗ (LinearMap.snd F S (LabVals p n))
|
| 43 |
-
obtain ⟨f,hf⟩ : ∃ f,f ∘ₗ P=Q := by
|
| 44 |
-
refine HadwigerCounterexample.mem_range_comp (show LinearMap.ker P≤LinearMap.ker Q from ?_)
|
| 45 |
-
rintro ⟨w,z⟩ hw
|
| 46 |
-
change w.val + labcomb p n L z=0 at hw
|
| 47 |
-
have hb : labcomb p n L z ∈ S := by
|
| 48 |
-
rw [show labcomb p n L z=w.val from add_left_cancel (hw.trans (char_two w.val).symm)]
|
| 49 |
-
exact w.property
|
| 50 |
-
change dotProduct ψ (z s)=0
|
| 51 |
-
rw [h L z hb hl s hs he,dotProduct_zero]
|
| 52 |
-
obtain ⟨x,rfl⟩ := dotL_surj f
|
| 53 |
-
refine ⟨x,?_,fun j hj => ?_⟩
|
| 54 |
-
· rw [annih_mem]; intro y hy
|
| 55 |
-
have hh := LinearMap.congr_fun hf (⟨y,hy⟩,0)
|
| 56 |
-
change dotProduct x (y+labcomb p n L 0)=dotProduct ψ 0 at hh
|
| 57 |
-
rw [map_zero,add_zero,dotProduct_zero] at hh
|
| 58 |
-
exact hh
|
| 59 |
-
have h1 (z : Vec (AIdx p.g n)) : dotProduct z ((labMat p n j)ᵀ *ᵥ x)=
|
| 60 |
-
if j=s then dotProduct ψ z else 0 := by
|
| 61 |
-
let y : LabVals p n := Pi.single j z
|
| 62 |
-
have hh := LinearMap.congr_fun hf (0,y)
|
| 63 |
-
change dotProduct x (0+labcomb p n L y)=dotProduct ψ (y s) at hh
|
| 64 |
-
have hh' : labcomb p n L y = putLab p n j z := by
|
| 65 |
-
rw [labcomb_eval,Finset.sum_eq_single j]
|
| 66 |
-
· simp [y]
|
| 67 |
-
· intro k _ hk; simp [y,Pi.single_eq_of_ne hk]
|
| 68 |
-
simp [hj]
|
| 69 |
-
rw [dotProduct_transpose_mulVec,labMat_act]
|
| 70 |
-
rw [zero_add,hh'] at hh
|
| 71 |
-
rw [hh]
|
| 72 |
-
by_cases h : j = s
|
| 73 |
-
· simp [y,h]
|
| 74 |
-
simp [y,h]
|
| 75 |
-
funext i
|
| 76 |
-
have h2 := h1 (Pi.single i 1)
|
| 77 |
-
by_cases hh : j = s
|
| 78 |
-
· simpa only [hh,ite_true,dotProduct_single,single_dotProduct,mul_one,one_mul] using h2
|
| 79 |
-
simpa only [ite_eq_right hh,Pi.zero_apply,single_dotProduct,one_mul] using h2
|
| 80 |
-
|
| 81 |
-
namespace Volley
|
| 82 |
-
variable {v : Volley p n I}
|
| 83 |
-
|
| 84 |
-
private theorem mark_test {w : I → Bool} (hb : v.bounded w)
|
| 85 |
-
(t : Tagging p I) {a : Plan p n} {q} (hv : v.avoids a q)
|
| 86 |
-
(j : I) (z : Place p) (L : Finset (Label p.b)) (hl : L.card+14 ≤ q)
|
| 87 |
-
(ψ : Vec (AIdx p.g n))
|
| 88 |
-
(hh : inc z.1 (t j) → dotProduct ψ (baseV (v.par j)) = 0) :
|
| 89 |
-
∃ x ∈ annih (sPin (v.frozen a t) z (v.obj j)),∀ k∈L,(labMat p n k)ᵀ *ᵥ x=
|
| 90 |
-
if k=v.sel j then ψ else 0 := by
|
| 91 |
-
classical
|
| 92 |
-
let i := v.obj j
|
| 93 |
-
obtain ⟨B,hB,hj,hc,hsel⟩ := hv i
|
| 94 |
-
let T := L∪v.marked i
|
| 95 |
-
have hT : T.card ≤ q :=
|
| 96 |
-
(Finset.card_union_le _ _).trans ((Nat.add_le_add_left (v.marked_card hb i) L.card).trans hl)
|
| 97 |
-
have hjj : j ∈ v.here i := by simp [here,i]
|
| 98 |
-
obtain ⟨x,hx,hX⟩ := protection_test (L:=T) (hB z)
|
| 99 |
-
(mem_union_right L (v.marked_mem j)) (hj _ hjj) hT ψ
|
| 100 |
-
refine ⟨x, ?_, fun k hk => hX k (mem_union_left _ hk)⟩
|
| 101 |
-
have he : sPin (v.frozen a t) z i ≤ LinearMap.ker (dotL x) := by
|
| 102 |
-
rw [v.sPin_frozen]
|
| 103 |
-
refine sup_le (fun y hy => (annih_mem ..).mp hx y hy) ?_
|
| 104 |
-
rintro y ⟨y,⟨u,rfl⟩,rfl⟩
|
| 105 |
-
rw [LinearMap.mem_ker]
|
| 106 |
-
rw [mulVecLin_apply,mulVecLin_apply,v.key_proj,map_sum]
|
| 107 |
-
refine Finset.sum_eq_zero fun k hk => ?_
|
| 108 |
-
rw [map_smul]
|
| 109 |
-
suffices h : dotL x (v.rayAt k.val)=0 by rw [h,smul_zero]
|
| 110 |
-
change dotProduct x (point p (v.sel k.val) (v.par k.val))= _
|
| 111 |
-
have hh' : k.val ∈ v.here i := (v.visitH_here ..).mp hk
|
| 112 |
-
have hx' : v.sel k.val ∈ T := mem_union_right _ (Finset.mem_image_of_mem _ hh')
|
| 113 |
-
rw [point,←labMat_act, ←dotProduct_transpose_mulVec,hX _ hx']
|
| 114 |
-
by_cases h : v.sel k.val=v.sel j
|
| 115 |
-
· have he' : k.val=j := hsel hh' hjj h
|
| 116 |
-
rw [ite_eq_left h,dotProduct_comm,he']
|
| 117 |
-
exact hh (he' ▸ k.property)
|
| 118 |
-
rw [ite_eq_right h,dotProduct_zero]
|
| 119 |
-
rw [annih_mem]
|
| 120 |
-
exact fun y hy => he hy
|
| 121 |
-
|
| 122 |
-
private theorem ev_mput (s : Label p.b) (M : BaseMat p n) (x y : Ray p n) :
|
| 123 |
-
evmat (mput p s M) x y = evmat M ((labMat p n s)ᵀ *ᵥ x) ((labMat p n s)ᵀ *ᵥ y) := by
|
| 124 |
-
rw [← evmat_pull]
|
| 125 |
-
unfold mput pullM
|
| 126 |
-
rw [transpose_transpose]
|
| 127 |
-
|
| 128 |
-
/-- Diagnostic for the two quotients by one affine ray. -/
|
| 129 |
-
private theorem mark_diag {J : Type} [Fintype J] (Z : Mat (Option J) (Option J))
|
| 130 |
-
(hZ : Zᵀ = Z) (hd : ∀ i,Z i i=Z none i) (v : Vec (Option J))
|
| 131 |
-
(hv : v none=1) (he : ∀ φ, dotProduct φ v = 0 → ∀ ψ, dotProduct ψ v = 0 →
|
| 132 |
-
evmat Z φ ψ=0) :
|
| 133 |
-
Z = (Z none none) • vecMulVec v v := by
|
| 134 |
-
classical
|
| 135 |
-
let θ (i : Option J) := Pi.single i 1 + (Pi.single none (v i) : Vec (Option J))
|
| 136 |
-
have hθ (i) : dotProduct (θ i) v=0 := by
|
| 137 |
-
rw [show θ i=_+_ from rfl,add_dotProduct,single_dotProduct,single_dotProduct,
|
| 138 |
-
hv,one_mul,mul_one,char_two]
|
| 139 |
-
have hg (i j : Option J) :
|
| 140 |
-
Z i j + Z i none * v j + (v i*(Z none j)+v i * (Z none none * v j)) = 0 := by
|
| 141 |
-
|
| 142 |
-
have hh := he _ (hθ i) _ (hθ j)
|
| 143 |
-
simp only [θ,evmat,Matrix.mulVec_add,add_dotProduct,dotProduct_add, single_dotProduct,Matrix.mulVec_single,op_smul_eq_smul, one_mul,one_smul,Pi.smul_apply,smul_eq_mul,col_apply] at hh
|
| 144 |
-
simpa only [mul_comm,mul_left_comm,mul_assoc,add_comm,add_left_comm,add_assoc] using hh
|
| 145 |
-
have hf i : Z i none=Z none i := congr_fun (congr_fun hZ none) i
|
| 146 |
-
have h0 (i : Option J) : Z none i=Z none none * v i := by
|
| 147 |
-
have h := hg i i
|
| 148 |
-
rw [hd i,hf,mul_comm (Z none i),show v i*(Z none none*v i)=Z none none*v i from
|
| 149 |
-
(by rw [mul_left_comm,bit_sq])] at h
|
| 150 |
-
have h' : Z none i+Z none none*v i=0 := calc
|
| 151 |
-
_ = Z none i + ((v i * Z none i+v i * Z none i)+Z none none*v i) := by rw [char_two,zero_add]
|
| 152 |
-
_ = 0 := (by simpa only [add_assoc] using h)
|
| 153 |
-
exact add_right_cancel (h'.trans (char_two _).symm)
|
| 154 |
-
ext i j
|
| 155 |
-
change Z i j=Z none none*(v i*v j)
|
| 156 |
-
have h := hg i j
|
| 157 |
-
rw [h0 j,char_two,add_zero,hf,h0, mul_assoc] at h
|
| 158 |
-
exact add_right_cancel (h.trans (char_two _).symm)
|
| 159 |
-
|
| 160 |
-
set_option maxHeartbeats 600000 in
|
| 161 |
-
theorem mark_atom {w : I → Bool} (hb : v.bounded w)
|
| 162 |
-
(t : Tagging p I) {a : Plan p n} {q} (hv : v.avoids a q)
|
| 163 |
-
(j : I) (e : Comp p.g)
|
| 164 |
-
(L : Finset (Label p.b)) (hl : L.card+14≤q)
|
| 165 |
-
(Z : Label p.b → BaseMat p n)
|
| 166 |
-
(ht : ∀ s,s∉L → Z s=0) (hh : ∀ s∈L,(Z s)ᵀ=Z s ∧ ∀ i,Z s i i=Z s none i)
|
| 167 |
-
(hg : vanish (sPin (v.frozen a t) (e,true) (v.obj j))
|
| 168 |
-
(sPin (v.frozen a t) (e,false) (v.obj j)) (labelSum p L Z)) :
|
| 169 |
-
Z (v.sel j) = if inc e (t j) then
|
| 170 |
-
Z (v.sel j) none none • vecMulVec (baseV (v.par j)) (baseV (v.par j)) else 0 := by
|
| 171 |
-
classical
|
| 172 |
-
let s := v.sel j
|
| 173 |
-
change Z s = if inc e (t j) then _ else _
|
| 174 |
-
by_cases hs : s∈L
|
| 175 |
-
· let y := baseV (v.par j)
|
| 176 |
-
have he (φ ψ : Vec (AIdx p.g n)) (hφ : inc e (t j) → dotProduct φ y=0)
|
| 177 |
-
(hψ : inc e (t j) → dotProduct ψ y=0) :
|
| 178 |
-
evmat (Z s) φ ψ=0 := by
|
| 179 |
-
obtain ⟨x,hx,hX⟩ := mark_test hb t hv j (e,true) L hl φ hφ
|
| 180 |
-
obtain ⟨y,hy,hY⟩ := mark_test hb t hv j (e,false) L hl ψ hψ
|
| 181 |
-
have h := hg x hx y hy
|
| 182 |
-
unfold labelSum at h
|
| 183 |
-
rw [←mpair_outer,mpair_sum,Finset.sum_eq_single s] at h
|
| 184 |
-
· rwa [mpair_outer,ev_mput,hX _ hs,hY _ hs,ite_eq_left rfl,ite_eq_left rfl] at h
|
| 185 |
-
· intro i hi he; rw [mpair_outer,ev_mput,hX _ hi,hY _ hi,ite_eq_right he,ite_eq_right he]
|
| 186 |
-
simp [evmat]
|
| 187 |
-
simp [hs]
|
| 188 |
-
by_cases h : inc e (t j)
|
| 189 |
-
· rw [ite_eq_left h]
|
| 190 |
-
exact mark_diag _ (hh s hs).1 (hh s hs).2 y rfl (fun φ hφ ψ hψ => he φ ψ (fun _ => hφ)
|
| 191 |
-
(fun _ => hψ))
|
| 192 |
-
rw [ite_eq_right h]
|
| 193 |
-
apply evmat_ext
|
| 194 |
-
intro φ ψ
|
| 195 |
-
rw [he φ ψ (fun e => (h e).elim) (fun e => (h e).elim)]
|
| 196 |
-
simp [evmat]
|
| 197 |
-
change Z s = if inc e (t j) then Z s none none • _ else _
|
| 198 |
-
rw [ht s hs]
|
| 199 |
-
simp
|
| 200 |
-
|
| 201 |
-
end Volley
|
| 202 |
-
end HadwigerCounterexample
|
| 203 |
-
|
| 204 |
-
end
|
| 205 |
-
|
| 206 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FrozenProjections
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Response Annihilators -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix Finset LinearMap Submodule Module
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n : ℕ}
|
| 12 |
+
variable {I : Type} [Fintype I]
|
| 13 |
+
|
| 14 |
+
def dotL (x : Vec I) : Vec I →ₗ[F] F where
|
| 15 |
+
toFun y := dotProduct x y
|
| 16 |
+
map_add' u v := dotProduct_add x _ _
|
| 17 |
+
map_smul' b u := by
|
| 18 |
+
simp only [dotProduct,Pi.smul_apply,RingHom.id_apply,smul_eq_mul,mul_sum,mul_left_comm]
|
| 19 |
+
|
| 20 |
+
theorem dotL_surj (x : Vec I →ₗ[F] F) : ∃ y : Vec I,x=dotL y := by
|
| 21 |
+
classical
|
| 22 |
+
let y (i:I) := x (Pi.single i 1)
|
| 23 |
+
refine ⟨y,LinearMap.ext fun v => ?_⟩
|
| 24 |
+
have he : x v=x (∑ i, Pi.single i (v i)) := by rw [Finset.univ_sum_single]
|
| 25 |
+
rw [he,map_sum]
|
| 26 |
+
change (∑ i,x (Pi.single i (v i)))=∑ i,y i*v i
|
| 27 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 28 |
+
rw [show Pi.single i (v i)=v i • (Pi.single i 1 : Vec I) from (by
|
| 29 |
+
funext j
|
| 30 |
+
by_cases h : j = i
|
| 31 |
+
· simp [h]
|
| 32 |
+
simp [Pi.single_eq_of_ne h]),
|
| 33 |
+
map_smul]
|
| 34 |
+
exact mul_comm _ _
|
| 35 |
+
|
| 36 |
+
private theorem protection_test {S : Space (Ray p n)} {q} {E L : Finset (Label p.b)}
|
| 37 |
+
(h : protectedBy p S q E) {s} (hs : s∈L) (he : s∉E) (hl : L.card≤q)
|
| 38 |
+
(ψ : Vec (AIdx p.g n)) :
|
| 39 |
+
∃ x ∈ annih S,∀ j∈L,(labMat p n j)ᵀ *ᵥ x= if j=s then ψ else 0 := by
|
| 40 |
+
classical
|
| 41 |
+
let P := S.subtype.coprod (labcomb p n L)
|
| 42 |
+
let Q := dotL ψ ∘ₗ LinearMap.proj s ∘ₗ (LinearMap.snd F S (LabVals p n))
|
| 43 |
+
obtain ⟨f,hf⟩ : ∃ f,f ∘ₗ P=Q := by
|
| 44 |
+
refine HadwigerCounterexample.mem_range_comp (show LinearMap.ker P≤LinearMap.ker Q from ?_)
|
| 45 |
+
rintro ⟨w,z⟩ hw
|
| 46 |
+
change w.val + labcomb p n L z=0 at hw
|
| 47 |
+
have hb : labcomb p n L z ∈ S := by
|
| 48 |
+
rw [show labcomb p n L z=w.val from add_left_cancel (hw.trans (char_two w.val).symm)]
|
| 49 |
+
exact w.property
|
| 50 |
+
change dotProduct ψ (z s)=0
|
| 51 |
+
rw [h L z hb hl s hs he,dotProduct_zero]
|
| 52 |
+
obtain ⟨x,rfl⟩ := dotL_surj f
|
| 53 |
+
refine ⟨x,?_,fun j hj => ?_⟩
|
| 54 |
+
· rw [annih_mem]; intro y hy
|
| 55 |
+
have hh := LinearMap.congr_fun hf (⟨y,hy⟩,0)
|
| 56 |
+
change dotProduct x (y+labcomb p n L 0)=dotProduct ψ 0 at hh
|
| 57 |
+
rw [map_zero,add_zero,dotProduct_zero] at hh
|
| 58 |
+
exact hh
|
| 59 |
+
have h1 (z : Vec (AIdx p.g n)) : dotProduct z ((labMat p n j)ᵀ *ᵥ x)=
|
| 60 |
+
if j=s then dotProduct ψ z else 0 := by
|
| 61 |
+
let y : LabVals p n := Pi.single j z
|
| 62 |
+
have hh := LinearMap.congr_fun hf (0,y)
|
| 63 |
+
change dotProduct x (0+labcomb p n L y)=dotProduct ψ (y s) at hh
|
| 64 |
+
have hh' : labcomb p n L y = putLab p n j z := by
|
| 65 |
+
rw [labcomb_eval,Finset.sum_eq_single j]
|
| 66 |
+
· simp [y]
|
| 67 |
+
· intro k _ hk; simp [y,Pi.single_eq_of_ne hk]
|
| 68 |
+
simp [hj]
|
| 69 |
+
rw [dotProduct_transpose_mulVec,labMat_act]
|
| 70 |
+
rw [zero_add,hh'] at hh
|
| 71 |
+
rw [hh]
|
| 72 |
+
by_cases h : j = s
|
| 73 |
+
· simp [y,h]
|
| 74 |
+
simp [y,h]
|
| 75 |
+
funext i
|
| 76 |
+
have h2 := h1 (Pi.single i 1)
|
| 77 |
+
by_cases hh : j = s
|
| 78 |
+
· simpa only [hh,ite_true,dotProduct_single,single_dotProduct,mul_one,one_mul] using h2
|
| 79 |
+
simpa only [ite_eq_right hh,Pi.zero_apply,single_dotProduct,one_mul] using h2
|
| 80 |
+
|
| 81 |
+
namespace Volley
|
| 82 |
+
variable {v : Volley p n I}
|
| 83 |
+
|
| 84 |
+
private theorem mark_test {w : I → Bool} (hb : v.bounded w)
|
| 85 |
+
(t : Tagging p I) {a : Plan p n} {q} (hv : v.avoids a q)
|
| 86 |
+
(j : I) (z : Place p) (L : Finset (Label p.b)) (hl : L.card+14 ≤ q)
|
| 87 |
+
(ψ : Vec (AIdx p.g n))
|
| 88 |
+
(hh : inc z.1 (t j) → dotProduct ψ (baseV (v.par j)) = 0) :
|
| 89 |
+
∃ x ∈ annih (sPin (v.frozen a t) z (v.obj j)),∀ k∈L,(labMat p n k)ᵀ *ᵥ x=
|
| 90 |
+
if k=v.sel j then ψ else 0 := by
|
| 91 |
+
classical
|
| 92 |
+
let i := v.obj j
|
| 93 |
+
obtain ⟨B,hB,hj,hc,hsel⟩ := hv i
|
| 94 |
+
let T := L∪v.marked i
|
| 95 |
+
have hT : T.card ≤ q :=
|
| 96 |
+
(Finset.card_union_le _ _).trans ((Nat.add_le_add_left (v.marked_card hb i) L.card).trans hl)
|
| 97 |
+
have hjj : j ∈ v.here i := by simp [here,i]
|
| 98 |
+
obtain ⟨x,hx,hX⟩ := protection_test (L:=T) (hB z)
|
| 99 |
+
(mem_union_right L (v.marked_mem j)) (hj _ hjj) hT ψ
|
| 100 |
+
refine ⟨x, ?_, fun k hk => hX k (mem_union_left _ hk)⟩
|
| 101 |
+
have he : sPin (v.frozen a t) z i ≤ LinearMap.ker (dotL x) := by
|
| 102 |
+
rw [v.sPin_frozen]
|
| 103 |
+
refine sup_le (fun y hy => (annih_mem ..).mp hx y hy) ?_
|
| 104 |
+
rintro y ⟨y,⟨u,rfl⟩,rfl⟩
|
| 105 |
+
rw [LinearMap.mem_ker]
|
| 106 |
+
rw [mulVecLin_apply,mulVecLin_apply,v.key_proj,map_sum]
|
| 107 |
+
refine Finset.sum_eq_zero fun k hk => ?_
|
| 108 |
+
rw [map_smul]
|
| 109 |
+
suffices h : dotL x (v.rayAt k.val)=0 by rw [h,smul_zero]
|
| 110 |
+
change dotProduct x (point p (v.sel k.val) (v.par k.val))= _
|
| 111 |
+
have hh' : k.val ∈ v.here i := (v.visitH_here ..).mp hk
|
| 112 |
+
have hx' : v.sel k.val ∈ T := mem_union_right _ (Finset.mem_image_of_mem _ hh')
|
| 113 |
+
rw [point,←labMat_act, ←dotProduct_transpose_mulVec,hX _ hx']
|
| 114 |
+
by_cases h : v.sel k.val=v.sel j
|
| 115 |
+
· have he' : k.val=j := hsel hh' hjj h
|
| 116 |
+
rw [ite_eq_left h,dotProduct_comm,he']
|
| 117 |
+
exact hh (he' ▸ k.property)
|
| 118 |
+
rw [ite_eq_right h,dotProduct_zero]
|
| 119 |
+
rw [annih_mem]
|
| 120 |
+
exact fun y hy => he hy
|
| 121 |
+
|
| 122 |
+
private theorem ev_mput (s : Label p.b) (M : BaseMat p n) (x y : Ray p n) :
|
| 123 |
+
evmat (mput p s M) x y = evmat M ((labMat p n s)ᵀ *ᵥ x) ((labMat p n s)ᵀ *ᵥ y) := by
|
| 124 |
+
rw [← evmat_pull]
|
| 125 |
+
unfold mput pullM
|
| 126 |
+
rw [transpose_transpose]
|
| 127 |
+
|
| 128 |
+
/-- Diagnostic for the two quotients by one affine ray. -/
|
| 129 |
+
private theorem mark_diag {J : Type} [Fintype J] (Z : Mat (Option J) (Option J))
|
| 130 |
+
(hZ : Zᵀ = Z) (hd : ∀ i,Z i i=Z none i) (v : Vec (Option J))
|
| 131 |
+
(hv : v none=1) (he : ∀ φ, dotProduct φ v = 0 → ∀ ψ, dotProduct ψ v = 0 →
|
| 132 |
+
evmat Z φ ψ=0) :
|
| 133 |
+
Z = (Z none none) • vecMulVec v v := by
|
| 134 |
+
classical
|
| 135 |
+
let θ (i : Option J) := Pi.single i 1 + (Pi.single none (v i) : Vec (Option J))
|
| 136 |
+
have hθ (i) : dotProduct (θ i) v=0 := by
|
| 137 |
+
rw [show θ i=_+_ from rfl,add_dotProduct,single_dotProduct,single_dotProduct,
|
| 138 |
+
hv,one_mul,mul_one,char_two]
|
| 139 |
+
have hg (i j : Option J) :
|
| 140 |
+
Z i j + Z i none * v j + (v i*(Z none j)+v i * (Z none none * v j)) = 0 := by
|
| 141 |
+
|
| 142 |
+
have hh := he _ (hθ i) _ (hθ j)
|
| 143 |
+
simp only [θ,evmat,Matrix.mulVec_add,add_dotProduct,dotProduct_add, single_dotProduct,Matrix.mulVec_single,op_smul_eq_smul, one_mul,one_smul,Pi.smul_apply,smul_eq_mul,col_apply] at hh
|
| 144 |
+
simpa only [mul_comm,mul_left_comm,mul_assoc,add_comm,add_left_comm,add_assoc] using hh
|
| 145 |
+
have hf i : Z i none=Z none i := congr_fun (congr_fun hZ none) i
|
| 146 |
+
have h0 (i : Option J) : Z none i=Z none none * v i := by
|
| 147 |
+
have h := hg i i
|
| 148 |
+
rw [hd i,hf,mul_comm (Z none i),show v i*(Z none none*v i)=Z none none*v i from
|
| 149 |
+
(by rw [mul_left_comm,bit_sq])] at h
|
| 150 |
+
have h' : Z none i+Z none none*v i=0 := calc
|
| 151 |
+
_ = Z none i + ((v i * Z none i+v i * Z none i)+Z none none*v i) := by rw [char_two,zero_add]
|
| 152 |
+
_ = 0 := (by simpa only [add_assoc] using h)
|
| 153 |
+
exact add_right_cancel (h'.trans (char_two _).symm)
|
| 154 |
+
ext i j
|
| 155 |
+
change Z i j=Z none none*(v i*v j)
|
| 156 |
+
have h := hg i j
|
| 157 |
+
rw [h0 j,char_two,add_zero,hf,h0, mul_assoc] at h
|
| 158 |
+
exact add_right_cancel (h.trans (char_two _).symm)
|
| 159 |
+
|
| 160 |
+
set_option maxHeartbeats 600000 in
|
| 161 |
+
theorem mark_atom {w : I → Bool} (hb : v.bounded w)
|
| 162 |
+
(t : Tagging p I) {a : Plan p n} {q} (hv : v.avoids a q)
|
| 163 |
+
(j : I) (e : Comp p.g)
|
| 164 |
+
(L : Finset (Label p.b)) (hl : L.card+14≤q)
|
| 165 |
+
(Z : Label p.b → BaseMat p n)
|
| 166 |
+
(ht : ∀ s,s∉L → Z s=0) (hh : ∀ s∈L,(Z s)ᵀ=Z s ∧ ∀ i,Z s i i=Z s none i)
|
| 167 |
+
(hg : vanish (sPin (v.frozen a t) (e,true) (v.obj j))
|
| 168 |
+
(sPin (v.frozen a t) (e,false) (v.obj j)) (labelSum p L Z)) :
|
| 169 |
+
Z (v.sel j) = if inc e (t j) then
|
| 170 |
+
Z (v.sel j) none none • vecMulVec (baseV (v.par j)) (baseV (v.par j)) else 0 := by
|
| 171 |
+
classical
|
| 172 |
+
let s := v.sel j
|
| 173 |
+
change Z s = if inc e (t j) then _ else _
|
| 174 |
+
by_cases hs : s∈L
|
| 175 |
+
· let y := baseV (v.par j)
|
| 176 |
+
have he (φ ψ : Vec (AIdx p.g n)) (hφ : inc e (t j) → dotProduct φ y=0)
|
| 177 |
+
(hψ : inc e (t j) → dotProduct ψ y=0) :
|
| 178 |
+
evmat (Z s) φ ψ=0 := by
|
| 179 |
+
obtain ⟨x,hx,hX⟩ := mark_test hb t hv j (e,true) L hl φ hφ
|
| 180 |
+
obtain ⟨y,hy,hY⟩ := mark_test hb t hv j (e,false) L hl ψ hψ
|
| 181 |
+
have h := hg x hx y hy
|
| 182 |
+
unfold labelSum at h
|
| 183 |
+
rw [←mpair_outer,mpair_sum,Finset.sum_eq_single s] at h
|
| 184 |
+
· rwa [mpair_outer,ev_mput,hX _ hs,hY _ hs,ite_eq_left rfl,ite_eq_left rfl] at h
|
| 185 |
+
· intro i hi he; rw [mpair_outer,ev_mput,hX _ hi,hY _ hi,ite_eq_right he,ite_eq_right he]
|
| 186 |
+
simp [evmat]
|
| 187 |
+
simp [hs]
|
| 188 |
+
by_cases h : inc e (t j)
|
| 189 |
+
· rw [ite_eq_left h]
|
| 190 |
+
exact mark_diag _ (hh s hs).1 (hh s hs).2 y rfl (fun φ hφ ψ hψ => he φ ψ (fun _ => hφ)
|
| 191 |
+
(fun _ => hψ))
|
| 192 |
+
rw [ite_eq_right h]
|
| 193 |
+
apply evmat_ext
|
| 194 |
+
intro φ ψ
|
| 195 |
+
rw [he φ ψ (fun e => (h e).elim) (fun e => (h e).elim)]
|
| 196 |
+
simp [evmat]
|
| 197 |
+
change Z s = if inc e (t j) then Z s none none • _ else _
|
| 198 |
+
rw [ht s hs]
|
| 199 |
+
simp
|
| 200 |
+
|
| 201 |
+
end Volley
|
| 202 |
+
end HadwigerCounterexample
|
| 203 |
+
|
| 204 |
+
end
|
| 205 |
+
|
| 206 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ResponseSolvability.lean
CHANGED
|
@@ -1,188 +1,188 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ResidualCutPairs
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Response Solvability -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Module Finset Submodule
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]
|
| 12 |
-
|
| 13 |
-
abbrev Individual (p : Shape) (n : ℕ) := Bool → Profile p n
|
| 14 |
-
abbrev OnForms (p : Shape) (n : ℕ) := Bool → (Profile p n →ₗ[F] F)
|
| 15 |
-
abbrev ReqF (p : Shape) (n : ℕ) := Module.Dual F (Xpair p n)
|
| 16 |
-
|
| 17 |
-
def combineF (p : Shape) {n} : OnForms p n →ₗ[F] ReqF p n where
|
| 18 |
-
toFun f := ∑ i : Bool, f i ∘ₗ (Xspace p n).subtype ∘ₗ LinearMap.proj i
|
| 19 |
-
map_add' f g := LinearMap.ext fun x => by
|
| 20 |
-
simp only [LinearMap.sum_apply,LinearMap.comp_apply,Pi.add_apply,LinearMap.add_apply,
|
| 21 |
-
Finset.sum_add_distrib]
|
| 22 |
-
map_smul' a f := LinearMap.ext fun x => by
|
| 23 |
-
simp only [LinearMap.sum_apply,LinearMap.comp_apply,Pi.smul_apply,LinearMap.smul_apply,
|
| 24 |
-
RingHom.id_apply,smul_eq_mul,mul_sum]
|
| 25 |
-
|
| 26 |
-
theorem combineF_val (f : OnForms p n) (x : Xpair p n) :
|
| 27 |
-
combineF p f x= ∑ i, f i (x i).val := by
|
| 28 |
-
simp only [combineF,LinearMap.coe_mk,AddHom.coe_mk,LinearMap.sum_apply]; rfl
|
| 29 |
-
|
| 30 |
-
theorem combineF_single (f : OnForms p n) (i : Bool) (x : Xspace p n) :
|
| 31 |
-
combineF p f (Pi.single i x)=f i x.val := by
|
| 32 |
-
rw [combineF_val,Finset.sum_eq_single i]
|
| 33 |
-
· rw [Pi.single_eq_same]
|
| 34 |
-
· intro j _ hj; simp [hj]
|
| 35 |
-
simp
|
| 36 |
-
|
| 37 |
-
theorem combineF_same (f g : OnForms p n) : combineF p f=combineF p g ↔
|
| 38 |
-
∀ i,∀ x ∈ Xspace p n,f i x=g i x := by
|
| 39 |
-
constructor
|
| 40 |
-
· intro h i x hx
|
| 41 |
-
exact (combineF_single f i ⟨x,hx⟩).symm.trans (h ▸ combineF_single g i ⟨x,hx⟩)
|
| 42 |
-
intro h
|
| 43 |
-
apply LinearMap.ext; intro x
|
| 44 |
-
rw [combineF_val,combineF_val]
|
| 45 |
-
exact Finset.sum_congr rfl fun i _ => h i _ (x i).property
|
| 46 |
-
|
| 47 |
-
def obsPair (p : Shape) {n} : PureForms p n →ₗ[F] ReqF p n :=
|
| 48 |
-
react p 0 ∘ₗ LinearMap.inr F (ChanOut p n) (PureForms p n)
|
| 49 |
-
|
| 50 |
-
theorem obsPair_val (A : PureForms p n) (x : Xpair p n) :
|
| 51 |
-
obsPair p A x=∑ i,mpair (A i) (purePair p n x i) := by
|
| 52 |
-
change ∑ i : Comp p.g, _ = _
|
| 53 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 54 |
-
change mpair ((chanDeriv p (n:=n) 0 0+A) _) _=_
|
| 55 |
-
simp only [chanDeriv,chanInner,Pi.add_apply,Pi.zero_apply,Matrix.transpose_zero,Matrix.zero_mul,
|
| 56 |
-
zero_add]
|
| 57 |
-
|
| 58 |
-
/-- Restrict pure form to individual diagonal blocks. -/
|
| 59 |
-
def eachF (p : Shape) {n} :
|
| 60 |
-
PureForms p n →ₗ[F] Individual p n where
|
| 61 |
-
toFun P i e := pullM (IP p n i) (IP p n i) (P e)
|
| 62 |
-
map_add' P Q := by ext; simp only [Pi.add_apply,map_add]
|
| 63 |
-
map_smul' a P := by ext; simp only [Pi.smul_apply,map_smul,RingHom.id_apply]
|
| 64 |
-
|
| 65 |
-
/-- Extend the individual forms by zero outside respective blocks, then add. -/
|
| 66 |
-
def sumF (p : Shape) {n} : Individual p n → PureForms p n :=
|
| 67 |
-
fun A e => ∑ i,liftM (IP p n i) (IP p n i) (A i e)
|
| 68 |
-
theorem each_sumF (A : Individual p n) : eachF p (sumF p A)=A := by
|
| 69 |
-
classical
|
| 70 |
-
funext i e
|
| 71 |
-
change pullM _ _ (∑ j,_) = _
|
| 72 |
-
rw [map_sum,Finset.sum_eq_single i]
|
| 73 |
-
· unfold pullM; rw [liftM_comp,IP_self]
|
| 74 |
-
simp [liftM_def]
|
| 75 |
-
· intro j _ hj
|
| 76 |
-
unfold pullM
|
| 77 |
-
rw [liftM_comp,IP_cross (Ne.symm hj)]
|
| 78 |
-
simp [liftM_def]
|
| 79 |
-
simp
|
| 80 |
-
|
| 81 |
-
def repF (p : Shape) {n} (A : Individual p n) : OnForms p n :=
|
| 82 |
-
fun i => ∑ e : Comp p.g, mpair (A i e) ∘ₗ LinearMap.proj e
|
| 83 |
-
|
| 84 |
-
theorem repF_rep (A : Individual p n) (i) :
|
| 85 |
-
Represents (repF p A i) (A i) := by
|
| 86 |
-
intro x
|
| 87 |
-
simp only [repF,LinearMap.sum_apply]; rfl
|
| 88 |
-
|
| 89 |
-
theorem obsPair_each (P : PureForms p n) :
|
| 90 |
-
obsPair p P=combineF p (repF p (eachF p P)) := by
|
| 91 |
-
apply LinearMap.ext
|
| 92 |
-
intro x
|
| 93 |
-
rw [obsPair_val,combineF_val]
|
| 94 |
-
simp_rw [purePair,Finset.sum_apply,map_sum]
|
| 95 |
-
rw [Finset.sum_comm]
|
| 96 |
-
refine Finset.sum_congr rfl fun i _ => ?_
|
| 97 |
-
rw [repF_rep]
|
| 98 |
-
refine Finset.sum_congr rfl fun e _ => ?_
|
| 99 |
-
rw [mpair_liftM]; rfl
|
| 100 |
-
|
| 101 |
-
theorem obsPair_chan (B : Cross p n) (j : Bool) :
|
| 102 |
-
obsPair p (chanInner p (channelOut p B j) (channelOut p B j))=
|
| 103 |
-
combineF p (fun i => contract p B i j) := by
|
| 104 |
-
apply LinearMap.ext; intro x
|
| 105 |
-
rw [obsPair_val,combineF_val]
|
| 106 |
-
simp_rw [purePair,Finset.sum_apply,map_sum]
|
| 107 |
-
rw [Finset.sum_comm]; rfl
|
| 108 |
-
|
| 109 |
-
theorem each_chan_val (B C : ChanOut p n) (i) (e : Comp p.g) :
|
| 110 |
-
eachF p (chanInner p B C) i e=(B (e,true) * IP p n i)ᵀ * (C (e,false)*IP p n i) := by
|
| 111 |
-
change pullM _ _ _=_
|
| 112 |
-
simp only [pullM_def,chanInner,transpose_mul,Matrix.mul_assoc]
|
| 113 |
-
|
| 114 |
-
theorem obsPair_chan_change (B C : ChanOut p n) :
|
| 115 |
-
obsPair p (chanInner p (B+C) (B+C))=
|
| 116 |
-
obsPair p (chanInner p B B)+ obsPair p (chanDeriv p B C) + obsPair p (chanInner p C C) := by
|
| 117 |
-
rw [←map_add,←map_add]
|
| 118 |
-
congr 1
|
| 119 |
-
unfold chanInner chanDeriv
|
| 120 |
-
funext i
|
| 121 |
-
simp only [chanInner,Pi.add_apply,Matrix.transpose_add,Matrix.add_mul,Matrix.mul_add,add_assoc]
|
| 122 |
-
ac_rfl
|
| 123 |
-
|
| 124 |
-
theorem react_obsPair (B C : ChanOut p n) (D : PureForms p n) :
|
| 125 |
-
react p B (C,D)=obsPair p (chanDeriv p B C) + obsPair p D := by
|
| 126 |
-
rw [←map_add]
|
| 127 |
-
exact LinearMap.ext (fun x => (obsPair_val _ x).symm)
|
| 128 |
-
|
| 129 |
-
namespace Volley
|
| 130 |
-
variable (v w : Volley p n I)
|
| 131 |
-
|
| 132 |
-
def demand (t : Tagging p I) (m : Mixer p n) (j : Bool) : OnForms p n :=
|
| 133 |
-
fun i => grad m (v.sumAt t w.obj i j)
|
| 134 |
-
|
| 135 |
-
theorem realize_linear {t : Tagging p I} (m : Mixer p n)
|
| 136 |
-
(x y : UnitType p n N) (a b : Plan p n) (t' B : Cross p n)
|
| 137 |
-
(hb : v.bounded w.obj) (ht : v.legal t)
|
| 138 |
-
(q R : ℕ) (hv : v.avoids a q) (hj : 6*R+4≤p.j)
|
| 139 |
-
(hr : 2*planRank a+28≤R) (hq : R+14≤q)
|
| 140 |
-
(hB : fitsTable a b B t') (hT : tableInj a b t')
|
| 141 |
-
(hf : rowAgree (v.frozen a t) B (actual p x y))
|
| 142 |
-
(hR : v.scalarRecipe w t m x a t') (hk : v.keys t x=w.keys t y)
|
| 143 |
-
(hL : ∀ i, frameLaw m (onSide y i))
|
| 144 |
-
(hS : v.attackGrad w t m y) (j : Bool) :
|
| 145 |
-
∃ C∈deltaSpace p (v.frozen a t) b j,
|
| 146 |
-
∃ P∈pureSpace p (v.frozen a t),
|
| 147 |
-
obsPair p (chanInner p (channelOut p B j) (channelOut p B j))+
|
| 148 |
-
obsPair p (chanDeriv p (channelOut p B j) C) + obsPair p P=
|
| 149 |
-
combineF p (v.demand w t m j) := by
|
| 150 |
-
classical
|
| 151 |
-
let G := v.demand w t m j
|
| 152 |
-
let K : OnForms p n := fun i => contract p B i j
|
| 153 |
-
let CC := channelOut p B j
|
| 154 |
-
have h1 (i : I) : G (v.obj i) (v.atomAt t i) = K (v.obj i) (v.atomAt t i) := by
|
| 155 |
-
change grad m (v.sumAt t w.obj (v.obj i) j) _ = contract p B _ _ _
|
| 156 |
-
rw [frozen_contract_key v t hf,contract_actual,LinearMap.comp_apply,hS i j,
|
| 157 |
-
v.atom_share w t x y hk]
|
| 158 |
-
by_cases h : j=w.obj i
|
| 159 |
-
· rw [ite_eq_left h,h,ufun_self (hL _)]
|
| 160 |
-
have hh : (! (w.obj i))=j := by cases j <;> cases e : w.obj i <;> simp_all
|
| 161 |
-
rw [ite_eq_right h, innerP, hh]; rfl
|
| 162 |
-
have hg (z : Xpair p n) (h : orth p CC (v.frozen a t) b j z) :
|
| 163 |
-
combineF p (G-K) z=0 := by
|
| 164 |
-
obtain ⟨c,z,rfl,ho,hy⟩ := split_orth hb ht h hv hj hr hq
|
| 165 |
-
have he (i : Bool) := clean_effective t hb hv hq B z ho (fits_inj hB hT) i (hy i)
|
| 166 |
-
rw [map_add,map_sum]
|
| 167 |
-
have h2 : combineF p (G-K) z = 0 := by
|
| 168 |
-
rw [combineF_val]
|
| 169 |
-
refine Finset.sum_eq_zero fun i _ => ?_
|
| 170 |
-
rw [Pi.sub_apply,LinearMap.sub_apply]
|
| 171 |
-
exact sub_eq_zero.mpr ((hR.gradient i j _ (he i)).trans (fits_contract hB i j _ (he i)).symm)
|
| 172 |
-
rw [h2,zero_add]
|
| 173 |
-
refine Finset.sum_eq_zero fun i _ => ?_
|
| 174 |
-
rw [map_smul,strike,combineF_single,Pi.sub_apply,LinearMap.sub_apply,
|
| 175 |
-
h1 i,sub_self,smul_zero]
|
| 176 |
-
|
| 177 |
-
obtain ⟨C,hC,P,hP,h⟩ := solve_by_dual _ hg
|
| 178 |
-
rw [react_obsPair,map_sub] at h
|
| 179 |
-
rw [obsPair_chan]
|
| 180 |
-
refine ⟨C,hC,P,hP,?_⟩
|
| 181 |
-
rw [add_assoc,h,add_sub_cancel]
|
| 182 |
-
end Volley
|
| 183 |
-
|
| 184 |
-
end HadwigerCounterexample
|
| 185 |
-
|
| 186 |
-
end
|
| 187 |
-
|
| 188 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ResidualCutPairs
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Response Solvability -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Module Finset Submodule
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I]
|
| 12 |
+
|
| 13 |
+
abbrev Individual (p : Shape) (n : ℕ) := Bool → Profile p n
|
| 14 |
+
abbrev OnForms (p : Shape) (n : ℕ) := Bool → (Profile p n →ₗ[F] F)
|
| 15 |
+
abbrev ReqF (p : Shape) (n : ℕ) := Module.Dual F (Xpair p n)
|
| 16 |
+
|
| 17 |
+
def combineF (p : Shape) {n} : OnForms p n →ₗ[F] ReqF p n where
|
| 18 |
+
toFun f := ∑ i : Bool, f i ∘ₗ (Xspace p n).subtype ∘ₗ LinearMap.proj i
|
| 19 |
+
map_add' f g := LinearMap.ext fun x => by
|
| 20 |
+
simp only [LinearMap.sum_apply,LinearMap.comp_apply,Pi.add_apply,LinearMap.add_apply,
|
| 21 |
+
Finset.sum_add_distrib]
|
| 22 |
+
map_smul' a f := LinearMap.ext fun x => by
|
| 23 |
+
simp only [LinearMap.sum_apply,LinearMap.comp_apply,Pi.smul_apply,LinearMap.smul_apply,
|
| 24 |
+
RingHom.id_apply,smul_eq_mul,mul_sum]
|
| 25 |
+
|
| 26 |
+
theorem combineF_val (f : OnForms p n) (x : Xpair p n) :
|
| 27 |
+
combineF p f x= ∑ i, f i (x i).val := by
|
| 28 |
+
simp only [combineF,LinearMap.coe_mk,AddHom.coe_mk,LinearMap.sum_apply]; rfl
|
| 29 |
+
|
| 30 |
+
theorem combineF_single (f : OnForms p n) (i : Bool) (x : Xspace p n) :
|
| 31 |
+
combineF p f (Pi.single i x)=f i x.val := by
|
| 32 |
+
rw [combineF_val,Finset.sum_eq_single i]
|
| 33 |
+
· rw [Pi.single_eq_same]
|
| 34 |
+
· intro j _ hj; simp [hj]
|
| 35 |
+
simp
|
| 36 |
+
|
| 37 |
+
theorem combineF_same (f g : OnForms p n) : combineF p f=combineF p g ↔
|
| 38 |
+
∀ i,∀ x ∈ Xspace p n,f i x=g i x := by
|
| 39 |
+
constructor
|
| 40 |
+
· intro h i x hx
|
| 41 |
+
exact (combineF_single f i ⟨x,hx⟩).symm.trans (h ▸ combineF_single g i ⟨x,hx⟩)
|
| 42 |
+
intro h
|
| 43 |
+
apply LinearMap.ext; intro x
|
| 44 |
+
rw [combineF_val,combineF_val]
|
| 45 |
+
exact Finset.sum_congr rfl fun i _ => h i _ (x i).property
|
| 46 |
+
|
| 47 |
+
def obsPair (p : Shape) {n} : PureForms p n →ₗ[F] ReqF p n :=
|
| 48 |
+
react p 0 ∘ₗ LinearMap.inr F (ChanOut p n) (PureForms p n)
|
| 49 |
+
|
| 50 |
+
theorem obsPair_val (A : PureForms p n) (x : Xpair p n) :
|
| 51 |
+
obsPair p A x=∑ i,mpair (A i) (purePair p n x i) := by
|
| 52 |
+
change ∑ i : Comp p.g, _ = _
|
| 53 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 54 |
+
change mpair ((chanDeriv p (n:=n) 0 0+A) _) _=_
|
| 55 |
+
simp only [chanDeriv,chanInner,Pi.add_apply,Pi.zero_apply,Matrix.transpose_zero,Matrix.zero_mul,
|
| 56 |
+
zero_add]
|
| 57 |
+
|
| 58 |
+
/-- Restrict pure form to individual diagonal blocks. -/
|
| 59 |
+
def eachF (p : Shape) {n} :
|
| 60 |
+
PureForms p n →ₗ[F] Individual p n where
|
| 61 |
+
toFun P i e := pullM (IP p n i) (IP p n i) (P e)
|
| 62 |
+
map_add' P Q := by ext; simp only [Pi.add_apply,map_add]
|
| 63 |
+
map_smul' a P := by ext; simp only [Pi.smul_apply,map_smul,RingHom.id_apply]
|
| 64 |
+
|
| 65 |
+
/-- Extend the individual forms by zero outside respective blocks, then add. -/
|
| 66 |
+
def sumF (p : Shape) {n} : Individual p n → PureForms p n :=
|
| 67 |
+
fun A e => ∑ i,liftM (IP p n i) (IP p n i) (A i e)
|
| 68 |
+
theorem each_sumF (A : Individual p n) : eachF p (sumF p A)=A := by
|
| 69 |
+
classical
|
| 70 |
+
funext i e
|
| 71 |
+
change pullM _ _ (∑ j,_) = _
|
| 72 |
+
rw [map_sum,Finset.sum_eq_single i]
|
| 73 |
+
· unfold pullM; rw [liftM_comp,IP_self]
|
| 74 |
+
simp [liftM_def]
|
| 75 |
+
· intro j _ hj
|
| 76 |
+
unfold pullM
|
| 77 |
+
rw [liftM_comp,IP_cross (Ne.symm hj)]
|
| 78 |
+
simp [liftM_def]
|
| 79 |
+
simp
|
| 80 |
+
|
| 81 |
+
def repF (p : Shape) {n} (A : Individual p n) : OnForms p n :=
|
| 82 |
+
fun i => ∑ e : Comp p.g, mpair (A i e) ∘ₗ LinearMap.proj e
|
| 83 |
+
|
| 84 |
+
theorem repF_rep (A : Individual p n) (i) :
|
| 85 |
+
Represents (repF p A i) (A i) := by
|
| 86 |
+
intro x
|
| 87 |
+
simp only [repF,LinearMap.sum_apply]; rfl
|
| 88 |
+
|
| 89 |
+
theorem obsPair_each (P : PureForms p n) :
|
| 90 |
+
obsPair p P=combineF p (repF p (eachF p P)) := by
|
| 91 |
+
apply LinearMap.ext
|
| 92 |
+
intro x
|
| 93 |
+
rw [obsPair_val,combineF_val]
|
| 94 |
+
simp_rw [purePair,Finset.sum_apply,map_sum]
|
| 95 |
+
rw [Finset.sum_comm]
|
| 96 |
+
refine Finset.sum_congr rfl fun i _ => ?_
|
| 97 |
+
rw [repF_rep]
|
| 98 |
+
refine Finset.sum_congr rfl fun e _ => ?_
|
| 99 |
+
rw [mpair_liftM]; rfl
|
| 100 |
+
|
| 101 |
+
theorem obsPair_chan (B : Cross p n) (j : Bool) :
|
| 102 |
+
obsPair p (chanInner p (channelOut p B j) (channelOut p B j))=
|
| 103 |
+
combineF p (fun i => contract p B i j) := by
|
| 104 |
+
apply LinearMap.ext; intro x
|
| 105 |
+
rw [obsPair_val,combineF_val]
|
| 106 |
+
simp_rw [purePair,Finset.sum_apply,map_sum]
|
| 107 |
+
rw [Finset.sum_comm]; rfl
|
| 108 |
+
|
| 109 |
+
theorem each_chan_val (B C : ChanOut p n) (i) (e : Comp p.g) :
|
| 110 |
+
eachF p (chanInner p B C) i e=(B (e,true) * IP p n i)ᵀ * (C (e,false)*IP p n i) := by
|
| 111 |
+
change pullM _ _ _=_
|
| 112 |
+
simp only [pullM_def,chanInner,transpose_mul,Matrix.mul_assoc]
|
| 113 |
+
|
| 114 |
+
theorem obsPair_chan_change (B C : ChanOut p n) :
|
| 115 |
+
obsPair p (chanInner p (B+C) (B+C))=
|
| 116 |
+
obsPair p (chanInner p B B)+ obsPair p (chanDeriv p B C) + obsPair p (chanInner p C C) := by
|
| 117 |
+
rw [←map_add,←map_add]
|
| 118 |
+
congr 1
|
| 119 |
+
unfold chanInner chanDeriv
|
| 120 |
+
funext i
|
| 121 |
+
simp only [chanInner,Pi.add_apply,Matrix.transpose_add,Matrix.add_mul,Matrix.mul_add,add_assoc]
|
| 122 |
+
ac_rfl
|
| 123 |
+
|
| 124 |
+
theorem react_obsPair (B C : ChanOut p n) (D : PureForms p n) :
|
| 125 |
+
react p B (C,D)=obsPair p (chanDeriv p B C) + obsPair p D := by
|
| 126 |
+
rw [←map_add]
|
| 127 |
+
exact LinearMap.ext (fun x => (obsPair_val _ x).symm)
|
| 128 |
+
|
| 129 |
+
namespace Volley
|
| 130 |
+
variable (v w : Volley p n I)
|
| 131 |
+
|
| 132 |
+
def demand (t : Tagging p I) (m : Mixer p n) (j : Bool) : OnForms p n :=
|
| 133 |
+
fun i => grad m (v.sumAt t w.obj i j)
|
| 134 |
+
|
| 135 |
+
theorem realize_linear {t : Tagging p I} (m : Mixer p n)
|
| 136 |
+
(x y : UnitType p n N) (a b : Plan p n) (t' B : Cross p n)
|
| 137 |
+
(hb : v.bounded w.obj) (ht : v.legal t)
|
| 138 |
+
(q R : ℕ) (hv : v.avoids a q) (hj : 6*R+4≤p.j)
|
| 139 |
+
(hr : 2*planRank a+28≤R) (hq : R+14≤q)
|
| 140 |
+
(hB : fitsTable a b B t') (hT : tableInj a b t')
|
| 141 |
+
(hf : rowAgree (v.frozen a t) B (actual p x y))
|
| 142 |
+
(hR : v.scalarRecipe w t m x a t') (hk : v.keys t x=w.keys t y)
|
| 143 |
+
(hL : ∀ i, frameLaw m (onSide y i))
|
| 144 |
+
(hS : v.attackGrad w t m y) (j : Bool) :
|
| 145 |
+
∃ C∈deltaSpace p (v.frozen a t) b j,
|
| 146 |
+
∃ P∈pureSpace p (v.frozen a t),
|
| 147 |
+
obsPair p (chanInner p (channelOut p B j) (channelOut p B j))+
|
| 148 |
+
obsPair p (chanDeriv p (channelOut p B j) C) + obsPair p P=
|
| 149 |
+
combineF p (v.demand w t m j) := by
|
| 150 |
+
classical
|
| 151 |
+
let G := v.demand w t m j
|
| 152 |
+
let K : OnForms p n := fun i => contract p B i j
|
| 153 |
+
let CC := channelOut p B j
|
| 154 |
+
have h1 (i : I) : G (v.obj i) (v.atomAt t i) = K (v.obj i) (v.atomAt t i) := by
|
| 155 |
+
change grad m (v.sumAt t w.obj (v.obj i) j) _ = contract p B _ _ _
|
| 156 |
+
rw [frozen_contract_key v t hf,contract_actual,LinearMap.comp_apply,hS i j,
|
| 157 |
+
v.atom_share w t x y hk]
|
| 158 |
+
by_cases h : j=w.obj i
|
| 159 |
+
· rw [ite_eq_left h,h,ufun_self (hL _)]
|
| 160 |
+
have hh : (! (w.obj i))=j := by cases j <;> cases e : w.obj i <;> simp_all
|
| 161 |
+
rw [ite_eq_right h, innerP, hh]; rfl
|
| 162 |
+
have hg (z : Xpair p n) (h : orth p CC (v.frozen a t) b j z) :
|
| 163 |
+
combineF p (G-K) z=0 := by
|
| 164 |
+
obtain ⟨c,z,rfl,ho,hy⟩ := split_orth hb ht h hv hj hr hq
|
| 165 |
+
have he (i : Bool) := clean_effective t hb hv hq B z ho (fits_inj hB hT) i (hy i)
|
| 166 |
+
rw [map_add,map_sum]
|
| 167 |
+
have h2 : combineF p (G-K) z = 0 := by
|
| 168 |
+
rw [combineF_val]
|
| 169 |
+
refine Finset.sum_eq_zero fun i _ => ?_
|
| 170 |
+
rw [Pi.sub_apply,LinearMap.sub_apply]
|
| 171 |
+
exact sub_eq_zero.mpr ((hR.gradient i j _ (he i)).trans (fits_contract hB i j _ (he i)).symm)
|
| 172 |
+
rw [h2,zero_add]
|
| 173 |
+
refine Finset.sum_eq_zero fun i _ => ?_
|
| 174 |
+
rw [map_smul,strike,combineF_single,Pi.sub_apply,LinearMap.sub_apply,
|
| 175 |
+
h1 i,sub_self,smul_zero]
|
| 176 |
+
|
| 177 |
+
obtain ⟨C,hC,P,hP,h⟩ := solve_by_dual _ hg
|
| 178 |
+
rw [react_obsPair,map_sub] at h
|
| 179 |
+
rw [obsPair_chan]
|
| 180 |
+
refine ⟨C,hC,P,hP,?_⟩
|
| 181 |
+
rw [add_assoc,h,add_sub_cancel]
|
| 182 |
+
end Volley
|
| 183 |
+
|
| 184 |
+
end HadwigerCounterexample
|
| 185 |
+
|
| 186 |
+
end
|
| 187 |
+
|
| 188 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RestrictedComparisonLaws.lean
CHANGED
|
@@ -1,101 +1,101 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.ConditionalFlags
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Restricted Comparison Laws -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 12 |
-
|
| 13 |
-
def hung (Q : Wgt B→Prop) (P : B→Prop) (w : Wgt B) :=
|
| 14 |
-
∃ v : Wgt B, Q v ∧ w=subW v P
|
| 15 |
-
def smallSet (Q : Wgt B→Prop) (q : Wgt B) (δ η : ℝ) :=
|
| 16 |
-
∀ p,Q p → ∀ P : B→ Prop, pr q P ≤ δ → pr p P ≤ η
|
| 17 |
-
def rosterTail (Q : Wgt B→Prop) (q : Wgt B) (R η : ℝ) :=
|
| 18 |
-
∀ p,Q p → pr p (fun x => R≤density q p x)≤η
|
| 19 |
-
|
| 20 |
-
theorem hung_roster (Q : Wgt B → Prop) (P : B→Prop) (r : ℕ) (ε : ℝ) :
|
| 21 |
-
roster Q r ε → roster (hung Q P) r ε := by
|
| 22 |
-
classical
|
| 23 |
-
rintro ⟨t,ht,w,hw⟩
|
| 24 |
-
refine ⟨t,ht,fun i => subW (w i) P,?_⟩
|
| 25 |
-
rintro p ⟨v,h,rfl⟩
|
| 26 |
-
obtain ⟨i,hi⟩ := hw v h
|
| 27 |
-
refine ⟨i,le_trans ?_ hi⟩
|
| 28 |
-
unfold varOne subW
|
| 29 |
-
refine sum_le_sum fun x _ => ?_
|
| 30 |
-
by_cases h : P x <;> simp [ind,h]
|
| 31 |
-
|
| 32 |
-
variable [Nonempty B]
|
| 33 |
-
|
| 34 |
-
theorem hung_small (Q : Wgt B→Prop) (P : B→Prop) (δ η : ℝ)
|
| 35 |
-
(hq : smallSet Q unif δ η) : smallSet (hung Q P) (unifOn P) δ η := by
|
| 36 |
-
classical
|
| 37 |
-
rintro p ⟨v,hv,rfl⟩ S hs
|
| 38 |
-
rw [pr_sub]
|
| 39 |
-
refine hq v hv (fun x => P x∧ S x) ?_
|
| 40 |
-
rw [pr_of_on unif_law.nz,on_unif]
|
| 41 |
-
refine le_trans ?_ hs
|
| 42 |
-
have ht := (pr_le_tot (α:=B) (p:=P) unif_law.nz).trans unif_law.total.le
|
| 43 |
-
exact (mul_le_mul_of_nonneg_right ht (pr_nonneg (unifOn_sub _).nz)).trans_eq (one_mul _)
|
| 44 |
-
|
| 45 |
-
omit [Nonempty B] in
|
| 46 |
-
theorem density_hung (P : B→Prop) (w : Wgt B) (hw : carried w P) :
|
| 47 |
-
∀ i, unifOn P i * density (unifOn P) w i=w i := by
|
| 48 |
-
classical
|
| 49 |
-
intro i
|
| 50 |
-
by_cases h : w i =0
|
| 51 |
-
· simp only [density,h,zero_div,mul_zero]
|
| 52 |
-
have ht : P i := not_not.mp fun hi => h (hw i hi)
|
| 53 |
-
have hn := unifOn_law (p:=P) ⟨i,ht⟩
|
| 54 |
-
have he : unifOn P i≠0 := by
|
| 55 |
-
rw [unifOn_val,ind_one ht]
|
| 56 |
-
have hh : nbr P ≠0 := by
|
| 57 |
-
have he := weight_le_tot (fun j => ind_nonneg (P j)) i
|
| 58 |
-
rw [ind_one ht] at he
|
| 59 |
-
exact (lt_of_lt_of_le zero_lt_one he).ne'
|
| 60 |
-
exact div_ne_zero one_ne_zero hh
|
| 61 |
-
unfold density; field_simp
|
| 62 |
-
|
| 63 |
-
theorem hung_tail (Q : Wgt B→Prop) (P : B→ Prop)
|
| 64 |
-
(h : ∀ p,Q p → SubLaw p) (δ η : ℝ)
|
| 65 |
-
(hδ : 0<δ) (hh : smallSet Q unif δ η) :
|
| 66 |
-
rosterTail (hung Q P) (unifOn P) δ⁻¹ η := by
|
| 67 |
-
intro p hp
|
| 68 |
-
apply hung_small Q P δ η hh p hp
|
| 69 |
-
obtain ⟨w,hw,rfl⟩ := hp
|
| 70 |
-
let q := unifOn P
|
| 71 |
-
let v := subW w P
|
| 72 |
-
let f := density q v
|
| 73 |
-
have hq := unifOn_sub P
|
| 74 |
-
have hv := subLaw_sub (h w hw) P
|
| 75 |
-
have hh :
|
| 76 |
-
avg q f = tot v := Finset.sum_congr rfl fun i _ => density_hung P v
|
| 77 |
-
(subW_carried w P) i
|
| 78 |
-
have hz := le_avg_markov hq.nz (fun i => div_nonneg (hv.nz i) (hq.nz i)) δ⁻¹
|
| 79 |
-
change δ⁻¹*pr q _≤avg q f at hz
|
| 80 |
-
apply le_of_mul_le_mul_left _ (inv_pos_of_pos hδ)
|
| 81 |
-
rw [inv_mul_cancel₀ hδ.ne']
|
| 82 |
-
exact (hz.trans_eq hh).trans hv.total
|
| 83 |
-
|
| 84 |
-
omit [Nonempty B] in
|
| 85 |
-
theorem hung_var (P : B→Prop) (p q : Wgt B) (hp : carried p P) (hq : carried q P) :
|
| 86 |
-
avg (unifOn P) (fun i => |density (unifOn P) p i-density (unifOn P) q i|)=varOne p q := by
|
| 87 |
-
classical
|
| 88 |
-
unfold avg varOne
|
| 89 |
-
refine sum_congr rfl fun i _ => ?_
|
| 90 |
-
rw [←abs_of_nonneg ((unifOn_sub P).nz i)]
|
| 91 |
-
have he := density_hung P p hp i
|
| 92 |
-
|
| 93 |
-
simp_rw [abs_of_nonneg ((unifOn_sub P).nz i)]
|
| 94 |
-
calc _ = |unifOn P i * (density (unifOn P) p i - density (unifOn P) q i)| :=
|
| 95 |
-
by rw [abs_mul,abs_of_nonneg ((unifOn_sub P).nz i)]
|
| 96 |
-
_ = _ := by rw [mul_sub,he,density_hung P q hq i]
|
| 97 |
-
end HadwigerCounterexample
|
| 98 |
-
|
| 99 |
-
end
|
| 100 |
-
|
| 101 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.ConditionalFlags
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Restricted Comparison Laws -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C : Type} [Fintype A] [Fintype B] [Fintype C]
|
| 12 |
+
|
| 13 |
+
def hung (Q : Wgt B→Prop) (P : B→Prop) (w : Wgt B) :=
|
| 14 |
+
∃ v : Wgt B, Q v ∧ w=subW v P
|
| 15 |
+
def smallSet (Q : Wgt B→Prop) (q : Wgt B) (δ η : ℝ) :=
|
| 16 |
+
∀ p,Q p → ∀ P : B→ Prop, pr q P ≤ δ → pr p P ≤ η
|
| 17 |
+
def rosterTail (Q : Wgt B→Prop) (q : Wgt B) (R η : ℝ) :=
|
| 18 |
+
∀ p,Q p → pr p (fun x => R≤density q p x)≤η
|
| 19 |
+
|
| 20 |
+
theorem hung_roster (Q : Wgt B → Prop) (P : B→Prop) (r : ℕ) (ε : ℝ) :
|
| 21 |
+
roster Q r ε → roster (hung Q P) r ε := by
|
| 22 |
+
classical
|
| 23 |
+
rintro ⟨t,ht,w,hw⟩
|
| 24 |
+
refine ⟨t,ht,fun i => subW (w i) P,?_⟩
|
| 25 |
+
rintro p ⟨v,h,rfl⟩
|
| 26 |
+
obtain ⟨i,hi⟩ := hw v h
|
| 27 |
+
refine ⟨i,le_trans ?_ hi⟩
|
| 28 |
+
unfold varOne subW
|
| 29 |
+
refine sum_le_sum fun x _ => ?_
|
| 30 |
+
by_cases h : P x <;> simp [ind,h]
|
| 31 |
+
|
| 32 |
+
variable [Nonempty B]
|
| 33 |
+
|
| 34 |
+
theorem hung_small (Q : Wgt B→Prop) (P : B→Prop) (δ η : ℝ)
|
| 35 |
+
(hq : smallSet Q unif δ η) : smallSet (hung Q P) (unifOn P) δ η := by
|
| 36 |
+
classical
|
| 37 |
+
rintro p ⟨v,hv,rfl⟩ S hs
|
| 38 |
+
rw [pr_sub]
|
| 39 |
+
refine hq v hv (fun x => P x∧ S x) ?_
|
| 40 |
+
rw [pr_of_on unif_law.nz,on_unif]
|
| 41 |
+
refine le_trans ?_ hs
|
| 42 |
+
have ht := (pr_le_tot (α:=B) (p:=P) unif_law.nz).trans unif_law.total.le
|
| 43 |
+
exact (mul_le_mul_of_nonneg_right ht (pr_nonneg (unifOn_sub _).nz)).trans_eq (one_mul _)
|
| 44 |
+
|
| 45 |
+
omit [Nonempty B] in
|
| 46 |
+
theorem density_hung (P : B→Prop) (w : Wgt B) (hw : carried w P) :
|
| 47 |
+
∀ i, unifOn P i * density (unifOn P) w i=w i := by
|
| 48 |
+
classical
|
| 49 |
+
intro i
|
| 50 |
+
by_cases h : w i =0
|
| 51 |
+
· simp only [density,h,zero_div,mul_zero]
|
| 52 |
+
have ht : P i := not_not.mp fun hi => h (hw i hi)
|
| 53 |
+
have hn := unifOn_law (p:=P) ⟨i,ht⟩
|
| 54 |
+
have he : unifOn P i≠0 := by
|
| 55 |
+
rw [unifOn_val,ind_one ht]
|
| 56 |
+
have hh : nbr P ≠0 := by
|
| 57 |
+
have he := weight_le_tot (fun j => ind_nonneg (P j)) i
|
| 58 |
+
rw [ind_one ht] at he
|
| 59 |
+
exact (lt_of_lt_of_le zero_lt_one he).ne'
|
| 60 |
+
exact div_ne_zero one_ne_zero hh
|
| 61 |
+
unfold density; field_simp
|
| 62 |
+
|
| 63 |
+
theorem hung_tail (Q : Wgt B→Prop) (P : B→ Prop)
|
| 64 |
+
(h : ∀ p,Q p → SubLaw p) (δ η : ℝ)
|
| 65 |
+
(hδ : 0<δ) (hh : smallSet Q unif δ η) :
|
| 66 |
+
rosterTail (hung Q P) (unifOn P) δ⁻¹ η := by
|
| 67 |
+
intro p hp
|
| 68 |
+
apply hung_small Q P δ η hh p hp
|
| 69 |
+
obtain ⟨w,hw,rfl⟩ := hp
|
| 70 |
+
let q := unifOn P
|
| 71 |
+
let v := subW w P
|
| 72 |
+
let f := density q v
|
| 73 |
+
have hq := unifOn_sub P
|
| 74 |
+
have hv := subLaw_sub (h w hw) P
|
| 75 |
+
have hh :
|
| 76 |
+
avg q f = tot v := Finset.sum_congr rfl fun i _ => density_hung P v
|
| 77 |
+
(subW_carried w P) i
|
| 78 |
+
have hz := le_avg_markov hq.nz (fun i => div_nonneg (hv.nz i) (hq.nz i)) δ⁻¹
|
| 79 |
+
change δ⁻¹*pr q _≤avg q f at hz
|
| 80 |
+
apply le_of_mul_le_mul_left _ (inv_pos_of_pos hδ)
|
| 81 |
+
rw [inv_mul_cancel₀ hδ.ne']
|
| 82 |
+
exact (hz.trans_eq hh).trans hv.total
|
| 83 |
+
|
| 84 |
+
omit [Nonempty B] in
|
| 85 |
+
theorem hung_var (P : B→Prop) (p q : Wgt B) (hp : carried p P) (hq : carried q P) :
|
| 86 |
+
avg (unifOn P) (fun i => |density (unifOn P) p i-density (unifOn P) q i|)=varOne p q := by
|
| 87 |
+
classical
|
| 88 |
+
unfold avg varOne
|
| 89 |
+
refine sum_congr rfl fun i _ => ?_
|
| 90 |
+
rw [←abs_of_nonneg ((unifOn_sub P).nz i)]
|
| 91 |
+
have he := density_hung P p hp i
|
| 92 |
+
|
| 93 |
+
simp_rw [abs_of_nonneg ((unifOn_sub P).nz i)]
|
| 94 |
+
calc _ = |unifOn P i * (density (unifOn P) p i - density (unifOn P) q i)| :=
|
| 95 |
+
by rw [abs_mul,abs_of_nonneg ((unifOn_sub P).nz i)]
|
| 96 |
+
_ = _ := by rw [mul_sub,he,density_hung P q hq i]
|
| 97 |
+
end HadwigerCounterexample
|
| 98 |
+
|
| 99 |
+
end
|
| 100 |
+
|
| 101 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/RoundedRefinements.lean
CHANGED
|
@@ -1,156 +1,156 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RefinementEnergy
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Rounded Refinements -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Filter Matrix Real
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {A B C D : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype D]
|
| 12 |
-
|
| 13 |
-
set_option maxHeartbeats 900000 in
|
| 14 |
-
theorem divide_fit (q : Wgt B) (hq : IsLaw q) (f : B→C) (P : B→Prop)
|
| 15 |
-
(δ γ : ℝ) (hγ : 0<γ) (hz : 2*γ ≤ δ) (h : stamina (mapW q f) δ) :
|
| 16 |
-
∃ F : B→C×Bool, f=Prod.fst∘F ∧ stamina (mapW q F) γ ∧
|
| 17 |
-
pr q (fun i => ¬(P i ↔ (F i).2))≤num (C×Bool)*γ := by
|
| 18 |
-
classical
|
| 19 |
-
let g (i : B) : C × Bool := (f i,decide (P i))
|
| 20 |
-
let Q := mapW q g
|
| 21 |
-
have hQ := mapW_law hq g
|
| 22 |
-
have hf : f=Prod.fst∘g := rfl
|
| 23 |
-
have hi (i) : mapW q f i=Q (i,true)+Q (i,false) := by
|
| 24 |
-
have hs : mapW q f=mapW Q Prod.fst := hf ▸ Eq.symm (map_nested g Prod.fst)
|
| 25 |
-
rw [hs]
|
| 26 |
-
simp only [mapW,pr,avg,Fintype.sum_prod_type,Fintype.sum_bool]; simp [ind,Finset.sum_add_distrib]
|
| 27 |
-
let s (j:C×Bool) : Bool := if Q (j.1,true) < γ then false else
|
| 28 |
-
if Q (j.1,false) < γ then true else j.2
|
| 29 |
-
let F (j : C × Bool) : C × Bool := (j.1,s j)
|
| 30 |
-
refine ⟨F ∘ g,rfl,?_,?_⟩
|
| 31 |
-
· rintro ⟨i,b⟩ h'
|
| 32 |
-
have hb :
|
| 33 |
-
mapW Q F (i,b)=Q (i,true)*ind (s (i,true)=b)+
|
| 34 |
-
Q (i,false)*ind (s (i,false)=b) := by
|
| 35 |
-
unfold mapW pr avg
|
| 36 |
-
rw [Fintype.sum_prod_type, sum_eq_single i]
|
| 37 |
-
· rw [Fintype.sum_bool]; simp [ind,F]
|
| 38 |
-
· intro j _ hj; rw [Fintype.sum_bool]; simp [ind,F,hj]
|
| 39 |
-
simp
|
| 40 |
-
rw [←map_nested,hb] at h' ⊢
|
| 41 |
-
by_cases hx : Q (i,true)<γ
|
| 42 |
-
· cases b
|
| 43 |
-
· simp only [s,hx,ite_true,ind_true,mul_one] at *
|
| 44 |
-
rw [←hi] at *
|
| 45 |
-
exact le_trans (by linarith only [hz,hγ]) (h i h')
|
| 46 |
-
simp [s,hx,ind] at h'
|
| 47 |
-
by_cases hy : Q (i,false)<γ
|
| 48 |
-
· cases b
|
| 49 |
-
· simp [s,hx,hy,ind] at h'
|
| 50 |
-
simp only [s,hx,hy,ite_true,ite_false,ind_true,mul_one] at *
|
| 51 |
-
rw [←hi] at *
|
| 52 |
-
exact le_trans (by linarith only [hz,hγ]) (h i h')
|
| 53 |
-
cases b
|
| 54 |
-
· simpa [s,hx,hy,ind] using (le_of_not_gt hy)
|
| 55 |
-
simpa [s,hx,hy,ind] using (le_of_not_gt hx)
|
| 56 |
-
let R (i : C×Bool) := i.2≠s i
|
| 57 |
-
have he j : (¬ (P j ↔ (F (g j)).2)) ↔ R (g j) := by
|
| 58 |
-
change (¬ (P j ↔ s (g j)=true)) ↔ decide (P j)≠s (g j)
|
| 59 |
-
cases s (g j) <;> simp
|
| 60 |
-
have h1 (j : C×Bool) : R j→ Q j≤γ := by
|
| 61 |
-
intro hj
|
| 62 |
-
rcases j with ⟨i,b⟩
|
| 63 |
-
by_cases hx : Q (i,true)<γ
|
| 64 |
-
· cases b
|
| 65 |
-
· simp [R,s,hx] at hj
|
| 66 |
-
exact hx.le
|
| 67 |
-
by_cases hy : Q (i,false)<γ
|
| 68 |
-
· cases b
|
| 69 |
-
· exact hy.le
|
| 70 |
-
simp [R,s,hx,hy] at hj
|
| 71 |
-
simp [R,s,hx,hy] at hj
|
| 72 |
-
have hg (j) : Q j * ind (R j) ≤ γ := by
|
| 73 |
-
by_cases hh : R j
|
| 74 |
-
· simpa only [ind_one hh,mul_one] using h1 j hh
|
| 75 |
-
rw [ind_zero hh,mul_zero]; exact hγ.le
|
| 76 |
-
simp_rw [Function.comp_apply,he]
|
| 77 |
-
rw [← mapW_pr]
|
| 78 |
-
exact (Finset.sum_le_sum fun i _ => hg i).trans_eq (by simp only [Finset.sum_const,
|
| 79 |
-
Finset.card_univ,nsmul_eq_mul,num])
|
| 80 |
-
|
| 81 |
-
theorem bucket_upper (w : Wgt B) (hw : SubLaw w) (q : Wgt B) (hq : IsLaw q)
|
| 82 |
-
(f : B→ C) (δ : ℝ) (h0 : 0<δ) (hz : stamina (mapW q f) δ) :
|
| 83 |
-
∀ i,bucket q f w i ≤ δ⁻¹*q i := by
|
| 84 |
-
intro i
|
| 85 |
-
have he : mapW w f (f i) ≤1 := by
|
| 86 |
-
exact (pr_le_tot hw.nz).trans hw.total
|
| 87 |
-
unfold bucket pour
|
| 88 |
-
by_cases hi : mapW q f (f i)=0
|
| 89 |
-
· rw [hi,div_zero,mul_zero]; exact mul_nonneg (inv_pos_of_pos h0).le (hq.nz _)
|
| 90 |
-
rw [mul_comm δ⁻¹]
|
| 91 |
-
exact mul_le_mul_of_nonneg_left ((div_le_div₀ zero_le_one he h0 (hz _ hi)).trans_eq
|
| 92 |
-
(one_div _)) (hq.nz _)
|
| 93 |
-
|
| 94 |
-
theorem pr_ref_delta (w : Wgt A) (hw : ∀ i,0 ≤ w i) (P Q : A→ Prop) :
|
| 95 |
-
pr w P ≤ pr w Q + pr w (fun i => ¬(P i↔Q i)) :=
|
| 96 |
-
(pr_mono hw (q:=fun i => Q i ∨ ¬(P i↔Q i)) fun i _ => by tauto).trans (pr_or_le hw)
|
| 97 |
-
|
| 98 |
-
variable {μ : Wgt A} {p : A →Wgt B}
|
| 99 |
-
|
| 100 |
-
set_option maxHeartbeats 1000000 in
|
| 101 |
-
theorem divide_progress [Nonempty B] (h : Ultra μ p)
|
| 102 |
-
(ε δ α k : ℝ) (hε : 0<ε) (hk : 0<k) (hk' : 2*k≤1)
|
| 103 |
-
(hδ : 0<δ) (hα : δ≤1)
|
| 104 |
-
(hB : ∀ P : B→ Prop, pr unif P ≤α → pr (mixW μ p) P ≤ε)
|
| 105 |
-
(f : B→ C) (hz : stamina (mapW unif f) δ)
|
| 106 |
-
(hC : num (C×Bool)*k ≤min α ε)
|
| 107 |
-
(w : Wgt B) (hw : catalog μ p w) (hr : 8*ε<varOne w (bucket unif f w)) :
|
| 108 |
-
∃ F : B → C×Bool, stamina (mapW unif F) (k*δ) ∧
|
| 109 |
-
budget μ p f + ε^2 ≤ budget μ p F := by
|
| 110 |
-
classical
|
| 111 |
-
let q : Wgt B := unif
|
| 112 |
-
have hq : IsLaw q := unif_law
|
| 113 |
-
let v := bucket q f w
|
| 114 |
-
have ht := h.cat_sub w hw
|
| 115 |
-
let P (i : B) := v i < w i
|
| 116 |
-
have hv (i) : 0≤v i := pour_nz _ hq.nz (map_nz ht.nz f) i
|
| 117 |
-
have hh : varOne w v=2*(pr w P-pr v P) := by
|
| 118 |
-
have hx : lsupp w q := fun i _ => by unfold q; rw [unif_apply]; positivity
|
| 119 |
-
exact var_event w v (by rw [←map_mass w f,←map_mass v f,bucket_scale q w hq.nz hx])
|
| 120 |
-
obtain ⟨F,hF,hφ,hL⟩ := divide_fit q hq f P δ (k*δ) (by positivity)
|
| 121 |
-
((le_of_eq (by rw [← mul_assoc])).trans ((mul_le_mul_of_nonneg_right hk' hδ.le).trans_eq
|
| 122 |
-
(one_mul _))) hz
|
| 123 |
-
refine ⟨F,hφ,?_⟩
|
| 124 |
-
let Q := fun i : B => ((F i).2=true)
|
| 125 |
-
let S := fun i => ¬(P i ↔ Q i)
|
| 126 |
-
have h1 : pr w S ≤ ε := by
|
| 127 |
-
obtain ⟨hu,he⟩ := h.cat_dom w hw
|
| 128 |
-
have hs : pr q S ≤α := by
|
| 129 |
-
have hμ := (le_min_iff.mp hC).1
|
| 130 |
-
have : 0≤num (C×Bool) := Nat.cast_nonneg _
|
| 131 |
-
exact hL.trans (by nlinarith only [this,hk,hα,hμ,
|
| 132 |
-
mul_le_mul_of_nonneg_left hα (mul_nonneg this hk.le)])
|
| 133 |
-
exact (pr_mono_left he S).trans (hB S hs)
|
| 134 |
-
have h2 : pr v S ≤ ε := by
|
| 135 |
-
have hh := (pr_cap (bucket_upper w ht q hq f δ hδ hz) S).trans
|
| 136 |
-
(mul_le_mul_of_nonneg_left hL (inv_pos_of_pos hδ).le)
|
| 137 |
-
exact hh.trans ((le_of_eq (by field_simp)).trans (le_min_iff.mp hC).2)
|
| 138 |
-
have h3 : 2*ε < pr w Q-pr v Q := by
|
| 139 |
-
have he := pr_ref_delta w ht.nz P Q
|
| 140 |
-
have hr' := pr_ref_delta v hv Q P
|
| 141 |
-
have heq : (fun i=>¬(Q i↔P i))=S := funext fun i => propext (by unfold S; tauto)
|
| 142 |
-
rw [heq] at hr'
|
| 143 |
-
change 8*ε < varOne w v at hr
|
| 144 |
-
rw [hh] at hr; change pr w P≤pr w Q+pr w S at he
|
| 145 |
-
linarith only [hr,h1,h2,he,hr']
|
| 146 |
-
have h4 := var_pr (mapW w F) (mapW v F) (fun i:C×Bool => i.2=true)
|
| 147 |
-
rw [mapW_pr,mapW_pr] at h4
|
| 148 |
-
have he := budget_progress h w hw F Prod.fst
|
| 149 |
-
change varOne _ (mapW (bucket q (Prod.fst ∘ F) w) F) ^ 2 ≤ _ at he
|
| 150 |
-
rw [← hF] at he
|
| 151 |
-
nlinarith only [he,hε,(le_trans h3.le h4)]
|
| 152 |
-
end HadwigerCounterexample
|
| 153 |
-
|
| 154 |
-
end
|
| 155 |
-
|
| 156 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RefinementEnergy
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Rounded Refinements -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Filter Matrix Real
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {A B C D : Type} [Fintype A] [Fintype B] [Fintype C] [Fintype D]
|
| 12 |
+
|
| 13 |
+
set_option maxHeartbeats 900000 in
|
| 14 |
+
theorem divide_fit (q : Wgt B) (hq : IsLaw q) (f : B→C) (P : B→Prop)
|
| 15 |
+
(δ γ : ℝ) (hγ : 0<γ) (hz : 2*γ ≤ δ) (h : stamina (mapW q f) δ) :
|
| 16 |
+
∃ F : B→C×Bool, f=Prod.fst∘F ∧ stamina (mapW q F) γ ∧
|
| 17 |
+
pr q (fun i => ¬(P i ↔ (F i).2))≤num (C×Bool)*γ := by
|
| 18 |
+
classical
|
| 19 |
+
let g (i : B) : C × Bool := (f i,decide (P i))
|
| 20 |
+
let Q := mapW q g
|
| 21 |
+
have hQ := mapW_law hq g
|
| 22 |
+
have hf : f=Prod.fst∘g := rfl
|
| 23 |
+
have hi (i) : mapW q f i=Q (i,true)+Q (i,false) := by
|
| 24 |
+
have hs : mapW q f=mapW Q Prod.fst := hf ▸ Eq.symm (map_nested g Prod.fst)
|
| 25 |
+
rw [hs]
|
| 26 |
+
simp only [mapW,pr,avg,Fintype.sum_prod_type,Fintype.sum_bool]; simp [ind,Finset.sum_add_distrib]
|
| 27 |
+
let s (j:C×Bool) : Bool := if Q (j.1,true) < γ then false else
|
| 28 |
+
if Q (j.1,false) < γ then true else j.2
|
| 29 |
+
let F (j : C × Bool) : C × Bool := (j.1,s j)
|
| 30 |
+
refine ⟨F ∘ g,rfl,?_,?_⟩
|
| 31 |
+
· rintro ⟨i,b⟩ h'
|
| 32 |
+
have hb :
|
| 33 |
+
mapW Q F (i,b)=Q (i,true)*ind (s (i,true)=b)+
|
| 34 |
+
Q (i,false)*ind (s (i,false)=b) := by
|
| 35 |
+
unfold mapW pr avg
|
| 36 |
+
rw [Fintype.sum_prod_type, sum_eq_single i]
|
| 37 |
+
· rw [Fintype.sum_bool]; simp [ind,F]
|
| 38 |
+
· intro j _ hj; rw [Fintype.sum_bool]; simp [ind,F,hj]
|
| 39 |
+
simp
|
| 40 |
+
rw [←map_nested,hb] at h' ⊢
|
| 41 |
+
by_cases hx : Q (i,true)<γ
|
| 42 |
+
· cases b
|
| 43 |
+
· simp only [s,hx,ite_true,ind_true,mul_one] at *
|
| 44 |
+
rw [←hi] at *
|
| 45 |
+
exact le_trans (by linarith only [hz,hγ]) (h i h')
|
| 46 |
+
simp [s,hx,ind] at h'
|
| 47 |
+
by_cases hy : Q (i,false)<γ
|
| 48 |
+
· cases b
|
| 49 |
+
· simp [s,hx,hy,ind] at h'
|
| 50 |
+
simp only [s,hx,hy,ite_true,ite_false,ind_true,mul_one] at *
|
| 51 |
+
rw [←hi] at *
|
| 52 |
+
exact le_trans (by linarith only [hz,hγ]) (h i h')
|
| 53 |
+
cases b
|
| 54 |
+
· simpa [s,hx,hy,ind] using (le_of_not_gt hy)
|
| 55 |
+
simpa [s,hx,hy,ind] using (le_of_not_gt hx)
|
| 56 |
+
let R (i : C×Bool) := i.2≠s i
|
| 57 |
+
have he j : (¬ (P j ↔ (F (g j)).2)) ↔ R (g j) := by
|
| 58 |
+
change (¬ (P j ↔ s (g j)=true)) ↔ decide (P j)≠s (g j)
|
| 59 |
+
cases s (g j) <;> simp
|
| 60 |
+
have h1 (j : C×Bool) : R j→ Q j≤γ := by
|
| 61 |
+
intro hj
|
| 62 |
+
rcases j with ⟨i,b⟩
|
| 63 |
+
by_cases hx : Q (i,true)<γ
|
| 64 |
+
· cases b
|
| 65 |
+
· simp [R,s,hx] at hj
|
| 66 |
+
exact hx.le
|
| 67 |
+
by_cases hy : Q (i,false)<γ
|
| 68 |
+
· cases b
|
| 69 |
+
· exact hy.le
|
| 70 |
+
simp [R,s,hx,hy] at hj
|
| 71 |
+
simp [R,s,hx,hy] at hj
|
| 72 |
+
have hg (j) : Q j * ind (R j) ≤ γ := by
|
| 73 |
+
by_cases hh : R j
|
| 74 |
+
· simpa only [ind_one hh,mul_one] using h1 j hh
|
| 75 |
+
rw [ind_zero hh,mul_zero]; exact hγ.le
|
| 76 |
+
simp_rw [Function.comp_apply,he]
|
| 77 |
+
rw [← mapW_pr]
|
| 78 |
+
exact (Finset.sum_le_sum fun i _ => hg i).trans_eq (by simp only [Finset.sum_const,
|
| 79 |
+
Finset.card_univ,nsmul_eq_mul,num])
|
| 80 |
+
|
| 81 |
+
theorem bucket_upper (w : Wgt B) (hw : SubLaw w) (q : Wgt B) (hq : IsLaw q)
|
| 82 |
+
(f : B→ C) (δ : ℝ) (h0 : 0<δ) (hz : stamina (mapW q f) δ) :
|
| 83 |
+
∀ i,bucket q f w i ≤ δ⁻¹*q i := by
|
| 84 |
+
intro i
|
| 85 |
+
have he : mapW w f (f i) ≤1 := by
|
| 86 |
+
exact (pr_le_tot hw.nz).trans hw.total
|
| 87 |
+
unfold bucket pour
|
| 88 |
+
by_cases hi : mapW q f (f i)=0
|
| 89 |
+
· rw [hi,div_zero,mul_zero]; exact mul_nonneg (inv_pos_of_pos h0).le (hq.nz _)
|
| 90 |
+
rw [mul_comm δ⁻¹]
|
| 91 |
+
exact mul_le_mul_of_nonneg_left ((div_le_div₀ zero_le_one he h0 (hz _ hi)).trans_eq
|
| 92 |
+
(one_div _)) (hq.nz _)
|
| 93 |
+
|
| 94 |
+
theorem pr_ref_delta (w : Wgt A) (hw : ∀ i,0 ≤ w i) (P Q : A→ Prop) :
|
| 95 |
+
pr w P ≤ pr w Q + pr w (fun i => ¬(P i↔Q i)) :=
|
| 96 |
+
(pr_mono hw (q:=fun i => Q i ∨ ¬(P i↔Q i)) fun i _ => by tauto).trans (pr_or_le hw)
|
| 97 |
+
|
| 98 |
+
variable {μ : Wgt A} {p : A →Wgt B}
|
| 99 |
+
|
| 100 |
+
set_option maxHeartbeats 1000000 in
|
| 101 |
+
theorem divide_progress [Nonempty B] (h : Ultra μ p)
|
| 102 |
+
(ε δ α k : ℝ) (hε : 0<ε) (hk : 0<k) (hk' : 2*k≤1)
|
| 103 |
+
(hδ : 0<δ) (hα : δ≤1)
|
| 104 |
+
(hB : ∀ P : B→ Prop, pr unif P ≤α → pr (mixW μ p) P ≤ε)
|
| 105 |
+
(f : B→ C) (hz : stamina (mapW unif f) δ)
|
| 106 |
+
(hC : num (C×Bool)*k ≤min α ε)
|
| 107 |
+
(w : Wgt B) (hw : catalog μ p w) (hr : 8*ε<varOne w (bucket unif f w)) :
|
| 108 |
+
∃ F : B → C×Bool, stamina (mapW unif F) (k*δ) ∧
|
| 109 |
+
budget μ p f + ε^2 ≤ budget μ p F := by
|
| 110 |
+
classical
|
| 111 |
+
let q : Wgt B := unif
|
| 112 |
+
have hq : IsLaw q := unif_law
|
| 113 |
+
let v := bucket q f w
|
| 114 |
+
have ht := h.cat_sub w hw
|
| 115 |
+
let P (i : B) := v i < w i
|
| 116 |
+
have hv (i) : 0≤v i := pour_nz _ hq.nz (map_nz ht.nz f) i
|
| 117 |
+
have hh : varOne w v=2*(pr w P-pr v P) := by
|
| 118 |
+
have hx : lsupp w q := fun i _ => by unfold q; rw [unif_apply]; positivity
|
| 119 |
+
exact var_event w v (by rw [←map_mass w f,←map_mass v f,bucket_scale q w hq.nz hx])
|
| 120 |
+
obtain ⟨F,hF,hφ,hL⟩ := divide_fit q hq f P δ (k*δ) (by positivity)
|
| 121 |
+
((le_of_eq (by rw [← mul_assoc])).trans ((mul_le_mul_of_nonneg_right hk' hδ.le).trans_eq
|
| 122 |
+
(one_mul _))) hz
|
| 123 |
+
refine ⟨F,hφ,?_⟩
|
| 124 |
+
let Q := fun i : B => ((F i).2=true)
|
| 125 |
+
let S := fun i => ¬(P i ↔ Q i)
|
| 126 |
+
have h1 : pr w S ≤ ε := by
|
| 127 |
+
obtain ⟨hu,he⟩ := h.cat_dom w hw
|
| 128 |
+
have hs : pr q S ≤α := by
|
| 129 |
+
have hμ := (le_min_iff.mp hC).1
|
| 130 |
+
have : 0≤num (C×Bool) := Nat.cast_nonneg _
|
| 131 |
+
exact hL.trans (by nlinarith only [this,hk,hα,hμ,
|
| 132 |
+
mul_le_mul_of_nonneg_left hα (mul_nonneg this hk.le)])
|
| 133 |
+
exact (pr_mono_left he S).trans (hB S hs)
|
| 134 |
+
have h2 : pr v S ≤ ε := by
|
| 135 |
+
have hh := (pr_cap (bucket_upper w ht q hq f δ hδ hz) S).trans
|
| 136 |
+
(mul_le_mul_of_nonneg_left hL (inv_pos_of_pos hδ).le)
|
| 137 |
+
exact hh.trans ((le_of_eq (by field_simp)).trans (le_min_iff.mp hC).2)
|
| 138 |
+
have h3 : 2*ε < pr w Q-pr v Q := by
|
| 139 |
+
have he := pr_ref_delta w ht.nz P Q
|
| 140 |
+
have hr' := pr_ref_delta v hv Q P
|
| 141 |
+
have heq : (fun i=>¬(Q i↔P i))=S := funext fun i => propext (by unfold S; tauto)
|
| 142 |
+
rw [heq] at hr'
|
| 143 |
+
change 8*ε < varOne w v at hr
|
| 144 |
+
rw [hh] at hr; change pr w P≤pr w Q+pr w S at he
|
| 145 |
+
linarith only [hr,h1,h2,he,hr']
|
| 146 |
+
have h4 := var_pr (mapW w F) (mapW v F) (fun i:C×Bool => i.2=true)
|
| 147 |
+
rw [mapW_pr,mapW_pr] at h4
|
| 148 |
+
have he := budget_progress h w hw F Prod.fst
|
| 149 |
+
change varOne _ (mapW (bucket q (Prod.fst ∘ F) w) F) ^ 2 ≤ _ at he
|
| 150 |
+
rw [← hF] at he
|
| 151 |
+
nlinarith only [he,hε,(le_trans h3.le h4)]
|
| 152 |
+
end HadwigerCounterexample
|
| 153 |
+
|
| 154 |
+
end
|
| 155 |
+
|
| 156 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/SampledGraphs.lean
CHANGED
|
@@ -1,102 +1,102 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerMatching.BasicMatching
|
| 2 |
-
import Mathlib.Data.Fintype.EquivFin
|
| 3 |
-
import Mathlib.Combinatorics.SimpleGraph.Clique
|
| 4 |
-
import Lean.Elab.Tactic.Omega
|
| 5 |
-
|
| 6 |
-
namespace OAI
|
| 7 |
-
|
| 8 |
-
/-! # Sampled Graphs -/
|
| 9 |
-
|
| 10 |
-
noncomputable section
|
| 11 |
-
namespace HadwigerCounterexample
|
| 12 |
-
open HadwigerMatching Finset
|
| 13 |
-
variable {A V : Type*}
|
| 14 |
-
|
| 15 |
-
structure Holes (A : Type*) where
|
| 16 |
-
rel : A → A → Prop
|
| 17 |
-
sym {x y : A} : rel x y → rel y x
|
| 18 |
-
irr (x : A) : ¬ rel x x
|
| 19 |
-
ntri {x y z : A} : rel x y → rel y z → ¬ rel x z
|
| 20 |
-
|
| 21 |
-
namespace Holes
|
| 22 |
-
|
| 23 |
-
variable (H : Holes A)
|
| 24 |
-
def unit (p : A × A) := ¬H.rel p.1 p.2
|
| 25 |
-
def conflict (p q : A × A) := H.rel p.1 q.1 ∧ H.rel p.1 q.2 ∧ H.rel p.2 q.1 ∧ H.rel p.2 q.2
|
| 26 |
-
|
| 27 |
-
theorem no_self_conflict (p : A × A) : ¬ H.conflict p p := fun h => H.irr p.1 h.1
|
| 28 |
-
|
| 29 |
-
def graph (x : V → A) : SimpleGraph V where
|
| 30 |
-
Adj i j := i ≠ j ∧ ¬H.rel (x i) (x j)
|
| 31 |
-
symm := ⟨fun _ _ ⟨hne,h⟩ => ⟨hne.symm,fun h' => h (H.sym h')⟩⟩
|
| 32 |
-
loopless := ⟨fun _ h => h.1 rfl⟩
|
| 33 |
-
|
| 34 |
-
theorem indepNum_graph_le [Fintype V] (x : V → A) : (graph H x).indepNum ≤ 2 := by
|
| 35 |
-
classical
|
| 36 |
-
obtain ⟨S, hS, he⟩ := (graph H x).exists_isNIndepSet_indepNum
|
| 37 |
-
rw [← he]
|
| 38 |
-
by_contra h
|
| 39 |
-
have hr : Fintype.card (Fin 3) ≤ Fintype.card S := by simp; omega
|
| 40 |
-
obtain ⟨e⟩ := Function.Embedding.nonempty_of_card_le hr
|
| 41 |
-
let f : Fin 3 → V := fun i => e i
|
| 42 |
-
have hf {i j} (h : i ≠ j) : H.rel (x (f i)) (x (f j)) := by
|
| 43 |
-
by_contra hp
|
| 44 |
-
apply hS (show f i ∈ (S : Set V) from (e i).property)
|
| 45 |
-
(show f j ∈ (S : Set V) from (e j).property)
|
| 46 |
-
(show f i ≠ f j from fun g => h (e.injective (Subtype.ext g)))
|
| 47 |
-
exact ⟨fun g => h (e.injective (Subtype.ext g)), hp⟩
|
| 48 |
-
exact H.ntri (hf (i:=0) (j:=1) (by decide)) (hf (j:=2) (by decide))
|
| 49 |
-
(hf (by decide))
|
| 50 |
-
|
| 51 |
-
/-- Enumerate endpoints of an actual maximum connected matching on positions to
|
| 52 |
-
obtain pairwise disjoint ordered pairs; their raw unit types do not conflict. -/
|
| 53 |
-
theorem matching_pairs [Fintype V] (x : V → A) :
|
| 54 |
-
let t := connectedMatchingNumber (graph H x)
|
| 55 |
-
∃ e : (Fin t ⊕ Fin t) → V, Function.Injective e ∧
|
| 56 |
-
let f : Fin t → A × A := fun i => (x (e (.inl i)), x (e (.inr i)))
|
| 57 |
-
(∀ i, H.unit (f i)) ∧ (∀ i j, ¬H.conflict (f i) (f j)) := by
|
| 58 |
-
classical
|
| 59 |
-
let G := graph H x
|
| 60 |
-
let t := connectedMatchingNumber G
|
| 61 |
-
obtain ⟨M,hM,hc⟩ := exists_matching_card_eq_number G
|
| 62 |
-
have ht : Fintype.card M = t := by rw [Fintype.card_coe,hc]
|
| 63 |
-
let m := (Fintype.equivFinOfCardEq ht).symm
|
| 64 |
-
let m' (i : Fin t) : Finset V := (m i).val
|
| 65 |
-
have hm i : m' i ∈ M := (m i).property
|
| 66 |
-
have hex (i : Fin t) : ∃ v w : V, v ≠ w ∧ m' i = {v,w} :=
|
| 67 |
-
card_eq_two.mp (hM.1 _ (hm i)).1
|
| 68 |
-
choose v w hv he using hex
|
| 69 |
-
let e := Sum.elim v w
|
| 70 |
-
have hmem (i : Fin t ⊕ Fin t) : e i ∈ m' (Sum.elim id id i) := by
|
| 71 |
-
cases i <;> simp [e,he]
|
| 72 |
-
have hminj : Function.Injective m' := fun i j g => m.injective (Subtype.ext g)
|
| 73 |
-
have hei : Function.Injective e := by
|
| 74 |
-
intro i j h
|
| 75 |
-
have hi : Sum.elim id id i = Sum.elim id id j := by
|
| 76 |
-
by_contra hn
|
| 77 |
-
have hh := hM.2.1 _ (hm _) _ (hm _) (hminj.ne hn)
|
| 78 |
-
exact Finset.disjoint_left.mp hh (hmem i) (by rw [h]; exact hmem j)
|
| 79 |
-
cases i <;> cases j <;> simp_all [e]
|
| 80 |
-
exact hv _ h.symm
|
| 81 |
-
refine ⟨e, hei, fun i => ?_, fun i j => ?_⟩
|
| 82 |
-
· have h1 : v i ∈ m' i := by simp [he]
|
| 83 |
-
have h2 : w i ∈ m' i := by simp [he]
|
| 84 |
-
exact ((hM.1 _ (hm i)).2 h1 h2 (hv i)).2
|
| 85 |
-
· by_cases h : i = j
|
| 86 |
-
· subst j; exact no_self_conflict _ _
|
| 87 |
-
· obtain ⟨a,ha,b,hb,hadj⟩ := hM.2.2 _ (hm i) _ (hm j) (hminj.ne h)
|
| 88 |
-
have ha' : a = v i ∨ a = w i := by simpa [he] using ha
|
| 89 |
-
have hb' : b = v j ∨ b = w j := by simpa [he] using hb
|
| 90 |
-
intro hz
|
| 91 |
-
apply hadj.2
|
| 92 |
-
rcases ha' with h1|h1 <;> rcases hb' with h2|h2 <;> rw [h1,h2]
|
| 93 |
-
· exact hz.1
|
| 94 |
-
· exact hz.2.1
|
| 95 |
-
· exact hz.2.2.1
|
| 96 |
-
· exact hz.2.2.2
|
| 97 |
-
end Holes
|
| 98 |
-
end HadwigerCounterexample
|
| 99 |
-
|
| 100 |
-
end
|
| 101 |
-
|
| 102 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerMatching.BasicMatching
|
| 2 |
+
import Mathlib.Data.Fintype.EquivFin
|
| 3 |
+
import Mathlib.Combinatorics.SimpleGraph.Clique
|
| 4 |
+
import Lean.Elab.Tactic.Omega
|
| 5 |
+
|
| 6 |
+
namespace OAI
|
| 7 |
+
|
| 8 |
+
/-! # Sampled Graphs -/
|
| 9 |
+
|
| 10 |
+
noncomputable section
|
| 11 |
+
namespace HadwigerCounterexample
|
| 12 |
+
open HadwigerMatching Finset
|
| 13 |
+
variable {A V : Type*}
|
| 14 |
+
|
| 15 |
+
structure Holes (A : Type*) where
|
| 16 |
+
rel : A → A → Prop
|
| 17 |
+
sym {x y : A} : rel x y → rel y x
|
| 18 |
+
irr (x : A) : ¬ rel x x
|
| 19 |
+
ntri {x y z : A} : rel x y → rel y z → ¬ rel x z
|
| 20 |
+
|
| 21 |
+
namespace Holes
|
| 22 |
+
|
| 23 |
+
variable (H : Holes A)
|
| 24 |
+
def unit (p : A × A) := ¬H.rel p.1 p.2
|
| 25 |
+
def conflict (p q : A × A) := H.rel p.1 q.1 ∧ H.rel p.1 q.2 ∧ H.rel p.2 q.1 ∧ H.rel p.2 q.2
|
| 26 |
+
|
| 27 |
+
theorem no_self_conflict (p : A × A) : ¬ H.conflict p p := fun h => H.irr p.1 h.1
|
| 28 |
+
|
| 29 |
+
def graph (x : V → A) : SimpleGraph V where
|
| 30 |
+
Adj i j := i ≠ j ∧ ¬H.rel (x i) (x j)
|
| 31 |
+
symm := ⟨fun _ _ ⟨hne,h⟩ => ⟨hne.symm,fun h' => h (H.sym h')⟩⟩
|
| 32 |
+
loopless := ⟨fun _ h => h.1 rfl⟩
|
| 33 |
+
|
| 34 |
+
theorem indepNum_graph_le [Fintype V] (x : V → A) : (graph H x).indepNum ≤ 2 := by
|
| 35 |
+
classical
|
| 36 |
+
obtain ⟨S, hS, he⟩ := (graph H x).exists_isNIndepSet_indepNum
|
| 37 |
+
rw [← he]
|
| 38 |
+
by_contra h
|
| 39 |
+
have hr : Fintype.card (Fin 3) ≤ Fintype.card S := by simp; omega
|
| 40 |
+
obtain ⟨e⟩ := Function.Embedding.nonempty_of_card_le hr
|
| 41 |
+
let f : Fin 3 → V := fun i => e i
|
| 42 |
+
have hf {i j} (h : i ≠ j) : H.rel (x (f i)) (x (f j)) := by
|
| 43 |
+
by_contra hp
|
| 44 |
+
apply hS (show f i ∈ (S : Set V) from (e i).property)
|
| 45 |
+
(show f j ∈ (S : Set V) from (e j).property)
|
| 46 |
+
(show f i ≠ f j from fun g => h (e.injective (Subtype.ext g)))
|
| 47 |
+
exact ⟨fun g => h (e.injective (Subtype.ext g)), hp⟩
|
| 48 |
+
exact H.ntri (hf (i:=0) (j:=1) (by decide)) (hf (j:=2) (by decide))
|
| 49 |
+
(hf (by decide))
|
| 50 |
+
|
| 51 |
+
/-- Enumerate endpoints of an actual maximum connected matching on positions to
|
| 52 |
+
obtain pairwise disjoint ordered pairs; their raw unit types do not conflict. -/
|
| 53 |
+
theorem matching_pairs [Fintype V] (x : V → A) :
|
| 54 |
+
let t := connectedMatchingNumber (graph H x)
|
| 55 |
+
∃ e : (Fin t ⊕ Fin t) → V, Function.Injective e ∧
|
| 56 |
+
let f : Fin t → A × A := fun i => (x (e (.inl i)), x (e (.inr i)))
|
| 57 |
+
(∀ i, H.unit (f i)) ∧ (∀ i j, ¬H.conflict (f i) (f j)) := by
|
| 58 |
+
classical
|
| 59 |
+
let G := graph H x
|
| 60 |
+
let t := connectedMatchingNumber G
|
| 61 |
+
obtain ⟨M,hM,hc⟩ := exists_matching_card_eq_number G
|
| 62 |
+
have ht : Fintype.card M = t := by rw [Fintype.card_coe,hc]
|
| 63 |
+
let m := (Fintype.equivFinOfCardEq ht).symm
|
| 64 |
+
let m' (i : Fin t) : Finset V := (m i).val
|
| 65 |
+
have hm i : m' i ∈ M := (m i).property
|
| 66 |
+
have hex (i : Fin t) : ∃ v w : V, v ≠ w ∧ m' i = {v,w} :=
|
| 67 |
+
card_eq_two.mp (hM.1 _ (hm i)).1
|
| 68 |
+
choose v w hv he using hex
|
| 69 |
+
let e := Sum.elim v w
|
| 70 |
+
have hmem (i : Fin t ⊕ Fin t) : e i ∈ m' (Sum.elim id id i) := by
|
| 71 |
+
cases i <;> simp [e,he]
|
| 72 |
+
have hminj : Function.Injective m' := fun i j g => m.injective (Subtype.ext g)
|
| 73 |
+
have hei : Function.Injective e := by
|
| 74 |
+
intro i j h
|
| 75 |
+
have hi : Sum.elim id id i = Sum.elim id id j := by
|
| 76 |
+
by_contra hn
|
| 77 |
+
have hh := hM.2.1 _ (hm _) _ (hm _) (hminj.ne hn)
|
| 78 |
+
exact Finset.disjoint_left.mp hh (hmem i) (by rw [h]; exact hmem j)
|
| 79 |
+
cases i <;> cases j <;> simp_all [e]
|
| 80 |
+
exact hv _ h.symm
|
| 81 |
+
refine ⟨e, hei, fun i => ?_, fun i j => ?_⟩
|
| 82 |
+
· have h1 : v i ∈ m' i := by simp [he]
|
| 83 |
+
have h2 : w i ∈ m' i := by simp [he]
|
| 84 |
+
exact ((hM.1 _ (hm i)).2 h1 h2 (hv i)).2
|
| 85 |
+
· by_cases h : i = j
|
| 86 |
+
· subst j; exact no_self_conflict _ _
|
| 87 |
+
· obtain ⟨a,ha,b,hb,hadj⟩ := hM.2.2 _ (hm i) _ (hm j) (hminj.ne h)
|
| 88 |
+
have ha' : a = v i ∨ a = w i := by simpa [he] using ha
|
| 89 |
+
have hb' : b = v j ∨ b = w j := by simpa [he] using hb
|
| 90 |
+
intro hz
|
| 91 |
+
apply hadj.2
|
| 92 |
+
rcases ha' with h1|h1 <;> rcases hb' with h2|h2 <;> rw [h1,h2]
|
| 93 |
+
· exact hz.1
|
| 94 |
+
· exact hz.2.1
|
| 95 |
+
· exact hz.2.2.1
|
| 96 |
+
· exact hz.2.2.2
|
| 97 |
+
end Holes
|
| 98 |
+
end HadwigerCounterexample
|
| 99 |
+
|
| 100 |
+
end
|
| 101 |
+
|
| 102 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ScalarStatusAlgebra.lean
CHANGED
|
@@ -1,162 +1,162 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.BasisConditioning
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Scalar Status Algebra -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Matrix LinearMap Submodule Finset Function Module
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
|
| 12 |
-
namespace StatusAnalysis
|
| 13 |
-
abbrev Nodes := Bool
|
| 14 |
-
abbrev Grid := Nodes × Nodes
|
| 15 |
-
abbrev Cell (d : ℕ) := Vec (Fin d)
|
| 16 |
-
|
| 17 |
-
abbrev Par (d : ℕ) := F × Cell d
|
| 18 |
-
abbrev Whole (d : ℕ) := Par d × F
|
| 19 |
-
|
| 20 |
-
abbrev Signal (d e : ℕ) := F × Whole d × Whole e
|
| 21 |
-
abbrev View (d e : ℕ) := F × Par d × Par e
|
| 22 |
-
abbrev Question (d e : ℕ) := F × F × Cell d × Cell e
|
| 23 |
-
variable {d e : ℕ}
|
| 24 |
-
|
| 25 |
-
def view (d e : ℕ) : Signal d e→ₗ[F] View d e where
|
| 26 |
-
toFun x := (x.1,x.2.1.1,x.2.2.1)
|
| 27 |
-
map_add' _ _ := rfl
|
| 28 |
-
map_smul' _ _ := rfl
|
| 29 |
-
def testV (d e : ℕ) : View d e →ₗ[F] Question d e where
|
| 30 |
-
toFun x := (x.1,x.2.1.1 + x.2.2.1,x.2.1.2,x.2.2.2)
|
| 31 |
-
map_add' _ _ := Prod.ext rfl (Prod.ext (add_add_add_comm ..) rfl)
|
| 32 |
-
map_smul' _ _ := Prod.ext rfl (Prod.ext (mul_add _ _ _).symm rfl)
|
| 33 |
-
def want (d e : ℕ) := testV d e ∘ₗ view d e
|
| 34 |
-
|
| 35 |
-
def couple (d : ℕ) : Whole d→ₗ[F] F where
|
| 36 |
-
toFun x := x.1.1+x.2
|
| 37 |
-
map_add' _ _ := add_add_add_comm ..
|
| 38 |
-
map_smul' a _ := (mul_add a _ _).symm
|
| 39 |
-
|
| 40 |
-
def coverBase (V : Space (Signal d e)) := Surjective (view d e ∘ₗ V.subtype)
|
| 41 |
-
theorem testV_surj (d e : ℕ) : Surjective (testV d e) := by
|
| 42 |
-
rintro ⟨a,b,x,y⟩
|
| 43 |
-
exact ⟨(a,(b,x),(0,y)),Prod.ext rfl (Prod.ext (add_zero _) rfl)⟩
|
| 44 |
-
theorem coversFull {V : Space (Signal d e)} (h : coverBase V) : Surjective (want d e ∘ₗ V.subtype) :=
|
| 45 |
-
(testV_surj _ _).comp h
|
| 46 |
-
|
| 47 |
-
abbrev Rates := Nodes→ℕ
|
| 48 |
-
abbrev Suite (A B : Rates) (i : Grid) := Signal (A i.1) (B i.2)
|
| 49 |
-
abbrev LedgerS (A B : Rates) (i : Grid) := Question (A i.1) (B i.2)
|
| 50 |
-
abbrev Cabinet (A B : Rates) := ∀ i, LedgerS A B i
|
| 51 |
-
abbrev Quota := Vec Nodes
|
| 52 |
-
abbrev Court (A B : Rates) := Cabinet A B × Quota × Quota
|
| 53 |
-
abbrev StatusSp (A B : Rates) := ∀ i,Space (Suite A B i)
|
| 54 |
-
variable {A B : Rates}
|
| 55 |
-
|
| 56 |
-
def separate (A B : Rates) (i : Grid) :
|
| 57 |
-
Suite A B i →ₗ[F] Court A B :=
|
| 58 |
-
(LinearMap.single F (LedgerS A B) i ∘ₗ want _ _).prod
|
| 59 |
-
((LinearMap.single F (fun _ : Bool=>F) i.2 ∘ₗ
|
| 60 |
-
(couple (A i.1) ∘ₗ LinearMap.fst F _ _ ∘ₗ LinearMap.snd F _ _)).prod
|
| 61 |
-
(LinearMap.single F (fun _ : Bool=>F) i.1 ∘ₗ
|
| 62 |
-
(couple (B i.2) ∘ₗ LinearMap.snd F _ _ ∘ₗ LinearMap.snd F _ _)))
|
| 63 |
-
|
| 64 |
-
def speak (A B : Rates) :
|
| 65 |
-
(∀ i,Suite A B i) →ₗ[F] Court A B := ∑ i:Grid,separate A B i ∘ₗ LinearMap.proj i
|
| 66 |
-
|
| 67 |
-
theorem speak_solo (A B : Rates) (i : Grid) (x : Suite A B i) :
|
| 68 |
-
speak A B (Pi.single i x)=separate A B i x := by
|
| 69 |
-
classical
|
| 70 |
-
unfold speak; rw [LinearMap.sum_apply,sum_eq_single i]
|
| 71 |
-
· rw [LinearMap.comp_apply]; change separate _ _ _ ((Pi.single i x : ∀ i, Suite A B i) i)=_
|
| 72 |
-
rw [Pi.single_eq_same]
|
| 73 |
-
· intro j _ hj; rw [LinearMap.comp_apply]
|
| 74 |
-
change separate _ _ _ ((Pi.single i x : ∀ i, Suite A B i) j)=_
|
| 75 |
-
rw [Pi.single_eq_of_ne hj,map_zero]
|
| 76 |
-
simp
|
| 77 |
-
|
| 78 |
-
def scorecard (V : StatusSp A B) (T : Cabinet A B) :=
|
| 79 |
-
∃ v : ∀ i,Suite A B i,(∀ i,v i∈V i) ∧ speak A B v=(T,0)
|
| 80 |
-
|
| 81 |
-
structure Critic (A B : Rates) where
|
| 82 |
-
alf : ∀ i : Grid, LedgerS A B i →ₗ[F] F
|
| 83 |
-
altL : Quota
|
| 84 |
-
altR : Quota
|
| 85 |
-
def Counter (g : Critic A B) (V : StatusSp A B) :=
|
| 86 |
-
∀ i:Grid,∀ v∈V i, g.alf i (want _ _ v) =
|
| 87 |
-
g.altL i.2 * couple _ v.2.1 + g.altR i.1 * couple _ v.2.2
|
| 88 |
-
|
| 89 |
-
private theorem vanishes {M : Type} [AddCommGroup M] [Module F M] (V : Space M) {z}
|
| 90 |
-
(h : z∉ V) :
|
| 91 |
-
∃ f:M→ₗ[F] F,f z ≠0 ∧ ∀ i∈V,f i=0 := by
|
| 92 |
-
have he : V.mkQ z ≠0 := fun hg=>h ((Submodule.Quotient.mk_eq_zero V).mp hg)
|
| 93 |
-
obtain ⟨f,hf⟩ := Module.Projective.exists_dual_ne_zero F he
|
| 94 |
-
exact ⟨f ∘ₗ V.mkQ,hf,fun i hi =>by rw [LinearMap.comp_apply,show V.mkQ i=0 from
|
| 95 |
-
(Submodule.Quotient.mk_eq_zero V).mpr hi,map_zero]⟩
|
| 96 |
-
|
| 97 |
-
set_option maxHeartbeats 800000 in
|
| 98 |
-
theorem counter_score (V : StatusSp A B) (T : Cabinet A B)
|
| 99 |
-
(h : ¬scorecard V T) :
|
| 100 |
-
∃ g : Critic A B,Counter g V ∧ ∑ i,g.alf i (T i)≠0 := by
|
| 101 |
-
classical
|
| 102 |
-
let S := (Submodule.pi Set.univ V).map (speak A B)
|
| 103 |
-
have ht : (T,(0 : Quota × Quota))∉ S := by
|
| 104 |
-
rintro ⟨z,hz,he⟩
|
| 105 |
-
exact h ⟨z,fun i => hz i (Set.mem_univ _),he⟩
|
| 106 |
-
obtain ⟨f,hf,hx⟩ := vanishes S ht
|
| 107 |
-
let g : Critic A B := {
|
| 108 |
-
alf := fun i => f ∘ₗ LinearMap.inl F (Cabinet A B) _ ∘ₗ LinearMap.single F _ i
|
| 109 |
-
altL := fun i=> f (0,Pi.single i 1,0)
|
| 110 |
-
altR := fun i=> f (0,0,Pi.single i 1) }
|
| 111 |
-
refine ⟨g,fun i v hv => ?_,?_⟩
|
| 112 |
-
· have hi :
|
| 113 |
-
f (separate A B i v)=0 := by
|
| 114 |
-
apply hx
|
| 115 |
-
refine ⟨Pi.single i v,?_,speak_solo A B i v⟩
|
| 116 |
-
intro j _
|
| 117 |
-
by_cases ht : j=i
|
| 118 |
-
· subst j; rwa [Pi.single_eq_same]
|
| 119 |
-
rw [Pi.single_eq_of_ne ht]; exact zero_mem _
|
| 120 |
-
let a:= couple _ v.2.1
|
| 121 |
-
let b:= couple _ v.2.2
|
| 122 |
-
let Q:= want _ _ v
|
| 123 |
-
have hh (a:F) (i:Bool) :
|
| 124 |
-
(a • Pi.single i 1 : Quota)=Pi.single i a := by
|
| 125 |
-
ext j; by_cases he:j=i <;> simp [he]
|
| 126 |
-
have hz :
|
| 127 |
-
separate A B i v =
|
| 128 |
-
( (Pi.single i Q : Cabinet A B),0) + (a • (0,Pi.single i.2 1,(0:Quota))+
|
| 129 |
-
b • (0,(0:Quota),Pi.single i.1 1)) := by
|
| 130 |
-
change ((Pi.single i Q:Cabinet A B),(Pi.single i.2 a:Quota),(Pi.single i.1 b:Quota))=_
|
| 131 |
-
apply Prod.ext; simp
|
| 132 |
-
apply Prod.ext <;> simp [hh]
|
| 133 |
-
rw [hz,map_add,map_add,map_smul,map_smul] at hi
|
| 134 |
-
change g.alf i Q+(a*g.altL i.2+b*g.altR i.1)=0 at hi
|
| 135 |
-
change _=g.altL _ * a+g.altR _ * b
|
| 136 |
-
rw [mul_comm _ a,mul_comm _ b]
|
| 137 |
-
exact add_right_cancel (hi.trans (char_two _).symm)
|
| 138 |
-
· have hh (i) : g.alf i (T i)=f ((Pi.single i (T i) : Cabinet A B),0) := rfl
|
| 139 |
-
have ht : ∑ i:Grid, ((Pi.single i (T i) : Cabinet A B),(0 : Quota × Quota))=
|
| 140 |
-
(T,0) := by
|
| 141 |
-
apply Prod.ext
|
| 142 |
-
· rw [Prod.fst_sum]; exact Finset.univ_sum_single _
|
| 143 |
-
· simp only [Prod.snd_sum,Finset.sum_const_zero]
|
| 144 |
-
simp_rw [hh, ← map_sum,ht]
|
| 145 |
-
exact hf
|
| 146 |
-
|
| 147 |
-
theorem critic_nz (V : StatusSp A B) (T : Cabinet A B) (hV : ∀ i,coverBase (V i)) (g : Critic A B)
|
| 148 |
-
(h : Counter g V) (hh : ∑ i,g.alf i (T i)≠0) : g.altL≠0 ∨ g.altR≠0 := by
|
| 149 |
-
classical
|
| 150 |
-
by_contra! hz
|
| 151 |
-
apply hh; apply Finset.sum_eq_zero
|
| 152 |
-
intro i _
|
| 153 |
-
obtain ⟨⟨v,hv⟩,ht⟩ := coversFull (hV i) (T i)
|
| 154 |
-
simpa only [show want (A i.1) (B i.2) v=T i from ht,hz.1,hz.2,Pi.zero_apply,zero_mul,add_zero]
|
| 155 |
-
using h i v hv
|
| 156 |
-
|
| 157 |
-
end StatusAnalysis
|
| 158 |
-
end HadwigerCounterexample
|
| 159 |
-
|
| 160 |
-
end
|
| 161 |
-
|
| 162 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.BasisConditioning
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Scalar Status Algebra -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Matrix LinearMap Submodule Finset Function Module
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
|
| 12 |
+
namespace StatusAnalysis
|
| 13 |
+
abbrev Nodes := Bool
|
| 14 |
+
abbrev Grid := Nodes × Nodes
|
| 15 |
+
abbrev Cell (d : ℕ) := Vec (Fin d)
|
| 16 |
+
|
| 17 |
+
abbrev Par (d : ℕ) := F × Cell d
|
| 18 |
+
abbrev Whole (d : ℕ) := Par d × F
|
| 19 |
+
|
| 20 |
+
abbrev Signal (d e : ℕ) := F × Whole d × Whole e
|
| 21 |
+
abbrev View (d e : ℕ) := F × Par d × Par e
|
| 22 |
+
abbrev Question (d e : ℕ) := F × F × Cell d × Cell e
|
| 23 |
+
variable {d e : ℕ}
|
| 24 |
+
|
| 25 |
+
def view (d e : ℕ) : Signal d e→ₗ[F] View d e where
|
| 26 |
+
toFun x := (x.1,x.2.1.1,x.2.2.1)
|
| 27 |
+
map_add' _ _ := rfl
|
| 28 |
+
map_smul' _ _ := rfl
|
| 29 |
+
def testV (d e : ℕ) : View d e →ₗ[F] Question d e where
|
| 30 |
+
toFun x := (x.1,x.2.1.1 + x.2.2.1,x.2.1.2,x.2.2.2)
|
| 31 |
+
map_add' _ _ := Prod.ext rfl (Prod.ext (add_add_add_comm ..) rfl)
|
| 32 |
+
map_smul' _ _ := Prod.ext rfl (Prod.ext (mul_add _ _ _).symm rfl)
|
| 33 |
+
def want (d e : ℕ) := testV d e ∘ₗ view d e
|
| 34 |
+
|
| 35 |
+
def couple (d : ℕ) : Whole d→ₗ[F] F where
|
| 36 |
+
toFun x := x.1.1+x.2
|
| 37 |
+
map_add' _ _ := add_add_add_comm ..
|
| 38 |
+
map_smul' a _ := (mul_add a _ _).symm
|
| 39 |
+
|
| 40 |
+
def coverBase (V : Space (Signal d e)) := Surjective (view d e ∘ₗ V.subtype)
|
| 41 |
+
theorem testV_surj (d e : ℕ) : Surjective (testV d e) := by
|
| 42 |
+
rintro ⟨a,b,x,y⟩
|
| 43 |
+
exact ⟨(a,(b,x),(0,y)),Prod.ext rfl (Prod.ext (add_zero _) rfl)⟩
|
| 44 |
+
theorem coversFull {V : Space (Signal d e)} (h : coverBase V) : Surjective (want d e ∘ₗ V.subtype) :=
|
| 45 |
+
(testV_surj _ _).comp h
|
| 46 |
+
|
| 47 |
+
abbrev Rates := Nodes→ℕ
|
| 48 |
+
abbrev Suite (A B : Rates) (i : Grid) := Signal (A i.1) (B i.2)
|
| 49 |
+
abbrev LedgerS (A B : Rates) (i : Grid) := Question (A i.1) (B i.2)
|
| 50 |
+
abbrev Cabinet (A B : Rates) := ∀ i, LedgerS A B i
|
| 51 |
+
abbrev Quota := Vec Nodes
|
| 52 |
+
abbrev Court (A B : Rates) := Cabinet A B × Quota × Quota
|
| 53 |
+
abbrev StatusSp (A B : Rates) := ∀ i,Space (Suite A B i)
|
| 54 |
+
variable {A B : Rates}
|
| 55 |
+
|
| 56 |
+
def separate (A B : Rates) (i : Grid) :
|
| 57 |
+
Suite A B i →ₗ[F] Court A B :=
|
| 58 |
+
(LinearMap.single F (LedgerS A B) i ∘ₗ want _ _).prod
|
| 59 |
+
((LinearMap.single F (fun _ : Bool=>F) i.2 ∘ₗ
|
| 60 |
+
(couple (A i.1) ∘ₗ LinearMap.fst F _ _ ∘ₗ LinearMap.snd F _ _)).prod
|
| 61 |
+
(LinearMap.single F (fun _ : Bool=>F) i.1 ∘ₗ
|
| 62 |
+
(couple (B i.2) ∘ₗ LinearMap.snd F _ _ ∘ₗ LinearMap.snd F _ _)))
|
| 63 |
+
|
| 64 |
+
def speak (A B : Rates) :
|
| 65 |
+
(∀ i,Suite A B i) →ₗ[F] Court A B := ∑ i:Grid,separate A B i ∘ₗ LinearMap.proj i
|
| 66 |
+
|
| 67 |
+
theorem speak_solo (A B : Rates) (i : Grid) (x : Suite A B i) :
|
| 68 |
+
speak A B (Pi.single i x)=separate A B i x := by
|
| 69 |
+
classical
|
| 70 |
+
unfold speak; rw [LinearMap.sum_apply,sum_eq_single i]
|
| 71 |
+
· rw [LinearMap.comp_apply]; change separate _ _ _ ((Pi.single i x : ∀ i, Suite A B i) i)=_
|
| 72 |
+
rw [Pi.single_eq_same]
|
| 73 |
+
· intro j _ hj; rw [LinearMap.comp_apply]
|
| 74 |
+
change separate _ _ _ ((Pi.single i x : ∀ i, Suite A B i) j)=_
|
| 75 |
+
rw [Pi.single_eq_of_ne hj,map_zero]
|
| 76 |
+
simp
|
| 77 |
+
|
| 78 |
+
def scorecard (V : StatusSp A B) (T : Cabinet A B) :=
|
| 79 |
+
∃ v : ∀ i,Suite A B i,(∀ i,v i∈V i) ∧ speak A B v=(T,0)
|
| 80 |
+
|
| 81 |
+
structure Critic (A B : Rates) where
|
| 82 |
+
alf : ∀ i : Grid, LedgerS A B i →ₗ[F] F
|
| 83 |
+
altL : Quota
|
| 84 |
+
altR : Quota
|
| 85 |
+
def Counter (g : Critic A B) (V : StatusSp A B) :=
|
| 86 |
+
∀ i:Grid,∀ v∈V i, g.alf i (want _ _ v) =
|
| 87 |
+
g.altL i.2 * couple _ v.2.1 + g.altR i.1 * couple _ v.2.2
|
| 88 |
+
|
| 89 |
+
private theorem vanishes {M : Type} [AddCommGroup M] [Module F M] (V : Space M) {z}
|
| 90 |
+
(h : z∉ V) :
|
| 91 |
+
∃ f:M→ₗ[F] F,f z ≠0 ∧ ∀ i∈V,f i=0 := by
|
| 92 |
+
have he : V.mkQ z ≠0 := fun hg=>h ((Submodule.Quotient.mk_eq_zero V).mp hg)
|
| 93 |
+
obtain ⟨f,hf⟩ := Module.Projective.exists_dual_ne_zero F he
|
| 94 |
+
exact ⟨f ∘ₗ V.mkQ,hf,fun i hi =>by rw [LinearMap.comp_apply,show V.mkQ i=0 from
|
| 95 |
+
(Submodule.Quotient.mk_eq_zero V).mpr hi,map_zero]⟩
|
| 96 |
+
|
| 97 |
+
set_option maxHeartbeats 800000 in
|
| 98 |
+
theorem counter_score (V : StatusSp A B) (T : Cabinet A B)
|
| 99 |
+
(h : ¬scorecard V T) :
|
| 100 |
+
∃ g : Critic A B,Counter g V ∧ ∑ i,g.alf i (T i)≠0 := by
|
| 101 |
+
classical
|
| 102 |
+
let S := (Submodule.pi Set.univ V).map (speak A B)
|
| 103 |
+
have ht : (T,(0 : Quota × Quota))∉ S := by
|
| 104 |
+
rintro ⟨z,hz,he⟩
|
| 105 |
+
exact h ⟨z,fun i => hz i (Set.mem_univ _),he⟩
|
| 106 |
+
obtain ⟨f,hf,hx⟩ := vanishes S ht
|
| 107 |
+
let g : Critic A B := {
|
| 108 |
+
alf := fun i => f ∘ₗ LinearMap.inl F (Cabinet A B) _ ∘ₗ LinearMap.single F _ i
|
| 109 |
+
altL := fun i=> f (0,Pi.single i 1,0)
|
| 110 |
+
altR := fun i=> f (0,0,Pi.single i 1) }
|
| 111 |
+
refine ⟨g,fun i v hv => ?_,?_⟩
|
| 112 |
+
· have hi :
|
| 113 |
+
f (separate A B i v)=0 := by
|
| 114 |
+
apply hx
|
| 115 |
+
refine ⟨Pi.single i v,?_,speak_solo A B i v⟩
|
| 116 |
+
intro j _
|
| 117 |
+
by_cases ht : j=i
|
| 118 |
+
· subst j; rwa [Pi.single_eq_same]
|
| 119 |
+
rw [Pi.single_eq_of_ne ht]; exact zero_mem _
|
| 120 |
+
let a:= couple _ v.2.1
|
| 121 |
+
let b:= couple _ v.2.2
|
| 122 |
+
let Q:= want _ _ v
|
| 123 |
+
have hh (a:F) (i:Bool) :
|
| 124 |
+
(a • Pi.single i 1 : Quota)=Pi.single i a := by
|
| 125 |
+
ext j; by_cases he:j=i <;> simp [he]
|
| 126 |
+
have hz :
|
| 127 |
+
separate A B i v =
|
| 128 |
+
( (Pi.single i Q : Cabinet A B),0) + (a • (0,Pi.single i.2 1,(0:Quota))+
|
| 129 |
+
b • (0,(0:Quota),Pi.single i.1 1)) := by
|
| 130 |
+
change ((Pi.single i Q:Cabinet A B),(Pi.single i.2 a:Quota),(Pi.single i.1 b:Quota))=_
|
| 131 |
+
apply Prod.ext; simp
|
| 132 |
+
apply Prod.ext <;> simp [hh]
|
| 133 |
+
rw [hz,map_add,map_add,map_smul,map_smul] at hi
|
| 134 |
+
change g.alf i Q+(a*g.altL i.2+b*g.altR i.1)=0 at hi
|
| 135 |
+
change _=g.altL _ * a+g.altR _ * b
|
| 136 |
+
rw [mul_comm _ a,mul_comm _ b]
|
| 137 |
+
exact add_right_cancel (hi.trans (char_two _).symm)
|
| 138 |
+
· have hh (i) : g.alf i (T i)=f ((Pi.single i (T i) : Cabinet A B),0) := rfl
|
| 139 |
+
have ht : ∑ i:Grid, ((Pi.single i (T i) : Cabinet A B),(0 : Quota × Quota))=
|
| 140 |
+
(T,0) := by
|
| 141 |
+
apply Prod.ext
|
| 142 |
+
· rw [Prod.fst_sum]; exact Finset.univ_sum_single _
|
| 143 |
+
· simp only [Prod.snd_sum,Finset.sum_const_zero]
|
| 144 |
+
simp_rw [hh, ← map_sum,ht]
|
| 145 |
+
exact hf
|
| 146 |
+
|
| 147 |
+
theorem critic_nz (V : StatusSp A B) (T : Cabinet A B) (hV : ∀ i,coverBase (V i)) (g : Critic A B)
|
| 148 |
+
(h : Counter g V) (hh : ∑ i,g.alf i (T i)≠0) : g.altL≠0 ∨ g.altR≠0 := by
|
| 149 |
+
classical
|
| 150 |
+
by_contra! hz
|
| 151 |
+
apply hh; apply Finset.sum_eq_zero
|
| 152 |
+
intro i _
|
| 153 |
+
obtain ⟨⟨v,hv⟩,ht⟩ := coversFull (hV i) (T i)
|
| 154 |
+
simpa only [show want (A i.1) (B i.2) v=T i from ht,hz.1,hz.2,Pi.zero_apply,zero_mul,add_zero]
|
| 155 |
+
using h i v hv
|
| 156 |
+
|
| 157 |
+
end StatusAnalysis
|
| 158 |
+
end HadwigerCounterexample
|
| 159 |
+
|
| 160 |
+
end
|
| 161 |
+
|
| 162 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/ScriptGramCorrespondence.lean
CHANGED
|
@@ -1,104 +1,104 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.EndpointEvaluations
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Script Gram Correspondence -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Finset Matrix LinearMap Function
|
| 10 |
-
open scoped BigOperators
|
| 11 |
-
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
-
|
| 13 |
-
namespace Template
|
| 14 |
-
variable (v : Template p I)
|
| 15 |
-
|
| 16 |
-
def lyrics (s : Script p I) (i : v.Chorus) : Vec (v.Abbey i) :=
|
| 17 |
-
match i with
|
| 18 |
-
| .inl z => Sum.elim (fun j => if j.2 then s z.val.1 z.val.2 j.1 else s z.val.2 z.val.1 j.1)
|
| 19 |
-
(fun _ => 0)
|
| 20 |
-
| .inr _ => 0
|
| 21 |
-
def performs (s : Script p I) (m : Mixer p n) (x : UnitType p n N) (z : Inputs p n I) :=
|
| 22 |
-
listen v.choral (v.chime m x) z=v.lyrics s
|
| 23 |
-
|
| 24 |
-
omit [DecidableEq I] in
|
| 25 |
-
theorem across_duet (v : Template p I) {i j} (h : i ≠ j) :
|
| 26 |
-
∃ k : v.Chorus,v.verses k=(i,j)∨v.verses k=(j,i) := by
|
| 27 |
-
classical
|
| 28 |
-
let e := Fintype.equivFin I
|
| 29 |
-
by_cases hg : v.aim i=v.aim j
|
| 30 |
-
· rcases lt_or_gt_of_ne (e.injective.ne h) with hh|hh
|
| 31 |
-
· exact ⟨.inl ⟨⟨i,j⟩,hg,hh⟩,Or.inl rfl⟩
|
| 32 |
-
exact ⟨.inl ⟨⟨j,i⟩,hg.symm,hh⟩,Or.inr rfl⟩
|
| 33 |
-
cases hi : v.aim i <;> cases hj : v.aim j
|
| 34 |
-
· simp [hi,hj] at hg
|
| 35 |
-
· exact ⟨.inr ⟨⟨j,i⟩,hj,hi⟩,Or.inr rfl⟩
|
| 36 |
-
· exact ⟨.inr ⟨⟨i,j⟩,hi,hj⟩,Or.inl rfl⟩
|
| 37 |
-
simp [hi,hj] at hg
|
| 38 |
-
|
| 39 |
-
def voices (v : Template p I) (x : Keys (p:=p) v.t N) (i j) (e : Comp p.g) (a : inc e (v.t i))
|
| 40 |
-
(b : inc e (v.t j)) (q : Bool) :=
|
| 41 |
-
dotProduct (x i ⟨e,a⟩ q) (x j ⟨e,b⟩ (!q))
|
| 42 |
-
|
| 43 |
-
omit [Fintype I] [DecidableEq I] in
|
| 44 |
-
theorem voice_note (v : Template p I) (x : UnitType p n N) (z : Inputs p n I)
|
| 45 |
-
(e : Comp p.g) (i j) (a : inc e (v.t i)) (b : inc e (v.t j)) (q : Bool) :
|
| 46 |
-
v.voices ((v.draw z).keys v.t x) i j e a b q=evmat
|
| 47 |
-
(duel p (onSide x (v.aim i) e) (onSide x (v.aim j) e) q)
|
| 48 |
-
(v.croon i (z i)) (v.croon j (z j)) := by
|
| 49 |
-
let P := primary (takeSign (p:=p) (onSide x (v.aim i) e) q)
|
| 50 |
-
let Q := primary (takeSign (p:=p) (onSide x (v.aim j) e) (!q))
|
| 51 |
-
let u := v.croon i (z i); let t := v.croon j (z j)
|
| 52 |
-
change dotProduct (P *ᵥ u) (Q *ᵥ t)=dotProduct u ((Pᵀ *Q)*ᵥ t)
|
| 53 |
-
rw [← mulVec_mulVec,dotProduct_transpose_mulVec]
|
| 54 |
-
exact dotProduct_comm _ _
|
| 55 |
-
|
| 56 |
-
omit [Fintype I] [DecidableEq I] in
|
| 57 |
-
theorem voice_same (v : Template p I) (x : UnitType p n N) (z : Inputs p n I)
|
| 58 |
-
(m : Mixer p n) (hw : ∀ i,frameLaw m (onSide x i))
|
| 59 |
-
(e : Comp p.g) (i j) (a : inc e (v.t i)) (b : inc e (v.t j))
|
| 60 |
-
(h : v.aim i=v.aim j) (q : Bool) :
|
| 61 |
-
v.voices ((v.draw z).keys v.t x) i j e a b q=evmat
|
| 62 |
-
(eitherM q (selfM p n m.mixM)) (v.croon i (z i)) (v.croon j (z j)) := by
|
| 63 |
-
rw [voice_note,h]
|
| 64 |
-
let y := onSide x (v.aim j) e
|
| 65 |
-
have he : (primary y.1)ᵀ*primary y.2=selfM p n m.mixM := (hw (v.aim j) e).2.2.1
|
| 66 |
-
congr 1
|
| 67 |
-
unfold duel
|
| 68 |
-
cases q
|
| 69 |
-
· change (primary y.2)ᵀ*primary y.1=_
|
| 70 |
-
rw [←he]; simp only [eitherM,Bool.false_eq_true,ite_false, transpose_mul,transpose_transpose]
|
| 71 |
-
exact he
|
| 72 |
-
|
| 73 |
-
def verges (v : Template p I) (x : Keys (p:=p) v.t N) (i j) :=
|
| 74 |
-
∀ e a b q,v.voices x i j e a b q=0
|
| 75 |
-
omit [Fintype I] [DecidableEq I] in
|
| 76 |
-
theorem verges_rev (v : Template p I) {x : Keys (p:=p) v.t N} {i j}
|
| 77 |
-
(h : v.verges x i j) : v.verges x j i := by
|
| 78 |
-
intro e a b q
|
| 79 |
-
have ht := h e b a (!q)
|
| 80 |
-
unfold voices at *; rw [dotProduct_comm]; rwa [Bool.not_not] at ht
|
| 81 |
-
|
| 82 |
-
omit [Fintype I] [DecidableEq I] in
|
| 83 |
-
theorem voices_diag (v : Template p I) (m : Mixer p n) (x : UnitType p n N)
|
| 84 |
-
(w : Inputs p n I) (hw : ∀ i,frameLaw m (onSide x i)) (hj : 1≤p.j) (i : I) :
|
| 85 |
-
ownOne p (v.t i) (dialed p (v.t i) (v.f i) (w i))
|
| 86 |
-
((v.draw w).keys v.t x i) := by
|
| 87 |
-
intro e
|
| 88 |
-
let y := (v.draw w).par i
|
| 89 |
-
let A := mom p (v.s i) y
|
| 90 |
-
have h : A∈Wspace p n := Submodule.subset_span ⟨_,_,rfl⟩
|
| 91 |
-
have he := v.voice_same x w m hw e.val i i e.property e.property rfl true
|
| 92 |
-
let E := selfM p n m.mixM
|
| 93 |
-
change v.voices _ i i e.val e.property e.property true=_
|
| 94 |
-
rw [he]
|
| 95 |
-
change evmat E (point p _ y) (point p _ y)=_
|
| 96 |
-
rw [← mpair_outer]
|
| 97 |
-
exact (selfM_pair p hj m.mixM h).trans (etaScan p (n:=n) (v.t i) (v.s i) _ (w i)).symm
|
| 98 |
-
|
| 99 |
-
end Template
|
| 100 |
-
end HadwigerCounterexample
|
| 101 |
-
|
| 102 |
-
end
|
| 103 |
-
|
| 104 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.EndpointEvaluations
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Script Gram Correspondence -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Finset Matrix LinearMap Function
|
| 10 |
+
open scoped BigOperators
|
| 11 |
+
variable {p : Shape} {n N : ℕ} {I : Type} [Fintype I] [DecidableEq I]
|
| 12 |
+
|
| 13 |
+
namespace Template
|
| 14 |
+
variable (v : Template p I)
|
| 15 |
+
|
| 16 |
+
def lyrics (s : Script p I) (i : v.Chorus) : Vec (v.Abbey i) :=
|
| 17 |
+
match i with
|
| 18 |
+
| .inl z => Sum.elim (fun j => if j.2 then s z.val.1 z.val.2 j.1 else s z.val.2 z.val.1 j.1)
|
| 19 |
+
(fun _ => 0)
|
| 20 |
+
| .inr _ => 0
|
| 21 |
+
def performs (s : Script p I) (m : Mixer p n) (x : UnitType p n N) (z : Inputs p n I) :=
|
| 22 |
+
listen v.choral (v.chime m x) z=v.lyrics s
|
| 23 |
+
|
| 24 |
+
omit [DecidableEq I] in
|
| 25 |
+
theorem across_duet (v : Template p I) {i j} (h : i ≠ j) :
|
| 26 |
+
∃ k : v.Chorus,v.verses k=(i,j)∨v.verses k=(j,i) := by
|
| 27 |
+
classical
|
| 28 |
+
let e := Fintype.equivFin I
|
| 29 |
+
by_cases hg : v.aim i=v.aim j
|
| 30 |
+
· rcases lt_or_gt_of_ne (e.injective.ne h) with hh|hh
|
| 31 |
+
· exact ⟨.inl ⟨⟨i,j⟩,hg,hh⟩,Or.inl rfl⟩
|
| 32 |
+
exact ⟨.inl ⟨⟨j,i⟩,hg.symm,hh⟩,Or.inr rfl⟩
|
| 33 |
+
cases hi : v.aim i <;> cases hj : v.aim j
|
| 34 |
+
· simp [hi,hj] at hg
|
| 35 |
+
· exact ⟨.inr ⟨⟨j,i⟩,hj,hi⟩,Or.inr rfl⟩
|
| 36 |
+
· exact ⟨.inr ⟨⟨i,j⟩,hi,hj⟩,Or.inl rfl⟩
|
| 37 |
+
simp [hi,hj] at hg
|
| 38 |
+
|
| 39 |
+
def voices (v : Template p I) (x : Keys (p:=p) v.t N) (i j) (e : Comp p.g) (a : inc e (v.t i))
|
| 40 |
+
(b : inc e (v.t j)) (q : Bool) :=
|
| 41 |
+
dotProduct (x i ⟨e,a⟩ q) (x j ⟨e,b⟩ (!q))
|
| 42 |
+
|
| 43 |
+
omit [Fintype I] [DecidableEq I] in
|
| 44 |
+
theorem voice_note (v : Template p I) (x : UnitType p n N) (z : Inputs p n I)
|
| 45 |
+
(e : Comp p.g) (i j) (a : inc e (v.t i)) (b : inc e (v.t j)) (q : Bool) :
|
| 46 |
+
v.voices ((v.draw z).keys v.t x) i j e a b q=evmat
|
| 47 |
+
(duel p (onSide x (v.aim i) e) (onSide x (v.aim j) e) q)
|
| 48 |
+
(v.croon i (z i)) (v.croon j (z j)) := by
|
| 49 |
+
let P := primary (takeSign (p:=p) (onSide x (v.aim i) e) q)
|
| 50 |
+
let Q := primary (takeSign (p:=p) (onSide x (v.aim j) e) (!q))
|
| 51 |
+
let u := v.croon i (z i); let t := v.croon j (z j)
|
| 52 |
+
change dotProduct (P *ᵥ u) (Q *ᵥ t)=dotProduct u ((Pᵀ *Q)*ᵥ t)
|
| 53 |
+
rw [← mulVec_mulVec,dotProduct_transpose_mulVec]
|
| 54 |
+
exact dotProduct_comm _ _
|
| 55 |
+
|
| 56 |
+
omit [Fintype I] [DecidableEq I] in
|
| 57 |
+
theorem voice_same (v : Template p I) (x : UnitType p n N) (z : Inputs p n I)
|
| 58 |
+
(m : Mixer p n) (hw : ∀ i,frameLaw m (onSide x i))
|
| 59 |
+
(e : Comp p.g) (i j) (a : inc e (v.t i)) (b : inc e (v.t j))
|
| 60 |
+
(h : v.aim i=v.aim j) (q : Bool) :
|
| 61 |
+
v.voices ((v.draw z).keys v.t x) i j e a b q=evmat
|
| 62 |
+
(eitherM q (selfM p n m.mixM)) (v.croon i (z i)) (v.croon j (z j)) := by
|
| 63 |
+
rw [voice_note,h]
|
| 64 |
+
let y := onSide x (v.aim j) e
|
| 65 |
+
have he : (primary y.1)ᵀ*primary y.2=selfM p n m.mixM := (hw (v.aim j) e).2.2.1
|
| 66 |
+
congr 1
|
| 67 |
+
unfold duel
|
| 68 |
+
cases q
|
| 69 |
+
· change (primary y.2)ᵀ*primary y.1=_
|
| 70 |
+
rw [←he]; simp only [eitherM,Bool.false_eq_true,ite_false, transpose_mul,transpose_transpose]
|
| 71 |
+
exact he
|
| 72 |
+
|
| 73 |
+
def verges (v : Template p I) (x : Keys (p:=p) v.t N) (i j) :=
|
| 74 |
+
∀ e a b q,v.voices x i j e a b q=0
|
| 75 |
+
omit [Fintype I] [DecidableEq I] in
|
| 76 |
+
theorem verges_rev (v : Template p I) {x : Keys (p:=p) v.t N} {i j}
|
| 77 |
+
(h : v.verges x i j) : v.verges x j i := by
|
| 78 |
+
intro e a b q
|
| 79 |
+
have ht := h e b a (!q)
|
| 80 |
+
unfold voices at *; rw [dotProduct_comm]; rwa [Bool.not_not] at ht
|
| 81 |
+
|
| 82 |
+
omit [Fintype I] [DecidableEq I] in
|
| 83 |
+
theorem voices_diag (v : Template p I) (m : Mixer p n) (x : UnitType p n N)
|
| 84 |
+
(w : Inputs p n I) (hw : ∀ i,frameLaw m (onSide x i)) (hj : 1≤p.j) (i : I) :
|
| 85 |
+
ownOne p (v.t i) (dialed p (v.t i) (v.f i) (w i))
|
| 86 |
+
((v.draw w).keys v.t x i) := by
|
| 87 |
+
intro e
|
| 88 |
+
let y := (v.draw w).par i
|
| 89 |
+
let A := mom p (v.s i) y
|
| 90 |
+
have h : A∈Wspace p n := Submodule.subset_span ⟨_,_,rfl⟩
|
| 91 |
+
have he := v.voice_same x w m hw e.val i i e.property e.property rfl true
|
| 92 |
+
let E := selfM p n m.mixM
|
| 93 |
+
change v.voices _ i i e.val e.property e.property true=_
|
| 94 |
+
rw [he]
|
| 95 |
+
change evmat E (point p _ y) (point p _ y)=_
|
| 96 |
+
rw [← mpair_outer]
|
| 97 |
+
exact (selfM_pair p hj m.mixM h).trans (etaScan p (n:=n) (v.t i) (v.s i) _ (w i)).symm
|
| 98 |
+
|
| 99 |
+
end Template
|
| 100 |
+
end HadwigerCounterexample
|
| 101 |
+
|
| 102 |
+
end
|
| 103 |
+
|
| 104 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/SimultaneousProjection.lean
CHANGED
|
@@ -1,142 +1,142 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.AdaptiveProjectionBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Simultaneous Projection -/
|
| 6 |
-
|
| 7 |
-
noncomputable section
|
| 8 |
-
namespace HadwigerCounterexample
|
| 9 |
-
open Filter Finset Matrix
|
| 10 |
-
open scoped BigOperators Topology
|
| 11 |
-
namespace StatusAnalysis
|
| 12 |
-
open Station PreparationParameters
|
| 13 |
-
|
| 14 |
-
variable {p : Shape} {M s0 n N K : ℕ} {q:Format} {d e:Rates}
|
| 15 |
-
{l:Filter ℕ} {b:PreparationParameters} {m:cycleM p} {w:tale p M} {s:rhythms p M}
|
| 16 |
-
|
| 17 |
-
def sparks (v : Stations p M b.pins s) (i:Scrip p b.pins) (m:cycleM p) (w:tale p M)
|
| 18 |
-
{r} (n:ℕ) (Y: Silhouette p (M*n) r) :=
|
| 19 |
-
Station.stratum (v n) i.2.2 (m n) (w n) i.2.1 Y
|
| 20 |
-
|
| 21 |
-
def bullseye (v: Stations p M K s) (m:cycleM p) (w:tale p M) (x:Typus p q d e)
|
| 22 |
-
(k : Fin (2^deckMax p K)) (ε : ℝ) {r : ℕ} (n : ℕ) (Y : Silhouette p (M*n) r)
|
| 23 |
-
(τ u:ℝ) :=
|
| 24 |
-
∀ (r':ℕ) (Y':Silhouette p (M*n) r'),refines Y' Y →
|
| 25 |
-
∀ τ' δ:ℝ,τ'≤τ →
|
| 26 |
-
pr ((s n).sap (w n)) (fun i=>¬ gauze p τ' δ Y' (m n) K i) ≤u →
|
| 27 |
-
Station.stratum (v n) x (m n) (w n) k Y'≤ ε
|
| 28 |
-
|
| 29 |
-
set_option maxHeartbeats 2400000 in
|
| 30 |
-
theorem glowLamp (v:Stations p M b.pins s) (h:veil p M b s0 l m s w) (x:Typus p q d e)
|
| 31 |
-
(k:Fin (2^deckMax p b.pins)) (hP:x.permission) (ε:ℝ) (he:0<ε) :
|
| 32 |
-
∃ (r : ℕ) (τ u:ℝ), 0<τ∧0<u∧∀ᶠ n in l,∃ Y:Silhouette p (M*n) r,
|
| 33 |
-
bullseye v m w x k ε n Y τ u := by
|
| 34 |
-
classical
|
| 35 |
-
have hq:=h.easel; have ht:=hq.enter.first
|
| 36 |
-
obtain ⟨z,η,hη,hX⟩:=projectCut x hP k h v ε he
|
| 37 |
-
let a:= η/(12*(z+1:ℝ))
|
| 38 |
-
have ha:0<a:=by unfold a; positivity
|
| 39 |
-
obtain ⟨i,u,c,hi,hc,hA⟩:= x.qA.sideRelease x.t x.z M hq hP.2.1 a ha
|
| 40 |
-
obtain ⟨j,v',C,hj,hC,hB⟩:= x.qB.sideRelease x.t x.z M hq hP.2.2.1 a ha
|
| 41 |
-
let f:=fun _ : Fin z=>i*j; let r:=bouquet f
|
| 42 |
-
let τ:= min u v'
|
| 43 |
-
refine ⟨r,τ,a,lt_min hi hj,ha,?_⟩
|
| 44 |
-
have hz:= (trend_sizes l h.timeL ht.hM).2
|
| 45 |
-
filter_upwards [hX,h.upright,h.durableS.shape,h.durableS.mass.positive,h.moment,
|
| 46 |
-
hA.filter_mono h.timeL,hB.filter_mono h.timeL,
|
| 47 |
-
((bp_nat_vanish hc).eventually (eventually_le_nhds ha)).filter_mono h.timeL,
|
| 48 |
-
((bp_nat_vanish hC).eventually (eventually_le_nhds ha)).filter_mono h.timeL,
|
| 49 |
-
hz.eventually (eventually_ge_atTop (2*num (Messenger q×Toast p)+1))]
|
| 50 |
-
with n hn ha' hB' hW he' hA hB hM hV hG
|
| 51 |
-
let N:=M*n; let p0:=s n
|
| 52 |
-
obtain ⟨P,hP'⟩:=hn
|
| 53 |
-
let e k y:=ind (P y=k)
|
| 54 |
-
have heq k y : |e k y| ≤1 := by unfold e; rw [abs_of_nonneg (ind_nonneg _)]; exact ind_le_one _
|
| 55 |
-
choose X hF using fun i:Fin z=> hA (e i) (heq i)
|
| 56 |
-
choose Z hF' using fun i:Fin z=> hB (e i) (heq i)
|
| 57 |
-
let Y k:=duoY (X k) (Z k)
|
| 58 |
-
refine ⟨bundleY f Y,fun r Y' hR τ' δ hτ hpos=>?_⟩
|
| 59 |
-
apply hP' r Y'
|
| 60 |
-
have hw:=he'.1.law
|
| 61 |
-
let hh:=hB'.1
|
| 62 |
-
have hx' i : IsLaw (x.qA.policies x.t x.z n i) :=
|
| 63 |
-
Appearance.witLaw (x.qA.allure_apt _ _ hP.2.1 _) ht.hR ha'.age
|
| 64 |
-
have hy' i : IsLaw (x.qB.policies x.t x.z n i) :=
|
| 65 |
-
Appearance.witLaw (x.qB.allure_apt _ _ hP.2.2.1 _) ht.hR ha'.age
|
| 66 |
-
have hN:= show 2*num (Messenger q×Toast p)-(N:ℝ) ≤ -1 from by
|
| 67 |
-
change _ ≤ (N:ℝ) at hG; linarith only [hG]
|
| 68 |
-
have hp := nuLaw x.t x.z hN
|
| 69 |
-
have ht' : ∀ i:Fin z,refines Y' (Y i) := fun i=> refines_next hR (bundle_refines f Y i)
|
| 70 |
-
refine (projectSum (v n) x (m n) k (w n) Y' P hh.part hw (fun i hi=>(hh.leaf i hi).pos)
|
| 71 |
-
hW hx' hy' hp a u v' τ' a δ ha.le hP ⟨hτ.trans (min_le_left ..),hτ.trans (min_le_right ..)⟩
|
| 72 |
-
hpos (fun i=>?_) (fun i=>?_)).trans ?_
|
| 73 |
-
· exact (hF i _ Y' (refines_next (ht' i) (duo_good ..).1) _ _ ha').trans hM
|
| 74 |
-
· exact (hF' i _ Y' (refines_next (ht' i) (duo_good ..).2) _ _ ha').trans hV
|
| 75 |
-
have hi : 12*(z+1:ℝ)*a=η := by unfold a; field_simp
|
| 76 |
-
nlinarith only [hi,ha,(Nat.cast_nonneg z : 0≤(z:ℝ))]
|
| 77 |
-
|
| 78 |
-
private theorem minimums {A:Type} [Fintype A] (x : Wgt A) (hx:∀ i,0<x i) :
|
| 79 |
-
∃ ε : ℝ,0<ε ∧ ∀ i, ε ≤ x i := by
|
| 80 |
-
classical
|
| 81 |
-
cases isEmpty_or_nonempty A
|
| 82 |
-
next he => exact ⟨1,zero_lt_one,fun i=> (he.false i).elim⟩
|
| 83 |
-
next he =>
|
| 84 |
-
let f:= univ.image x
|
| 85 |
-
have hf : f.Nonempty := Finset.image_nonempty.mpr Finset.univ_nonempty
|
| 86 |
-
obtain ⟨i,hi,ht⟩:= mem_image.mp (Finset.min'_mem _ hf)
|
| 87 |
-
exact ⟨f.min' hf,ht ▸ hx i,fun i=>Finset.min'_le _ _ (mem_image_of_mem _ (mem_univ i))⟩
|
| 88 |
-
|
| 89 |
-
set_option maxHeartbeats 1400000 in
|
| 90 |
-
theorem twinkle (v:Stations p M b.pins s) (h:veil p M b s0 l m s w)
|
| 91 |
-
(ε:ℝ) (he:0<ε) :
|
| 92 |
-
∃ (r : ℕ) (τ u:ℝ),0<τ∧0<u∧∀ᶠ n in l,∃ Y:Silhouette p (M*n) r,
|
| 93 |
-
∀ i:Scrip p b.pins, i.2.2.permission → bullseye v m w i.2.2 i.2.1 ε n Y τ u := by
|
| 94 |
-
classical
|
| 95 |
-
choose r q A hr hq hh using
|
| 96 |
-
(fun i:Scrip p b.pins=> show ∃ (r : ℕ) (τ u:ℝ),0<τ∧0<u∧∀ᶠ n in l,
|
| 97 |
-
∃ Y:Silhouette p (M*n) r, i.2.2.permission → bullseye v m w i.2.2 i.2.1 ε n Y τ u from by
|
| 98 |
-
by_cases hP : i.2.2.permission
|
| 99 |
-
· obtain ⟨r,τ,u,hτ,hu,hh⟩:=glowLamp v h i.2.2 i.2.1 hP ε he
|
| 100 |
-
refine ⟨r,τ,u,hτ,hu, hh.mono (fun i hi=> ?_)⟩
|
| 101 |
-
obtain ⟨Y,hY⟩:=hi; exact ⟨Y,fun _=>hY⟩
|
| 102 |
-
exact ⟨1,1,1,zero_lt_one,zero_lt_one,.of_forall (fun n=> ⟨fun _ _ _=>0,fun hi=>(hP hi).elim⟩)⟩)
|
| 103 |
-
obtain ⟨δ,hd,hd'⟩:=minimums q hr
|
| 104 |
-
obtain ⟨e,he,he'⟩:=minimums A hq
|
| 105 |
-
refine ⟨bouquet r,δ,e,hd,he,?_⟩
|
| 106 |
-
filter_upwards [eventually_all.mpr hh] with n hn
|
| 107 |
-
choose F hF using hn
|
| 108 |
-
refine ⟨bundleY r F,fun i hi r' Y' hR τ' δ' hτ hp=> ?_⟩
|
| 109 |
-
exact hF i hi r' Y' (refines_next hR (bundle_refines r F i)) _ _ (hτ.trans (hd' _)) (hp.trans (he' _))
|
| 110 |
-
|
| 111 |
-
set_option maxHeartbeats 1200000 in
|
| 112 |
-
theorem lateSilk (v:Stations p M b.pins s) (h:veil p M b s0 l m s w)
|
| 113 |
-
(ε η:ℝ) (he:0<ε) (hη:0<η) (L:ℕ) :
|
| 114 |
-
∃ (r:ℕ) (δ:ℝ),0<δ ∧ (r+1:ℝ)*δ≤η ∧ ∀ᶠ n in l,
|
| 115 |
-
∀ Y:Silhouette p (M*n) L,∃ X:Silhouette p (M*n) r, refines X Y ∧
|
| 116 |
-
pr ((s n).sap (w n)) (fun i=>¬ gauze p δ δ X (m n) b.pins i)≤ η ∧
|
| 117 |
-
∀ i:Scrip p b.pins,i.2.2.permission →
|
| 118 |
-
sparks (b:=b) v i m w n X ≤ ε := by
|
| 119 |
-
classical
|
| 120 |
-
obtain ⟨r,τ,u,hτ,hu,hg⟩:= twinkle v h ε he
|
| 121 |
-
let d:=r*L
|
| 122 |
-
let a:= d+1; let δ := min τ (η/(a:ℝ))
|
| 123 |
-
have hD : 0<(a:ℝ):=by unfold a; positivity
|
| 124 |
-
have hd : 0<δ:=lt_min hτ (by positivity)
|
| 125 |
-
have hb := gauzeCalendar p d M h.easel δ δ hd hd
|
| 126 |
-
refine ⟨d,δ,hd,?_,?_⟩
|
| 127 |
-
· have hh := (le_div_iff₀ hD).mp (show δ ≤ η/(a:ℝ) from min_le_right ..)
|
| 128 |
-
rw [mul_comm]; simpa [a] using hh
|
| 129 |
-
filter_upwards [hg,hb.filter_mono h.timeL,h.upright,((bp_nat_vanish (by norm_num :
|
| 130 |
-
(0:ℝ)<1/100)).eventually (eventually_le_nhds (lt_min hu hη))).filter_mono h.timeL]
|
| 131 |
-
with n hn hb hc hz Y
|
| 132 |
-
obtain ⟨X,hX⟩:=hn
|
| 133 |
-
let Z:= duoY X Y
|
| 134 |
-
have hm := (hb _ _ hc Z).trans hz
|
| 135 |
-
exact ⟨Z,(duo_good X Y).2,hm.trans (min_le_right ..),fun i h=> hX i h d Z (duo_good X Y).1
|
| 136 |
-
δ δ (min_le_left ..) (hm.trans (min_le_left ..))⟩
|
| 137 |
-
end StatusAnalysis
|
| 138 |
-
end HadwigerCounterexample
|
| 139 |
-
|
| 140 |
-
end
|
| 141 |
-
|
| 142 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.AdaptiveProjectionBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Simultaneous Projection -/
|
| 6 |
+
|
| 7 |
+
noncomputable section
|
| 8 |
+
namespace HadwigerCounterexample
|
| 9 |
+
open Filter Finset Matrix
|
| 10 |
+
open scoped BigOperators Topology
|
| 11 |
+
namespace StatusAnalysis
|
| 12 |
+
open Station PreparationParameters
|
| 13 |
+
|
| 14 |
+
variable {p : Shape} {M s0 n N K : ℕ} {q:Format} {d e:Rates}
|
| 15 |
+
{l:Filter ℕ} {b:PreparationParameters} {m:cycleM p} {w:tale p M} {s:rhythms p M}
|
| 16 |
+
|
| 17 |
+
def sparks (v : Stations p M b.pins s) (i:Scrip p b.pins) (m:cycleM p) (w:tale p M)
|
| 18 |
+
{r} (n:ℕ) (Y: Silhouette p (M*n) r) :=
|
| 19 |
+
Station.stratum (v n) i.2.2 (m n) (w n) i.2.1 Y
|
| 20 |
+
|
| 21 |
+
def bullseye (v: Stations p M K s) (m:cycleM p) (w:tale p M) (x:Typus p q d e)
|
| 22 |
+
(k : Fin (2^deckMax p K)) (ε : ℝ) {r : ℕ} (n : ℕ) (Y : Silhouette p (M*n) r)
|
| 23 |
+
(τ u:ℝ) :=
|
| 24 |
+
∀ (r':ℕ) (Y':Silhouette p (M*n) r'),refines Y' Y →
|
| 25 |
+
∀ τ' δ:ℝ,τ'≤τ →
|
| 26 |
+
pr ((s n).sap (w n)) (fun i=>¬ gauze p τ' δ Y' (m n) K i) ≤u →
|
| 27 |
+
Station.stratum (v n) x (m n) (w n) k Y'≤ ε
|
| 28 |
+
|
| 29 |
+
set_option maxHeartbeats 2400000 in
|
| 30 |
+
theorem glowLamp (v:Stations p M b.pins s) (h:veil p M b s0 l m s w) (x:Typus p q d e)
|
| 31 |
+
(k:Fin (2^deckMax p b.pins)) (hP:x.permission) (ε:ℝ) (he:0<ε) :
|
| 32 |
+
∃ (r : ℕ) (τ u:ℝ), 0<τ∧0<u∧∀ᶠ n in l,∃ Y:Silhouette p (M*n) r,
|
| 33 |
+
bullseye v m w x k ε n Y τ u := by
|
| 34 |
+
classical
|
| 35 |
+
have hq:=h.easel; have ht:=hq.enter.first
|
| 36 |
+
obtain ⟨z,η,hη,hX⟩:=projectCut x hP k h v ε he
|
| 37 |
+
let a:= η/(12*(z+1:ℝ))
|
| 38 |
+
have ha:0<a:=by unfold a; positivity
|
| 39 |
+
obtain ⟨i,u,c,hi,hc,hA⟩:= x.qA.sideRelease x.t x.z M hq hP.2.1 a ha
|
| 40 |
+
obtain ⟨j,v',C,hj,hC,hB⟩:= x.qB.sideRelease x.t x.z M hq hP.2.2.1 a ha
|
| 41 |
+
let f:=fun _ : Fin z=>i*j; let r:=bouquet f
|
| 42 |
+
let τ:= min u v'
|
| 43 |
+
refine ⟨r,τ,a,lt_min hi hj,ha,?_⟩
|
| 44 |
+
have hz:= (trend_sizes l h.timeL ht.hM).2
|
| 45 |
+
filter_upwards [hX,h.upright,h.durableS.shape,h.durableS.mass.positive,h.moment,
|
| 46 |
+
hA.filter_mono h.timeL,hB.filter_mono h.timeL,
|
| 47 |
+
((bp_nat_vanish hc).eventually (eventually_le_nhds ha)).filter_mono h.timeL,
|
| 48 |
+
((bp_nat_vanish hC).eventually (eventually_le_nhds ha)).filter_mono h.timeL,
|
| 49 |
+
hz.eventually (eventually_ge_atTop (2*num (Messenger q×Toast p)+1))]
|
| 50 |
+
with n hn ha' hB' hW he' hA hB hM hV hG
|
| 51 |
+
let N:=M*n; let p0:=s n
|
| 52 |
+
obtain ⟨P,hP'⟩:=hn
|
| 53 |
+
let e k y:=ind (P y=k)
|
| 54 |
+
have heq k y : |e k y| ≤1 := by unfold e; rw [abs_of_nonneg (ind_nonneg _)]; exact ind_le_one _
|
| 55 |
+
choose X hF using fun i:Fin z=> hA (e i) (heq i)
|
| 56 |
+
choose Z hF' using fun i:Fin z=> hB (e i) (heq i)
|
| 57 |
+
let Y k:=duoY (X k) (Z k)
|
| 58 |
+
refine ⟨bundleY f Y,fun r Y' hR τ' δ hτ hpos=>?_⟩
|
| 59 |
+
apply hP' r Y'
|
| 60 |
+
have hw:=he'.1.law
|
| 61 |
+
let hh:=hB'.1
|
| 62 |
+
have hx' i : IsLaw (x.qA.policies x.t x.z n i) :=
|
| 63 |
+
Appearance.witLaw (x.qA.allure_apt _ _ hP.2.1 _) ht.hR ha'.age
|
| 64 |
+
have hy' i : IsLaw (x.qB.policies x.t x.z n i) :=
|
| 65 |
+
Appearance.witLaw (x.qB.allure_apt _ _ hP.2.2.1 _) ht.hR ha'.age
|
| 66 |
+
have hN:= show 2*num (Messenger q×Toast p)-(N:ℝ) ≤ -1 from by
|
| 67 |
+
change _ ≤ (N:ℝ) at hG; linarith only [hG]
|
| 68 |
+
have hp := nuLaw x.t x.z hN
|
| 69 |
+
have ht' : ∀ i:Fin z,refines Y' (Y i) := fun i=> refines_next hR (bundle_refines f Y i)
|
| 70 |
+
refine (projectSum (v n) x (m n) k (w n) Y' P hh.part hw (fun i hi=>(hh.leaf i hi).pos)
|
| 71 |
+
hW hx' hy' hp a u v' τ' a δ ha.le hP ⟨hτ.trans (min_le_left ..),hτ.trans (min_le_right ..)⟩
|
| 72 |
+
hpos (fun i=>?_) (fun i=>?_)).trans ?_
|
| 73 |
+
· exact (hF i _ Y' (refines_next (ht' i) (duo_good ..).1) _ _ ha').trans hM
|
| 74 |
+
· exact (hF' i _ Y' (refines_next (ht' i) (duo_good ..).2) _ _ ha').trans hV
|
| 75 |
+
have hi : 12*(z+1:ℝ)*a=η := by unfold a; field_simp
|
| 76 |
+
nlinarith only [hi,ha,(Nat.cast_nonneg z : 0≤(z:ℝ))]
|
| 77 |
+
|
| 78 |
+
private theorem minimums {A:Type} [Fintype A] (x : Wgt A) (hx:∀ i,0<x i) :
|
| 79 |
+
∃ ε : ℝ,0<ε ∧ ∀ i, ε ≤ x i := by
|
| 80 |
+
classical
|
| 81 |
+
cases isEmpty_or_nonempty A
|
| 82 |
+
next he => exact ⟨1,zero_lt_one,fun i=> (he.false i).elim⟩
|
| 83 |
+
next he =>
|
| 84 |
+
let f:= univ.image x
|
| 85 |
+
have hf : f.Nonempty := Finset.image_nonempty.mpr Finset.univ_nonempty
|
| 86 |
+
obtain ⟨i,hi,ht⟩:= mem_image.mp (Finset.min'_mem _ hf)
|
| 87 |
+
exact ⟨f.min' hf,ht ▸ hx i,fun i=>Finset.min'_le _ _ (mem_image_of_mem _ (mem_univ i))⟩
|
| 88 |
+
|
| 89 |
+
set_option maxHeartbeats 1400000 in
|
| 90 |
+
theorem twinkle (v:Stations p M b.pins s) (h:veil p M b s0 l m s w)
|
| 91 |
+
(ε:ℝ) (he:0<ε) :
|
| 92 |
+
∃ (r : ℕ) (τ u:ℝ),0<τ∧0<u∧∀ᶠ n in l,∃ Y:Silhouette p (M*n) r,
|
| 93 |
+
∀ i:Scrip p b.pins, i.2.2.permission → bullseye v m w i.2.2 i.2.1 ε n Y τ u := by
|
| 94 |
+
classical
|
| 95 |
+
choose r q A hr hq hh using
|
| 96 |
+
(fun i:Scrip p b.pins=> show ∃ (r : ℕ) (τ u:ℝ),0<τ∧0<u∧∀ᶠ n in l,
|
| 97 |
+
∃ Y:Silhouette p (M*n) r, i.2.2.permission → bullseye v m w i.2.2 i.2.1 ε n Y τ u from by
|
| 98 |
+
by_cases hP : i.2.2.permission
|
| 99 |
+
· obtain ⟨r,τ,u,hτ,hu,hh⟩:=glowLamp v h i.2.2 i.2.1 hP ε he
|
| 100 |
+
refine ⟨r,τ,u,hτ,hu, hh.mono (fun i hi=> ?_)⟩
|
| 101 |
+
obtain ⟨Y,hY⟩:=hi; exact ⟨Y,fun _=>hY⟩
|
| 102 |
+
exact ⟨1,1,1,zero_lt_one,zero_lt_one,.of_forall (fun n=> ⟨fun _ _ _=>0,fun hi=>(hP hi).elim⟩)⟩)
|
| 103 |
+
obtain ⟨δ,hd,hd'⟩:=minimums q hr
|
| 104 |
+
obtain ⟨e,he,he'⟩:=minimums A hq
|
| 105 |
+
refine ⟨bouquet r,δ,e,hd,he,?_⟩
|
| 106 |
+
filter_upwards [eventually_all.mpr hh] with n hn
|
| 107 |
+
choose F hF using hn
|
| 108 |
+
refine ⟨bundleY r F,fun i hi r' Y' hR τ' δ' hτ hp=> ?_⟩
|
| 109 |
+
exact hF i hi r' Y' (refines_next hR (bundle_refines r F i)) _ _ (hτ.trans (hd' _)) (hp.trans (he' _))
|
| 110 |
+
|
| 111 |
+
set_option maxHeartbeats 1200000 in
|
| 112 |
+
theorem lateSilk (v:Stations p M b.pins s) (h:veil p M b s0 l m s w)
|
| 113 |
+
(ε η:ℝ) (he:0<ε) (hη:0<η) (L:ℕ) :
|
| 114 |
+
∃ (r:ℕ) (δ:ℝ),0<δ ∧ (r+1:ℝ)*δ≤η ∧ ∀ᶠ n in l,
|
| 115 |
+
∀ Y:Silhouette p (M*n) L,∃ X:Silhouette p (M*n) r, refines X Y ∧
|
| 116 |
+
pr ((s n).sap (w n)) (fun i=>¬ gauze p δ δ X (m n) b.pins i)≤ η ∧
|
| 117 |
+
∀ i:Scrip p b.pins,i.2.2.permission →
|
| 118 |
+
sparks (b:=b) v i m w n X ≤ ε := by
|
| 119 |
+
classical
|
| 120 |
+
obtain ⟨r,τ,u,hτ,hu,hg⟩:= twinkle v h ε he
|
| 121 |
+
let d:=r*L
|
| 122 |
+
let a:= d+1; let δ := min τ (η/(a:ℝ))
|
| 123 |
+
have hD : 0<(a:ℝ):=by unfold a; positivity
|
| 124 |
+
have hd : 0<δ:=lt_min hτ (by positivity)
|
| 125 |
+
have hb := gauzeCalendar p d M h.easel δ δ hd hd
|
| 126 |
+
refine ⟨d,δ,hd,?_,?_⟩
|
| 127 |
+
· have hh := (le_div_iff₀ hD).mp (show δ ≤ η/(a:ℝ) from min_le_right ..)
|
| 128 |
+
rw [mul_comm]; simpa [a] using hh
|
| 129 |
+
filter_upwards [hg,hb.filter_mono h.timeL,h.upright,((bp_nat_vanish (by norm_num :
|
| 130 |
+
(0:ℝ)<1/100)).eventually (eventually_le_nhds (lt_min hu hη))).filter_mono h.timeL]
|
| 131 |
+
with n hn hb hc hz Y
|
| 132 |
+
obtain ⟨X,hX⟩:=hn
|
| 133 |
+
let Z:= duoY X Y
|
| 134 |
+
have hm := (hb _ _ hc Z).trans hz
|
| 135 |
+
exact ⟨Z,(duo_good X Y).2,hm.trans (min_le_right ..),fun i h=> hX i h d Z (duo_good X Y).1
|
| 136 |
+
δ δ (min_le_left ..) (hm.trans (min_le_left ..))⟩
|
| 137 |
+
end StatusAnalysis
|
| 138 |
+
end HadwigerCounterexample
|
| 139 |
+
|
| 140 |
+
end
|
| 141 |
+
|
| 142 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/SinglePositionExpansion.lean
CHANGED
|
@@ -1,82 +1,82 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.FourCornerViews
|
| 2 |
-
import OAI.Combinatorics.HadwigerCounterexample.ScriptGramCorrespondence
|
| 3 |
-
|
| 4 |
-
namespace OAI
|
| 5 |
-
|
| 6 |
-
/-! # Single Position Expansion -/
|
| 7 |
-
|
| 8 |
-
noncomputable section
|
| 9 |
-
namespace HadwigerCounterexample
|
| 10 |
-
open Finset Function Matrix
|
| 11 |
-
open scoped BigOperators
|
| 12 |
-
variable {I A B C : Type} [Fintype I] [DecidableEq I]
|
| 13 |
-
variable {p : Shape} {n N : ℕ}
|
| 14 |
-
variable {X : I → Type}
|
| 15 |
-
|
| 16 |
-
abbrev Aside (i : I) := {j:I//j≠i}
|
| 17 |
-
def chair (X : I →Type) (i:I) := Equiv.piSplitAt i X
|
| 18 |
-
|
| 19 |
-
theorem chair_split (p : ∀ i,Wgt (X i)) (x : ∀ i,X i) (a : I) :
|
| 20 |
-
prodW p x = p a (x a) *
|
| 21 |
-
prodW (fun i : Aside a=>p i.val) ((chair X a x).2) := by
|
| 22 |
-
exact Fintype.prod_eq_mul_prod_subtype_ne _ _
|
| 23 |
-
|
| 24 |
-
variable [∀ i,Fintype (X i)]
|
| 25 |
-
set_option maxHeartbeats 600000 in
|
| 26 |
-
theorem chair_weight (p : ∀ i,Wgt (X i)) (a : I) :
|
| 27 |
-
mapW (prodW p) (chair X a)= pairW (p a)
|
| 28 |
-
(prodW (fun i : Aside a=>p i.val)) := by
|
| 29 |
-
funext i
|
| 30 |
-
obtain ⟨i,rfl⟩ := (chair X a).surjective i
|
| 31 |
-
rw [mapW_equiv_val,Equiv.symm_apply_apply]; exact chair_split p i a
|
| 32 |
-
|
| 33 |
-
def arm (i j : I) (x : Corn) := if j=i then x.1 else x.2
|
| 34 |
-
omit [Fintype I] [∀ i,Fintype (X i)] in
|
| 35 |
-
theorem chair_arm (p : (∀ i,X i)×(∀ i,X i)) (i j : I) (x : Corn) :
|
| 36 |
-
criss (chair X i) p x j=(onSide p (arm i j x)) j := by
|
| 37 |
-
rcases x with ⟨a,b⟩
|
| 38 |
-
have he := criss_pair p a b (chair X i)
|
| 39 |
-
by_cases h : j=i
|
| 40 |
-
· subst j
|
| 41 |
-
rw [arm,ite_eq_left rfl]; exact congrArg Prod.fst he
|
| 42 |
-
rw [arm,ite_eq_right h]
|
| 43 |
-
exact congr_fun (congrArg Prod.snd he) (⟨j,h⟩:Aside i)
|
| 44 |
-
|
| 45 |
-
namespace Template
|
| 46 |
-
variable (v : Template p I)
|
| 47 |
-
|
| 48 |
-
def beyond (v : Template p I) (i : I) : Template p (Aside i) :=
|
| 49 |
-
collect p v Subtype.val
|
| 50 |
-
def chairK (v : Template p I) (i : I) (N : ℕ) :
|
| 51 |
-
Keys (p:=p) v.t N ≃ (AtomKey (p:=p) (v.t i) N × Keys (p:=p) (v.beyond i).t N) :=
|
| 52 |
-
chair _ _
|
| 53 |
-
def chairI (_ : Template p I) (i : I) (n : ℕ) :
|
| 54 |
-
Inputs p n I ≃ Knobs p.g n × Inputs p n (Aside i) := chair _ _
|
| 55 |
-
|
| 56 |
-
omit [Fintype I] in
|
| 57 |
-
theorem key_quoin (v : Template p I) (x : I) (o : UnitType p n N)
|
| 58 |
-
(p' : Inputs p n I× Inputs p n I) (c : Corn) :
|
| 59 |
-
criss (v.chairK x N) (Prod.map (v.resultKey o) (v.resultKey o) p') c=
|
| 60 |
-
v.resultKey o (criss (v.chairI x n) p' c) := by
|
| 61 |
-
classical
|
| 62 |
-
funext i; unfold resultKey
|
| 63 |
-
change criss (chair (fun i=>AtomKey (p:=p) (v.t i) N) x) _ _ i=keyOne p _ _ (lit _ _ (criss (chair (fun _=>Knobs p.g n) x) _ _ i)) _
|
| 64 |
-
rw [chair_arm _ x,chair_arm _ x]
|
| 65 |
-
cases arm x i c <;> rfl
|
| 66 |
-
|
| 67 |
-
omit [Fintype I] in
|
| 68 |
-
theorem key_split (v : Template p I) (x : I) (o : UnitType p n N)
|
| 69 |
-
(z : Inputs p n I) :
|
| 70 |
-
chairK v x N (v.resultKey o z) = (v.callOne x (z x) (onSide o (v.aim x)),
|
| 71 |
-
(v.beyond x).resultKey o (fun i=>z i.val)) := by
|
| 72 |
-
apply Prod.ext <;> rfl
|
| 73 |
-
|
| 74 |
-
def earns (v : Template p I) (s : Script p I) (m : Mixer p n) (q : I→F)
|
| 75 |
-
(o : UnitType p n N) (x : Inputs p n I) :=
|
| 76 |
-
(v.draw x).reads s m ∧ ownPart (p:=p) v.t q (v.resultKey o x)
|
| 77 |
-
end Template
|
| 78 |
-
end HadwigerCounterexample
|
| 79 |
-
|
| 80 |
-
end
|
| 81 |
-
|
| 82 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.FourCornerViews
|
| 2 |
+
import OAI.Combinatorics.HadwigerCounterexample.ScriptGramCorrespondence
|
| 3 |
+
|
| 4 |
+
namespace OAI
|
| 5 |
+
|
| 6 |
+
/-! # Single Position Expansion -/
|
| 7 |
+
|
| 8 |
+
noncomputable section
|
| 9 |
+
namespace HadwigerCounterexample
|
| 10 |
+
open Finset Function Matrix
|
| 11 |
+
open scoped BigOperators
|
| 12 |
+
variable {I A B C : Type} [Fintype I] [DecidableEq I]
|
| 13 |
+
variable {p : Shape} {n N : ℕ}
|
| 14 |
+
variable {X : I → Type}
|
| 15 |
+
|
| 16 |
+
abbrev Aside (i : I) := {j:I//j≠i}
|
| 17 |
+
def chair (X : I →Type) (i:I) := Equiv.piSplitAt i X
|
| 18 |
+
|
| 19 |
+
theorem chair_split (p : ∀ i,Wgt (X i)) (x : ∀ i,X i) (a : I) :
|
| 20 |
+
prodW p x = p a (x a) *
|
| 21 |
+
prodW (fun i : Aside a=>p i.val) ((chair X a x).2) := by
|
| 22 |
+
exact Fintype.prod_eq_mul_prod_subtype_ne _ _
|
| 23 |
+
|
| 24 |
+
variable [∀ i,Fintype (X i)]
|
| 25 |
+
set_option maxHeartbeats 600000 in
|
| 26 |
+
theorem chair_weight (p : ∀ i,Wgt (X i)) (a : I) :
|
| 27 |
+
mapW (prodW p) (chair X a)= pairW (p a)
|
| 28 |
+
(prodW (fun i : Aside a=>p i.val)) := by
|
| 29 |
+
funext i
|
| 30 |
+
obtain ⟨i,rfl⟩ := (chair X a).surjective i
|
| 31 |
+
rw [mapW_equiv_val,Equiv.symm_apply_apply]; exact chair_split p i a
|
| 32 |
+
|
| 33 |
+
def arm (i j : I) (x : Corn) := if j=i then x.1 else x.2
|
| 34 |
+
omit [Fintype I] [∀ i,Fintype (X i)] in
|
| 35 |
+
theorem chair_arm (p : (∀ i,X i)×(∀ i,X i)) (i j : I) (x : Corn) :
|
| 36 |
+
criss (chair X i) p x j=(onSide p (arm i j x)) j := by
|
| 37 |
+
rcases x with ⟨a,b⟩
|
| 38 |
+
have he := criss_pair p a b (chair X i)
|
| 39 |
+
by_cases h : j=i
|
| 40 |
+
· subst j
|
| 41 |
+
rw [arm,ite_eq_left rfl]; exact congrArg Prod.fst he
|
| 42 |
+
rw [arm,ite_eq_right h]
|
| 43 |
+
exact congr_fun (congrArg Prod.snd he) (⟨j,h⟩:Aside i)
|
| 44 |
+
|
| 45 |
+
namespace Template
|
| 46 |
+
variable (v : Template p I)
|
| 47 |
+
|
| 48 |
+
def beyond (v : Template p I) (i : I) : Template p (Aside i) :=
|
| 49 |
+
collect p v Subtype.val
|
| 50 |
+
def chairK (v : Template p I) (i : I) (N : ℕ) :
|
| 51 |
+
Keys (p:=p) v.t N ≃ (AtomKey (p:=p) (v.t i) N × Keys (p:=p) (v.beyond i).t N) :=
|
| 52 |
+
chair _ _
|
| 53 |
+
def chairI (_ : Template p I) (i : I) (n : ℕ) :
|
| 54 |
+
Inputs p n I ≃ Knobs p.g n × Inputs p n (Aside i) := chair _ _
|
| 55 |
+
|
| 56 |
+
omit [Fintype I] in
|
| 57 |
+
theorem key_quoin (v : Template p I) (x : I) (o : UnitType p n N)
|
| 58 |
+
(p' : Inputs p n I× Inputs p n I) (c : Corn) :
|
| 59 |
+
criss (v.chairK x N) (Prod.map (v.resultKey o) (v.resultKey o) p') c=
|
| 60 |
+
v.resultKey o (criss (v.chairI x n) p' c) := by
|
| 61 |
+
classical
|
| 62 |
+
funext i; unfold resultKey
|
| 63 |
+
change criss (chair (fun i=>AtomKey (p:=p) (v.t i) N) x) _ _ i=keyOne p _ _ (lit _ _ (criss (chair (fun _=>Knobs p.g n) x) _ _ i)) _
|
| 64 |
+
rw [chair_arm _ x,chair_arm _ x]
|
| 65 |
+
cases arm x i c <;> rfl
|
| 66 |
+
|
| 67 |
+
omit [Fintype I] in
|
| 68 |
+
theorem key_split (v : Template p I) (x : I) (o : UnitType p n N)
|
| 69 |
+
(z : Inputs p n I) :
|
| 70 |
+
chairK v x N (v.resultKey o z) = (v.callOne x (z x) (onSide o (v.aim x)),
|
| 71 |
+
(v.beyond x).resultKey o (fun i=>z i.val)) := by
|
| 72 |
+
apply Prod.ext <;> rfl
|
| 73 |
+
|
| 74 |
+
def earns (v : Template p I) (s : Script p I) (m : Mixer p n) (q : I→F)
|
| 75 |
+
(o : UnitType p n N) (x : Inputs p n I) :=
|
| 76 |
+
(v.draw x).reads s m ∧ ownPart (p:=p) v.t q (v.resultKey o x)
|
| 77 |
+
end Template
|
| 78 |
+
end HadwigerCounterexample
|
| 79 |
+
|
| 80 |
+
end
|
| 81 |
+
|
| 82 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/SingletonPhaseTests.lean
CHANGED
|
@@ -1,135 +1,135 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.OffsetFourierBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Singleton Phase Tests -/
|
| 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} {A : Type} [Fintype A]
|
| 12 |
-
|
| 13 |
-
theorem avg_on_support {w f g : Wgt A} (h : ∀ x,0≤w x)
|
| 14 |
-
(he : ∀ x,w x≠0 → f x≤g x) : avg w f ≤ avg w g :=
|
| 15 |
-
Finset.sum_le_sum (fun x _ => by
|
| 16 |
-
by_cases hh : w x=0
|
| 17 |
-
· rw [hh,zero_mul,zero_mul]
|
| 18 |
-
exact mul_le_mul_of_nonneg_left (he x hh) (h x))
|
| 19 |
-
|
| 20 |
-
namespace Bazaar
|
| 21 |
-
variable (s : Bazaar p n r T)
|
| 22 |
-
|
| 23 |
-
set_option maxHeartbeats 600000 in
|
| 24 |
-
theorem single_pitch {w : Wgt (UnitType p n N)} {Δ}
|
| 25 |
-
(hl : s.opened Δ w) (hv : IsLaw w) (i : Bool) (R : Party)
|
| 26 |
-
(m : Mixer p n) {ε H : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 27 |
-
(hH : 0 ≤ H) (hw : bySide p w m H)
|
| 28 |
-
(hp : selPrice p r n N H ε) (ht : num (Atlas p r T) ≤ bp (0.002*N))
|
| 29 |
-
(hN : 2*num (Full p n)-N≤ -1) :
|
| 30 |
-
|pitch p Δ w (unary i) R|≤ glimpsesBill p r H+bp (-0.24*N) ∧
|
| 31 |
-
((∀ x,w x≠0 → ∀ y,w y≠0 → glimpse p y i (src (s.ix x))) →
|
| 32 |
-
|pitch p Δ w (unary i) R|≤bp (-0.24*N)) := by
|
| 33 |
-
classical
|
| 34 |
-
let C : Sales p n r T := fun M _ y => glimpse p y i (src M)
|
| 35 |
-
have hb M G (hh : standard M) (hh' : standard G) :=
|
| 36 |
-
glimpse_prize m hH hm he hv.sub hw hl hp M G i hh hh' (C M G) (fun _ _ h => h)
|
| 37 |
-
have hf := beat_mix s hl hv (unary i) R i C (fun M => bag_rate m hH hm he hv.sub hw hl hp M i)
|
| 38 |
-
hb ht
|
| 39 |
-
have he : discard (s:=s) w C = avg w (fun x =>
|
| 40 |
-
pr w (fun y => ¬ glimpse p y i (src (s.ix x)))) := pairW_avg ..
|
| 41 |
-
rw [he] at hf
|
| 42 |
-
constructor
|
| 43 |
-
· refine hf.trans (add_le_add_left ?_ _)
|
| 44 |
-
rw [← hv.avg_const (glimpsesBill p r H)]
|
| 45 |
-
apply avg_on_support hv.nz
|
| 46 |
-
intro x hx
|
| 47 |
-
have hX := (hl x hx).1
|
| 48 |
-
exact glimpse_failure m hH hw hv.sub i hN _ r hX.2.2 (fun z =>
|
| 49 |
-
Nat.lt_add_one_iff.mp ((s.ix x).1 z).isLt)
|
| 50 |
-
intro hh
|
| 51 |
-
have hW : avg w (fun x => pr w (fun y => ¬glimpse p y i (src (s.ix x))))=0 := by
|
| 52 |
-
rw [← hv.avg_const 0]
|
| 53 |
-
refine avg_congr (fun x hx => ?_)
|
| 54 |
-
rw [← hv.avg_const 0]
|
| 55 |
-
exact avg_congr fun y hy => ind_zero (by simp [hh x hx y hy])
|
| 56 |
-
rwa [hW,zero_add] at hf
|
| 57 |
-
|
| 58 |
-
def frequent (w : Wgt (UnitType p n N)) (S : Party) (j : Bool)
|
| 59 |
-
(M G : Atlas p r T) (y : UnitType p n N) :=
|
| 60 |
-
prize p N (cells G) < mapW (s.chart w G) (s.pay M G j S) (s.pay M G j S y)
|
| 61 |
-
|
| 62 |
-
theorem calm_pitch {w : Wgt (UnitType p n N)} {Δ}
|
| 63 |
-
(hl : s.opened Δ w) (hv : IsLaw w) (i : Bool) (R S : Party)
|
| 64 |
-
(m : Mixer p n) {ε H : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 65 |
-
(hH : 0 ≤ H) (hw : bySide p w m H)
|
| 66 |
-
(hp : selPrice p r n N H ε) (ht : num (Atlas p r T) ≤ bp (0.002*N)) :
|
| 67 |
-
|pitch p Δ w S R| ≤ pr (pairW w w)
|
| 68 |
-
(fun x => s.frequent w S i (s.ix x.1) (s.ix x.2) x.2) + bp (-0.24*N) := by
|
| 69 |
-
classical
|
| 70 |
-
let C : Sales p n r T := fun M G y => ¬ s.frequent w S i M G y
|
| 71 |
-
have hb (M G : Atlas p r T) (hh : standard M) (hh' : standard G) :
|
| 72 |
-
∀ y,mapW (subW (s.chart w G) (C M G)) (s.pay M G i S) y ≤ prize p N (cells G) := by
|
| 73 |
-
let v := s.chart w G
|
| 74 |
-
let J := s.pay M G i S
|
| 75 |
-
have hw' : SubLaw v := subLaw_sub hv.sub _
|
| 76 |
-
intro y
|
| 77 |
-
by_cases he : mapW v J y≤prize p N (cells G)
|
| 78 |
-
· exact (pr_mono_left (subW_le hw'.nz _) _).trans he
|
| 79 |
-
change pr (subW v (C M G)) (fun x => J x=y) ≤ _
|
| 80 |
-
rw [pr_sub]
|
| 81 |
-
have hx : (fun x => C M G x ∧ J x=y)=(fun _ => False) := by
|
| 82 |
-
funext x
|
| 83 |
-
refine propext (iff_false_intro (fun ⟨h,h'⟩ => he ?_))
|
| 84 |
-
rw [← h']
|
| 85 |
-
exact le_of_not_gt h
|
| 86 |
-
rw [hx,pr_false]; exact (bp_pos _).le
|
| 87 |
-
have hf := beat_mix s hl hv S R i C (fun M => bag_rate m hH hm he hv.sub hw hl hp M i) hb ht
|
| 88 |
-
unfold discard C at hf; simpa only [not_not] using hf
|
| 89 |
-
|
| 90 |
-
/-- fixed companion Z restrict frequent pair to this list of small Φ values -/
|
| 91 |
-
def bids (w : Wgt (UnitType p n N)) (S : Party) (i : Bool)
|
| 92 |
-
(M G : Atlas p r T) (Z : Batch G N) : Finset (Batch M N) :=
|
| 93 |
-
open scoped Classical in
|
| 94 |
-
Finset.univ.filter (fun x => prize p N (cells G)<mapW (s.chart w G) (s.pay M G i S) (x,Z))
|
| 95 |
-
|
| 96 |
-
theorem bids_mem (w : Wgt (UnitType p n N)) (S : Party) (i : Bool)
|
| 97 |
-
(M G : Atlas p r T) (x : UnitType p n N) :
|
| 98 |
-
s.frequent w S i M G x ↔
|
| 99 |
-
thermal p x S (src M) ∈ s.bids w S i M G (s.bag G i x) := by
|
| 100 |
-
classical
|
| 101 |
-
simp only [bids,Finset.mem_filter,Finset.mem_univ,true_and]
|
| 102 |
-
rfl
|
| 103 |
-
|
| 104 |
-
theorem bids_bound {w : Wgt (UnitType p n N)} (S : Party) (i : Bool)
|
| 105 |
-
(M G : Atlas p r T) (Z : Batch G N) (hw : SubLaw w)
|
| 106 |
-
(h : ∀ x,mapW (s.chart w G) (s.bag G i) x ≤ loseA p N (cells G) 0) :
|
| 107 |
-
(↑(s.bids w S i M G Z).card:ℝ) ≤ bp (0.51*N) := by
|
| 108 |
-
classical
|
| 109 |
-
let f := s.pay M G i S
|
| 110 |
-
let v := s.chart w G
|
| 111 |
-
have hv : SubLaw v := subLaw_sub hw _
|
| 112 |
-
let B := s.bids w S i M G Z
|
| 113 |
-
let P := prize p N (cells G)
|
| 114 |
-
have he (x) (hx : x∈B) : P
|
| 115 |
-
have hg : ↑B.card * P ≤ loseA p N (cells G) 0 := by
|
| 116 |
-
have hZ : ∑ x : Batch M N,mapW v f (x,Z)=mapW v (s.bag G i) Z := by
|
| 117 |
-
let T := fun x => (f x).1
|
| 118 |
-
have hh (x : Batch M N) : (fun y => f y=(x,Z))=
|
| 119 |
-
fun y => s.bag G i y=Z ∧ T y=x := by ext y; simp [Prod.mk.injEq,f,T,pay,and_comm]
|
| 120 |
-
simp only [mapW,hh,sum_pr_tag]
|
| 121 |
-
calc ↑B.card * P = ∑ x ∈ B,P := (by simp)
|
| 122 |
-
_ ≤ ∑ x∈B,mapW v f (x,Z) := Finset.sum_le_sum he
|
| 123 |
-
_ ≤ ∑ x : Batch M N,mapW v f (x,Z) := Finset.sum_le_sum_of_subset_of_nonneg
|
| 124 |
-
(Finset.subset_univ B) (fun i _ _ => pr_nonneg hv.nz)
|
| 125 |
-
_ ≤ loseA p N (cells G) 0 := hZ.trans_le (h Z)
|
| 126 |
-
refine (le_of_mul_le_mul_right (hg.trans_eq ?_) (bp_pos _ : 0<P))
|
| 127 |
-
unfold P prize loseA
|
| 128 |
-
rw [← bp_add]; congr 1; push_cast; ring
|
| 129 |
-
|
| 130 |
-
end Bazaar
|
| 131 |
-
end HadwigerCounterexample
|
| 132 |
-
|
| 133 |
-
end
|
| 134 |
-
|
| 135 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.OffsetFourierBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Singleton Phase Tests -/
|
| 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} {A : Type} [Fintype A]
|
| 12 |
+
|
| 13 |
+
theorem avg_on_support {w f g : Wgt A} (h : ∀ x,0≤w x)
|
| 14 |
+
(he : ∀ x,w x≠0 → f x≤g x) : avg w f ≤ avg w g :=
|
| 15 |
+
Finset.sum_le_sum (fun x _ => by
|
| 16 |
+
by_cases hh : w x=0
|
| 17 |
+
· rw [hh,zero_mul,zero_mul]
|
| 18 |
+
exact mul_le_mul_of_nonneg_left (he x hh) (h x))
|
| 19 |
+
|
| 20 |
+
namespace Bazaar
|
| 21 |
+
variable (s : Bazaar p n r T)
|
| 22 |
+
|
| 23 |
+
set_option maxHeartbeats 600000 in
|
| 24 |
+
theorem single_pitch {w : Wgt (UnitType p n N)} {Δ}
|
| 25 |
+
(hl : s.opened Δ w) (hv : IsLaw w) (i : Bool) (R : Party)
|
| 26 |
+
(m : Mixer p n) {ε H : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 27 |
+
(hH : 0 ≤ H) (hw : bySide p w m H)
|
| 28 |
+
(hp : selPrice p r n N H ε) (ht : num (Atlas p r T) ≤ bp (0.002*N))
|
| 29 |
+
(hN : 2*num (Full p n)-N≤ -1) :
|
| 30 |
+
|pitch p Δ w (unary i) R|≤ glimpsesBill p r H+bp (-0.24*N) ∧
|
| 31 |
+
((∀ x,w x≠0 → ∀ y,w y≠0 → glimpse p y i (src (s.ix x))) →
|
| 32 |
+
|pitch p Δ w (unary i) R|≤bp (-0.24*N)) := by
|
| 33 |
+
classical
|
| 34 |
+
let C : Sales p n r T := fun M _ y => glimpse p y i (src M)
|
| 35 |
+
have hb M G (hh : standard M) (hh' : standard G) :=
|
| 36 |
+
glimpse_prize m hH hm he hv.sub hw hl hp M G i hh hh' (C M G) (fun _ _ h => h)
|
| 37 |
+
have hf := beat_mix s hl hv (unary i) R i C (fun M => bag_rate m hH hm he hv.sub hw hl hp M i)
|
| 38 |
+
hb ht
|
| 39 |
+
have he : discard (s:=s) w C = avg w (fun x =>
|
| 40 |
+
pr w (fun y => ¬ glimpse p y i (src (s.ix x)))) := pairW_avg ..
|
| 41 |
+
rw [he] at hf
|
| 42 |
+
constructor
|
| 43 |
+
· refine hf.trans (add_le_add_left ?_ _)
|
| 44 |
+
rw [← hv.avg_const (glimpsesBill p r H)]
|
| 45 |
+
apply avg_on_support hv.nz
|
| 46 |
+
intro x hx
|
| 47 |
+
have hX := (hl x hx).1
|
| 48 |
+
exact glimpse_failure m hH hw hv.sub i hN _ r hX.2.2 (fun z =>
|
| 49 |
+
Nat.lt_add_one_iff.mp ((s.ix x).1 z).isLt)
|
| 50 |
+
intro hh
|
| 51 |
+
have hW : avg w (fun x => pr w (fun y => ¬glimpse p y i (src (s.ix x))))=0 := by
|
| 52 |
+
rw [← hv.avg_const 0]
|
| 53 |
+
refine avg_congr (fun x hx => ?_)
|
| 54 |
+
rw [← hv.avg_const 0]
|
| 55 |
+
exact avg_congr fun y hy => ind_zero (by simp [hh x hx y hy])
|
| 56 |
+
rwa [hW,zero_add] at hf
|
| 57 |
+
|
| 58 |
+
def frequent (w : Wgt (UnitType p n N)) (S : Party) (j : Bool)
|
| 59 |
+
(M G : Atlas p r T) (y : UnitType p n N) :=
|
| 60 |
+
prize p N (cells G) < mapW (s.chart w G) (s.pay M G j S) (s.pay M G j S y)
|
| 61 |
+
|
| 62 |
+
theorem calm_pitch {w : Wgt (UnitType p n N)} {Δ}
|
| 63 |
+
(hl : s.opened Δ w) (hv : IsLaw w) (i : Bool) (R S : Party)
|
| 64 |
+
(m : Mixer p n) {ε H : ℝ} (hm : IsLaw (raw m N)) (he : initCap p N m ε)
|
| 65 |
+
(hH : 0 ≤ H) (hw : bySide p w m H)
|
| 66 |
+
(hp : selPrice p r n N H ε) (ht : num (Atlas p r T) ≤ bp (0.002*N)) :
|
| 67 |
+
|pitch p Δ w S R| ≤ pr (pairW w w)
|
| 68 |
+
(fun x => s.frequent w S i (s.ix x.1) (s.ix x.2) x.2) + bp (-0.24*N) := by
|
| 69 |
+
classical
|
| 70 |
+
let C : Sales p n r T := fun M G y => ¬ s.frequent w S i M G y
|
| 71 |
+
have hb (M G : Atlas p r T) (hh : standard M) (hh' : standard G) :
|
| 72 |
+
∀ y,mapW (subW (s.chart w G) (C M G)) (s.pay M G i S) y ≤ prize p N (cells G) := by
|
| 73 |
+
let v := s.chart w G
|
| 74 |
+
let J := s.pay M G i S
|
| 75 |
+
have hw' : SubLaw v := subLaw_sub hv.sub _
|
| 76 |
+
intro y
|
| 77 |
+
by_cases he : mapW v J y≤prize p N (cells G)
|
| 78 |
+
· exact (pr_mono_left (subW_le hw'.nz _) _).trans he
|
| 79 |
+
change pr (subW v (C M G)) (fun x => J x=y) ≤ _
|
| 80 |
+
rw [pr_sub]
|
| 81 |
+
have hx : (fun x => C M G x ∧ J x=y)=(fun _ => False) := by
|
| 82 |
+
funext x
|
| 83 |
+
refine propext (iff_false_intro (fun ⟨h,h'⟩ => he ?_))
|
| 84 |
+
rw [← h']
|
| 85 |
+
exact le_of_not_gt h
|
| 86 |
+
rw [hx,pr_false]; exact (bp_pos _).le
|
| 87 |
+
have hf := beat_mix s hl hv S R i C (fun M => bag_rate m hH hm he hv.sub hw hl hp M i) hb ht
|
| 88 |
+
unfold discard C at hf; simpa only [not_not] using hf
|
| 89 |
+
|
| 90 |
+
/-- fixed companion Z restrict frequent pair to this list of small Φ values -/
|
| 91 |
+
def bids (w : Wgt (UnitType p n N)) (S : Party) (i : Bool)
|
| 92 |
+
(M G : Atlas p r T) (Z : Batch G N) : Finset (Batch M N) :=
|
| 93 |
+
open scoped Classical in
|
| 94 |
+
Finset.univ.filter (fun x => prize p N (cells G)<mapW (s.chart w G) (s.pay M G i S) (x,Z))
|
| 95 |
+
|
| 96 |
+
theorem bids_mem (w : Wgt (UnitType p n N)) (S : Party) (i : Bool)
|
| 97 |
+
(M G : Atlas p r T) (x : UnitType p n N) :
|
| 98 |
+
s.frequent w S i M G x ↔
|
| 99 |
+
thermal p x S (src M) ∈ s.bids w S i M G (s.bag G i x) := by
|
| 100 |
+
classical
|
| 101 |
+
simp only [bids,Finset.mem_filter,Finset.mem_univ,true_and]
|
| 102 |
+
rfl
|
| 103 |
+
|
| 104 |
+
theorem bids_bound {w : Wgt (UnitType p n N)} (S : Party) (i : Bool)
|
| 105 |
+
(M G : Atlas p r T) (Z : Batch G N) (hw : SubLaw w)
|
| 106 |
+
(h : ∀ x,mapW (s.chart w G) (s.bag G i) x ≤ loseA p N (cells G) 0) :
|
| 107 |
+
(↑(s.bids w S i M G Z).card:ℝ) ≤ bp (0.51*N) := by
|
| 108 |
+
classical
|
| 109 |
+
let f := s.pay M G i S
|
| 110 |
+
let v := s.chart w G
|
| 111 |
+
have hv : SubLaw v := subLaw_sub hw _
|
| 112 |
+
let B := s.bids w S i M G Z
|
| 113 |
+
let P := prize p N (cells G)
|
| 114 |
+
have he (x) (hx : x∈B) : P≤mapW v f (x,Z) := (Finset.mem_filter.mp hx).2.le
|
| 115 |
+
have hg : ↑B.card * P ≤ loseA p N (cells G) 0 := by
|
| 116 |
+
have hZ : ∑ x : Batch M N,mapW v f (x,Z)=mapW v (s.bag G i) Z := by
|
| 117 |
+
let T := fun x => (f x).1
|
| 118 |
+
have hh (x : Batch M N) : (fun y => f y=(x,Z))=
|
| 119 |
+
fun y => s.bag G i y=Z ∧ T y=x := by ext y; simp [Prod.mk.injEq,f,T,pay,and_comm]
|
| 120 |
+
simp only [mapW,hh,sum_pr_tag]
|
| 121 |
+
calc ↑B.card * P = ∑ x ∈ B,P := (by simp)
|
| 122 |
+
_ ≤ ∑ x∈B,mapW v f (x,Z) := Finset.sum_le_sum he
|
| 123 |
+
_ ≤ ∑ x : Batch M N,mapW v f (x,Z) := Finset.sum_le_sum_of_subset_of_nonneg
|
| 124 |
+
(Finset.subset_univ B) (fun i _ _ => pr_nonneg hv.nz)
|
| 125 |
+
_ ≤ loseA p N (cells G) 0 := hZ.trans_le (h Z)
|
| 126 |
+
refine (le_of_mul_le_mul_right (hg.trans_eq ?_) (bp_pos _ : 0<P))
|
| 127 |
+
unfold P prize loseA
|
| 128 |
+
rw [← bp_add]; congr 1; push_cast; ring
|
| 129 |
+
|
| 130 |
+
end Bazaar
|
| 131 |
+
end HadwigerCounterexample
|
| 132 |
+
|
| 133 |
+
end
|
| 134 |
+
|
| 135 |
+
end OAI
|
lean/OAI/Combinatorics/HadwigerCounterexample/SmallCoverBounds.lean
CHANGED
|
@@ -1,116 +1,116 @@
|
|
| 1 |
-
import OAI.Combinatorics.HadwigerCounterexample.RelativeInjectionBounds
|
| 2 |
-
|
| 3 |
-
namespace OAI
|
| 4 |
-
|
| 5 |
-
/-! # Small Cover 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 : ℕ} {A B V : Type} [Fintype A] [Fintype B]
|
| 12 |
-
|
| 13 |
-
def allSide : Party := fun _ => 1
|
| 14 |
-
|
| 15 |
-
def cutDown (p : Shape) {n N}
|
| 16 |
-
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N))
|
| 17 |
-
(x : UnitType p n N) : coverX p T :=
|
| 18 |
-
open scoped Classical in
|
| 19 |
-
if h : w x≠0 ∧ covered p T (Δ x) then ⟨_,h.2⟩ else 0
|
| 20 |
-
|
| 21 |
-
def juris (p : Shape) {n N} (T : Cov p N) (x : UnitType p n N) (S : Party) :
|
| 22 |
-
Module.Dual F (coverX p T) :=
|
| 23 |
-
joinPhase p (listens p x) S ∘ₗ (coverX p T).subtype
|
| 24 |
-
|
| 25 |
-
abbrev Daypair (p : Shape) {N} (T : Cov p N) :=
|
| 26 |
-
coverX p T × (Bool → Module.Dual F (coverX p T))
|
| 27 |
-
|
| 28 |
-
def daypair (p : Shape) {n N}
|
| 29 |
-
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N))
|
| 30 |
-
(x : UnitType p n N) : Daypair p T :=
|
| 31 |
-
(cutDown p T Δ w x,fun i => juris p T x (unary i))
|
| 32 |
-
|
| 33 |
-
def shadow (p : Shape) {n N}
|
| 34 |
-
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N))
|
| 35 |
-
(x y : UnitType p n N) (S : Party) :=
|
| 36 |
-
juris p T y S (cutDown p T Δ w x)
|
| 37 |
-
|
| 38 |
-
theorem shadow_valid (p : Shape) {n N} (T : Cov p N)
|
| 39 |
-
(Δ : UnitType p n N→Ambient p N) {w}
|
| 40 |
-
(h : ∀ x,w x≠0 → covered p T (Δ x)) (x y : UnitType p n N) (S) (hx : w x≠0) :
|
| 41 |
-
shadow p T Δ w x y S=tone p y S (Δ x) := by
|
| 42 |
-
classical
|
| 43 |
-
unfold shadow cutDown
|
| 44 |
-
rw [dite_eq_left ⟨hx,h x hx⟩]; rfl
|
| 45 |
-
|
| 46 |
-
theorem tone_vec (p : Shape) {n N} (x : UnitType p n N) (S : Party) (Δ : Ambient p N) :
|
| 47 |
-
tone p x S Δ=dotProduct S (fun i => tone p x (unary i) Δ) := by
|
| 48 |
-
classical
|
| 49 |
-
have hg (i) : tone p x (unary i) Δ=uPhase p (onSide (listens p x) i) Δ := by
|
| 50 |
-
unfold tone joinPhase unary
|
| 51 |
-
rw [Finset.sum_eq_single i]
|
| 52 |
-
· rw [Pi.single_eq_same,one_smul]
|
| 53 |
-
· intro j _ hj; simp [hj]
|
| 54 |
-
simp
|
| 55 |
-
unfold dotProduct
|
| 56 |
-
simp_rw [hg]
|
| 57 |
-
unfold tone joinPhase
|
| 58 |
-
simp
|
| 59 |
-
|
| 60 |
-
theorem shadow_day (p : Shape) {n N} (T : Cov p N)
|
| 61 |
-
(Δ : UnitType p n N→Ambient p N) (w : Wgt (UnitType p n N))
|
| 62 |
-
(x y) (S : Party) :
|
| 63 |
-
shadow p T Δ w x y S =
|
| 64 |
-
dotProduct S (fun i => (daypair p T Δ w y).2 i (daypair p T Δ w x).1) :=
|
| 65 |
-
tone_vec p y _ (cutDown p T Δ w x).val
|
| 66 |
-
|
| 67 |
-
theorem day_named (p : Shape) {n N} (T : Cov p N)
|
| 68 |
-
(Δ : UnitType p n N→Ambient p N)
|
| 69 |
-
(w : Wgt (UnitType p n N)) (d : ℕ) (hT : cdim p T≤d)
|
| 70 |
-
(P : Daypair p T × Daypair p T → Prop) :
|
| 71 |
-
named (fun v => P (daypair p T Δ w v.1,daypair p T Δ w v.2)) (bp (3*d*(N:ℝ))) := by
|
| 72 |
-
classical
|
| 73 |
-
let A := (coverX p T)
|
| 74 |
-
let : Finite (Module.Dual F (coverX p T)) := Finite.of_injective _ DFunLike.coe_injective
|
| 75 |
-
let : Fintype (Module.Dual F (coverX p T)) := Fintype.ofFinite _
|
| 76 |
-
have he : dim (Daypair p T) ≤ 3*d*N := by
|
| 77 |
-
unfold Daypair dim
|
| 78 |
-
rw [Module.finrank_prod, Module.finrank_pi_fintype,Fintype.sum_bool,
|
| 79 |
-
Subspace.dual_finrank_eq]
|
| 80 |
-
change dim A+(dim A+dim A)≤_
|
| 81 |
-
have h : dim A≤N*d := (cover_dim p T).trans (Nat.mul_le_mul_left N hT)
|
| 82 |
-
nlinarith
|
| 83 |
-
refine named_at (fun y x => P (daypair p T Δ w x,y)) ?_ (fun y => ⟨daypair p T Δ w y,fun x => Iff.rfl⟩)
|
| 84 |
-
rw [card_space]
|
| 85 |
-
exact bp_le (by exact_mod_cast he)
|
| 86 |
-
|
| 87 |
-
variable [AddCommGroup V] [Module F V] [FiniteDimensional F V]
|
| 88 |
-
|
| 89 |
-
theorem dual_matrix_rank (f : A→ V) (g : B→Module.Dual F V) :
|
| 90 |
-
(Matrix.of (fun x : A => fun y : B => g y (f x))).rank ≤ dim V := by
|
| 91 |
-
classical
|
| 92 |
-
let M := Matrix.of (fun x : A => fun y : B => g y (f x))
|
| 93 |
-
let L : V →ₗ[F] Vec B := LinearMap.pi g
|
| 94 |
-
have hi : colSp Mᵀ ≤ LinearMap.range L := by
|
| 95 |
-
rw [colSp, range_mulVecLin]
|
| 96 |
-
exact Submodule.span_le.mpr (Set.range_subset_iff.mpr fun x => ⟨f x,rfl⟩)
|
| 97 |
-
have he : dim (colSp Mᵀ) ≤ dim V := (Submodule.finrank_mono hi).trans
|
| 98 |
-
(LinearMap.finrank_range_le L)
|
| 99 |
-
rw [colSp_dim,Matrix.rank_transpose] at he
|
| 100 |
-
exact he
|
| 101 |
-
|
| 102 |
-
def circus (p : Shape) {n N}
|
| 103 |
-
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N)) :
|
| 104 |
-
Mat (UnitType p n N) (UnitType p n N) :=
|
| 105 |
-
Matrix.of (fun x y => shadow p T Δ w x y allSide)
|
| 106 |
-
|
| 107 |
-
theorem circus_rank (p : Shape) {n N}
|
| 108 |
-
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N)) :
|
| 109 |
-
(circus p T Δ w).rank≤ N*cdim p T := (dual_matrix_rank (cutDown p T Δ w)
|
| 110 |
-
(fun y => juris p T y allSide)).trans (cover_dim p T)
|
| 111 |
-
|
| 112 |
-
end HadwigerCounterexample
|
| 113 |
-
|
| 114 |
-
end
|
| 115 |
-
|
| 116 |
-
end OAI
|
|
|
|
| 1 |
+
import OAI.Combinatorics.HadwigerCounterexample.RelativeInjectionBounds
|
| 2 |
+
|
| 3 |
+
namespace OAI
|
| 4 |
+
|
| 5 |
+
/-! # Small Cover 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 : ℕ} {A B V : Type} [Fintype A] [Fintype B]
|
| 12 |
+
|
| 13 |
+
def allSide : Party := fun _ => 1
|
| 14 |
+
|
| 15 |
+
def cutDown (p : Shape) {n N}
|
| 16 |
+
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N))
|
| 17 |
+
(x : UnitType p n N) : coverX p T :=
|
| 18 |
+
open scoped Classical in
|
| 19 |
+
if h : w x≠0 ∧ covered p T (Δ x) then ⟨_,h.2⟩ else 0
|
| 20 |
+
|
| 21 |
+
def juris (p : Shape) {n N} (T : Cov p N) (x : UnitType p n N) (S : Party) :
|
| 22 |
+
Module.Dual F (coverX p T) :=
|
| 23 |
+
joinPhase p (listens p x) S ∘ₗ (coverX p T).subtype
|
| 24 |
+
|
| 25 |
+
abbrev Daypair (p : Shape) {N} (T : Cov p N) :=
|
| 26 |
+
coverX p T × (Bool → Module.Dual F (coverX p T))
|
| 27 |
+
|
| 28 |
+
def daypair (p : Shape) {n N}
|
| 29 |
+
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N))
|
| 30 |
+
(x : UnitType p n N) : Daypair p T :=
|
| 31 |
+
(cutDown p T Δ w x,fun i => juris p T x (unary i))
|
| 32 |
+
|
| 33 |
+
def shadow (p : Shape) {n N}
|
| 34 |
+
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N))
|
| 35 |
+
(x y : UnitType p n N) (S : Party) :=
|
| 36 |
+
juris p T y S (cutDown p T Δ w x)
|
| 37 |
+
|
| 38 |
+
theorem shadow_valid (p : Shape) {n N} (T : Cov p N)
|
| 39 |
+
(Δ : UnitType p n N→Ambient p N) {w}
|
| 40 |
+
(h : ∀ x,w x≠0 → covered p T (Δ x)) (x y : UnitType p n N) (S) (hx : w x≠0) :
|
| 41 |
+
shadow p T Δ w x y S=tone p y S (Δ x) := by
|
| 42 |
+
classical
|
| 43 |
+
unfold shadow cutDown
|
| 44 |
+
rw [dite_eq_left ⟨hx,h x hx⟩]; rfl
|
| 45 |
+
|
| 46 |
+
theorem tone_vec (p : Shape) {n N} (x : UnitType p n N) (S : Party) (Δ : Ambient p N) :
|
| 47 |
+
tone p x S Δ=dotProduct S (fun i => tone p x (unary i) Δ) := by
|
| 48 |
+
classical
|
| 49 |
+
have hg (i) : tone p x (unary i) Δ=uPhase p (onSide (listens p x) i) Δ := by
|
| 50 |
+
unfold tone joinPhase unary
|
| 51 |
+
rw [Finset.sum_eq_single i]
|
| 52 |
+
· rw [Pi.single_eq_same,one_smul]
|
| 53 |
+
· intro j _ hj; simp [hj]
|
| 54 |
+
simp
|
| 55 |
+
unfold dotProduct
|
| 56 |
+
simp_rw [hg]
|
| 57 |
+
unfold tone joinPhase
|
| 58 |
+
simp
|
| 59 |
+
|
| 60 |
+
theorem shadow_day (p : Shape) {n N} (T : Cov p N)
|
| 61 |
+
(Δ : UnitType p n N→Ambient p N) (w : Wgt (UnitType p n N))
|
| 62 |
+
(x y) (S : Party) :
|
| 63 |
+
shadow p T Δ w x y S =
|
| 64 |
+
dotProduct S (fun i => (daypair p T Δ w y).2 i (daypair p T Δ w x).1) :=
|
| 65 |
+
tone_vec p y _ (cutDown p T Δ w x).val
|
| 66 |
+
|
| 67 |
+
theorem day_named (p : Shape) {n N} (T : Cov p N)
|
| 68 |
+
(Δ : UnitType p n N→Ambient p N)
|
| 69 |
+
(w : Wgt (UnitType p n N)) (d : ℕ) (hT : cdim p T≤d)
|
| 70 |
+
(P : Daypair p T × Daypair p T → Prop) :
|
| 71 |
+
named (fun v => P (daypair p T Δ w v.1,daypair p T Δ w v.2)) (bp (3*d*(N:ℝ))) := by
|
| 72 |
+
classical
|
| 73 |
+
let A := (coverX p T)
|
| 74 |
+
let : Finite (Module.Dual F (coverX p T)) := Finite.of_injective _ DFunLike.coe_injective
|
| 75 |
+
let : Fintype (Module.Dual F (coverX p T)) := Fintype.ofFinite _
|
| 76 |
+
have he : dim (Daypair p T) ≤ 3*d*N := by
|
| 77 |
+
unfold Daypair dim
|
| 78 |
+
rw [Module.finrank_prod, Module.finrank_pi_fintype,Fintype.sum_bool,
|
| 79 |
+
Subspace.dual_finrank_eq]
|
| 80 |
+
change dim A+(dim A+dim A)≤_
|
| 81 |
+
have h : dim A≤N*d := (cover_dim p T).trans (Nat.mul_le_mul_left N hT)
|
| 82 |
+
nlinarith
|
| 83 |
+
refine named_at (fun y x => P (daypair p T Δ w x,y)) ?_ (fun y => ⟨daypair p T Δ w y,fun x => Iff.rfl⟩)
|
| 84 |
+
rw [card_space]
|
| 85 |
+
exact bp_le (by exact_mod_cast he)
|
| 86 |
+
|
| 87 |
+
variable [AddCommGroup V] [Module F V] [FiniteDimensional F V]
|
| 88 |
+
|
| 89 |
+
theorem dual_matrix_rank (f : A→ V) (g : B→Module.Dual F V) :
|
| 90 |
+
(Matrix.of (fun x : A => fun y : B => g y (f x))).rank ≤ dim V := by
|
| 91 |
+
classical
|
| 92 |
+
let M := Matrix.of (fun x : A => fun y : B => g y (f x))
|
| 93 |
+
let L : V →ₗ[F] Vec B := LinearMap.pi g
|
| 94 |
+
have hi : colSp Mᵀ ≤ LinearMap.range L := by
|
| 95 |
+
rw [colSp, range_mulVecLin]
|
| 96 |
+
exact Submodule.span_le.mpr (Set.range_subset_iff.mpr fun x => ⟨f x,rfl⟩)
|
| 97 |
+
have he : dim (colSp Mᵀ) ≤ dim V := (Submodule.finrank_mono hi).trans
|
| 98 |
+
(LinearMap.finrank_range_le L)
|
| 99 |
+
rw [colSp_dim,Matrix.rank_transpose] at he
|
| 100 |
+
exact he
|
| 101 |
+
|
| 102 |
+
def circus (p : Shape) {n N}
|
| 103 |
+
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N)) :
|
| 104 |
+
Mat (UnitType p n N) (UnitType p n N) :=
|
| 105 |
+
Matrix.of (fun x y => shadow p T Δ w x y allSide)
|
| 106 |
+
|
| 107 |
+
theorem circus_rank (p : Shape) {n N}
|
| 108 |
+
(T : Cov p N) (Δ : UnitType p n N→ Ambient p N) (w : Wgt (UnitType p n N)) :
|
| 109 |
+
(circus p T Δ w).rank≤ N*cdim p T := (dual_matrix_rank (cutDown p T Δ w)
|
| 110 |
+
(fun y => juris p T y allSide)).trans (cover_dim p T)
|
| 111 |
+
|
| 112 |
+
end HadwigerCounterexample
|
| 113 |
+
|
| 114 |
+
end
|
| 115 |
+
|
| 116 |
+
end OAI
|